/* Support framework for SP800-90 DRBGs */
-static int fips_drbg_init(DRBG_CTX *dctx, int type, unsigned int flags)
+int FIPS_drbg_init(DRBG_CTX *dctx, int type, unsigned int flags)
{
int rv;
memset(dctx, 0, sizeof(DRBG_CTX));
if (rv == -2)
rv = fips_drbg_ctr_init(dctx);
+ if (rv <= 0)
+ {
+ if (rv == -2)
+ FIPSerr(FIPS_F_FIPS_DRBG_INIT, FIPS_R_UNSUPPORTED_DRBG_TYPE);
+ else
+ FIPSerr(FIPS_F_FIPS_DRBG_INIT, FIPS_R_ERROR_INITIALISING_DRBG);
+ }
+
return rv;
}
FIPSerr(FIPS_F_FIPS_DRBG_NEW, ERR_R_MALLOC_FAILURE);
return NULL;
}
- rv = fips_drbg_init(dctx, type, flags);
+ if (type == 0)
+ return dctx;
+ rv = FIPS_drbg_init(dctx, type, flags);
- if (rv <= 0)
+ if (FIPS_drbg_init(dctx, type, flags) <= 0)
{
- if (rv == -2)
- FIPSerr(FIPS_F_FIPS_DRBG_NEW, FIPS_R_UNSUPPORTED_DRBG_TYPE);
- else
- FIPSerr(FIPS_F_FIPS_DRBG_NEW, FIPS_R_ERROR_INITIALISING_DRBG);
-
OPENSSL_free(dctx);
return NULL;
}
+
return dctx;
}
rv = dctx->uninstantiate(dctx);
OPENSSL_cleanse(dctx, sizeof(DRBG_CTX));
/* If method has problems uninstantiating, return error */
- if (rv <= 0)
- return rv;
- return fips_drbg_init(dctx, save_type, save_flags);
+ return rv;
}
int FIPS_drbg_set_test_mode(DRBG_CTX *dctx,