Linux cryptographic layer development
 help / color / mirror / Atom feed
* [PATCH] ansi_cprng: enforce key != seed in fips mode
@ 2011-11-03 20:24 Jarod Wilson
  2011-11-04 10:51 ` Neil Horman
  0 siblings, 1 reply; 5+ messages in thread
From: Jarod Wilson @ 2011-11-03 20:24 UTC (permalink / raw)
  To: linux-crypto; +Cc: Jarod Wilson, Neil Horman, Stephan Mueller, Steve Grubb

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.

CC: Neil Horman <nhorman@tuxdriver.com>
CC: Stephan Mueller <smueller@atsec.com>
CC: Steve Grubb <sgrubb@redhat.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
---
 crypto/ansi_cprng.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index ffa0245..a7fdcb4 100644
--- a/crypto/ansi_cprng.c
+++ b/crypto/ansi_cprng.c
@@ -414,10 +414,15 @@ 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);
 
+	/* fips strictly requires seed != key */
+	if (!memcmp(seed, key, DEFAULT_PRNG_KSZ))
+		return -EINVAL;
+
 	rc = cprng_reset(tfm, seed, slen);
 
 	if (!rc)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-09  4:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-03 20:24 [PATCH] ansi_cprng: enforce key != seed in fips mode Jarod Wilson
2011-11-04 10:51 ` Neil Horman
2011-11-04 14:01   ` [PATCH v2] " Jarod Wilson
2011-11-04 15:25     ` Neil Horman
2011-11-09  4:07       ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox