Signed-off-by: Ard Biesheuvel <ard.biesheu...@linaro.org>
---
 drivers/crypto/rockchip/rk3288_crypto.h            |  2 +-
 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 @@
 #define __RK3288_CRYPTO_H__
 
 #include <crypto/aes.h>
-#include <crypto/des.h>
+#include <crypto/internal/des.h>
 #include <crypto/algapi.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
diff --git a/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c 
b/drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c
index 96078aaa2098..ec84c2374b90 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,
 static int rk_des_setkey(struct crypto_ablkcipher *cipher,
                         const u8 *key, unsigned int keylen)
 {
-       struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher);
-       struct rk_cipher_ctx *ctx = crypto_tfm_ctx(tfm);
-       u32 tmp[DES_EXPKEY_WORDS];
+       struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(cipher);
+       int err;
 
-       if (!des_ekey(tmp, key) &&
-           (tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) {
-               tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY;
-               return -EINVAL;
-       }
+       err = crypto_des_verify_key(crypto_ablkcipher_tfm(cipher), key);
+       if (err)
+               return err;
 
        ctx->keylen = keylen;
        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,
                          const u8 *key, unsigned int keylen)
 {
        struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(cipher);
-       u32 flags;
        int err;
 
-       flags = crypto_ablkcipher_get_flags(cipher);
-       err = __des3_verify_key(&flags, key);
-       if (unlikely(err)) {
-               crypto_ablkcipher_set_flags(cipher, flags);
+       err = crypto_des3_ede_verify_key(crypto_ablkcipher_tfm(cipher), key);
+       if (err)
                return err;
-       }
 
        ctx->keylen = keylen;
        memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen);
-- 
2.17.1

Reply via email to