diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2019-04-11 10:51:19 +0200 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2019-04-18 16:15:01 +0200 |
commit | aee118139afa14398c92030d7d5f722b26281806 (patch) | |
tree | a84e64d08c52c62e91cde49f9f25bfdbfd59f315 /drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | |
parent | crypto: stm32 - Forbid 2-key 3DES in FIPS mode (diff) | |
download | linux-aee118139afa14398c92030d7d5f722b26281806.tar.xz linux-aee118139afa14398c92030d7d5f722b26281806.zip |
crypto: sun4i-ss - 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: Corentin Labbe <clabbe.montjoie@gmail.com>
Tested-by: Corentin Labbe <clabbe.montjoie@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to '')
-rw-r--r-- | drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c index 54fd714d53ca..06df336488fb 100644 --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c @@ -533,13 +533,12 @@ int sun4i_ss_des3_setkey(struct crypto_skcipher *tfm, const u8 *key, unsigned int keylen) { struct sun4i_tfm_ctx *op = crypto_skcipher_ctx(tfm); - struct sun4i_ss_ctx *ss = op->ss; + int err; + + err = des3_verify_key(tfm, key); + if (unlikely(err)) + return err; - if (unlikely(keylen != 3 * DES_KEY_SIZE)) { - dev_err(ss->dev, "Invalid keylen %u\n", keylen); - crypto_skcipher_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); - return -EINVAL; - } op->keylen = keylen; memcpy(op->key, key, keylen); return 0; |