Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

crypto: arm/ghash - Use new AES library API

Switch from the old AES library functions (which use struct
crypto_aes_ctx) to the new ones (which use struct aes_enckey). This
eliminates the unnecessary computation and caching of the decryption
round keys. The new AES en/decryption functions are also much faster
and use AES instructions when supported by the CPU.

Note that in addition to the change in the key preparation function and
the key struct type itself, the change in the type of the key struct
results in aes_encrypt() (which is temporarily a type-generic macro)
calling the new encryption function rather than the old one.

Acked-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20260112192035.10427-24-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

+9 -5
+9 -5
arch/arm/crypto/ghash-ce-glue.c
··· 204 204 unsigned int keylen) 205 205 { 206 206 struct gcm_key *ctx = crypto_aead_ctx(tfm); 207 - struct crypto_aes_ctx aes_ctx; 207 + struct aes_enckey aes_key; 208 208 be128 h, k; 209 209 int ret; 210 210 211 - ret = aes_expandkey(&aes_ctx, inkey, keylen); 211 + ret = aes_prepareenckey(&aes_key, inkey, keylen); 212 212 if (ret) 213 213 return -EINVAL; 214 214 215 - aes_encrypt(&aes_ctx, (u8 *)&k, (u8[AES_BLOCK_SIZE]){}); 215 + aes_encrypt(&aes_key, (u8 *)&k, (u8[AES_BLOCK_SIZE]){}); 216 216 217 - memcpy(ctx->rk, aes_ctx.key_enc, sizeof(ctx->rk)); 217 + /* 218 + * Note: this assumes that the arm implementation of the AES library 219 + * stores the standard round keys in k.rndkeys. 220 + */ 221 + memcpy(ctx->rk, aes_key.k.rndkeys, sizeof(ctx->rk)); 218 222 ctx->rounds = 6 + keylen / 4; 219 223 220 - memzero_explicit(&aes_ctx, sizeof(aes_ctx)); 224 + memzero_explicit(&aes_key, sizeof(aes_key)); 221 225 222 226 ghash_reflect(ctx->h[0], &k); 223 227