]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
RNG test: add get_entropy hook for testing.
authorPauli <ppzgs1@gmail.com>
Fri, 12 Feb 2021 02:44:43 +0000 (12:44 +1000)
committerPauli <ppzgs1@gmail.com>
Wed, 17 Feb 2021 03:10:49 +0000 (13:10 +1000)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/14162)

providers/implementations/rands/test_rng.c

index 33cbd20e9b0dd6739ca0909e81ddbd62a4c93462..0c0e0e3b42ed368a9fae443f449f3ea78734994c 100644 (file)
@@ -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 }
 };