Commit 4eaef052 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Herbert Xu

crypto: rk3288/des - switch to new verification routines

Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent f96c897c
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#define __RK3288_CRYPTO_H__ #define __RK3288_CRYPTO_H__
#include <crypto/aes.h> #include <crypto/aes.h>
#include <crypto/des.h> #include <crypto/internal/des.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/delay.h> #include <linux/delay.h>
......
...@@ -46,15 +46,12 @@ static int rk_aes_setkey(struct crypto_ablkcipher *cipher, ...@@ -46,15 +46,12 @@ static int rk_aes_setkey(struct crypto_ablkcipher *cipher,
static int rk_des_setkey(struct crypto_ablkcipher *cipher, static int rk_des_setkey(struct crypto_ablkcipher *cipher,
const u8 *key, unsigned int keylen) const u8 *key, unsigned int keylen)
{ {
struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(cipher);
struct rk_cipher_ctx *ctx = crypto_tfm_ctx(tfm); int err;
u32 tmp[DES_EXPKEY_WORDS];
if (!des_ekey(tmp, key) && err = verify_ablkcipher_des_key(cipher, key);
(tfm->crt_flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { if (err)
tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; return err;
return -EINVAL;
}
ctx->keylen = keylen; ctx->keylen = keylen;
memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, 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, ...@@ -65,15 +62,11 @@ static int rk_tdes_setkey(struct crypto_ablkcipher *cipher,
const u8 *key, unsigned int keylen) const u8 *key, unsigned int keylen)
{ {
struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(cipher); struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(cipher);
u32 flags;
int err; int err;
flags = crypto_ablkcipher_get_flags(cipher); err = verify_ablkcipher_des3_key(cipher, key);
err = __des3_verify_key(&flags, key); if (err)
if (unlikely(err)) {
crypto_ablkcipher_set_flags(cipher, flags);
return err; return err;
}
ctx->keylen = keylen; ctx->keylen = keylen;
memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen); memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment