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: n2/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
d4b90dbc 9bfa85eb

+9 -23
+9 -23
drivers/crypto/n2_core.c
··· 17 17 #include <crypto/md5.h> 18 18 #include <crypto/sha.h> 19 19 #include <crypto/aes.h> 20 - #include <crypto/des.h> 20 + #include <crypto/internal/des.h> 21 21 #include <linux/mutex.h> 22 22 #include <linux/delay.h> 23 23 #include <linux/sched.h> ··· 757 757 static int n2_des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, 758 758 unsigned int keylen) 759 759 { 760 - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); 761 - struct n2_cipher_context *ctx = crypto_tfm_ctx(tfm); 760 + struct n2_cipher_context *ctx = crypto_ablkcipher_ctx(cipher); 762 761 struct n2_cipher_alg *n2alg = n2_cipher_alg(tfm); 763 - u32 tmp[DES_EXPKEY_WORDS]; 764 762 int err; 765 763 764 + err = verify_ablkcipher_des_key(cipher, key); 765 + if (err) 766 + return err; 767 + 766 768 ctx->enc_type = n2alg->enc_type; 767 - 768 - if (keylen != DES_KEY_SIZE) { 769 - crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN); 770 - return -EINVAL; 771 - } 772 - 773 - err = des_ekey(tmp, key); 774 - if (err == 0 && (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { 775 - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; 776 - return -EINVAL; 777 - } 778 769 779 770 ctx->key_len = keylen; 780 771 memcpy(ctx->key.des, key, keylen); ··· 775 784 static int n2_3des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, 776 785 unsigned int keylen) 777 786 { 778 - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); 779 - struct n2_cipher_context *ctx = crypto_tfm_ctx(tfm); 787 + struct n2_cipher_context *ctx = crypto_ablkcipher_ctx(cipher); 780 788 struct n2_cipher_alg *n2alg = n2_cipher_alg(tfm); 781 - u32 flags; 782 789 int err; 783 790 784 - flags = crypto_ablkcipher_get_flags(cipher); 785 - err = __des3_verify_key(&flags, key); 786 - if (unlikely(err)) { 787 - crypto_ablkcipher_set_flags(cipher, flags); 791 + err = verify_ablkcipher_des3_key(cipher, key); 792 + if (err) 788 793 return err; 789 - } 790 794 791 795 ctx->enc_type = n2alg->enc_type; 792 796