]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
crypto: rk3288/des - switch to new verification routines
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Thu, 15 Aug 2019 09:01:02 +0000 (12:01 +0300)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 22 Aug 2019 04:57:32 +0000 (14:57 +1000)
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/rockchip/rk3288_crypto.h
drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c

index 54ee5b3ed9db8d23b13c0f34dc82d146503ec491..18e2b3f2933631e8dcc7b93e3d106f78e17b18e7 100644 (file)
@@ -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>
index 96078aaa209832dc85d55612af4d36af9df5d431..d0f4b2d180592e8c7f9cff5976e70cbf29bf8f54 100644 (file)
@@ -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 = verify_ablkcipher_des_key(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 = verify_ablkcipher_des3_key(cipher, key);
+       if (err)
                return err;
-       }
 
        ctx->keylen = keylen;
        memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen);