diff options
author | Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> | 2019-05-30 18:52:39 +0200 |
---|---|---|
committer | Dr. Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> | 2019-09-11 11:22:18 +0200 |
commit | 5562dbb39cbf9db41dad9b8d3ae643262e458c63 (patch) | |
tree | ec3cc7ef1b46aa11724b4c9945d6206a221b0d07 /crypto/rand/rand_unix.c | |
parent | drbg: ensure fork-safety without using a pthread_atfork handler (diff) | |
download | openssl-5562dbb39cbf9db41dad9b8d3ae643262e458c63.tar.xz openssl-5562dbb39cbf9db41dad9b8d3ae643262e458c63.zip |
drbg: add fork id to additional data on UNIX systems
Provides a little extra fork-safety on UNIX systems, adding to the
fact that all DRBGs reseed automatically when the fork_id changes.
Reviewed-by: Paul Dale <paul.dale@oracle.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/9832)
Diffstat (limited to 'crypto/rand/rand_unix.c')
-rw-r--r-- | crypto/rand/rand_unix.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c index 813964665f..8641badbff 100644 --- a/crypto/rand/rand_unix.c +++ b/crypto/rand/rand_unix.c @@ -704,6 +704,7 @@ int rand_pool_add_nonce_data(RAND_POOL *pool) int rand_pool_add_additional_data(RAND_POOL *pool) { struct { + int fork_id; CRYPTO_THREAD_ID tid; uint64_t time; } data; @@ -713,9 +714,11 @@ int rand_pool_add_additional_data(RAND_POOL *pool) /* * Add some noise from the thread id and a high resolution timer. + * The fork_id adds some extra fork-safety. * The thread id adds a little randomness if the drbg is accessed * concurrently (which is the case for the <master> drbg). */ + data.fork_id = openssl_get_fork_id(); data.tid = CRYPTO_THREAD_get_current_id(); data.time = get_timer_bits(); |