diff options
author | Pauli <pauli@openssl.org> | 2022-10-25 20:01:12 +1100 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2022-10-27 09:23:00 +1100 |
commit | da7db83cc44d2c8761e9074caf8befd443ea8be8 (patch) | |
tree | 071ca0362e8e3908f3874e4ddd0263b9cf82b337 /providers/implementations | |
parent | 428511ca66670e169a0e1b12e7540714b0be4cf8 (diff) |
rand: remove the ossl_rand_pool_add_additional_data() function.
This function isn't called from anywhere and cannot easily be used
by the current RNG infrastructure.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/19493)
Diffstat (limited to 'providers/implementations')
-rw-r--r-- | providers/implementations/include/prov/seeding.h | 11 | ||||
-rw-r--r-- | providers/implementations/rands/seeding/rand_unix.c | 76 | ||||
-rw-r--r-- | providers/implementations/rands/seeding/rand_vms.c | 26 | ||||
-rw-r--r-- | providers/implementations/rands/seeding/rand_vxworks.c | 20 | ||||
-rw-r--r-- | providers/implementations/rands/seeding/rand_win.c | 20 |
5 files changed, 0 insertions, 153 deletions
diff --git a/providers/implementations/include/prov/seeding.h b/providers/implementations/include/prov/seeding.h index 637b921b2b..af6cb79fb2 100644 --- a/providers/implementations/include/prov/seeding.h +++ b/providers/implementations/include/prov/seeding.h @@ -15,17 +15,6 @@ size_t ossl_prov_acquire_entropy_from_tsc(RAND_POOL *pool); size_t ossl_prov_acquire_entropy_from_cpu(RAND_POOL *pool); /* - * Add some platform specific additional data - * - * This function is platform specific and adds some random noise to the - * additional data used for generating random bytes and for reseeding - * the drbg. - * - * Returns 1 on success and 0 on failure. - */ -int ossl_rand_pool_add_additional_data(RAND_POOL *pool); - -/* * External seeding functions from the core dispatch table. */ int ossl_prov_seeding_from_dispatch(const OSSL_DISPATCH *fns); diff --git a/providers/implementations/rands/seeding/rand_unix.c b/providers/implementations/rands/seeding/rand_unix.c index 11dacc02a9..363f3b814e 100644 --- a/providers/implementations/rands/seeding/rand_unix.c +++ b/providers/implementations/rands/seeding/rand_unix.c @@ -49,7 +49,6 @@ # include <sys/time.h> static uint64_t get_time_stamp(void); -static uint64_t get_timer_bits(void); /* Macro to convert two thirty two bit values into a sixty four bit one */ # define TWO32TO64(a, b) ((((uint64_t)(a)) << 32) + (b)) @@ -773,31 +772,6 @@ int ossl_pool_add_nonce_data(RAND_POOL *pool) return ossl_rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0); } -int ossl_rand_pool_add_additional_data(RAND_POOL *pool) -{ - struct { - int fork_id; - CRYPTO_THREAD_ID tid; - uint64_t time; - } data; - - /* Erase the entire structure including any padding */ - memset(&data, 0, sizeof(data)); - - /* - * 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(); - - return ossl_rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0); -} - - /* * Get the current time with the highest possible resolution * @@ -827,55 +801,5 @@ static uint64_t get_time_stamp(void) return time(NULL); } -/* - * Get an arbitrary timer value of the highest possible resolution - * - * The timer value is added as random noise to the additional data, - * which is not considered a trusted entropy sourec, so any result - * is acceptable. - */ -static uint64_t get_timer_bits(void) -{ - uint64_t res = OPENSSL_rdtsc(); - - if (res != 0) - return res; - -# if defined(__sun) || defined(__hpux) - return gethrtime(); -# elif defined(_AIX) - { - timebasestruct_t t; - - read_wall_time(&t, TIMEBASE_SZ); - return TWO32TO64(t.tb_high, t.tb_low); - } -# elif defined(OSSL_POSIX_TIMER_OKAY) - { - struct timespec ts; - -# ifdef CLOCK_BOOTTIME -# define CLOCK_TYPE CLOCK_BOOTTIME -# elif defined(_POSIX_MONOTONIC_CLOCK) -# define CLOCK_TYPE CLOCK_MONOTONIC -# else -# define CLOCK_TYPE CLOCK_REALTIME -# endif - - if (clock_gettime(CLOCK_TYPE, &ts) == 0) - return TWO32TO64(ts.tv_sec, ts.tv_nsec); - } -# endif -# if defined(__unix__) \ - || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L) - { - struct timeval tv; - - if (gettimeofday(&tv, NULL) == 0) - return TWO32TO64(tv.tv_sec, tv.tv_usec); - } -# endif - return time(NULL); -} #endif /* (defined(OPENSSL_SYS_UNIX) && !defined(OPENSSL_SYS_VXWORKS)) || defined(__DJGPP__) */ diff --git a/providers/implementations/rands/seeding/rand_vms.c b/providers/implementations/rands/seeding/rand_vms.c index 61b731f2fb..a0531b32b7 100644 --- a/providers/implementations/rands/seeding/rand_vms.c +++ b/providers/implementations/rands/seeding/rand_vms.c @@ -575,32 +575,6 @@ size_t ossl_pool_acquire_entropy(RAND_POOL *pool) return data_collect_method(pool); } - -int ossl_rand_pool_add_additional_data(RAND_POOL *pool) -{ - struct { - CRYPTO_THREAD_ID tid; - unsigned __int64 time; - } data; - - /* Erase the entire structure including any padding */ - memset(&data, 0, sizeof(data)); - - /* - * Add some noise from the thread id and a high resolution timer. - * The thread id adds a little randomness if the drbg is accessed - * concurrently (which is the case for the <master> drbg). - */ - data.tid = CRYPTO_THREAD_get_current_id(); -#if __CRTL_VER >= 80400000 - sys$gettim_prec(&data.time); -#else - sys$gettim((void*)&data.time); -#endif - - return ossl_rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0); -} - int ossl_rand_pool_init(void) { return 1; diff --git a/providers/implementations/rands/seeding/rand_vxworks.c b/providers/implementations/rands/seeding/rand_vxworks.c index de26b86e25..a28fbd7997 100644 --- a/providers/implementations/rands/seeding/rand_vxworks.c +++ b/providers/implementations/rands/seeding/rand_vxworks.c @@ -76,26 +76,6 @@ void ossl_rand_pool_keep_random_devices_open(int keep) { } -int ossl_rand_pool_add_additional_data(RAND_POOL *pool) -{ - struct { - CRYPTO_THREAD_ID tid; - uint64_t time; - } data; - - memset(&data, 0, sizeof(data)); - - /* - * Add some noise from the thread id and a high resolution timer. - * The thread id adds a little randomness if the drbg is accessed - * concurrently (which is the case for the <master> drbg). - */ - data.tid = CRYPTO_THREAD_get_current_id(); - data.time = get_timer_bits(); - - return ossl_rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0); -} - int ossl_pool_add_nonce_data(RAND_POOL *pool) { struct { diff --git a/providers/implementations/rands/seeding/rand_win.c b/providers/implementations/rands/seeding/rand_win.c index a21b74dd86..ee2d3e4d7f 100644 --- a/providers/implementations/rands/seeding/rand_win.c +++ b/providers/implementations/rands/seeding/rand_win.c @@ -147,26 +147,6 @@ int ossl_pool_add_nonce_data(RAND_POOL *pool) return ossl_rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0); } -int ossl_rand_pool_add_additional_data(RAND_POOL *pool) -{ - struct { - DWORD tid; - LARGE_INTEGER time; - } data; - - /* Erase the entire structure including any padding */ - memset(&data, 0, sizeof(data)); - - /* - * Add some noise from the thread id and a high resolution timer. - * The thread id adds a little randomness if the drbg is accessed - * concurrently (which is the case for the <master> drbg). - */ - data.tid = GetCurrentThreadId(); - QueryPerformanceCounter(&data.time); - return ossl_rand_pool_add(pool, (unsigned char *)&data, sizeof(data), 0); -} - int ossl_rand_pool_init(void) { return 1; |