Skip to content

Commit b5d0ba8

Browse files
Ard Biesheuvelherbertx
authored andcommitted
crypto: stm32/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 4eaef05 commit b5d0ba8

1 file changed

Lines changed: 5 additions & 25 deletions

File tree

‎drivers/crypto/stm32/stm32-cryp.c‎

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include <linux/reset.h>
1616

1717
#include <crypto/aes.h>
18-
#include <crypto/des.h>
18+
#include <crypto/internal/des.h>
1919
#include <crypto/engine.h>
2020
#include <crypto/scatterwalk.h>
2121
#include <crypto/internal/aead.h>
@@ -767,35 +767,15 @@ static int stm32_cryp_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
767767
static int stm32_cryp_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
768768
unsigned int keylen)
769769
{
770-
u32 tmp[DES_EXPKEY_WORDS];
771-
772-
if (keylen != DES_KEY_SIZE)
773-
return -EINVAL;
774-
775-
if ((crypto_ablkcipher_get_flags(tfm) &
776-
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) &&
777-
unlikely(!des_ekey(tmp, key))) {
778-
crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_RES_WEAK_KEY);
779-
return -EINVAL;
780-
}
781-
782-
return stm32_cryp_setkey(tfm, key, keylen);
770+
return verify_ablkcipher_des_key(tfm, key) ?:
771+
stm32_cryp_setkey(tfm, key, keylen);
783772
}
784773

785774
static int stm32_cryp_tdes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
786775
unsigned int keylen)
787776
{
788-
u32 flags;
789-
int err;
790-
791-
flags = crypto_ablkcipher_get_flags(tfm);
792-
err = __des3_verify_key(&flags, key);
793-
if (unlikely(err)) {
794-
crypto_ablkcipher_set_flags(tfm, flags);
795-
return err;
796-
}
797-
798-
return stm32_cryp_setkey(tfm, key, keylen);
777+
return verify_ablkcipher_des3_key(tfm, key) ?:
778+
stm32_cryp_setkey(tfm, key, keylen);
799779
}
800780

801781
static int stm32_cryp_aes_aead_setkey(struct crypto_aead *tfm, const u8 *key,

0 commit comments

Comments
 (0)