summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
4420b3b)
prediction resistance requests. Although SP 800-90 is arguably unclear
on whether this is necessary adding an additional check has minimal
penalty (very few applications will make an explicit reseed request).
-int FIPS_drbg_reseed(DRBG_CTX *dctx,
- const unsigned char *adin, size_t adinlen)
+static int drbg_reseed(DRBG_CTX *dctx,
+ const unsigned char *adin, size_t adinlen, int hcheck)
{
unsigned char *entropy = NULL;
size_t entlen;
{
unsigned char *entropy = NULL;
size_t entlen;
}
dctx->status = DRBG_STATUS_ERROR;
}
dctx->status = DRBG_STATUS_ERROR;
+ /* Peform health check on all reseed operations if not a prediction
+ * resistance request and not in test mode.
+ */
+ if (hcheck && !(dctx->xflags & DRBG_FLAG_TEST))
+ {
+ if (!FIPS_drbg_test(dctx))
+ {
+ r = FIPS_R_SELFTEST_FAILURE;
+ goto end;
+ }
+ }
entlen = fips_get_entropy(dctx, &entropy, dctx->strength,
dctx->min_entropy, dctx->max_entropy);
entlen = fips_get_entropy(dctx, &entropy, dctx->strength,
dctx->min_entropy, dctx->max_entropy);
+int FIPS_drbg_reseed(DRBG_CTX *dctx,
+ const unsigned char *adin, size_t adinlen)
+ {
+ return drbg_reseed(dctx, adin, adinlen, 1);
+ }
+
static int fips_drbg_check(DRBG_CTX *dctx)
{
if (dctx->xflags & DRBG_FLAG_TEST)
static int fips_drbg_check(DRBG_CTX *dctx)
{
if (dctx->xflags & DRBG_FLAG_TEST)
dctx->health_check_cnt++;
if (dctx->health_check_cnt >= dctx->health_check_interval)
{
dctx->health_check_cnt++;
if (dctx->health_check_cnt >= dctx->health_check_interval)
{
- if (FIPS_drbg_test(dctx) <= 0)
+ if (!FIPS_drbg_test(dctx))
{
FIPSerr(FIPS_F_FIPS_DRBG_CHECK, FIPS_R_SELFTEST_FAILURE);
dctx->status = DRBG_STATUS_ERROR;
{
FIPSerr(FIPS_F_FIPS_DRBG_CHECK, FIPS_R_SELFTEST_FAILURE);
dctx->status = DRBG_STATUS_ERROR;
if (dctx->status == DRBG_STATUS_RESEED || prediction_resistance)
{
if (dctx->status == DRBG_STATUS_RESEED || prediction_resistance)
{
- if (!FIPS_drbg_reseed(dctx, adin, adinlen))
+ /* If prediction resistance request don't do health check */
+ int hcheck = prediction_resistance ? 0 : 1;
+
+ if (!drbg_reseed(dctx, adin, adinlen, hcheck))
{
r = FIPS_R_RESEED_ERROR;
goto end;
{
r = FIPS_R_RESEED_ERROR;
goto end;
{
if (td->nid == nid && td->flags == flags)
{
{
if (td->nid == nid && td->flags == flags)
{
- rv = fips_drbg_single_kat(dctx, td, 0);
- if (rv <= 0)
- return rv;
+ if (!fips_drbg_single_kat(dctx, td, 0))
+ return 0;
return fips_drbg_health_check(dctx, td);
}
}
return fips_drbg_health_check(dctx, td);
}
}