Skip to content

Commit e073f12

Browse files
author
Eric Biggers
committed
crypto: aes - Fix conditions for selecting MAC dependencies
Starting in commit 7137cbf ("crypto: aes - Add cmac, xcbc, and cbcmac algorithms using library"), the aes module (CRYPTO_AES) supports CBC based MACs using the corresponding library functions. To avoid including unneeded functionality, that support honors the existing CRYPTO_CMAC, CRYPTO_XCBC, and CRYPTO_CCM kconfig options. The dependencies are selected if at least one of those is enabled. However, the select statements don't correctly handle the case where CRYPTO_AES=y and (for example) CRYPTO_CMAC=m. In that case the dependencies get selected at level 'm', due to how the kconfig language works. That causes a linker error. Fix this by changing the selection conditions to use '!= n'. A similar issue also exists for CRYPTO_LIB_AES's conditional selection of CRYPTO_LIB_UTILS. The same '!= n' would work, but instead just make CRYPTO_LIB_AES always select CRYPTO_LIB_UTILS. CRYPTO_LIB_UTILS is lightweight, and it's needed by most AES modes and many other things. Fixes: 7137cbf ("crypto: aes - Add cmac, xcbc, and cbcmac algorithms using library") Fixes: 309a7e5 ("lib/crypto: aes: Add support for CBC-based MACs") Cc: stable@vger.kernel.org Link: https://patch.msgid.link/20260709022954.45113-1-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
1 parent 9665e22 commit e073f12

2 files changed

Lines changed: 3 additions & 4 deletions

File tree

crypto/Kconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ config CRYPTO_AES
358358
tristate "AES (Advanced Encryption Standard)"
359359
select CRYPTO_ALGAPI
360360
select CRYPTO_LIB_AES
361-
select CRYPTO_LIB_AES_CBC_MACS if CRYPTO_CMAC || CRYPTO_XCBC || CRYPTO_CCM
362-
select CRYPTO_HASH if CRYPTO_CMAC || CRYPTO_XCBC || CRYPTO_CCM
361+
select CRYPTO_LIB_AES_CBC_MACS if CRYPTO_CMAC != n || CRYPTO_XCBC != n || CRYPTO_CCM != n
362+
select CRYPTO_HASH if CRYPTO_CMAC != n || CRYPTO_XCBC != n || CRYPTO_CCM != n
363363
help
364364
AES cipher algorithms (Rijndael)(FIPS-197, ISO/IEC 18033-3)
365365

lib/crypto/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ config CRYPTO_LIB_UTILS
88

99
config CRYPTO_LIB_AES
1010
tristate
11-
# Select dependencies of modes that are part of libaes.
12-
select CRYPTO_LIB_UTILS if CRYPTO_LIB_AES_CBC_MACS
11+
select CRYPTO_LIB_UTILS
1312

1413
config CRYPTO_LIB_AES_ARCH
1514
bool

0 commit comments

Comments
 (0)