summaryrefslogtreecommitdiffstats
path: root/providers/implementations/rands
diff options
context:
space:
mode:
authorPauli <ppzgs1@gmail.com>2021-02-26 10:55:40 +1000
committerPauli <ppzgs1@gmail.com>2021-02-28 17:25:49 +1000
commitb98d550d807eccde3bd3f88f9831e002d3835cc3 (patch)
tree9cb7db1c711d61d26bb019bba7b5ebbbc91d017e /providers/implementations/rands
parent8d5b197b289988f8bc55e01e7ae27b82b16964b6 (diff)
prov: update rand implementations to have a params argument for the instantiate call
Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/14310)
Diffstat (limited to 'providers/implementations/rands')
-rw-r--r--providers/implementations/rands/drbg.c3
-rw-r--r--providers/implementations/rands/drbg_ctr.c6
-rw-r--r--providers/implementations/rands/drbg_hash.c5
-rw-r--r--providers/implementations/rands/drbg_hmac.c5
-rw-r--r--providers/implementations/rands/seed_src.c3
-rw-r--r--providers/implementations/rands/test_rng.c5
6 files changed, 18 insertions, 9 deletions
diff --git a/providers/implementations/rands/drbg.c b/providers/implementations/rands/drbg.c
index fc8ac52ac2..a05c9397c8 100644
--- a/providers/implementations/rands/drbg.c
+++ b/providers/implementations/rands/drbg.c
@@ -365,9 +365,6 @@ int ossl_prov_drbg_instantiate(PROV_DRBG *drbg, unsigned int strength,
size_t noncelen = 0, entropylen = 0;
size_t min_entropy, min_entropylen, max_entropylen;
- if (!ossl_prov_is_running())
- return 0;
-
if (strength > drbg->strength) {
ERR_raise(ERR_LIB_PROV, PROV_R_INSUFFICIENT_DRBG_STRENGTH);
goto end;
diff --git a/providers/implementations/rands/drbg_ctr.c b/providers/implementations/rands/drbg_ctr.c
index 066775aa52..48e8677ec8 100644
--- a/providers/implementations/rands/drbg_ctr.c
+++ b/providers/implementations/rands/drbg_ctr.c
@@ -18,6 +18,7 @@
#include "crypto/modes.h"
#include "internal/thread_once.h"
#include "prov/implementations.h"
+#include "prov/providercommon.h"
#include "prov/provider_ctx.h"
#include "drbg_local.h"
@@ -326,10 +327,13 @@ static int drbg_ctr_instantiate(PROV_DRBG *drbg,
static int drbg_ctr_instantiate_wrapper(void *vdrbg, unsigned int strength,
int prediction_resistance,
const unsigned char *pstr,
- size_t pstr_len)
+ size_t pstr_len,
+ const OSSL_PARAM params[])
{
PROV_DRBG *drbg = (PROV_DRBG *)vdrbg;
+ if (!ossl_prov_is_running() || !drbg_ctr_set_ctx_params(drbg, params))
+ return 0;
return ossl_prov_drbg_instantiate(drbg, strength, prediction_resistance,
pstr, pstr_len);
}
diff --git a/providers/implementations/rands/drbg_hash.c b/providers/implementations/rands/drbg_hash.c
index c89b0cd5c3..4db104c773 100644
--- a/providers/implementations/rands/drbg_hash.c
+++ b/providers/implementations/rands/drbg_hash.c
@@ -266,10 +266,13 @@ static int drbg_hash_instantiate(PROV_DRBG *drbg,
static int drbg_hash_instantiate_wrapper(void *vdrbg, unsigned int strength,
int prediction_resistance,
const unsigned char *pstr,
- size_t pstr_len)
+ size_t pstr_len,
+ const OSSL_PARAM params[])
{
PROV_DRBG *drbg = (PROV_DRBG *)vdrbg;
+ if (!ossl_prov_is_running() || !drbg_hash_set_ctx_params(drbg, params))
+ return 0;
return ossl_prov_drbg_instantiate(drbg, strength, prediction_resistance,
pstr, pstr_len);
}
diff --git a/providers/implementations/rands/drbg_hmac.c b/providers/implementations/rands/drbg_hmac.c
index 85b7adfe86..67c0339801 100644
--- a/providers/implementations/rands/drbg_hmac.c
+++ b/providers/implementations/rands/drbg_hmac.c
@@ -143,10 +143,13 @@ static int drbg_hmac_instantiate(PROV_DRBG *drbg,
static int drbg_hmac_instantiate_wrapper(void *vdrbg, unsigned int strength,
int prediction_resistance,
const unsigned char *pstr,
- size_t pstr_len)
+ size_t pstr_len,
+ const OSSL_PARAM params[])
{
PROV_DRBG *drbg = (PROV_DRBG *)vdrbg;
+ if (!ossl_prov_is_running() || !drbg_hmac_set_ctx_params(drbg, params))
+ return 0;
return ossl_prov_drbg_instantiate(drbg, strength, prediction_resistance,
pstr, pstr_len);
}
diff --git a/providers/implementations/rands/seed_src.c b/providers/implementations/rands/seed_src.c
index b87aa0c6cd..ad315efb9b 100644
--- a/providers/implementations/rands/seed_src.c
+++ b/providers/implementations/rands/seed_src.c
@@ -70,7 +70,8 @@ static void seed_src_free(void *vseed)
static int seed_src_instantiate(void *vseed, unsigned int strength,
int prediction_resistance,
- const unsigned char *pstr, size_t pstr_len)
+ const unsigned char *pstr, size_t pstr_len,
+ ossl_unused const OSSL_PARAM params[])
{
PROV_SEED_SRC *s = (PROV_SEED_SRC *)vseed;
diff --git a/providers/implementations/rands/test_rng.c b/providers/implementations/rands/test_rng.c
index d28f7e0937..1335de8681 100644
--- a/providers/implementations/rands/test_rng.c
+++ b/providers/implementations/rands/test_rng.c
@@ -79,11 +79,12 @@ static void test_rng_free(void *vtest)
static int test_rng_instantiate(void *vtest, unsigned int strength,
int prediction_resistance,
- const unsigned char *pstr, size_t pstr_len)
+ const unsigned char *pstr, size_t pstr_len,
+ const OSSL_PARAM params[])
{
PROV_TEST_RNG *t = (PROV_TEST_RNG *)vtest;
- if (strength > t->strength)
+ if (!test_rng_set_ctx_params(t, params) || strength > t->strength)
return 0;
t->state = EVP_RAND_STATE_READY;