Lines Matching refs:drbg
67 static int hash_df(PROV_DRBG *drbg, unsigned char *out,
73 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data;
79 size_t outlen = drbg->seedlen;
131 static int hash_df1(PROV_DRBG *drbg, unsigned char *out,
135 return hash_df(drbg, out, in_byte, in1, in1len, NULL, 0, NULL, 0);
142 * where dst size is drbg->seedlen, and inlen <= drbg->seedlen.
144 static int add_bytes(PROV_DRBG *drbg, unsigned char *dst,
152 assert(drbg->seedlen >= 1 && inlen >= 1 && inlen <= drbg->seedlen);
154 d = &dst[drbg->seedlen - 1];
165 for (i = drbg->seedlen - inlen; i > 0; --i, d--) {
175 static int add_hash_to_v(PROV_DRBG *drbg, unsigned char inbyte,
178 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data;
183 && EVP_DigestUpdate(ctx, hash->V, drbg->seedlen)
186 && add_bytes(drbg, hash->V, hash->vtmp, hash->blocklen);
192 * drbg contains the current value of V.
207 static int hash_gen(PROV_DRBG *drbg, unsigned char *out, size_t outlen)
209 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data;
214 memcpy(hash->vtmp, hash->V, drbg->seedlen);
218 || !EVP_DigestUpdate(hash->ctx, hash->vtmp, drbg->seedlen))
234 add_bytes(drbg, hash->vtmp, &one, 1);
248 static int drbg_hash_instantiate(PROV_DRBG *drbg,
253 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data;
260 && hash_df(drbg, hash->V, INBYTE_IGNORE,
263 && hash_df1(drbg, hash->C, 0x00, hash->V, drbg->seedlen);
272 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg;
274 if (!ossl_prov_is_running() || !drbg_hash_set_ctx_params(drbg, params))
276 return ossl_prov_drbg_instantiate(drbg, strength, prediction_resistance,
288 static int drbg_hash_reseed(PROV_DRBG *drbg,
292 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data;
296 if (!hash_df(drbg, hash->C, 0x01, hash->V, drbg->seedlen, ent, ent_len,
299 memcpy(hash->V, hash->C, drbg->seedlen);
301 return hash_df1(drbg, hash->C, 0x00, hash->V, drbg->seedlen);
308 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg;
310 return ossl_prov_drbg_reseed(drbg, prediction_resistance, ent, ent_len,
317 * Generates pseudo random bytes using the drbg.
323 static int drbg_hash_generate(PROV_DRBG *drbg,
327 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data;
329 int reseed_counter = drbg->generate_counter;
340 || add_hash_to_v(drbg, 0x02, adin, adin_len))
342 && hash_gen(drbg, out, outlen)
344 && add_hash_to_v(drbg, 0x03, NULL, 0)
347 && add_bytes(drbg, hash->V, hash->C, drbg->seedlen)
349 && add_bytes(drbg, hash->V, counter, 4);
356 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg;
358 return ossl_prov_drbg_generate(drbg, out, outlen, strength,
362 static int drbg_hash_uninstantiate(PROV_DRBG *drbg)
364 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data;
369 return ossl_prov_drbg_uninstantiate(drbg);
379 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg;
380 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data;
421 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg;
424 if (drbg != NULL && (hash = (PROV_DRBG_HASH *)drbg->data) != NULL) {
429 ossl_rand_drbg_free(drbg);
434 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg;
435 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data;
446 return ossl_drbg_get_ctx_params(drbg, params);