Skip to content

Commit 4eaef05

Browse files
Ard Biesheuvelherbertx
authored andcommitted
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>
1 parent f96c897 commit 4eaef05

2 files changed

Lines changed: 8 additions & 15 deletions

File tree

‎drivers/crypto/rockchip/rk3288_crypto.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define __RK3288_CRYPTO_H__
44

55
#include <crypto/aes.h>
6-
#include <crypto/des.h>
6+
#include <crypto/internal/des.h>
77
#include <crypto/algapi.h>
88
#include <linux/interrupt.h>
99
#include <linux/delay.h>

‎drivers/crypto/rockchip/rk3288_crypto_ablkcipher.c‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,12 @@ static int rk_aes_setkey(struct crypto_ablkcipher *cipher,
4646
static int rk_des_setkey(struct crypto_ablkcipher *cipher,
4747
const u8 *key, unsigned int keylen)
4848
{
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;
5251

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;
5855

5956
ctx->keylen = keylen;
6057
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,
6562
const u8 *key, unsigned int keylen)
6663
{
6764
struct rk_cipher_ctx *ctx = crypto_ablkcipher_ctx(cipher);
68-
u32 flags;
6965
int err;
7066

71-
flags = crypto_ablkcipher_get_flags(cipher);
72-
err = __des3_verify_key(&flags, key);
73-
if (unlikely(err)) {
74-
crypto_ablkcipher_set_flags(cipher, flags);
67+
err = verify_ablkcipher_des3_key(cipher, key);
68+
if (err)
7569
return err;
76-
}
7770

7871
ctx->keylen = keylen;
7972
memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_KEY1_0, key, keylen);

0 commit comments

Comments
 (0)