From: Matt Caswell Date: Wed, 16 Jun 2021 15:57:18 +0000 (+0100) Subject: Add a test for a custom rand provider X-Git-Tag: openssl-3.0.0-beta2~260 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=86f4e260262aad7524cd6a097592530fc818d3d4;p=thirdparty%2Fopenssl.git Add a test for a custom rand provider Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/15810) --- diff --git a/test/provfetchtest.c b/test/provfetchtest.c index 8570beecff8..8717a03bc13 100644 --- a/test/provfetchtest.c +++ b/test/provfetchtest.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include "testutil.h" static int dummy_decoder_decode(void *ctx, OSSL_CORE_BIO *cin, int selection, @@ -84,6 +86,95 @@ static const OSSL_ALGORITHM dummy_store[] = { { NULL, NULL, NULL } }; +static void *dummy_rand_newctx(void *provctx, void *parent, + const OSSL_DISPATCH *parent_calls) +{ + return provctx; +} + +static void dummy_rand_freectx(void *vctx) +{ +} + +static int dummy_rand_instantiate(void *vdrbg, unsigned int strength, + int prediction_resistance, + const unsigned char *pstr, size_t pstr_len, + const OSSL_PARAM params[]) +{ + return 1; +} + +static int dummy_rand_uninstantiate(void *vdrbg) +{ + return 1; +} + +static int dummy_rand_generate(void *vctx, unsigned char *out, size_t outlen, + unsigned int strength, int prediction_resistance, + const unsigned char *addin, size_t addin_len) +{ + size_t i; + + for (i = 0; i