diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2011-02-11 15:19:54 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2011-02-11 15:19:54 +0000 |
commit | ed12c2f7cab57a31c153df4408763f7fca6ae64b (patch) | |
tree | 15c99df8c67946bc777af7fbe8a2b7356842208e /crypto/bn/bn_rand.c | |
parent | 16a7fcc44715101656e5e0292b3c68b7dd22911d (diff) |
In FIPS mode only use "Generation by Testing Candidates" equivalent.
Diffstat (limited to 'crypto/bn/bn_rand.c')
-rw-r--r-- | crypto/bn/bn_rand.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c index 215285b90f..30cc929ff6 100644 --- a/crypto/bn/bn_rand.c +++ b/crypto/bn/bn_rand.c @@ -247,7 +247,15 @@ static int bn_rand_range(int pseudo, BIGNUM *r, const BIGNUM *range) if (n == 1) BN_zero(r); +#ifdef OPENSSL_FIPS + /* FIPS 186-3 is picky about how random numbers for keys etc are + * generated. So we just use the second case which is equivalent to + * "Generation by Testing Candidates" mentioned in B.1.2 et al. + */ + else if (!FIPS_mode() && !BN_is_bit_set(range, n - 2) && !BN_is_bit_set(range, n - 3)) +#else else if (!BN_is_bit_set(range, n - 2) && !BN_is_bit_set(range, n - 3)) +#endif { /* range = 100..._2, * so 3*range (= 11..._2) is exactly one bit longer than range */ |