diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2019-08-15 05:01:06 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-08-22 00:57:33 -0400 |
commit | dcb15794ec571c10243c24eaff8512b789dfef2a (patch) | |
tree | 236d28dc9f98aaea538d15de7f3cc78ad457692a /drivers/crypto | |
parent | 9d574ae8ebc1e6e485ef949f086157601008a9d3 (diff) |
crypto: ux500/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/ux500/cryp/cryp_core.c | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/drivers/crypto/ux500/cryp/cryp_core.c b/drivers/crypto/ux500/cryp/cryp_core.c index b4beb54c0dbe..e966e9a64501 100644 --- a/drivers/crypto/ux500/cryp/cryp_core.c +++ b/drivers/crypto/ux500/cryp/cryp_core.c | |||
@@ -29,7 +29,7 @@ | |||
29 | #include <crypto/aes.h> | 29 | #include <crypto/aes.h> |
30 | #include <crypto/algapi.h> | 30 | #include <crypto/algapi.h> |
31 | #include <crypto/ctr.h> | 31 | #include <crypto/ctr.h> |
32 | #include <crypto/des.h> | 32 | #include <crypto/internal/des.h> |
33 | #include <crypto/scatterwalk.h> | 33 | #include <crypto/scatterwalk.h> |
34 | 34 | ||
35 | #include <linux/platform_data/crypto-ux500.h> | 35 | #include <linux/platform_data/crypto-ux500.h> |
@@ -987,26 +987,13 @@ static int des_ablkcipher_setkey(struct crypto_ablkcipher *cipher, | |||
987 | const u8 *key, unsigned int keylen) | 987 | const u8 *key, unsigned int keylen) |
988 | { | 988 | { |
989 | struct cryp_ctx *ctx = crypto_ablkcipher_ctx(cipher); | 989 | struct cryp_ctx *ctx = crypto_ablkcipher_ctx(cipher); |
990 | u32 *flags = &cipher->base.crt_flags; | 990 | int err; |
991 | u32 tmp[DES_EXPKEY_WORDS]; | ||
992 | int ret; | ||
993 | 991 | ||
994 | pr_debug(DEV_DBG_NAME " [%s]", __func__); | 992 | pr_debug(DEV_DBG_NAME " [%s]", __func__); |
995 | if (keylen != DES_KEY_SIZE) { | ||
996 | *flags |= CRYPTO_TFM_RES_BAD_KEY_LEN; | ||
997 | pr_debug(DEV_DBG_NAME " [%s]: CRYPTO_TFM_RES_BAD_KEY_LEN", | ||
998 | __func__); | ||
999 | return -EINVAL; | ||
1000 | } | ||
1001 | 993 | ||
1002 | ret = des_ekey(tmp, key); | 994 | err = verify_ablkcipher_des_key(cipher, key); |
1003 | if (unlikely(ret == 0) && | 995 | if (err) |
1004 | (*flags & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { | 996 | return err; |
1005 | *flags |= CRYPTO_TFM_RES_WEAK_KEY; | ||
1006 | pr_debug(DEV_DBG_NAME " [%s]: CRYPTO_TFM_RES_WEAK_KEY", | ||
1007 | __func__); | ||
1008 | return -EINVAL; | ||
1009 | } | ||
1010 | 997 | ||
1011 | memcpy(ctx->key, key, keylen); | 998 | memcpy(ctx->key, key, keylen); |
1012 | ctx->keylen = keylen; | 999 | ctx->keylen = keylen; |
@@ -1019,17 +1006,13 @@ static int des3_ablkcipher_setkey(struct crypto_ablkcipher *cipher, | |||
1019 | const u8 *key, unsigned int keylen) | 1006 | const u8 *key, unsigned int keylen) |
1020 | { | 1007 | { |
1021 | struct cryp_ctx *ctx = crypto_ablkcipher_ctx(cipher); | 1008 | struct cryp_ctx *ctx = crypto_ablkcipher_ctx(cipher); |
1022 | u32 flags; | ||
1023 | int err; | 1009 | int err; |
1024 | 1010 | ||
1025 | pr_debug(DEV_DBG_NAME " [%s]", __func__); | 1011 | pr_debug(DEV_DBG_NAME " [%s]", __func__); |
1026 | 1012 | ||
1027 | flags = crypto_ablkcipher_get_flags(cipher); | 1013 | err = verify_ablkcipher_des3_key(cipher, key); |
1028 | err = __des3_verify_key(&flags, key); | 1014 | if (err) |
1029 | if (unlikely(err)) { | ||
1030 | crypto_ablkcipher_set_flags(cipher, flags); | ||
1031 | return err; | 1015 | return err; |
1032 | } | ||
1033 | 1016 | ||
1034 | memcpy(ctx->key, key, keylen); | 1017 | memcpy(ctx->key, key, keylen); |
1035 | ctx->keylen = keylen; | 1018 | ctx->keylen = keylen; |