diff options
Diffstat (limited to 'drivers/crypto/ccree/cc_cipher.c')
-rw-r--r-- | drivers/crypto/ccree/cc_cipher.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c index 5b58226ea24d..c7ec20e90fc0 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <linux/module.h> | 5 | #include <linux/module.h> |
6 | #include <crypto/algapi.h> | 6 | #include <crypto/algapi.h> |
7 | #include <crypto/internal/skcipher.h> | 7 | #include <crypto/internal/skcipher.h> |
8 | #include <crypto/des.h> | 8 | #include <crypto/internal/des.h> |
9 | #include <crypto/xts.h> | 9 | #include <crypto/xts.h> |
10 | #include <crypto/sm4.h> | 10 | #include <crypto/sm4.h> |
11 | #include <crypto/scatterwalk.h> | 11 | #include <crypto/scatterwalk.h> |
@@ -411,16 +411,9 @@ static int cc_cipher_setkey(struct crypto_skcipher *sktfm, const u8 *key, | |||
411 | * HW does the expansion on its own. | 411 | * HW does the expansion on its own. |
412 | */ | 412 | */ |
413 | if (ctx_p->flow_mode == S_DIN_to_DES) { | 413 | if (ctx_p->flow_mode == S_DIN_to_DES) { |
414 | u32 tmp[DES3_EDE_EXPKEY_WORDS]; | 414 | if ((keylen == DES3_EDE_KEY_SIZE && |
415 | if (keylen == DES3_EDE_KEY_SIZE && | 415 | verify_skcipher_des3_key(sktfm, key)) || |
416 | __des3_ede_setkey(tmp, &tfm->crt_flags, key, | 416 | verify_skcipher_des_key(sktfm, key)) { |
417 | DES3_EDE_KEY_SIZE)) { | ||
418 | dev_dbg(dev, "weak 3DES key"); | ||
419 | return -EINVAL; | ||
420 | } else if (!des_ekey(tmp, key) && | ||
421 | (crypto_tfm_get_flags(tfm) & | ||
422 | CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) { | ||
423 | tfm->crt_flags |= CRYPTO_TFM_RES_WEAK_KEY; | ||
424 | dev_dbg(dev, "weak DES key"); | 417 | dev_dbg(dev, "weak DES key"); |
425 | return -EINVAL; | 418 | return -EINVAL; |
426 | } | 419 | } |