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

crypto: rk3288/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
4eaef052 f96c897c

+8 -15
+1 -1
drivers/crypto/rockchip/rk3288_crypto.h
··· 3 3 #define __RK3288_CRYPTO_H__ 4 4 5 5 #include <crypto/aes.h> 6 - #include <crypto/des.h> 6 + #include <crypto/internal/des.h> 7 7 #include <crypto/algapi.h> 8 8 #include <linux/interrupt.h> 9 9 #include <linux/delay.h>
+7 -14
drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c
··· 46 46 static int rk_des_setkey(struct crypto_ablkcipher *cipher, 47 47 const u8 *key, unsigned int keylen) 48 48 { 49 - struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); 50 - struct rk_cipher_ctx *ctx = crypto_tfm_ctx(tfm); 51 - u32 tmp[DES_EXPKEY_WORDS]; 49 + struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(cipher); 50 + int err; 52 51 53 - if (!des_ekey(tmp, key) && 54 - (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { 55 - tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; 56 - return -EINVAL; 57 - } 52 + err = verify_ablkcipher_des_key(cipher, key); 53 + if (err) 54 + return err; 58 55 59 56 ctx->keylen = keylen; 60 57 memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen); ··· 62 65 const u8 *key, unsigned int keylen) 63 66 { 64 67 struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(cipher); 65 - u32 flags; 66 68 int err; 67 69 68 - flags = crypto_ablkcipher_get_flags(cipher); 69 - err = __des3_verify_key(&flags, key); 70 - if (unlikely(err)) { 71 - crypto_ablkcipher_set_flags(cipher, flags); 70 + err = verify_ablkcipher_des3_key(cipher, key); 71 + if (err) 72 72 return err; 73 - } 74 73 75 74 ctx->keylen = keylen; 76 75 memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen);