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

crypto: talitos/des - switch to new verification routines

Cc: Christophe Leroy <christophe.leroy@c-s.fr>
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
9d574ae8 08d4b408

+7 -30
+7 -30
drivers/crypto/talitos.c
··· 30 30 31 31 #include <crypto/algapi.h> 32 32 #include <crypto/aes.h> 33 - #include <crypto/des.h> 33 + #include <crypto/internal/des.h> 34 34 #include <crypto/sha.h> 35 35 #include <crypto/md5.h> 36 36 #include <crypto/internal/aead.h> ··· 936 936 if (keys.authkeylen + keys.enckeylen > TALITOS_MAX_KEY_SIZE) 937 937 goto badkey; 938 938 939 - if (keys.enckeylen != DES3_EDE_KEY_SIZE) 940 - goto badkey; 941 - 942 - flags = crypto_aead_get_flags(authenc); 943 - err = __des3_verify_key(&flags, keys.enckey); 944 - if (unlikely(err)) { 945 - crypto_aead_set_flags(authenc, flags); 939 + err = verify_aead_des3_key(authenc, keys.enckey, keys.enckeylen); 940 + if (err) 946 941 goto out; 947 - } 948 942 949 943 if (ctx->keylen) 950 944 dma_unmap_single(dev, ctx->dma_key, ctx->keylen, DMA_TO_DEVICE); ··· 1511 1517 static int ablkcipher_des_setkey(struct crypto_ablkcipher *cipher, 1512 1518 const u8 *key, unsigned int keylen) 1513 1519 { 1514 - u32 tmp[DES_EXPKEY_WORDS]; 1515 - 1516 - if (unlikely(crypto_ablkcipher_get_flags(cipher) & 1517 - CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) && 1518 - !des_ekey(tmp, key)) { 1519 - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_WEAK_KEY); 1520 - return -EINVAL; 1521 - } 1522 - 1523 - return ablkcipher_setkey(cipher, key, keylen); 1520 + return verify_ablkcipher_des_key(cipher, key) ?: 1521 + ablkcipher_setkey(cipher, key, keylen); 1524 1522 } 1525 1523 1526 1524 static int ablkcipher_des3_setkey(struct crypto_ablkcipher *cipher, 1527 1525 const u8 *key, unsigned int keylen) 1528 1526 { 1529 - u32 flags; 1530 - int err; 1531 - 1532 - flags = crypto_ablkcipher_get_flags(cipher); 1533 - err = __des3_verify_key(&flags, key); 1534 - if (unlikely(err)) { 1535 - crypto_ablkcipher_set_flags(cipher, flags); 1536 - return err; 1537 - } 1538 - 1539 - return ablkcipher_setkey(cipher, key, keylen); 1527 + return verify_ablkcipher_des3_key(cipher, key) ?: 1528 + ablkcipher_setkey(cipher, key, keylen); 1540 1529 } 1541 1530 1542 1531 static int ablkcipher_aes_setkey(struct crypto_ablkcipher *cipher,