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)
{
FIPSerr(FIPS_F_FIPS_DRBG_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
}
+
if (type == 0)
+ {
+ memset(dctx, 0, sizeof(DRBG_CTX));
+ dctx->type = 0;
+ dctx->status = DRBG_STATUS_UNINITIALISED;
return dctx;
+ }
if (FIPS_drbg_init(dctx, type, flags) <= 0)
{
dctx->status = DRBG_STATUS_READY;
- dctx->reseed_counter = 1;
+ if (!(dctx->flags & DRBG_CUSTOM_RESEED))
+ dctx->reseed_counter = 1;
end:
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)
}
int FIPS_drbg_generate(DRBG_CTX *dctx, unsigned char *out, size_t outlen,
- int strength, int prediction_resistance,
+ int prediction_resistance,
const unsigned char *adin, size_t adinlen)
{
int r = 0;
return 0;
}
- if (strength > dctx->strength)
+ if (adinlen > dctx->max_adin)
{
- r = FIPS_R_INSUFFICIENT_SECURITY_STRENGTH;
+ r = FIPS_R_ADDITIONAL_INPUT_TOO_LONG;
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)
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)