Commit b5d0ba83 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Herbert Xu

crypto: stm32/des - switch to new verification routines

Signed-off-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 4eaef052
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
#include <linux/reset.h> #include <linux/reset.h>
#include <crypto/aes.h> #include <crypto/aes.h>
#include <crypto/des.h> #include <crypto/internal/des.h>
#include <crypto/engine.h> #include <crypto/engine.h>
#include <crypto/scatterwalk.h> #include <crypto/scatterwalk.h>
#include <crypto/internal/aead.h> #include <crypto/internal/aead.h>
...@@ -767,35 +767,15 @@ static int stm32_cryp_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key, ...@@ -767,35 +767,15 @@ static int stm32_cryp_aes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
static int stm32_cryp_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key, static int stm32_cryp_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
unsigned int keylen) unsigned int keylen)
{ {
u32 tmp[DES_EXPKEY_WORDS]; return verify_ablkcipher_des_key(tfm, key) ?:
stm32_cryp_setkey(tfm, key, keylen);
if (keylen != DES_KEY_SIZE)
return -EINVAL;
if ((crypto_ablkcipher_get_flags(tfm) &
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS) &&
unlikely(!des_ekey(tmp, key))) {
crypto_ablkcipher_set_flags(tfm, CRYPTO_TFM_RES_WEAK_KEY);
return -EINVAL;
}
return stm32_cryp_setkey(tfm, key, keylen);
} }
static int stm32_cryp_tdes_setkey(struct crypto_ablkcipher *tfm, const u8 *key, static int stm32_cryp_tdes_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
unsigned int keylen) unsigned int keylen)
{ {
u32 flags; return verify_ablkcipher_des3_key(tfm, key) ?:
int err; stm32_cryp_setkey(tfm, key, keylen);
flags = crypto_ablkcipher_get_flags(tfm);
err = __des3_verify_key(&flags, key);
if (unlikely(err)) {
crypto_ablkcipher_set_flags(tfm, flags);
return err;
}
return stm32_cryp_setkey(tfm, key, keylen);
} }
static int stm32_cryp_aes_aead_setkey(struct crypto_aead *tfm, const u8 *key, static int stm32_cryp_aes_aead_setkey(struct crypto_aead *tfm, const u8 *key,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment