aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/crypto/stm32/Kconfig1
-rw-r--r--drivers/crypto/stm32/stm32-cryp.c13
2 files changed, 12 insertions, 2 deletions
diff --git a/drivers/crypto/stm32/Kconfig b/drivers/crypto/stm32/Kconfig
index 63aa78c0b12b..4491e2197d9f 100644
--- a/drivers/crypto/stm32/Kconfig
+++ b/drivers/crypto/stm32/Kconfig
@@ -24,6 +24,7 @@ config CRYPTO_DEV_STM32_CRYP
24 depends on ARCH_STM32 24 depends on ARCH_STM32
25 select CRYPTO_HASH 25 select CRYPTO_HASH
26 select CRYPTO_ENGINE 26 select CRYPTO_ENGINE
27 select CRYPTO_DES
27 help 28 help
28 This enables support for the CRYP (AES/DES/TDES) hw accelerator which 29 This enables support for the CRYP (AES/DES/TDES) hw accelerator which
29 can be found on STMicroelectronics STM32 SOC. 30 can be found on STMicroelectronics STM32 SOC.
diff --git a/drivers/crypto/stm32/stm32-cryp.c b/drivers/crypto/stm32/stm32-cryp.c
index 5785f3e235ce..cfcb640c20d0 100644
--- a/drivers/crypto/stm32/stm32-cryp.c
+++ b/drivers/crypto/stm32/stm32-cryp.c
@@ -753,10 +753,19 @@ static int stm32_cryp_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
753static int stm32_cryp_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key, 753static int stm32_cryp_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
754 unsigned int keylen) 754 unsigned int keylen)
755{ 755{
756 u32 tmp[DES_EXPKEY_WORDS];
757
756 if (keylen != DES_KEY_SIZE) 758 if (keylen != DES_KEY_SIZE)
757 return -EINVAL; 759 return -EINVAL;
758 else 760
759 return stm32_cryp_setkey(tfm, key, keylen); 761 if ((crypto_ablkcipher_get_flags(tfm) &
762 CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) &&
763 unlikely(!des_ekey(tmp, key))) {
764 crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_RES_WEAK_KEY);
765 return -EINVAL;
766 }
767
768 return stm32_cryp_setkey(tfm, key, keylen);
760} 769}
761 770
762static int stm32_cryp_tdes_setkey(struct crypto_ablkcipher *tfm, const u8 *key, 771static int stm32_cryp_tdes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,