crypto: stm32 - Forbid 2-key 3DES in FIPS mode
This patch forbids the use of 2-key 3DES (K1 == K3) in FIPS mode. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Acked-by: Lionel Debieve<lionel.debieve@st.com> Tested-by: Lionel Debieve<lionel.debieve@st.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
@ -762,10 +762,17 @@ static int stm32_cryp_des_setkey(struct crypto_ablkcipher *tfm, const u8 *key,
|
|||||||
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)
|
||||||
{
|
{
|
||||||
if (keylen != (3 * DES_KEY_SIZE))
|
u32 flags;
|
||||||
return -EINVAL;
|
int err;
|
||||||
else
|
|
||||||
return 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,
|
||||||
|
Reference in New Issue
Block a user