mirror of
https://github.com/QuasarApp/openssl.git
synced 2025-04-26 17:54:37 +00:00
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)
This commit is contained in:
parent
8d5b197b28
commit
b98d550d80
@ -41,7 +41,8 @@ static int fuzz_rand_instantiate(ossl_unused void *vrng,
|
||||
ossl_unused unsigned int strength,
|
||||
ossl_unused int prediction_resistance,
|
||||
ossl_unused const unsigned char *pstr,
|
||||
ossl_unused size_t pstr_len)
|
||||
ossl_unused size_t pstr_len,
|
||||
ossl_unused const OSSL_PARAM params[])
|
||||
{
|
||||
*(int *)vrng = EVP_RAND_STATE_READY;
|
||||
return 1;
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -48,7 +48,8 @@ static void fake_rand_freectx(void *vrng)
|
||||
static int fake_rand_instantiate(void *vrng, ossl_unused unsigned int strength,
|
||||
ossl_unused int prediction_resistance,
|
||||
ossl_unused const unsigned char *pstr,
|
||||
size_t pstr_len)
|
||||
size_t pstr_len,
|
||||
ossl_unused const OSSL_PARAM params[])
|
||||
{
|
||||
FAKE_RAND *frng = (FAKE_RAND *)vrng;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user