Skip to content

crypto: rename hmac_sha256() to rtw_hmac_sha256() to fix build on Linux 7.0 - #7

Open
s-b-repo wants to merge 1 commit into
natimerry:dwa-x1850from
s-b-repo:fix-hmac-sha256-collision
Open

crypto: rename hmac_sha256() to rtw_hmac_sha256() to fix build on Linux 7.0#7
s-b-repo wants to merge 1 commit into
natimerry:dwa-x1850from
s-b-repo:fix-hmac-sha256-collision

Conversation

@s-b-repo

@s-b-repo s-b-repo commented Aug 7, 2026

Copy link
Copy Markdown

Problem

dwa-x1850 HEAD does not build on Linux 7.0:

core/crypto/sha256.h:16:5: error: conflicting types for 'hmac_sha256'; have
  'int(const u8 *, size_t,  const u8 *, size_t,  u8 *)'
core/crypto/sha256.c:100:5: error: conflicting types for 'hmac_sha256'; have
  'int(const u8 *, size_t,  const u8 *, size_t,  u8 *)'
make[4]: *** [scripts/Makefile.build:289: core/crypto/sha256.o] Error 1

Eric Biggers' lib/crypto SHA-256 series made HMAC a first-class part of the
SHA-256 library, adding to include/crypto/sha2.h:

void hmac_sha256(const struct hmac_sha256_key *key, const void *data,
                 size_t data_len, u8 out[SHA256_DIGEST_SIZE]);

That collides with the driver's wpa_supplicant-derived function of the same name
and incompatible signature:

int hmac_sha256(const u8 *key, size_t key_len, const u8 *data,
                size_t data_len, u8 *mac);

Both headers land in the same translation unit, so the declarations conflict.

Fix

Rename the driver's function to rtw_hmac_sha256().

grep -rnw hmac_sha256 finds exactly three occurrences — a kernel-doc comment,
the definition, and the declaration — and zero call sites. Only
hmac_sha256_vector() is actually used, by core/crypto/sha256-prf.c. The rename
is therefore behaviour-neutral, and because the symbol is driver-internal it needs
no LINUX_VERSION_CODE guard — it is safe on every kernel version.

Reproduction

git clone -b dwa-x1850 https://github.com/natimerry/rtl8852au
cd rtl8852au
make -j$(nproc) KVER=$(uname -r)     # on a 7.0 kernel

Verification

Built on Arch Linux, kernel 7.0.14-arch1-1 (x86_64), gcc 16.1.1 20260625:

Tree Result
dwa-x1850 HEAD, unmodified exit status 2, no module produced
dwa-x1850 HEAD + this commit exit status 0, zero errors, 8852au.ko built

modinfo on the resulting module reports vermagic: 7.0.14-arch1-1 SMP preempt mod_unload.

This also fixes the AUR rtl8852au-dkms-git package, which currently fails to
build on Arch for the same reason.

Unrelated observation: radio_id is not version-gated

Not part of this PR, just something I hit while bisecting. The kernel 6.17
radio_id fix already in dwa-x1850 is applied unconditionally:

static int cfg80211_rtw_set_wiphy_params(struct wiphy *wiphy, int radio_id, u32 changed)

struct cfg80211_ops only gained that parameter in 6.17, so as written the tree
no longer builds on older kernels. If you want to keep those working, the three
sites (cfg80211_rtw_set_wiphy_params, cfg80211_rtw_set_txpower,
cfg80211_rtw_get_txpower) want:

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 17, 0))
	int radio_id,
#endif

Happy to send that as a separate PR if it would be useful.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Xh5tbTQAWbek2feXD2uhaZ

Linux 7.0 provides its own hmac_sha256() in <crypto/sha2.h>, added by the
lib/crypto SHA-256 HMAC series:

    void hmac_sha256(const struct hmac_sha256_key *key, const void *data,
                     size_t data_len, u8 out[SHA256_DIGEST_SIZE]);

This collides with the driver's wpa_supplicant-derived function of the same
name, so core/crypto/sha256.{c,h} fail to compile:

    core/crypto/sha256.h:16:5: error: conflicting types for 'hmac_sha256'
    core/crypto/sha256.c:100:5: error: conflicting types for 'hmac_sha256'

The driver's hmac_sha256() has no callers anywhere in the tree - only
hmac_sha256_vector() is used, by core/crypto/sha256-prf.c - so the rename is
behaviour-neutral and needs no LINUX_VERSION_CODE guard.

Verified on 7.0.14-arch1-1 with gcc 16.1.1: dwa-x1850 HEAD fails with exit
status 2 and produces no module; with this change the build completes with
zero errors and 8852au.ko has vermagic 7.0.14-arch1-1.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Xh5tbTQAWbek2feXD2uhaZ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant