diff options
author | Ard Biesheuvel <ard.biesheuvel@linaro.org> | 2019-08-15 05:00:56 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-08-22 00:57:31 -0400 |
commit | 3ca20b65cbfd1acd733c2d12848261b00b2d55e1 (patch) | |
tree | 50162f0510188bf5a693c810192568687ae4bb5f /drivers/crypto | |
parent | 21f5a15e0f26c7ea15bee9ed3c5fd1daa40b0b77 (diff) |
crypto: ixp4xx/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/ixp4xx_crypto.c | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/drivers/crypto/ixp4xx_crypto.c b/drivers/crypto/ixp4xx_crypto.c index acedafe3fa98..9181523ba760 100644 --- a/drivers/crypto/ixp4xx_crypto.c +++ b/drivers/crypto/ixp4xx_crypto.c | |||
@@ -17,7 +17,7 @@ | |||
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | 18 | ||
19 | #include <crypto/ctr.h> | 19 | #include <crypto/ctr.h> |
20 | #include <crypto/des.h> | 20 | #include <crypto/internal/des.h> |
21 | #include <crypto/aes.h> | 21 | #include <crypto/aes.h> |
22 | #include <crypto/hmac.h> | 22 | #include <crypto/hmac.h> |
23 | #include <crypto/sha.h> | 23 | #include <crypto/sha.h> |
@@ -756,10 +756,7 @@ static int setup_cipher(struct crypto_tfm *tfm, int encrypt, | |||
756 | } | 756 | } |
757 | cipher_cfg |= keylen_cfg; | 757 | cipher_cfg |= keylen_cfg; |
758 | } else { | 758 | } else { |
759 | u32 tmp[DES_EXPKEY_WORDS]; | 759 | crypto_des_verify_key(tfm, key); |
760 | if (des_ekey(tmp, key) == 0) { | ||
761 | *flags |= CRYPTO_TFM_RES_WEAK_KEY; | ||
762 | } | ||
763 | } | 760 | } |
764 | /* write cfg word to cryptinfo */ | 761 | /* write cfg word to cryptinfo */ |
765 | *(u32*)cinfo = cpu_to_be32(cipher_cfg); | 762 | *(u32*)cinfo = cpu_to_be32(cipher_cfg); |
@@ -851,14 +848,8 @@ out: | |||
851 | static int ablk_des3_setkey(struct crypto_ablkcipher *tfm, const u8 *key, | 848 | static int ablk_des3_setkey(struct crypto_ablkcipher *tfm, const u8 *key, |
852 | unsigned int key_len) | 849 | unsigned int key_len) |
853 | { | 850 | { |
854 | u32 flags = crypto_ablkcipher_get_flags(tfm); | 851 | return verify_ablkcipher_des3_key(tfm, key) ?: |
855 | int err; | 852 | ablk_setkey(tfm, key, key_len); |
856 | |||
857 | err = __des3_verify_key(&flags, key); | ||
858 | if (unlikely(err)) | ||
859 | crypto_ablkcipher_set_flags(tfm, flags); | ||
860 | |||
861 | return ablk_setkey(tfm, key, key_len); | ||
862 | } | 853 | } |
863 | 854 | ||
864 | static int ablk_rfc3686_setkey(struct crypto_ablkcipher *tfm, const u8 *key, | 855 | static int ablk_rfc3686_setkey(struct crypto_ablkcipher *tfm, const u8 *key, |
@@ -1181,7 +1172,6 @@ static int des3_aead_setkey(struct crypto_aead *tfm, const u8 *key, | |||
1181 | unsigned int keylen) | 1172 | unsigned int keylen) |
1182 | { | 1173 | { |
1183 | struct ixp_ctx *ctx = crypto_aead_ctx(tfm); | 1174 | struct ixp_ctx *ctx = crypto_aead_ctx(tfm); |
1184 | u32 flags = CRYPTO_TFM_RES_BAD_KEY_LEN; | ||
1185 | struct crypto_authenc_keys keys; | 1175 | struct crypto_authenc_keys keys; |
1186 | int err; | 1176 | int err; |
1187 | 1177 | ||
@@ -1193,12 +1183,8 @@ static int des3_aead_setkey(struct crypto_aead *tfm, const u8 *key, | |||
1193 | if (keys.authkeylen > sizeof(ctx->authkey)) | 1183 | if (keys.authkeylen > sizeof(ctx->authkey)) |
1194 | goto badkey; | 1184 | goto badkey; |
1195 | 1185 | ||
1196 | if (keys.enckeylen != DES3_EDE_KEY_SIZE) | 1186 | err = verify_aead_des3_key(tfm, keys.enckey, keys.enckeylen); |
1197 | goto badkey; | 1187 | if (err) |
1198 | |||
1199 | flags = crypto_aead_get_flags(tfm); | ||
1200 | err = __des3_verify_key(&flags, keys.enckey); | ||
1201 | if (unlikely(err)) | ||
1202 | goto badkey; | 1188 | goto badkey; |
1203 | 1189 | ||
1204 | memcpy(ctx->authkey, keys.authkey, keys.authkeylen); | 1190 | memcpy(ctx->authkey, keys.authkey, keys.authkeylen); |
@@ -1209,7 +1195,6 @@ static int des3_aead_setkey(struct crypto_aead *tfm, const u8 *key, | |||
1209 | memzero_explicit(&keys, sizeof(keys)); | 1195 | memzero_explicit(&keys, sizeof(keys)); |
1210 | return aead_setup(tfm, crypto_aead_authsize(tfm)); | 1196 | return aead_setup(tfm, crypto_aead_authsize(tfm)); |
1211 | badkey: | 1197 | badkey: |
1212 | crypto_aead_set_flags(tfm, flags); | ||
1213 | memzero_explicit(&keys, sizeof(keys)); | 1198 | memzero_explicit(&keys, sizeof(keys)); |
1214 | return err; | 1199 | return err; |
1215 | } | 1200 | } |