Fix: drbgtest fails when tests are executed in random order
authorDr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
Mon, 19 Mar 2018 20:11:50 +0000 (21:11 +0100)
committerMatt Caswell <matt@openssl.org>
Mon, 19 Mar 2018 22:55:11 +0000 (22:55 +0000)
[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)

test/drbgtest.c

index ca8a2113910c11ba8d5c3d741ea20bde569ad843..bef504ebd1bb0d973646f57ccf3c51f91415311d 100644 (file)
@@ -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;