Trivial set of FIPS 140-3 related changes
Subsystems (9)
cover Trivial set of FIPS 140-3 related changes
Hi all,
these four rather unrelated patches are basically a dump of some of the more trivial changes required for working towards FIPS 140-3 conformance.
Please pick as you deem appropriate.
Thanks!
Nicolai
Nicolai Stange (4):
crypto: xts - restrict key lengths to approved values in FIPS mode
crypto: testmgr - disallow plain cbcmac(aes) in FIPS mode
crypto: testmgr - disallow plain ghash in FIPS mode
crypto: testmgr - allow ecdsa-nist-p256 and -p384 in FIPS mode
crypto/testmgr.c | 4 ++-- include/crypto/xts.h | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-)
Signature · 1 line
2.38.0
PATCH 1/4 crypto: xts - restrict key lengths to approved values in FIPS mode
According to FIPS 140-3 IG C.I., only (total) key lengths of either 256 bits or 512 bits are allowed with xts(aes). Make xts_verify_key() to reject anything else in FIPS mode.
As xts(aes) is the only approved xts() template instantiation in FIPS mode, the new restriction implemented in xts_verify_key() effectively only applies to this particular construction.
--- include/crypto/xts.h | 7 +++++++ 1 file changed, 7 insertions(+)
include/crypto/xts.h +7 -0
@@ -35,6 +35,13 @@ static inline int xts_verify_key(struct crypto_skcipher *tfm,if (keylen %2 )return -EINVAL ; +/* +* In FIPS mode only a combined key length of either 256 or +* 512 bits is allowed, c.f. FIPS 140-3 IG C.I. +*/ +if (fips_enabled && keylen !=32 && keylen !=64 ) +return -EINVAL ; +/* ensure that the AES and tweak key are not identical */ if ((fips_enabled || (crypto_skcipher_get_flags(tfm) & CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) &&
Signature · 1 line
2.38.0
RE: [PATCH 1/4] crypto: xts - restrict key lengths to approved values in FIPS mode
Quoted 3 lines
include/crypto/xts.h +0
-0
...
Quoted 14 lines
include/crypto/xts.h +7
-0@@ -35,6 +35,13 @@ static inline int xts_verify_key(struct crypto_skcipher *tfm, if (keylen % 2) return -EINVAL; +/* +* In FIPS mode only a combined key length of either 256 or +* 512 bits is allowed, c.f. FIPS 140-3 IG C.I. +*/ +if (fips_enabled && keylen !=32 && keylen !=64 ) +return -EINVAL ; +/* ensure that the AES and tweak key are not identical */ if ((fips_enabled || (crypto_skcipher_get_flags(tfm) &
Quoted 3 lines
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) &&
--
2.38.0
arch/s390/crypto/aes_s390.c has similar lines:
static int xts_aes_set_key(struct crypto_skcipher *tfm, const u8 *in_key,
unsigned int key_len)
{
struct s390_xts_ctx *xts_ctx = crypto_skcipher_ctx(tfm);
unsigned long fc;
int err;
err = xts_fallback_setkey(tfm, in_key, key_len);
if (err)
return err;
/* In fips mode only 128 bit or 256 bit keys are valid */
if (fips_enabled && key_len != 32 && key_len != 64)
return -EINVAL;xts_fallback_setkey will now enforce that rule when setting up the fallback algorithm keys, which makes the xts_aes_set_key check unreachable.
If that fallback setup were not present, then a call to xts_verify_key might be preferable to enforce any other rules like the WEAK_KEYS rule.
Re: [PATCH 1/4] crypto: xts - restrict key lengths to approved values in FIPS mode
Quoted 38 lines · Robert (Servers)
Quoted 1 line
include/crypto/xts.h +0
-0...
Quoted 14 lines
include/crypto/xts.h +7
-0@@ -35,6 +35,13 @@ static inline int xts_verify_key(struct crypto_skcipher *tfm, if (keylen % 2) return -EINVAL; +/* +* In FIPS mode only a combined key length of either 256 or +* 512 bits is allowed, c.f. FIPS 140-3 IG C.I. +*/ +if (fips_enabled && keylen !=32 && keylen !=64 ) +return -EINVAL ; +/* ensure that the AES and tweak key are not identical */ if ((fips_enabled || (crypto_skcipher_get_flags(tfm) &Quoted 3 lines
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) &&
--
2.38.0
arch/s390/crypto/aes_s390.chas similar lines:static int xts_aes_set_key(struct
crypto_skcipher*tfm, const u8*in_key,
unsigned intkey_len){ struct s390_xts_ctx *xts_ctx = crypto_skcipher_ctx(tfm); unsigned long fc; int err; err = xts_fallback_setkey(tfm, in_key, key_len); if (err) return err; /* In fips mode only 128 bit or 256 bit keys are valid */ if (fips_enabled && key_len != 32 && key_len != 64) return -EINVAL;
Quoted 3 lines
xts_fallback_setkeywill now enforce that rule when setting up the fallback algorithm keys, which makes thexts_aes_set_keycheck unreachable.
Good finding!
Quoted 5 lines
If that fallback setup were not present, then a call to
xts_verify_keymight be preferable to enforce any other rules like theWEAK_KEYSrule.
So if this patch here would get accepted, I'd propose to remove the then dead code from aes_s390 afterwards and make an explicit call to xts_verify_key() instead.
Or shall I split out the XTS patch from this series here and post these two changes separately then? Herbert, any preferences?
Thanks!
Nicolai
Signature · 3 lines
SUSE Software Solutions Germany GmbH, Frankenstraße 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman (HRB 36809, AG Nürnberg)
Herbert Xu
maintainerRe: [PATCH 1/4] crypto: xts - restrict key lengths to approved values in FIPS mode
Quoted 3 lines · Nicolai Stange
Or shall I split out the XTS patch from this series here and post these two changes separately then? Herbert, any preferences?
You can do this as a follow-up.
Thanks,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
RE: [PATCH 1/4] crypto: xts - restrict key lengths to approved values in FIPS mode
In reply to Nicolai StangeQuoted 1 line
include/crypto/xts.h +0
-0
...
Quoted 14 lines
include/crypto/xts.h +7
-0@@ -35,6 +35,13 @@ static inline int xts_verify_key(struct crypto_skcipher *tfm, if (keylen % 2) return -EINVAL; +/* +* In FIPS mode only a combined key length of either 256 or +* 512 bits is allowed, c.f. FIPS 140-3 IG C.I. +*/ +if (fips_enabled && keylen !=32 && keylen !=64 ) +return -EINVAL ; +/* ensure that the AES and tweak key are not identical */ if ((fips_enabled || (crypto_skcipher_get_flags(tfm) &
Quoted 3 lines
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) &&
--
2.38.0
There's another function in the same file called xts_check_key() that is used by some of the hardware drivers:
arch/s390/crypto/paes_s390.c: * xts_check_key verifies the key length is not odd and makes
[that references it in the comment but actually calls xts_verify_key in the code]drivers/crypto/axis/artpec6_crypto.c: ret = xts_check_key(&cipher->base, key, keylen);drivers/crypto/cavium/cpt/cptvf_algs.c: err = xts_check_key(tfm, key, keylen); drivers/crypto/cavium/nitrox/nitrox_skcipher.c: ret = xts_check_key(tfm, key, keylen);drivers/crypto/ccree/cc_cipher.c: xts_check_key(tfm, key, keylen)) {drivers/crypto/marvell/octeontx/otx_cptvf_algs.c: ret = xts_check_key(crypto_skcipher_tfm(tfm), key, keylen);drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c: ret = xts_check_key(crypto_skcipher_tfm(tfm), key, keylen);drivers/crypto/atmel-aes.c: err = xts_check_key(crypto_skcipher_tfm(tfm), key, keylen);
It already has one check qualified by fips_enabled:
/* ensure that the AES and tweak key are not identical */
if (fips_enabled && !crypto_memneq(key, key + (keylen / 2), keylen / 2))
return -EINVAL;Should that implement the same key length restrictions?
Re: [PATCH 1/4] crypto: xts - restrict key lengths to approved values in FIPS mode
Quoted 7 lines · Robert (Servers)
Quoted 1 line
include/crypto/xts.h +0
-0...
Quoted 5 lines
include/crypto/xts.h +0
-0@@ -35,6 +35,13 @@ static inline int xts_verify_key(struct crypto_skcipher *tfm, if (keylen % 2) return -EINVAL;
Quoted 15 lines
Quoted 9 lines
include/crypto/xts.h +7
-0+/* +* In FIPS mode only a combined key length of either 256 or +* 512 bits is allowed, c.f. FIPS 140-3 IG C.I. +*/ +if (fips_enabled && keylen !=32 && keylen !=64 ) +return -EINVAL ; +/* ensure that the AES and tweak key are not identical */ if ((fips_enabled || (crypto_skcipher_get_flags(tfm) &Quoted 3 lines
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) &&
--
2.38.0There's another function in the same file called
xts_check_key()that is used by some of the hardware drivers:
Right, thanks for spotting.
AFAICT, xts_check_key() is the older of the two variants, xts_verify_key() had been introduced with commit f1c131b45410 ("crypto:
xts - Convert to skcipher"). There had initially only been a single call from generic crypto/xts.c and the main difference to xts_check_key() had been that it took a crypto_skcipher for its tfm argument rather than a plain crypto_tfm as xts_check_key() did.
It seems that over time, xts crypto drivers adopted the newer xts_verify_key() variant then.
Quoted 11 lines
arch/s390/crypto/paes_s390.c: *xts_check_keyverifies the key length is not odd and makes
[that references it in the comment but actually callsxts_verify_keyin the code]drivers/crypto/axis/artpec6_crypto.c: ret =xts_check_key(&cipher->base, key, keylen);drivers/crypto/cavium/cpt/cptvf_algs.c: err =xts_check_key(tfm, key, keylen);drivers/crypto/cavium/nitrox/nitrox_skcipher.c: ret =xts_check_key(tfm, key, keylen);drivers/crypto/ccree/cc_cipher.c:xts_check_key(tfm, key, keylen)) {drivers/crypto/marvell/octeontx/otx_cptvf_algs.c: ret =xts_check_key(crypto_skcipher_tfm(tfm), key, keylen);drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c: ret =xts_check_key(crypto_skcipher_tfm(tfm), key, keylen);drivers/crypto/atmel-aes.c: err =xts_check_key(crypto_skcipher_tfm(tfm), key, keylen);
Quoted 7 lines
It already has one check qualified by
fips_enabled:/* ensure that the AES and tweak key are not identical */ if (fips_enabled && !crypto_memneq(key, key + (keylen / 2), keylen / 2)) return -EINVAL;Should that implement the same key length restrictions?
From a quick glance, all of the above drivers merely convert some crypto_skcipher to a crypto_tfm before passing it to xts_check_key().
So I think these should all be made to call xts_verify_key() directly instead, the former xts_check_key() could then get dropped. But that's more of a cleanup IMO and would probably deserve a separate patch series on its own.
Thanks!
Nicolai
Signature · 3 lines
SUSE Software Solutions Germany GmbH, Frankenstraße 146, 90461 Nürnberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman (HRB 36809, AG Nürnberg)
Herbert Xu
maintainerRe: [PATCH 1/4] crypto: xts - restrict key lengths to approved values in FIPS mode
Quoted 8 lines · Nicolai Stange
Quoted 2 lines
From a quick glance, all of the above drivers merely convert some
crypto_skcipherto acrypto_tfmbefore passing it toxts_check_key().So I think these should all be made to call
xts_verify_key()directly instead, the formerxts_check_key()could then get dropped. But that's more of a cleanup IMO and would probably deserve a separate patch series on its own.
We should make sure both do the same thing though. So either change all the drivers or just change xts_check_key in your patch in addition to xts_verify_key.
Cheers,
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
PATCH 2/4 crypto: testmgr - disallow plain cbcmac(aes) in FIPS mode
In reply to Nicolai Stangecbcmac(aes) may be used only as part of the ccm(aes) construction in FIPS mode. Since commit d6097b8d5d55 ("crypto: api - allow algs only in specific constructions in FIPS mode") there's support for using spawns which by itself are marked as non-approved from approved template instantiations. So simply mark plain cbcmac(aes) as non-approved in testmgr to block any attempts of direct instantiations in FIPS mode.
--- crypto/testmgr.c | 1 - 1 file changed, 1 deletion(-)
crypto/testmgr.c +0 -1
@@ -4501,7 +4501,6 @@ static const struct alg_test_desc alg_test_descs[] = { }, {#endif .alg = "cbcmac(aes)", - .fips_allowed = 1, .test = alg_test_hash, .suite = { .hash =__VECS (aes_cbcmac_tv_template)
Signature · 1 line
2.38.0
PATCH 3/4 crypto: testmgr - disallow plain ghash in FIPS mode
In reply to Nicolai Stangeghash may be used only as part of the gcm(aes) construction in FIPS mode. Since commit d6097b8d5d55 ("crypto: api - allow algs only in specific constructions in FIPS mode") there's support for using spawns which by itself are marked as non-approved from approved template instantiations. So simply mark plain ghash as non-approved in testmgr to block any attempts of direct instantiations in FIPS mode.
--- crypto/testmgr.c | 1 - 1 file changed, 1 deletion(-)
crypto/testmgr.c +0 -1
@@ -5125,7 +5125,6 @@ static const struct alg_test_desc alg_test_descs[] = { }, { .alg = "ghash", .test = alg_test_hash, - .fips_allowed = 1, .suite = { .hash = __VECS(ghash_tv_template) }
Signature · 1 line
2.38.0
PATCH 4/4 crypto: testmgr - allow ecdsa-nist-p256 and -p384 in FIPS mode
In reply to Nicolai StangeThe kernel provides implementations of the NIST ECDSA signature verification primitives. For key sizes of 256 and 384 bits respectively they are approved and can be enabled in FIPS mode. Do so.
--- crypto/testmgr.c | 2 ++ 1 file changed, 2 insertions(+)
crypto/testmgr.c +2 -0
@@ -5034,12 +5034,14 @@ static const struct alg_test_desc alg_test_descs[] = { }, { .alg = "ecdsa-nist-p256", .test = alg_test_akcipher, + .fips_allowed = 1, .suite = { .akcipher = __VECS(ecdsa_nist_p256_tv_template) } }, { .alg = "ecdsa-nist-p384", .test = alg_test_akcipher, + .fips_allowed = 1, .suite = { .akcipher =__VECS (ecdsa_nist_p384_tv_template) }
Signature · 1 line
2.38.0
Hi Nicolai, Robert, Herbert, all,
I would like to revive this older upstream email thread. I would like to address notes from reviewers (namely, Robert) by additional patches so the whole patchset can be accepted. This should ease our future kernel work re: FIPS.
The below 2 patches address (I hope) both notes Robert and Herbert have provided (thanks!). I hope the whole patchset can be accepted then.
Logically my 2 patches should follow [PATCH 1/4] and be patches 2 and 3. Herbert is it possible to reorder them when accepting?
Thank you! and
Best regards,
Vladis
Vladis Dronov (2):
crypto: xts - drop xts_check_key()
crypto: xts - drop redundant xts key check
Quoted 10 lines · Vladis Dronov
Hi Nicolai, Robert, Herbert, all,
I would like to revive this older upstream email thread. I would like to address notes from reviewers (namely, Robert) by additional patches so the whole patchset can be accepted. This should ease our future kernel work re: FIPS.
The below 2 patches address (I hope) both notes Robert and Herbert have provided (thanks!). I hope the whole patchset can be accepted then.
Quoted 7 lines
Logically my 2 patches should follow [PATCH 1/4] and be patches 2 and 3. Herbert is it possible to reorder them when accepting?
Thank you! and
Best regards,
Vladis
Please just resend the whole series, with the --base option to git format-patch used, so that reviewers don't have to try to piece it together.
- Eric
Hi,
Quoted 15 lines · Eric Biggers
Quoted 13 lines · Vladis Dronov
Hi Nicolai, Robert, Herbert, all,
I would like to revive this older upstream email thread. I would like to address notes from reviewers (namely, Robert) by additional patches so the whole patchset can be accepted. This should ease our future kernel work re: FIPS.
The below 2 patches address (I hope) both notes Robert and Herbert have provided (thanks!). I hope the whole patchset can be accepted then.
Logically my 2 patches should follow [PATCH 1/4] and be patches 2 and 3. Herbert is it possible to reorder them when accepting?
Quoted 7 lines
Quoted 4 lines
Thank you! and
Best regards,
VladisPlease just resend the whole series, with the --base option to git format-patch used, so that reviewers don't have to try to piece it together.
Thank you, Eric, the patchset was resend with a proper ordering:
https://lore.kernel.org/linux-crypto/[email protected]/T/#t
with a subject: [PATCH 0/6] Trivial set of FIPS 140-3 related changes
Best regards,
Vladis
PATCH 5/6 crypto: xts - drop xts_check_key()
In reply to Nicolai Stangexts_check_key() is obsoleted by xts_verify_key(). Over time XTS crypto drivers adopted the newer xts_verify_key() variant, but xts_check_key() is still used by a number of drivers. Switch drivers to use the newer xts_verify_key() and make a couple of cleanups. This allows us to drop xts_check_key() completely and avoid redundancy.
--- arch/s390/crypto/paes_s390.c | 2 +- drivers/crypto/atmel-aes.c | 2 +- drivers/crypto/axis/artpec6_crypto.c | 2 +- drivers/crypto/cavium/cpt/cptvf_algs.c | 8 +++---- .../crypto/cavium/nitrox/nitrox_skcipher.c | 8 +++---- drivers/crypto/ccree/cc_cipher.c | 2 +- .../crypto/marvell/octeontx/otx_cptvf_algs.c | 2 +- .../marvell/octeontx2/otx2_cptvf_algs.c | 2 +- include/crypto/xts.h | 21 +++---------------- 9 files changed, 15 insertions(+), 34 deletions(-)
arch/s390/crypto/paes_s390.c +1 -1
@@ -474,7 +474,7 @@ static int xts_paes_set_key(struct crypto_skcipher *tfm, const u8 *in_key,return rc;/* -* xts_check_key verifies the key length is not odd and makes +* xts_verify_key verifies the key length is not odd and makes * sure that the two keys are not the same. This can be done * on the two protected keys as well */
drivers/crypto/atmel-aes.c +1 -1
@@ -1879,7 +1879,7 @@ static int atmel_aes_xts_setkey(struct crypto_skcipher *tfm, const u8 *key,struct atmel_aes_xts_ctx *ctx =crypto_skcipher_ctx (tfm);int err; - err =xts_check_key (crypto_skcipher_tfm (tfm), key, keylen); + err =xts_verify_key (tfm, key, keylen);if (err)return err;
drivers/crypto/axis/artpec6_crypto.c +1 -1
@@ -1621,7 +1621,7 @@ artpec6_crypto_xts_set_key(struct crypto_skcipher *cipher, const u8 *key,crypto_skcipher_ctx (cipher);int ret; - ret =xts_check_key (&cipher->base, key, keylen); + ret =xts_verify_key (cipher, key, keylen);if (ret)return ret;
drivers/crypto/cavium/cpt/cptvf_algs.c +3 -5
@@ -232,13 +232,12 @@ static int cvm_decrypt(struct skcipher_request *req)static int cvm_xts_setkey (struct crypto_skcipher *cipher,const u8 *key,u32 keylen) { -struct crypto_tfm *tfm =crypto_skcipher_tfm (cipher); -struct cvm_enc_ctx *ctx =crypto_tfm_ctx (tfm); +struct cvm_enc_ctx *ctx =crypto_skcipher_ctx (cipher);int err;const u8 *key1 = key;const u8 *key2 = key + (keylen /2 ); - err =xts_check_key (tfm, key, keylen); + err =xts_verify_key (cipher, key, keylen);if (err)return err; ctx->key_len = keylen;
@@ -289,8 +288,7 @@ static int cvm_validate_keylen(struct cvm_enc_ctx *ctx, u32 keylen)static int cvm_setkey (struct crypto_skcipher *cipher,const u8 *key,u32 keylen,u8 cipher_type) { -struct crypto_tfm *tfm =crypto_skcipher_tfm (cipher); -struct cvm_enc_ctx *ctx =crypto_tfm_ctx (tfm); +struct cvm_enc_ctx *ctx =crypto_skcipher_ctx (cipher); ctx->cipher_type = cipher_type;if (!cvm_validate_keylen (ctx, keylen)) {
drivers/crypto/cavium/nitrox/nitrox_skcipher.c +3 -5
@@ -337,12 +337,11 @@ static int nitrox_3des_decrypt(struct skcipher_request *skreq)static int nitrox_aes_xts_setkey (struct crypto_skcipher *cipher,const u8 *key,unsigned int keylen) { -struct crypto_tfm *tfm =crypto_skcipher_tfm (cipher); -struct nitrox_crypto_ctx *nctx =crypto_tfm_ctx (tfm); +struct nitrox_crypto_ctx *nctx =crypto_skcipher_ctx (cipher);struct flexi_crypto_context *fctx;int aes_keylen, ret; - ret =xts_check_key (tfm, key, keylen); + ret =xts_verify_key (cipher, key, keylen);if (ret)return ret;
@@ -362,8 +361,7 @@ static int nitrox_aes_xts_setkey(struct crypto_skcipher *cipher,static int nitrox_aes_ctr_rfc3686_setkey (struct crypto_skcipher *cipher,const u8 *key,unsigned int keylen) { -struct crypto_tfm *tfm =crypto_skcipher_tfm (cipher); -struct nitrox_crypto_ctx *nctx =crypto_tfm_ctx (tfm); +struct nitrox_crypto_ctx *nctx =crypto_skcipher_ctx (cipher);struct flexi_crypto_context *fctx;int aes_keylen;
drivers/crypto/ccree/cc_cipher.c +1 -1
@@ -460,7 +460,7 @@ static int cc_cipher_setkey(struct crypto_skcipher *sktfm, const u8 *key, }if (ctx_p->cipher_mode ==DRV_CIPHER_XTS && -xts_check_key (tfm, key, keylen)) { +xts_verify_key (sktfm, key, keylen)) {dev_dbg (dev,"weak XTS key" );return -EINVAL ; }
drivers/crypto/marvell/octeontx/otx_cptvf_algs.c +1 -1
@@ -398,7 +398,7 @@ static int otx_cpt_skcipher_xts_setkey(struct crypto_skcipher *tfm,const u8 *key1 = key;int ret; - ret =xts_check_key (crypto_skcipher_tfm (tfm), key, keylen); + ret =xts_verify_key (tfm, key, keylen);if (ret)return ret; ctx->key_len = keylen;
drivers/crypto/marvell/octeontx2/otx2_cptvf_algs.c +1 -1
@@ -412,7 +412,7 @@ static int otx2_cpt_skcipher_xts_setkey(struct crypto_skcipher *tfm,const u8 *key1 = key;int ret; - ret =xts_check_key (crypto_skcipher_tfm (tfm), key, keylen); + ret =xts_verify_key (tfm, key, keylen);if (ret)return ret; ctx->key_len = keylen;
include/crypto/xts.h +3 -18
@@ -8,23 +8,6 @@#define XTS_BLOCK_SIZE 16 -static inline int xts_check_key (struct crypto_tfm *tfm, -const u8 *key,unsigned int keylen) -{ -/* -* key consists of keys of equal size concatenated, therefore -* the length must be even. -*/ -if (keylen %2 ) -return -EINVAL ; - -/* ensure that the AES and tweak key are not identical */ -if (fips_enabled && !crypto_memneq (key, key + (keylen /2 ), keylen /2 )) -return -EINVAL ; - -return 0 ; -} -static inline int xts_verify_key (struct crypto_skcipher *tfm,const u8 *key,unsigned int keylen) {
@@ -42,7 +25,9 @@ static inline int xts_verify_key(struct crypto_skcipher *tfm,if (fips_enabled && keylen !=32 && keylen !=64 )return -EINVAL ; -/* ensure that the AES and tweak key are not identical */ +/* ensure that the AES and tweak key are not identical +* when in FIPS mode or the FORBID_WEAK_KEYS flag is set. +*/ if ((fips_enabled || (crypto_skcipher_get_flags (tfm) &CRYPTO_TFM_REQ_FORBID_WEAK_KEYS )) && !crypto_memneq (key, key + (keylen /2 ), keylen /2 ))
Signature · 1 line
2.37.2
PATCH 6/6 crypto: xts - drop redundant xts key check
In reply to Nicolai Stangexts_fallback_setkey() in xts_aes_set_key() will now enforce key size rule in FIPS mode when setting up the fallback algorithm keys, which makes the check in xts_aes_set_key() redundant or unreachable. So just drop this check.
xts_fallback_setkey() now makes a key size check in xts_verify_key():
xts_fallback_setkey()
crypto_skcipher_setkey() [ skcipher_setkey_unaligned() ]
cipher->setkey() { .setkey = xts_setkey }
xts_setkey()
xts_verify_key()--- arch/s390/crypto/aes_s390.c | 4 ---- 1 file changed, 4 deletions(-)
arch/s390/crypto/aes_s390.c +0 -4
@@ -398,10 +398,6 @@ static int xts_aes_set_key(struct crypto_skcipher *tfm, const u8 *in_key,if (err)return err; -/* In fips mode only 128 bit or 256 bit keys are valid */ -if (fips_enabled && key_len !=32 && key_len !=64 ) -return -EINVAL ; -/* Pick the correct function code based on the key length */ fc = (key_len ==32 ) ?CPACF_KM_XTS_128 : (key_len ==64 ) ?CPACF_KM_XTS_256 :0 ;
Signature · 1 line
2.37.2