X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=fips%2Frand%2Ffips_drbg_lib.c;h=114f78e6ab33abf6f9abdda3f869f87e7e95b1bf;hp=a0bb9eda64d53e949a8ff88f82543414108c1b91;hb=7fdcb45745c01b90b256fe97e87eae31453e11e6;hpb=e4588dc486b947cf243b64ceab31acb637d40233 diff --git a/fips/rand/fips_drbg_lib.c b/fips/rand/fips_drbg_lib.c index a0bb9eda64..114f78e6ab 100644 --- a/fips/rand/fips_drbg_lib.c +++ b/fips/rand/fips_drbg_lib.c @@ -79,6 +79,8 @@ int FIPS_drbg_init(DRBG_CTX *dctx, int type, unsigned int flags) rv = fips_drbg_ctr_init(dctx); if (rv == -2) rv = fips_drbg_hmac_init(dctx); + if (rv == -2) + rv = fips_drbg_ec_init(dctx); if (rv <= 0) { @@ -243,7 +245,8 @@ int FIPS_drbg_instantiate(DRBG_CTX *dctx, dctx->status = DRBG_STATUS_READY; - dctx->reseed_counter = 1; + if (!(dctx->flags & DRBG_CUSTOM_RESEED)) + dctx->reseed_counter = 1; end: @@ -307,7 +310,8 @@ int FIPS_drbg_reseed(DRBG_CTX *dctx, goto end; dctx->status = DRBG_STATUS_READY; - dctx->reseed_counter = 1; + if (!(dctx->flags & DRBG_CUSTOM_RESEED)) + dctx->reseed_counter = 1; end: if (entropy && dctx->cleanup_entropy) @@ -373,7 +377,9 @@ int FIPS_drbg_generate(DRBG_CTX *dctx, unsigned char *out, size_t outlen, goto end; } - if (dctx->reseed_counter >= dctx->reseed_interval) + if (dctx->flags & DRBG_CUSTOM_RESEED) + dctx->generate(dctx, NULL, outlen, NULL, 0); + else if (dctx->reseed_counter >= dctx->reseed_interval) dctx->status = DRBG_STATUS_RESEED; if (dctx->status == DRBG_STATUS_RESEED || prediction_resistance) @@ -393,10 +399,13 @@ int FIPS_drbg_generate(DRBG_CTX *dctx, unsigned char *out, size_t outlen, dctx->status = DRBG_STATUS_ERROR; goto end; } - if (dctx->reseed_counter >= dctx->reseed_interval) - dctx->status = DRBG_STATUS_RESEED; - else - dctx->reseed_counter++; + if (!(dctx->flags & DRBG_CUSTOM_RESEED)) + { + if (dctx->reseed_counter >= dctx->reseed_interval) + dctx->status = DRBG_STATUS_RESEED; + else + dctx->reseed_counter++; + } end: if (r)