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.

Bluetooth: SMP: 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-20-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

+4 -4
+4 -4
net/bluetooth/smp.c
··· 374 374 375 375 static int smp_e(const u8 *k, u8 *r) 376 376 { 377 - struct crypto_aes_ctx ctx; 377 + struct aes_enckey aes; 378 378 uint8_t tmp[16], data[16]; 379 379 int err; 380 380 ··· 383 383 /* The most significant octet of key corresponds to k[0] */ 384 384 swap_buf(k, tmp, 16); 385 385 386 - err = aes_expandkey(&ctx, tmp, 16); 386 + err = aes_prepareenckey(&aes, tmp, 16); 387 387 if (err) { 388 388 BT_ERR("cipher setkey failed: %d", err); 389 389 return err; ··· 392 392 /* Most significant octet of plaintextData corresponds to data[0] */ 393 393 swap_buf(r, data, 16); 394 394 395 - aes_encrypt(&ctx, data, data); 395 + aes_encrypt(&aes, data, data); 396 396 397 397 /* Most significant octet of encryptedData corresponds to data[0] */ 398 398 swap_buf(data, r, 16); 399 399 400 400 SMP_DBG("r %16phN", r); 401 401 402 - memzero_explicit(&ctx, sizeof(ctx)); 402 + memzero_explicit(&aes, sizeof(aes)); 403 403 return err; 404 404 } 405 405