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: x86/aes - Remove the superseded AES-NI crypto_cipher

Remove the "aes-aesni" crypto_cipher algorithm and the code specific to
its implementation. It is no longer necessary because the AES library
is now optimized with x86 AES-NI, and crypto/aes.c exposes the AES
library via the crypto_cipher API.

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

+1 -88
-2
arch/x86/crypto/Kconfig
··· 7 7 select CRYPTO_AEAD 8 8 select CRYPTO_LIB_AES 9 9 select CRYPTO_LIB_GF128MUL 10 - select CRYPTO_ALGAPI 11 10 select CRYPTO_SKCIPHER 12 11 help 13 - Block cipher: AES cipher algorithms 14 12 AEAD cipher: AES with GCM 15 13 Length-preserving ciphers: AES with ECB, CBC, CTS, CTR, XCTR, XTS 16 14
-25
arch/x86/crypto/aesni-intel_asm.S
··· 437 437 SYM_FUNC_END(_aesni_enc4) 438 438 439 439 /* 440 - * void aesni_dec (const void *ctx, u8 *dst, const u8 *src) 441 - */ 442 - SYM_FUNC_START(aesni_dec) 443 - FRAME_BEGIN 444 - #ifndef __x86_64__ 445 - pushl KEYP 446 - pushl KLEN 447 - movl (FRAME_OFFSET+12)(%esp), KEYP # ctx 448 - movl (FRAME_OFFSET+16)(%esp), OUTP # dst 449 - movl (FRAME_OFFSET+20)(%esp), INP # src 450 - #endif 451 - mov 480(KEYP), KLEN # key length 452 - add $240, KEYP 453 - movups (INP), STATE # input 454 - call _aesni_dec1 455 - movups STATE, (OUTP) #output 456 - #ifndef __x86_64__ 457 - popl KLEN 458 - popl KEYP 459 - #endif 460 - FRAME_END 461 - RET 462 - SYM_FUNC_END(aesni_dec) 463 - 464 - /* 465 440 * _aesni_dec1: internal ABI 466 441 * input: 467 442 * KEYP: key struct pointer
+1 -61
arch/x86/crypto/aesni-intel_glue.c
··· 60 60 asmlinkage void aesni_set_key(struct crypto_aes_ctx *ctx, const u8 *in_key, 61 61 unsigned int key_len); 62 62 asmlinkage void aesni_enc(const void *ctx, u8 *out, const u8 *in); 63 - asmlinkage void aesni_dec(const void *ctx, u8 *out, const u8 *in); 64 63 asmlinkage void aesni_ecb_enc(struct crypto_aes_ctx *ctx, u8 *out, 65 64 const u8 *in, unsigned int len); 66 65 asmlinkage void aesni_ecb_dec(struct crypto_aes_ctx *ctx, u8 *out, ··· 110 111 aesni_set_key(ctx, in_key, key_len); 111 112 kernel_fpu_end(); 112 113 return 0; 113 - } 114 - 115 - static int aes_set_key(struct crypto_tfm *tfm, const u8 *in_key, 116 - unsigned int key_len) 117 - { 118 - return aes_set_key_common(aes_ctx(crypto_tfm_ctx(tfm)), in_key, 119 - key_len); 120 - } 121 - 122 - static void aesni_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) 123 - { 124 - struct crypto_aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(tfm)); 125 - 126 - if (!crypto_simd_usable()) { 127 - aes_encrypt(ctx, dst, src); 128 - } else { 129 - kernel_fpu_begin(); 130 - aesni_enc(ctx, dst, src); 131 - kernel_fpu_end(); 132 - } 133 - } 134 - 135 - static void aesni_decrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) 136 - { 137 - struct crypto_aes_ctx *ctx = aes_ctx(crypto_tfm_ctx(tfm)); 138 - 139 - if (!crypto_simd_usable()) { 140 - aes_decrypt(ctx, dst, src); 141 - } else { 142 - kernel_fpu_begin(); 143 - aesni_dec(ctx, dst, src); 144 - kernel_fpu_end(); 145 - } 146 114 } 147 115 148 116 static int aesni_skcipher_setkey(struct crypto_skcipher *tfm, const u8 *key, ··· 509 543 { 510 544 return xts_crypt(req, aesni_xts_encrypt_iv, aesni_xts_decrypt); 511 545 } 512 - 513 - static struct crypto_alg aesni_cipher_alg = { 514 - .cra_name = "aes", 515 - .cra_driver_name = "aes-aesni", 516 - .cra_priority = 300, 517 - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, 518 - .cra_blocksize = AES_BLOCK_SIZE, 519 - .cra_ctxsize = CRYPTO_AES_CTX_SIZE, 520 - .cra_module = THIS_MODULE, 521 - .cra_u = { 522 - .cipher = { 523 - .cia_min_keysize = AES_MIN_KEY_SIZE, 524 - .cia_max_keysize = AES_MAX_KEY_SIZE, 525 - .cia_setkey = aes_set_key, 526 - .cia_encrypt = aesni_encrypt, 527 - .cia_decrypt = aesni_decrypt 528 - } 529 - } 530 - }; 531 546 532 547 static struct skcipher_alg aesni_skciphers[] = { 533 548 { ··· 1636 1689 if (!x86_match_cpu(aesni_cpu_id)) 1637 1690 return -ENODEV; 1638 1691 1639 - err = crypto_register_alg(&aesni_cipher_alg); 1640 - if (err) 1641 - return err; 1642 - 1643 1692 err = crypto_register_skciphers(aesni_skciphers, 1644 1693 ARRAY_SIZE(aesni_skciphers)); 1645 1694 if (err) 1646 - goto unregister_cipher; 1695 + return err; 1647 1696 1648 1697 err = crypto_register_aeads(aes_gcm_algs_aesni, 1649 1698 ARRAY_SIZE(aes_gcm_algs_aesni)); ··· 1659 1716 unregister_skciphers: 1660 1717 crypto_unregister_skciphers(aesni_skciphers, 1661 1718 ARRAY_SIZE(aesni_skciphers)); 1662 - unregister_cipher: 1663 - crypto_unregister_alg(&aesni_cipher_alg); 1664 1719 return err; 1665 1720 } 1666 1721 ··· 1668 1727 ARRAY_SIZE(aes_gcm_algs_aesni)); 1669 1728 crypto_unregister_skciphers(aesni_skciphers, 1670 1729 ARRAY_SIZE(aesni_skciphers)); 1671 - crypto_unregister_alg(&aesni_cipher_alg); 1672 1730 unregister_avx_algs(); 1673 1731 } 1674 1732