Skip to content

Commit 1c4428b

Browse files
nicstangeherbertx
authored andcommitted
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. Signed-off-by: Nicolai Stange <[email protected]> Signed-off-by: Vladis Dronov <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 39a76cf commit 1c4428b

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

include/crypto/xts.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,13 @@ static inline int xts_verify_key(struct crypto_skcipher *tfm,
3535
if (keylen % 2)
3636
return -EINVAL;
3737

38+
/*
39+
* In FIPS mode only a combined key length of either 256 or
40+
* 512 bits is allowed, c.f. FIPS 140-3 IG C.I.
41+
*/
42+
if (fips_enabled && keylen != 32 && keylen != 64)
43+
return -EINVAL;
44+
3845
/* ensure that the AES and tweak key are not identical */
3946
if ((fips_enabled || (crypto_skcipher_get_flags(tfm) &
4047
CRYPTO_TFM_REQ_FORBID_WEAK_KEYS)) &&

0 commit comments

Comments
 (0)