summaryrefslogtreecommitdiffstats
path: root/test/drbgtest.c
diff options
context:
space:
mode:
authorDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>2019-04-11 00:06:37 +0200
committerDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>2019-05-10 07:22:05 +0200
commit3a50a8a91ad10e406544d16247957a17a5d5beac (patch)
tree65f9d74a00149f4d7b0e63792aa889d50c8cc2db /test/drbgtest.c
parentTest skip option. (diff)
downloadopenssl-3a50a8a91ad10e406544d16247957a17a5d5beac.tar.xz
openssl-3a50a8a91ad10e406544d16247957a17a5d5beac.zip
Ignore entropy from RAND_add()/RAND_seed() in FIPS mode
The functions RAND_add() and RAND_seed() provide a legacy API which enables the application to seed the CSPRNG. But NIST SP-800-90A clearly mandates that entropy *shall not* be provided by the consuming application, neither for instantiation, nor for reseeding. The provided random data will be mixed into the DRBG state as additional data only, and no entropy will accounted for it. Reviewed-by: Paul Dale <paul.dale@oracle.com> (Merged from https://github.com/openssl/openssl/pull/8722)
Diffstat (limited to 'test/drbgtest.c')
-rw-r--r--test/drbgtest.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/drbgtest.c b/test/drbgtest.c
index 42af048699..9e0aba83ab 100644
--- a/test/drbgtest.c
+++ b/test/drbgtest.c
@@ -802,6 +802,7 @@ static int test_rand_drbg_reseed(void)
/* fill 'randomness' buffer with some arbitrary data */
memset(rand_add_buf, 'r', sizeof(rand_add_buf));
+#ifndef FIPS_MODE
/*
* Test whether all three DRBGs are reseeded by RAND_add().
* The before_reseed time has to be measured here and passed into the
@@ -827,6 +828,20 @@ static int test_rand_drbg_reseed(void)
if (!TEST_true(test_drbg_reseed(0, master, public, private, 0, 0, 0, 0)))
goto error;
reset_drbg_hook_ctx();
+#else /* FIPS_MODE */
+ /*
+ * In FIPS mode, random data provided by the application via RAND_add()
+ * is not considered a trusted entropy source. It is only treated as
+ * additional_data and no reseeding is forced. This test assures that
+ * no reseeding occurs.
+ */
+ before_reseed = time(NULL);
+ RAND_add(rand_add_buf, sizeof(rand_add_buf), sizeof(rand_add_buf));
+ if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 0, 0,
+ before_reseed)))
+ goto error;
+ reset_drbg_hook_ctx();
+#endif
rv = 1;