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

crypto: atmel/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
92c203e2 8f467cf2

+7 -21
+7 -21
drivers/crypto/atmel-tdes.c
··· 33 33 #include <linux/cryptohash.h> 34 34 #include <crypto/scatterwalk.h> 35 35 #include <crypto/algapi.h> 36 - #include <crypto/des.h> 36 + #include <crypto/internal/des.h> 37 37 #include <crypto/hash.h> 38 38 #include <crypto/internal/hash.h> 39 39 #include <linux/platform_data/crypto-atmel.h> ··· 773 773 static int atmel_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key, 774 774 unsigned int keylen) 775 775 { 776 - u32 tmp[DES_EXPKEY_WORDS]; 777 - int err; 778 - struct crypto_tfm *ctfm = crypto_ablkcipher_tfm(tfm); 779 - 780 776 struct atmel_tdes_ctx *ctx = crypto_ablkcipher_ctx(tfm); 777 + int err; 781 778 782 - if (keylen != DES_KEY_SIZE) { 783 - crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); 784 - return -EINVAL; 785 - } 786 - 787 - err = des_ekey(tmp, key); 788 - if (err == 0 && (ctfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { 789 - ctfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; 790 - return -EINVAL; 791 - } 779 + err = verify_ablkcipher_des_key(tfm, key); 780 + if (err) 781 + return err; 792 782 793 783 memcpy(ctx->key, key, keylen); 794 784 ctx->keylen = keylen; ··· 790 800 unsigned int keylen) 791 801 { 792 802 struct atmel_tdes_ctx *ctx = crypto_ablkcipher_ctx(tfm); 793 - u32 flags; 794 803 int err; 795 804 796 - flags = crypto_ablkcipher_get_flags(tfm); 797 - err = __des3_verify_key(&flags, key); 798 - if (unlikely(err)) { 799 - crypto_ablkcipher_set_flags(tfm, flags); 805 + err = verify_ablkcipher_des3_key(tfm, key); 806 + if (err) 800 807 return err; 801 - } 802 808 803 809 memcpy(ctx->key, key, keylen); 804 810 ctx->keylen = keylen;