summaryrefslogtreecommitdiff
path: root/test/drbgtest.c
diff options
context:
space:
mode:
authorDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>2018-03-19 21:11:50 +0100
committerMatt Caswell <matt@openssl.org>2018-03-19 22:55:11 +0000
commit59f124f90f52395c240fcd2f387a91234b0d25be (patch)
tree181eceda18fda6436dfd56e4765a971fdb7e9672 /test/drbgtest.c
parent8f8be103fd7d8b5992724d618c99cbddd7dd00d7 (diff)
downloadopenssl-new-59f124f90f52395c240fcd2f387a91234b0d25be.tar.gz
Fix: drbgtest fails when tests are executed in random order
[extended tests] The test_rand_reseed assumed that the global DRBGs were not used previously. This assumption is false when the tests are executed in random order (OPENSSL_TEST_RAND_ORDER). So we uninstantiate them first and add a test for the first instantiation. Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5680)
Diffstat (limited to 'test/drbgtest.c')
-rw-r--r--test/drbgtest.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/test/drbgtest.c b/test/drbgtest.c
index ca8a211391..bef504ebd1 100644
--- a/test/drbgtest.c
+++ b/test/drbgtest.c
@@ -691,13 +691,28 @@ static int test_rand_reseed(void)
|| !TEST_ptr_eq(private->parent, master))
return 0;
+ /* uninstantiate the three global DRBGs */
+ RAND_DRBG_uninstantiate(private);
+ RAND_DRBG_uninstantiate(public);
+ RAND_DRBG_uninstantiate(master);
+
+
/* Install hooks for the following tests */
hook_drbg(master, &master_ctx);
hook_drbg(public, &public_ctx);
hook_drbg(private, &private_ctx);
+
+ /*
+ * Test initial seeding of shared DRBGs
+ */
+ if (!TEST_true(test_drbg_reseed(1, master, public, private, 1, 1, 1)))
+ goto error;
+ reset_drbg_hook_ctx();
+
+
/*
- * Test initial state of shared DRBs
+ * Test initial state of shared DRBGs
*/
if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 0, 0)))
goto error;