diff options
author | Pauli <ppzgs1@gmail.com> | 2021-02-12 12:44:43 +1000 |
---|---|---|
committer | Pauli <ppzgs1@gmail.com> | 2021-02-17 13:10:49 +1000 |
commit | e2730b8426eb9f1334412a026ea87c0c309b14b9 (patch) | |
tree | ef3f2b5ff1cab4201706d57ef3c34243efdc58e0 /providers | |
parent | 9ed185a926cc1b8527bba8efa28a6b15392484ce (diff) |
RNG test: add get_entropy hook for testing.
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/14162)
Diffstat (limited to 'providers')
-rw-r--r-- | providers/implementations/rands/test_rng.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/providers/implementations/rands/test_rng.c b/providers/implementations/rands/test_rng.c index 33cbd20e9b..0c0e0e3b42 100644 --- a/providers/implementations/rands/test_rng.c +++ b/providers/implementations/rands/test_rng.c @@ -35,6 +35,7 @@ static OSSL_FUNC_rand_verify_zeroization_fn test_rng_verify_zeroization; static OSSL_FUNC_rand_enable_locking_fn test_rng_enable_locking; static OSSL_FUNC_rand_lock_fn test_rng_lock; static OSSL_FUNC_rand_unlock_fn test_rng_unlock; +static OSSL_FUNC_rand_get_seed_fn test_rng_get_seed; typedef struct { void *provctx; @@ -228,6 +229,18 @@ static int test_rng_verify_zeroization(ossl_unused void *vtest) return 1; } +static size_t test_rng_get_seed(void *vtest, unsigned char **pout, + int entropy, size_t min_len, size_t max_len, + ossl_unused int prediction_resistance, + ossl_unused const unsigned char *adin, + ossl_unused size_t adin_len) +{ + PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; + + *pout = t->entropy; + return t->entropy_len > max_len ? max_len : t->entropy_len; +} + static int test_rng_enable_locking(void *vtest) { PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest; @@ -280,5 +293,6 @@ const OSSL_DISPATCH ossl_test_rng_functions[] = { { OSSL_FUNC_RAND_GET_CTX_PARAMS, (void(*)(void))test_rng_get_ctx_params }, { OSSL_FUNC_RAND_VERIFY_ZEROIZATION, (void(*)(void))test_rng_verify_zeroization }, + { OSSL_FUNC_RAND_GET_SEED, (void(*)(void))test_rng_get_seed }, { 0, NULL } }; |