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: stm32/des - switch to new verification routines

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Ard Biesheuvel and committed by
Herbert Xu
b5d0ba83 4eaef052

+5 -25
+5 -25
drivers/crypto/stm32/stm32-cryp.c
··· 15 15 #include <linux/reset.h> 16 16 17 17 #include <crypto/aes.h> 18 - #include <crypto/des.h> 18 + #include <crypto/internal/des.h> 19 19 #include <crypto/engine.h> 20 20 #include <crypto/scatterwalk.h> 21 21 #include <crypto/internal/aead.h> ··· 767 767 static int stm32_cryp_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key, 768 768 unsigned int keylen) 769 769 { 770 - u32 tmp[DES_EXPKEY_WORDS]; 771 - 772 - if (keylen != DES_KEY_SIZE) 773 - return -EINVAL; 774 - 775 - if ((crypto_ablkcipher_get_flags(tfm) & 776 - CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) && 777 - unlikely(!des_ekey(tmp, key))) { 778 - crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_RES_WEAK_KEY); 779 - return -EINVAL; 780 - } 781 - 782 - return stm32_cryp_setkey(tfm, key, keylen); 770 + return verify_ablkcipher_des_key(tfm, key) ?: 771 + stm32_cryp_setkey(tfm, key, keylen); 783 772 } 784 773 785 774 static int stm32_cryp_tdes_setkey(struct crypto_ablkcipher *tfm, const u8 *key, 786 775 unsigned int keylen) 787 776 { 788 - u32 flags; 789 - int err; 790 - 791 - flags = crypto_ablkcipher_get_flags(tfm); 792 - err = __des3_verify_key(&flags, key); 793 - if (unlikely(err)) { 794 - crypto_ablkcipher_set_flags(tfm, flags); 795 - return err; 796 - } 797 - 798 - return stm32_cryp_setkey(tfm, key, keylen); 777 + return verify_ablkcipher_des3_key(tfm, key) ?: 778 + stm32_cryp_setkey(tfm, key, keylen); 799 779 } 800 780 801 781 static int stm32_cryp_aes_aead_setkey(struct crypto_aead *tfm, const u8 *key,