Browse Source

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)
master
Pauli 8 months ago
parent
commit
b98d550d80
8 changed files with 22 additions and 11 deletions
  1. +2
    -1
      fuzz/fuzz_rand.c
  2. +0
    -3
      providers/implementations/rands/drbg.c
  3. +5
    -1
      providers/implementations/rands/drbg_ctr.c
  4. +4
    -1
      providers/implementations/rands/drbg_hash.c
  5. +4
    -1
      providers/implementations/rands/drbg_hmac.c
  6. +2
    -1
      providers/implementations/rands/seed_src.c
  7. +3
    -2
      providers/implementations/rands/test_rng.c
  8. +2
    -1
      test/testutil/fake_random.c

+ 2
- 1
fuzz/fuzz_rand.c View File

@ -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;


+ 0
- 3
providers/implementations/rands/drbg.c View File

@ -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;


+ 5
- 1
providers/implementations/rands/drbg_ctr.c View File

@ -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);
}


+ 4
- 1
providers/implementations/rands/drbg_hash.c View File

@ -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);
}


+ 4
- 1
providers/implementations/rands/drbg_hmac.c View File

@ -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);
}


+ 2
- 1
providers/implementations/rands/seed_src.c View File

@ -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;


+ 3
- 2
providers/implementations/rands/test_rng.c View File

@ -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;


+ 2
- 1
test/testutil/fake_random.c View File

@ -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…
Cancel
Save