Commit e4fffa5f authored by Herbert Xu's avatar Herbert Xu

crypto: n2 - Forbid 2-key 3DES in FIPS mode

This patch forbids the use of 2-key 3DES (K1 == K3) in FIPS mode.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent cc4bd9f2
...@@ -788,13 +788,18 @@ static int n2_3des_setkey(struct crypto_ablkcipher *cipher, const u8 *key, ...@@ -788,13 +788,18 @@ static int n2_3des_setkey(struct crypto_ablkcipher *cipher, const u8 *key,
struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher); struct crypto_tfm *tfm = crypto_ablkcipher_tfm(cipher);
struct n2_cipher_context *ctx = crypto_tfm_ctx(tfm); struct n2_cipher_context *ctx = crypto_tfm_ctx(tfm);
struct n2_cipher_alg *n2alg = n2_cipher_alg(tfm); struct n2_cipher_alg *n2alg = n2_cipher_alg(tfm);
u32 flags;
int err;
flags = crypto_ablkcipher_get_flags(cipher);
err = __des3_verify_key(&flags, key);
if (unlikely(err)) {
crypto_ablkcipher_set_flags(cipher, flags);
return err;
}
ctx->enc_type = n2alg->enc_type; ctx->enc_type = n2alg->enc_type;
if (keylen != (3 * DES_KEY_SIZE)) {
crypto_ablkcipher_set_flags(cipher, CRYPTO_TFM_RES_BAD_KEY_LEN);
return -EINVAL;
}
ctx->key_len = keylen; ctx->key_len = keylen;
memcpy(ctx->key.des3, key, keylen); memcpy(ctx->key.des3, key, keylen);
return 0; return 0;
......
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