Set OPENSSL_ENGINES for Windows
[openssl.git] / test / drbgtest.c
index b1fc751cd97cd36606ecc7303ae199f5678e151e..fcb4b2846010e1fccc9a7a35c55d1383694d4b8f 100644 (file)
@@ -438,7 +438,7 @@ static int error_check(DRBG_SELFTEST_DATA *td)
         goto err;
 
     /* Standard says we have to check uninstantiate really zeroes */
-    if (!TEST_mem_eq(zero, sizeof(drbg->ctr), &drbg->ctr, sizeof(drbg->ctr)))
+    if (!TEST_mem_eq(zero, sizeof(drbg->data), &drbg->data, sizeof(drbg->data)))
         goto err;
 
     ret = 1;
@@ -573,6 +573,7 @@ static int test_drbg_reseed(int expect_success,
                            )
 {
     unsigned char buf[32];
+    time_t before_reseed, after_reseed;
     int expected_state = (expect_success ? DRBG_READY : DRBG_ERROR);
 
     /*
@@ -595,9 +596,11 @@ static int test_drbg_reseed(int expect_success,
      */
 
     /* Generate random output from the public and private DRBG */
+    before_reseed = expect_master_reseed == 1 ? time(NULL) : 0;
     if (!TEST_int_eq(RAND_bytes(buf, sizeof(buf)), expect_success)
         || !TEST_int_eq(RAND_priv_bytes(buf, sizeof(buf)), expect_success))
         return 0;
+    after_reseed = time(NULL);
 
 
     /*
@@ -633,6 +636,16 @@ static int test_drbg_reseed(int expect_success,
         if (!TEST_int_eq(public->reseed_counter, master->reseed_counter)
             || !TEST_int_eq(private->reseed_counter, master->reseed_counter))
             return 0;
+
+        /* Test whether reseed time of master DRBG is set correctly */
+        if (!TEST_time_t_le(before_reseed, master->reseed_time)
+            || !TEST_time_t_le(master->reseed_time, after_reseed))
+            return 0;
+
+        /* Test whether reseed times of child DRBGs are synchronized with master */
+        if (!TEST_time_t_ge(public->reseed_time, master->reseed_time)
+            || !TEST_time_t_ge(private->reseed_time, master->reseed_time))
+            return 0;
     } else {
         ERR_clear_error();
     }