Skip to content

Commit

Permalink
Merge branch 'master' into upd_1.3.56
Browse files Browse the repository at this point in the history
  • Loading branch information
nickitat committed Jan 23, 2024
2 parents 5e0c164 + b9f485b commit 955d421
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions utils/s2n_random.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,19 @@ static S2N_RESULT s2n_register_cleanup_per_thread_rand_state()
return S2N_RESULT_OK;
}

static void s2n_make_per_thread_rand_state_cleanup_key()
{
pthread_key_create(&s2n_per_thread_rand_state_cleanup_key, s2n_cleanup_per_thread_rand_state);
}

/* Register calling s2n_rand_cleanup_thread() at the current thread's exit. */
static S2N_RESULT s2n_register_cleanup_per_thread_rand_state()
{
RESULT_GUARD_POSIX(pthread_once(&s2n_per_thread_rand_state_cleanup_key_once, s2n_make_per_thread_rand_state_cleanup_key));
RESULT_GUARD_POSIX(pthread_setspecific(s2n_per_thread_rand_state_cleanup_key, &s2n_per_thread_rand_state));
return S2N_RESULT_OK;
}

{
RESULT_GUARD_PTR(out_blob);
RESULT_GUARD_OSSL(RAND_bytes(out_blob->data, out_blob->size), S2N_ERR_DRBG);
Expand Down

0 comments on commit 955d421

Please sign in to comment.