From: Jarod Wilson <jarod@redhat.com>
To: linux-crypto@vger.kernel.org
Cc: Jarod Wilson <jarod@redhat.com>,
Neil Horman <nhorman@tuxdriver.com>,
Stephan Mueller <smueller@atsec.com>,
Steve Grubb <sgrubb@redhat.com>
Subject: [PATCH v2] ansi_cprng: enforce key != seed in fips mode
Date: Fri, 4 Nov 2011 10:01:25 -0400 [thread overview]
Message-ID: <1320415285-4527-1-git-send-email-jarod@redhat.com> (raw)
In-Reply-To: <20111104105101.GA23232@hmsreliant.think-freely.org>
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: 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 | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/crypto/ansi_cprng.c b/crypto/ansi_cprng.c
index ffa0245..6ddd99e 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);
+ if (slen < DEFAULT_PRNG_KSZ + DEFAULT_BLK_SZ)
+ return -EINVAL;
+
+ /* 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
next prev parent reply other threads:[~2011-11-04 14:01 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Jarod Wilson [this message]
2011-11-04 15:25 ` [PATCH v2] " Neil Horman
2011-11-09 4:07 ` Herbert Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1320415285-4527-1-git-send-email-jarod@redhat.com \
--to=jarod@redhat.com \
--cc=linux-crypto@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=sgrubb@redhat.com \
--cc=smueller@atsec.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox