path: root/crypto
diff options
authorJarod Wilson <>2011-11-09 12:04:06 +0800
committerHerbert Xu <>2011-11-09 12:04:06 +0800
commit505172e11f5a0d9916e20e40d3b0a6f87d3a59b6 (patch)
treede5c671a37c3b3479595c1c9c891848953199985 /crypto
parentbae6d3038b7faff187f4207448a40b9912cf787d (diff)
crypto: ansi_cprng - enforce key != seed in fips mode
Apparently, NIST is tightening up its requirements for FIPS validation with respect to RNGs. Its always been required that in fips mode, the ansi cprng not be fed key and seed material that was identical, but they're now interpreting FIPS 140-2, section AS07.09 as requiring that the implementation itself must enforce the requirement. Easy fix, we just do a memcmp of key and seed in fips_cprng_reset and call it a day. v2: Per Neil's advice, ensure slen is sufficiently long before we compare key and seed to avoid looking at potentially unallocated mem. CC: Stephan Mueller <> CC: Steve Grubb <> Signed-off-by: Jarod Wilson <> Acked-by: Neil Horman <> Signed-off-by: Herbert Xu <>
Diffstat (limited to 'crypto')
1 files changed, 8 insertions, 0 deletions
diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index ffa0245e2ab..6ddd99e6114 100644
--- a/crypto/ansi_cprng.c
+++ b/crypto/ansi_cprng.c
@@ -414,10 +414,18 @@ static int fips_cprng_get_random(struct crypto_rng *tfm, u8 *rdata,
static int fips_cprng_reset(struct crypto_rng *tfm, u8 *seed, unsigned int slen)
u8 rdata[DEFAULT_BLK_SZ];
+ u8 *key = seed + DEFAULT_BLK_SZ;
int rc;
struct prng_context *prng = crypto_rng_ctx(tfm);
+ return -EINVAL;
+ /* fips strictly requires seed != key */
+ if (!memcmp(seed, key, DEFAULT_PRNG_KSZ))
+ return -EINVAL;
rc = cprng_reset(tfm, seed, slen);
if (!rc)