2 * Copyright 2011-2018 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
11 #include "internal/nelem.h"
12 #include <openssl/crypto.h>
13 #include <openssl/err.h>
14 #include <openssl/rand.h>
15 #include <openssl/obj_mac.h>
16 #include <openssl/evp.h>
17 #include <openssl/aes.h>
18 #include "../crypto/rand/rand_lcl.h"
27 typedef struct drbg_selftest_data_st {
32 /* KAT data for no PR */
33 const unsigned char *entropy;
35 const unsigned char *nonce;
37 const unsigned char *pers;
39 const unsigned char *adin;
41 const unsigned char *entropyreseed;
42 size_t entropyreseedlen;
43 const unsigned char *adinreseed;
45 const unsigned char *adin2;
47 const unsigned char *expected;
49 const unsigned char *kat2;
53 const unsigned char *entropy_pr;
55 const unsigned char *nonce_pr;
57 const unsigned char *pers_pr;
59 const unsigned char *adin_pr;
61 const unsigned char *entropypr_pr;
62 size_t entropyprlen_pr;
63 const unsigned char *ading_pr;
65 const unsigned char *entropyg_pr;
66 size_t entropyglen_pr;
67 const unsigned char *kat_pr;
69 const unsigned char *kat2_pr;
73 #define make_drbg_test_data(nid, flag, pr, post) {\
75 pr##_entropyinput, sizeof(pr##_entropyinput), \
76 pr##_nonce, sizeof(pr##_nonce), \
77 pr##_personalizationstring, sizeof(pr##_personalizationstring), \
78 pr##_additionalinput, sizeof(pr##_additionalinput), \
79 pr##_entropyinputreseed, sizeof(pr##_entropyinputreseed), \
80 pr##_additionalinputreseed, sizeof(pr##_additionalinputreseed), \
81 pr##_additionalinput2, sizeof(pr##_additionalinput2), \
82 pr##_int_returnedbits, sizeof(pr##_int_returnedbits), \
83 pr##_returnedbits, sizeof(pr##_returnedbits), \
84 pr##_pr_entropyinput, sizeof(pr##_pr_entropyinput), \
85 pr##_pr_nonce, sizeof(pr##_pr_nonce), \
86 pr##_pr_personalizationstring, sizeof(pr##_pr_personalizationstring), \
87 pr##_pr_additionalinput, sizeof(pr##_pr_additionalinput), \
88 pr##_pr_entropyinputpr, sizeof(pr##_pr_entropyinputpr), \
89 pr##_pr_additionalinput2, sizeof(pr##_pr_additionalinput2), \
90 pr##_pr_entropyinputpr2, sizeof(pr##_pr_entropyinputpr2), \
91 pr##_pr_int_returnedbits, sizeof(pr##_pr_int_returnedbits), \
92 pr##_pr_returnedbits, sizeof(pr##_pr_returnedbits) \
95 #define make_drbg_test_data_use_df(nid, pr, p) \
96 make_drbg_test_data(nid, 0, pr, p)
98 #define make_drbg_test_data_no_df(nid, pr, p) \
99 make_drbg_test_data(nid, RAND_DRBG_FLAG_CTR_NO_DF, pr, p)
101 static DRBG_SELFTEST_DATA drbg_test[] = {
102 make_drbg_test_data_no_df (NID_aes_128_ctr, aes_128_no_df, 0),
103 make_drbg_test_data_no_df (NID_aes_192_ctr, aes_192_no_df, 0),
104 make_drbg_test_data_no_df (NID_aes_256_ctr, aes_256_no_df, 1),
105 make_drbg_test_data_use_df(NID_aes_128_ctr, aes_128_use_df, 0),
106 make_drbg_test_data_use_df(NID_aes_192_ctr, aes_192_use_df, 0),
107 make_drbg_test_data_use_df(NID_aes_256_ctr, aes_256_use_df, 1),
110 static int app_data_index;
113 * Test context data, attached as EXDATA to the RAND_DRBG
115 typedef struct test_ctx_st {
116 const unsigned char *entropy;
119 const unsigned char *nonce;
124 static size_t kat_entropy(RAND_DRBG *drbg, unsigned char **pout,
125 int entropy, size_t min_len, size_t max_len,
126 int prediction_resistance)
128 TEST_CTX *t = (TEST_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);
131 *pout = (unsigned char *)t->entropy;
132 return t->entropylen;
135 static size_t kat_nonce(RAND_DRBG *drbg, unsigned char **pout,
136 int entropy, size_t min_len, size_t max_len)
138 TEST_CTX *t = (TEST_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);
141 *pout = (unsigned char *)t->nonce;
145 static int uninstantiate(RAND_DRBG *drbg)
147 int ret = drbg == NULL ? 1 : RAND_DRBG_uninstantiate(drbg);
154 * Do a single KAT test. Return 0 on failure.
156 static int single_kat(DRBG_SELFTEST_DATA *td)
158 RAND_DRBG *drbg = NULL;
161 unsigned char buff[1024];
164 * Test without PR: Instantiate DRBG with test entropy, nonce and
165 * personalisation string.
167 if (!TEST_ptr(drbg = RAND_DRBG_new(td->nid, td->flags, NULL)))
169 if (!TEST_true(RAND_DRBG_set_callbacks(drbg, kat_entropy, NULL,
174 memset(&t, 0, sizeof(t));
175 t.entropy = td->entropy;
176 t.entropylen = td->entropylen;
178 t.noncelen = td->noncelen;
179 RAND_DRBG_set_ex_data(drbg, app_data_index, &t);
181 if (!TEST_true(RAND_DRBG_instantiate(drbg, td->pers, td->perslen))
182 || !TEST_true(RAND_DRBG_generate(drbg, buff, td->exlen, 0,
183 td->adin, td->adinlen))
184 || !TEST_mem_eq(td->expected, td->exlen, buff, td->exlen))
187 /* Reseed DRBG with test entropy and additional input */
188 t.entropy = td->entropyreseed;
189 t.entropylen = td->entropyreseedlen;
190 if (!TEST_true(RAND_DRBG_reseed(drbg, td->adinreseed, td->adinreseedlen, 0)
191 || !TEST_true(RAND_DRBG_generate(drbg, buff, td->kat2len, 0,
192 td->adin2, td->adin2len))
193 || !TEST_mem_eq(td->kat2, td->kat2len, buff, td->kat2len)))
198 * Now test with PR: Instantiate DRBG with test entropy, nonce and
199 * personalisation string.
201 if (!TEST_true(RAND_DRBG_set(drbg, td->nid, td->flags))
202 || !TEST_true(RAND_DRBG_set_callbacks(drbg, kat_entropy, NULL,
205 RAND_DRBG_set_ex_data(drbg, app_data_index, &t);
206 t.entropy = td->entropy_pr;
207 t.entropylen = td->entropylen_pr;
208 t.nonce = td->nonce_pr;
209 t.noncelen = td->noncelen_pr;
212 if (!TEST_true(RAND_DRBG_instantiate(drbg, td->pers_pr, td->perslen_pr)))
216 * Now generate with PR: we need to supply entropy as this will
217 * perform a reseed operation.
219 t.entropy = td->entropypr_pr;
220 t.entropylen = td->entropyprlen_pr;
221 if (!TEST_true(RAND_DRBG_generate(drbg, buff, td->katlen_pr, 1,
222 td->adin_pr, td->adinlen_pr))
223 || !TEST_mem_eq(td->kat_pr, td->katlen_pr, buff, td->katlen_pr))
227 * Now generate again with PR: supply new entropy again.
229 t.entropy = td->entropyg_pr;
230 t.entropylen = td->entropyglen_pr;
232 if (!TEST_true(RAND_DRBG_generate(drbg, buff, td->kat2len_pr, 1,
233 td->ading_pr, td->adinglen_pr))
234 || !TEST_mem_eq(td->kat2_pr, td->kat2len_pr,
235 buff, td->kat2len_pr))
240 RAND_DRBG_free(drbg);
241 return failures == 0;
245 * Initialise a DRBG based on selftest data
247 static int init(RAND_DRBG *drbg, DRBG_SELFTEST_DATA *td, TEST_CTX *t)
249 if (!TEST_true(RAND_DRBG_set(drbg, td->nid, td->flags))
250 || !TEST_true(RAND_DRBG_set_callbacks(drbg, kat_entropy, NULL,
253 RAND_DRBG_set_ex_data(drbg, app_data_index, t);
254 t->entropy = td->entropy;
255 t->entropylen = td->entropylen;
256 t->nonce = td->nonce;
257 t->noncelen = td->noncelen;
264 * Initialise and instantiate DRBG based on selftest data
266 static int instantiate(RAND_DRBG *drbg, DRBG_SELFTEST_DATA *td,
269 if (!TEST_true(init(drbg, td, t))
270 || !TEST_true(RAND_DRBG_instantiate(drbg, td->pers, td->perslen)))
276 * Perform extensive error checking as required by SP800-90.
277 * Induce several failure modes and check an error condition is set.
279 static int error_check(DRBG_SELFTEST_DATA *td)
281 static char zero[sizeof(RAND_DRBG)];
282 RAND_DRBG *drbg = NULL;
284 unsigned char buff[1024];
285 unsigned int generate_counter_tmp;
288 if (!TEST_ptr(drbg = RAND_DRBG_new(0, 0, NULL)))
292 * Personalisation string tests
295 /* Test detection of too large personlisation string */
296 if (!init(drbg, td, &t)
297 || RAND_DRBG_instantiate(drbg, td->pers, drbg->max_perslen + 1) > 0)
301 * Entropy source tests
304 /* Test entropy source failure detecion: i.e. returns no data */
306 if (TEST_int_le(RAND_DRBG_instantiate(drbg, td->pers, td->perslen), 0))
309 /* Try to generate output from uninstantiated DRBG */
310 if (!TEST_false(RAND_DRBG_generate(drbg, buff, td->exlen, 0,
311 td->adin, td->adinlen))
312 || !uninstantiate(drbg))
315 /* Test insufficient entropy */
316 t.entropylen = drbg->min_entropylen - 1;
317 if (!init(drbg, td, &t)
318 || RAND_DRBG_instantiate(drbg, td->pers, td->perslen) > 0
319 || !uninstantiate(drbg))
322 /* Test too much entropy */
323 t.entropylen = drbg->max_entropylen + 1;
324 if (!init(drbg, td, &t)
325 || RAND_DRBG_instantiate(drbg, td->pers, td->perslen) > 0
326 || !uninstantiate(drbg))
333 /* Test too small nonce */
334 if (drbg->min_noncelen) {
335 t.noncelen = drbg->min_noncelen - 1;
336 if (!init(drbg, td, &t)
337 || RAND_DRBG_instantiate(drbg, td->pers, td->perslen) > 0
338 || !uninstantiate(drbg))
342 /* Test too large nonce */
343 if (drbg->max_noncelen) {
344 t.noncelen = drbg->max_noncelen + 1;
345 if (!init(drbg, td, &t)
346 || RAND_DRBG_instantiate(drbg, td->pers, td->perslen) > 0
347 || !uninstantiate(drbg))
351 /* Instantiate with valid data, Check generation is now OK */
352 if (!instantiate(drbg, td, &t)
353 || !TEST_true(RAND_DRBG_generate(drbg, buff, td->exlen, 0,
354 td->adin, td->adinlen)))
357 /* Request too much data for one request */
358 if (!TEST_false(RAND_DRBG_generate(drbg, buff, drbg->max_request + 1, 0,
359 td->adin, td->adinlen)))
362 /* Try too large additional input */
363 if (!TEST_false(RAND_DRBG_generate(drbg, buff, td->exlen, 0,
364 td->adin, drbg->max_adinlen + 1)))
368 * Check prediction resistance request fails if entropy source
372 if (TEST_false(RAND_DRBG_generate(drbg, buff, td->exlen, 1,
373 td->adin, td->adinlen))
374 || !uninstantiate(drbg))
377 /* Instantiate again with valid data */
378 if (!instantiate(drbg, td, &t))
380 generate_counter_tmp = drbg->generate_counter;
381 drbg->generate_counter = drbg->reseed_interval;
383 /* Generate output and check entropy has been requested for reseed */
385 if (!TEST_true(RAND_DRBG_generate(drbg, buff, td->exlen, 0,
386 td->adin, td->adinlen))
387 || !TEST_int_eq(t.entropycnt, 1)
388 || !TEST_int_eq(drbg->generate_counter, generate_counter_tmp + 1)
389 || !uninstantiate(drbg))
393 * Check prediction resistance request fails if entropy source
397 if (!TEST_false(RAND_DRBG_generate(drbg, buff, td->exlen, 1,
398 td->adin, td->adinlen))
399 || !uninstantiate(drbg))
402 /* Test reseed counter works */
403 if (!instantiate(drbg, td, &t))
405 generate_counter_tmp = drbg->generate_counter;
406 drbg->generate_counter = drbg->reseed_interval;
408 /* Generate output and check entropy has been requested for reseed */
410 if (!TEST_true(RAND_DRBG_generate(drbg, buff, td->exlen, 0,
411 td->adin, td->adinlen))
412 || !TEST_int_eq(t.entropycnt, 1)
413 || !TEST_int_eq(drbg->generate_counter, generate_counter_tmp + 1)
414 || !uninstantiate(drbg))
418 * Explicit reseed tests
421 /* Test explicit reseed with too large additional input */
422 if (!init(drbg, td, &t)
423 || RAND_DRBG_reseed(drbg, td->adin, drbg->max_adinlen + 1, 0) > 0)
426 /* Test explicit reseed with entropy source failure */
428 if (!TEST_int_le(RAND_DRBG_reseed(drbg, td->adin, td->adinlen, 0), 0)
429 || !uninstantiate(drbg))
432 /* Test explicit reseed with too much entropy */
433 if (!init(drbg, td, &t))
435 t.entropylen = drbg->max_entropylen + 1;
436 if (!TEST_int_le(RAND_DRBG_reseed(drbg, td->adin, td->adinlen, 0), 0)
437 || !uninstantiate(drbg))
440 /* Test explicit reseed with too little entropy */
441 if (!init(drbg, td, &t))
443 t.entropylen = drbg->min_entropylen - 1;
444 if (!TEST_int_le(RAND_DRBG_reseed(drbg, td->adin, td->adinlen, 0), 0)
445 || !uninstantiate(drbg))
448 /* Standard says we have to check uninstantiate really zeroes */
449 if (!TEST_mem_eq(zero, sizeof(drbg->data), &drbg->data, sizeof(drbg->data)))
456 RAND_DRBG_free(drbg);
460 static int test_kats(int i)
462 DRBG_SELFTEST_DATA *td = &drbg_test[i];
473 static int test_error_checks(int i)
475 DRBG_SELFTEST_DATA *td = &drbg_test[i];
487 * Hook context data, attached as EXDATA to the RAND_DRBG
489 typedef struct hook_ctx_st {
492 * Currently, all DRBGs use the same get_entropy() callback.
493 * The tests however, don't assume this and store
494 * the original callback for every DRBG separately.
496 RAND_DRBG_get_entropy_fn get_entropy;
497 /* forces a failure of the get_entropy() call if nonzero */
499 /* counts successful reseeds */
503 static HOOK_CTX master_ctx, public_ctx, private_ctx;
505 static HOOK_CTX *get_hook_ctx(RAND_DRBG *drbg)
507 return (HOOK_CTX *)RAND_DRBG_get_ex_data(drbg, app_data_index);
510 /* Intercepts and counts calls to the get_entropy() callback */
511 static size_t get_entropy_hook(RAND_DRBG *drbg, unsigned char **pout,
512 int entropy, size_t min_len, size_t max_len,
513 int prediction_resistance)
516 HOOK_CTX *ctx = get_hook_ctx(drbg);
521 ret = ctx->get_entropy(drbg, pout, entropy, min_len, max_len,
522 prediction_resistance);
529 /* Installs a hook for the get_entropy() callback of the given drbg */
530 static void hook_drbg(RAND_DRBG *drbg, HOOK_CTX *ctx)
532 memset(ctx, 0, sizeof(*ctx));
534 ctx->get_entropy = drbg->get_entropy;
535 drbg->get_entropy = get_entropy_hook;
536 RAND_DRBG_set_ex_data(drbg, app_data_index, ctx);
539 /* Installs the hook for the get_entropy() callback of the given drbg */
540 static void unhook_drbg(RAND_DRBG *drbg)
542 HOOK_CTX *ctx = get_hook_ctx(drbg);
544 drbg->get_entropy = ctx->get_entropy;
545 CRYPTO_free_ex_data(CRYPTO_EX_INDEX_DRBG, drbg, &drbg->ex_data);
548 /* Resets the given hook context */
549 static void reset_hook_ctx(HOOK_CTX *ctx)
552 ctx->reseed_count = 0;
555 /* Resets all drbg hook contexts */
556 static void reset_drbg_hook_ctx()
558 reset_hook_ctx(&master_ctx);
559 reset_hook_ctx(&public_ctx);
560 reset_hook_ctx(&private_ctx);
564 * Generates random output using RAND_bytes() and RAND_priv_bytes()
565 * and checks whether the three shared DRBGs were reseeded as
568 * |expect_success|: expected outcome (as reported by RAND_status())
569 * |master|, |public|, |private|: pointers to the three shared DRBGs
570 * |expect_xxx_reseed| =
571 * 1: it is expected that the specified DRBG is reseeded
572 * 0: it is expected that the specified DRBG is not reseeded
573 * -1: don't check whether the specified DRBG was reseeded or not
575 static int test_drbg_reseed(int expect_success,
579 int expect_master_reseed,
580 int expect_public_reseed,
581 int expect_private_reseed
584 unsigned char buf[32];
585 time_t before_reseed, after_reseed;
586 int expected_state = (expect_success ? DRBG_READY : DRBG_ERROR);
589 * step 1: check preconditions
592 /* Test whether seed propagation is enabled */
593 if (!TEST_int_ne(master->reseed_counter, 0)
594 || !TEST_int_ne(public->reseed_counter, 0)
595 || !TEST_int_ne(private->reseed_counter, 0))
598 /* Check whether the master DRBG's reseed counter is the largest one */
599 if (!TEST_int_le(public->reseed_counter, master->reseed_counter)
600 || !TEST_int_le(private->reseed_counter, master->reseed_counter))
604 * step 2: generate random output
607 /* Generate random output from the public and private DRBG */
608 before_reseed = expect_master_reseed == 1 ? time(NULL) : 0;
609 if (!TEST_int_eq(RAND_bytes(buf, sizeof(buf)), expect_success)
610 || !TEST_int_eq(RAND_priv_bytes(buf, sizeof(buf)), expect_success))
612 after_reseed = time(NULL);
616 * step 3: check postconditions
619 /* Test whether reseeding succeeded as expected */
620 if (!TEST_int_eq(master->state, expected_state)
621 || !TEST_int_eq(public->state, expected_state)
622 || !TEST_int_eq(private->state, expected_state))
625 if (expect_master_reseed >= 0) {
626 /* Test whether master DRBG was reseeded as expected */
627 if (!TEST_int_eq(master_ctx.reseed_count, expect_master_reseed))
631 if (expect_public_reseed >= 0) {
632 /* Test whether public DRBG was reseeded as expected */
633 if (!TEST_int_eq(public_ctx.reseed_count, expect_public_reseed))
637 if (expect_private_reseed >= 0) {
638 /* Test whether public DRBG was reseeded as expected */
639 if (!TEST_int_eq(private_ctx.reseed_count, expect_private_reseed))
643 if (expect_success == 1) {
644 /* Test whether all three reseed counters are synchronized */
645 if (!TEST_int_eq(public->reseed_counter, master->reseed_counter)
646 || !TEST_int_eq(private->reseed_counter, master->reseed_counter))
649 /* Test whether reseed time of master DRBG is set correctly */
650 if (!TEST_time_t_le(before_reseed, master->reseed_time)
651 || !TEST_time_t_le(master->reseed_time, after_reseed))
654 /* Test whether reseed times of child DRBGs are synchronized with master */
655 if (!TEST_time_t_ge(public->reseed_time, master->reseed_time)
656 || !TEST_time_t_ge(private->reseed_time, master->reseed_time))
666 * Test whether the default rand_method (RAND_OpenSSL()) is
667 * setup correctly, in particular whether reseeding works
670 static int test_rand_reseed(void)
672 RAND_DRBG *master, *public, *private;
673 unsigned char rand_add_buf[256];
676 /* Check whether RAND_OpenSSL() is the default method */
677 if (!TEST_ptr_eq(RAND_get_rand_method(), RAND_OpenSSL()))
680 /* All three DRBGs should be non-null */
681 if (!TEST_ptr(master = RAND_DRBG_get0_master())
682 || !TEST_ptr(public = RAND_DRBG_get0_public())
683 || !TEST_ptr(private = RAND_DRBG_get0_private()))
686 /* There should be three distinct DRBGs, two of them chained to master */
687 if (!TEST_ptr_ne(public, private)
688 || !TEST_ptr_ne(public, master)
689 || !TEST_ptr_ne(private, master)
690 || !TEST_ptr_eq(public->parent, master)
691 || !TEST_ptr_eq(private->parent, master))
694 /* Install hooks for the following tests */
695 hook_drbg(master, &master_ctx);
696 hook_drbg(public, &public_ctx);
697 hook_drbg(private, &private_ctx);
700 * Test initial state of shared DRBs
702 if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 0, 0)))
704 reset_drbg_hook_ctx();
707 * Test whether the public and private DRBG are both reseeded when their
708 * reseed counters differ from the master's reseed counter.
710 master->reseed_counter++;
711 if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 1, 1)))
713 reset_drbg_hook_ctx();
716 * Test whether the public DRBG is reseeded when its reseed counter differs
717 * from the master's reseed counter.
719 master->reseed_counter++;
720 private->reseed_counter++;
721 if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 1, 0)))
723 reset_drbg_hook_ctx();
726 * Test whether the private DRBG is reseeded when its reseed counter differs
727 * from the master's reseed counter.
729 master->reseed_counter++;
730 public->reseed_counter++;
731 if (!TEST_true(test_drbg_reseed(1, master, public, private, 0, 0, 1)))
733 reset_drbg_hook_ctx();
736 /* fill 'randomness' buffer with some arbitrary data */
737 memset(rand_add_buf, 'r', sizeof(rand_add_buf));
740 * Test whether all three DRBGs are reseeded by RAND_add()
742 RAND_add(rand_add_buf, sizeof(rand_add_buf), sizeof(rand_add_buf));
743 if (!TEST_true(test_drbg_reseed(1, master, public, private, 1, 1, 1)))
745 reset_drbg_hook_ctx();
749 * Test whether none of the DRBGs is reseed if the master fails to reseed
752 master->reseed_counter++;
753 RAND_add(rand_add_buf, sizeof(rand_add_buf), sizeof(rand_add_buf));
754 if (!TEST_true(test_drbg_reseed(0, master, public, private, 0, 0, 0)))
756 reset_drbg_hook_ctx();
764 unhook_drbg(private);
769 #if defined(OPENSSL_THREADS)
771 static void run_multi_thread_test(void)
773 unsigned char buf[256];
774 time_t start = time(NULL);
775 RAND_DRBG *public, *private;
777 public = RAND_DRBG_get0_public();
778 private = RAND_DRBG_get0_private();
779 RAND_DRBG_set_reseed_time_interval(public, 1);
780 RAND_DRBG_set_reseed_time_interval(private, 1);
783 RAND_bytes(buf, sizeof(buf));
784 RAND_priv_bytes(buf, sizeof(buf));
786 while(time(NULL) - start < 5);
789 # if defined(OPENSSL_SYS_WINDOWS)
791 typedef HANDLE thread_t;
793 static DWORD WINAPI thread_run(LPVOID arg)
795 run_multi_thread_test();
799 static int run_thread(thread_t *t)
801 *t = CreateThread(NULL, 0, thread_run, NULL, 0, NULL);
805 static int wait_for_thread(thread_t thread)
807 return WaitForSingleObject(thread, INFINITE) == 0;
812 typedef pthread_t thread_t;
814 static void *thread_run(void *arg)
816 run_multi_thread_test();
820 static int run_thread(thread_t *t)
822 return pthread_create(t, NULL, thread_run, NULL) == 0;
825 static int wait_for_thread(thread_t thread)
827 return pthread_join(thread, NULL) == 0;
833 * The main thread will also run the test, so we'll have THREADS+1 parallel
838 static int test_multi_thread(void)
843 for (i = 0; i < THREADS; i++)
845 run_multi_thread_test();
846 for (i = 0; i < THREADS; i++)
847 wait_for_thread(t[i]);
852 int setup_tests(void)
854 app_data_index = RAND_DRBG_get_ex_new_index(0L, NULL, NULL, NULL, NULL);
856 ADD_ALL_TESTS(test_kats, OSSL_NELEM(drbg_test));
857 ADD_ALL_TESTS(test_error_checks, OSSL_NELEM(drbg_test));
858 ADD_TEST(test_rand_reseed);
859 #if defined(OPENSSL_THREADS)
860 ADD_TEST(test_multi_thread);