diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2019-08-15 05:01:02 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-08-22 00:57:32 -0400 |
commit | 4eaef05210cbe7052adf53d030fd44b37b69c5a3 (patch) | |
tree | b1de0df99b7c1005690f73e66193e3f98a8f1823 /drivers/crypto | |
parent | f96c897c855cfbde74d92f5cd65dc1108799bd8a (diff) |
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>
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/rockchip/rk3288_crypto.h | 2 | ||||
-rw-r--r-- | drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c | 21 |
2 files changed, 8 insertions, 15 deletions
diff --git a/drivers/crypto/rockchip/rk3288_crypto.h b/drivers/crypto/rockchip/rk3288_crypto.h index 54ee5b3ed9db..18e2b3f29336 100644 --- a/drivers/crypto/rockchip/rk3288_crypto.h +++ b/drivers/crypto/rockchip/rk3288_crypto.h | |||
@@ -3,7 +3,7 @@ | |||
3 | #define __RK3288_CRYPTO_H__ | 3 | #define __RK3288_CRYPTO_H__ |
4 | 4 | ||
5 | #include <crypto/aes.h> | 5 | #include <crypto/aes.h> |
6 | #include <crypto/des.h> | 6 | #include <crypto/internal/des.h> |
7 | #include <crypto/algapi.h> | 7 | #include <crypto/algapi.h> |
8 | #include <linux/interrupt.h> | 8 | #include <linux/interrupt.h> |
9 | #include <linux/delay.h> | 9 | #include <linux/delay.h> |
diff --git a/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c b/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c index 96078aaa2098..d0f4b2d18059 100644 --- a/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c +++ b/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c | |||
@@ -46,15 +46,12 @@ static int rk_aes_setkey(struct crypto_ablkcipher *cipher, | |||
46 | static int rk_des_setkey(struct crypto_ablkcipher *cipher, | 46 | static int rk_des_setkey(struct crypto_ablkcipher *cipher, |
47 | const u8 *key, unsigned int keylen) | 47 | const u8 *key, unsigned int keylen) |
48 | { | 48 | { |
49 | struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); | 49 | struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(cipher); |
50 | struct rk_cipher_ctx *ctx = crypto_tfm_ctx(tfm); | 50 | int err; |
51 | u32 tmp[DES_EXPKEY_WORDS]; | ||
52 | 51 | ||
53 | if (!des_ekey(tmp, key) && | 52 | err = verify_ablkcipher_des_key(cipher, key); |
54 | (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { | 53 | if (err) |
55 | tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; | 54 | return err; |
56 | return -EINVAL; | ||
57 | } | ||
58 | 55 | ||
59 | ctx->keylen = keylen; | 56 | ctx->keylen = keylen; |
60 | memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen); | 57 | memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen); |
@@ -65,15 +62,11 @@ static int rk_tdes_setkey(struct crypto_ablkcipher *cipher, | |||
65 | const u8 *key, unsigned int keylen) | 62 | const u8 *key, unsigned int keylen) |
66 | { | 63 | { |
67 | struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(cipher); | 64 | struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(cipher); |
68 | u32 flags; | ||
69 | int err; | 65 | int err; |
70 | 66 | ||
71 | flags = crypto_ablkcipher_get_flags(cipher); | 67 | err = verify_ablkcipher_des3_key(cipher, key); |
72 | err = __des3_verify_key(&flags, key); | 68 | if (err) |
73 | if (unlikely(err)) { | ||
74 | crypto_ablkcipher_set_flags(cipher, flags); | ||
75 | return err; | 69 | return err; |
76 | } | ||
77 | 70 | ||
78 | ctx->keylen = keylen; | 71 | ctx->keylen = keylen; |
79 | memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen); | 72 | memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen); |