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.

staging: rtl8723bs: core: 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-23-ebiggers@kernel.org
Signed-off-by: Eric Biggers <ebiggers@kernel.org>

+10 -10
+10 -10
drivers/staging/rtl8723bs/core/rtw_security.c
··· 637 637 /****************************************/ 638 638 static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) 639 639 { 640 - struct crypto_aes_ctx ctx; 640 + struct aes_enckey aes; 641 641 642 - aes_expandkey(&ctx, key, 16); 643 - aes_encrypt(&ctx, ciphertext, data); 644 - memzero_explicit(&ctx, sizeof(ctx)); 642 + aes_prepareenckey(&aes, key, 16); 643 + aes_encrypt(&aes, ciphertext, data); 644 + memzero_explicit(&aes, sizeof(aes)); 645 645 } 646 646 647 647 /************************************************/ ··· 1406 1406 static int omac1_aes_128_vector(u8 *key, size_t num_elem, 1407 1407 u8 *addr[], size_t *len, u8 *mac) 1408 1408 { 1409 - struct crypto_aes_ctx ctx; 1409 + struct aes_enckey aes; 1410 1410 u8 cbc[AES_BLOCK_SIZE], pad[AES_BLOCK_SIZE]; 1411 1411 u8 *pos, *end; 1412 1412 size_t i, e, left, total_len; 1413 1413 int ret; 1414 1414 1415 - ret = aes_expandkey(&ctx, key, 16); 1415 + ret = aes_prepareenckey(&aes, key, 16); 1416 1416 if (ret) 1417 1417 return -1; 1418 1418 memset(cbc, 0, AES_BLOCK_SIZE); ··· 1436 1436 } 1437 1437 } 1438 1438 if (left > AES_BLOCK_SIZE) 1439 - aes_encrypt(&ctx, cbc, cbc); 1439 + aes_encrypt(&aes, cbc, cbc); 1440 1440 left -= AES_BLOCK_SIZE; 1441 1441 } 1442 1442 1443 1443 memset(pad, 0, AES_BLOCK_SIZE); 1444 - aes_encrypt(&ctx, pad, pad); 1444 + aes_encrypt(&aes, pad, pad); 1445 1445 gf_mulx(pad); 1446 1446 1447 1447 if (left || total_len == 0) { ··· 1459 1459 1460 1460 for (i = 0; i < AES_BLOCK_SIZE; i++) 1461 1461 pad[i] ^= cbc[i]; 1462 - aes_encrypt(&ctx, pad, mac); 1463 - memzero_explicit(&ctx, sizeof(ctx)); 1462 + aes_encrypt(&aes, pad, mac); 1463 + memzero_explicit(&aes, sizeof(aes)); 1464 1464 return 0; 1465 1465 } 1466 1466