From e2730b8426eb9f1334412a026ea87c0c309b14b9 Mon Sep 17 00:00:00 2001 From: Pauli Date: Fri, 12 Feb 2021 12:44:43 +1000 Subject: RNG test: add get_entropy hook for testing. Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/14162) --- providers/implementations/rands/test_rng.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'providers/implementations/rands') 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 } }; -- cgit v1.2.3