security strength.
{ERR_REASON(FIPS_R_FIPS_SELFTEST_FAILED) ,"fips selftest failed"},
{ERR_REASON(FIPS_R_GENERATE_ERROR) ,"generate error"},
{ERR_REASON(FIPS_R_INSTANTIATE_ERROR) ,"instantiate error"},
+{ERR_REASON(FIPS_R_INSUFFICIENT_SECURITY_STRENGTH),"insufficient security strength"},
{ERR_REASON(FIPS_R_INVALID_KEY_LENGTH) ,"invalid key length"},
{ERR_REASON(FIPS_R_IN_ERROR_STATE) ,"in error state"},
{ERR_REASON(FIPS_R_KEY_TOO_SHORT) ,"key too short"},
#define FIPS_R_FIPS_SELFTEST_FAILED 106
#define FIPS_R_GENERATE_ERROR 124
#define FIPS_R_INSTANTIATE_ERROR 125
+#define FIPS_R_INSUFFICIENT_SECURITY_STRENGTH 132
#define FIPS_R_INVALID_KEY_LENGTH 109
#define FIPS_R_IN_ERROR_STATE 126
#define FIPS_R_KEY_TOO_SHORT 108
goto end;
}
+ if (strength > dctx->strength)
+ {
+ r = FIPS_R_INSUFFICIENT_SECURITY_STRENGTH;
+ goto end;
+ }
+
dctx->status = DRBG_STATUS_ERROR;
entlen = dctx->get_entropy(dctx, dctx->entropy, dctx->strength,
int FIPS_drbg_generate(DRBG_CTX *dctx, unsigned char *out, size_t outlen,
- int prediction_resistance,
+ int strength, int prediction_resistance,
const unsigned char *adin, size_t adinlen)
{
int r = 0;
r = FIPS_R_REQUEST_TOO_LARGE_FOR_DRBG;
return 0;
}
+
+ if (strength > dctx->strength)
+ {
+ r = FIPS_R_INSUFFICIENT_SECURITY_STRENGTH;
+ goto end;
+ }
+
if (dctx->status == DRBG_STATUS_RESEED || prediction_resistance)
{
if (!FIPS_drbg_reseed(dctx, adin, adinlen))
{
return dctx->blocklength;
}
+
+int FIPS_drbg_get_strength(DRBG_CTX *dctx)
+ {
+ return dctx->strength;
+ }
adin = hex2bin_m(value, &adinlen);
if (pr)
continue;
- r = FIPS_drbg_generate(dctx, randout, randoutlen, 0,
+ r = FIPS_drbg_generate(dctx, randout, randoutlen, 0, 0,
adin, adinlen);
if (!r)
{
t.ent = ent;
t.entlen = entlen;
r = FIPS_drbg_generate(dctx,
- randout, randoutlen, 1,
- adin, adinlen);
+ randout, randoutlen,
+ 0, 1, adin, adinlen);
if (!r)
{
fprintf(stderr,
const unsigned char *pers, size_t perslen);
int FIPS_drbg_reseed(DRBG_CTX *dctx, const unsigned char *adin, size_t adinlen);
int FIPS_drbg_generate(DRBG_CTX *dctx, unsigned char *out, size_t outlen,
- int prediction_resistance,
+ int strength, int prediction_resistance,
const unsigned char *adin, size_t adinlen);
int FIPS_drbg_uninstantiate(DRBG_CTX *dctx);
void *FIPS_drbg_get_app_data(DRBG_CTX *ctx);
void FIPS_drbg_set_app_data(DRBG_CTX *ctx, void *app_data);
size_t FIPS_drbg_get_blocklength(DRBG_CTX *dctx);
+int FIPS_drbg_get_strength(DRBG_CTX *dctx);
#ifdef __cplusplus
}