diff options
| author | Eric Biggers <ebiggers@kernel.org> | 2026-09-29 15:27:52 -0700 |
|---|---|---|
| committer | Eric Biggers <ebiggers@kernel.org> | 2026-09-30 08:38:06 -0700 |
| commit | 572af6872e520c7102e58362ef7cd7c2ed4342be (patch) | |
| tree | 20981008ebdab3cb1719c255b40a5f5082027c6c /drivers | |
| parent | 226154ea87952ad7141ce2dcf52a6c2edd71b8fe (diff) | |
crypto: aes - Fix undesired override of some optimized AES modes
The new library APIs for AES encryption modes were wired up to the
traditional crypto API via crypto/aes.c. However, for now the kernel is
still in a transitional state where various architectures still have
architecture-optimized implementations of AES modes in arch/*/crypto/,
wired up to the traditional crypto API only. Because of that, the
crypto/aes.c algorithms were given a cra_priority of only 110 to prevent
them from overriding arch/*/crypto/ in the traditional crypto API.
However, because of how the traditional crypto API works, the
cra_priority trick doesn't work in cases where the relevant algorithm
isn't directly implemented by arch/*/crypto/ but rather is provided by a
template instance using other code in arch/*/crypto/.
For example, x86 doesn't have its own "ccm(aes)" but rather relies on
the "ccm" template constructing it from the x86-optimized "ctr(aes)".
The existence of the library-based "ccm(aes)" prevents that, even though
its priority is lower than what the template would produce.
Thus, "ccm(aes)" ends up using the slower single-block AES code.
Therefore, skip wiring up the relevant library-based code to the
traditional crypto API on architectures where this problem can occur, as
determined by what exists in arch/*/crypto/ for each architecture.
This is ugly, but it's also temporary: these conditions will go away as
architecture-optimized implementations of AES modes are migrated into
the library. But until then, we need to prevent performance regressions
by ensuring that the optimized code continues to be used.
Fixes: 20df21a482aa ("crypto: aes - Add CBC and CBC-CTS support using library")
Fixes: 8ca62072faa1 ("crypto: aes - Add GCM support using library")
Fixes: f70ad727d1d6 ("crypto: aes - Add CCM support using library")
Fixes: 94efa0c9fb36 ("crypto: aes - Add XTS support using library")
Closes: https://github.com/sparclinux/issues/issues/106
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Stian Halseth <stian@itx.no>
Link: https://patch.msgid.link/20260929222752.36427-1-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Diffstat (limited to 'drivers')
0 files changed, 0 insertions, 0 deletions
