Lines Matching refs:drbg

69 static int hash_df(PROV_DRBG *drbg, unsigned char *out,  in hash_df()  argument
75 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data; in hash_df()
81 size_t outlen = drbg->seedlen; in hash_df()
133 static int hash_df1(PROV_DRBG *drbg, unsigned char *out, in hash_df1() argument
137 return hash_df(drbg, out, in_byte, in1, in1len, NULL, 0, NULL, 0); in hash_df1()
146 static int add_bytes(PROV_DRBG *drbg, unsigned char *dst, in add_bytes() argument
154 assert(drbg->seedlen >= 1 && inlen >= 1 && inlen <= drbg->seedlen); in add_bytes()
156 d = &dst[drbg->seedlen - 1]; in add_bytes()
167 for (i = drbg->seedlen - inlen; i > 0; --i, d--) { in add_bytes()
177 static int add_hash_to_v(PROV_DRBG *drbg, unsigned char inbyte, in add_hash_to_v() argument
180 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data; in add_hash_to_v()
185 && EVP_DigestUpdate(ctx, hash->V, drbg->seedlen) in add_hash_to_v()
188 && add_bytes(drbg, hash->V, hash->vtmp, hash->blocklen); in add_hash_to_v()
209 static int hash_gen(PROV_DRBG *drbg, unsigned char *out, size_t outlen) in hash_gen() argument
211 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data; in hash_gen()
216 memcpy(hash->vtmp, hash->V, drbg->seedlen); in hash_gen()
220 || !EVP_DigestUpdate(hash->ctx, hash->vtmp, drbg->seedlen)) in hash_gen()
236 add_bytes(drbg, hash->vtmp, &one, 1); in hash_gen()
250 static int drbg_hash_instantiate(PROV_DRBG *drbg, in drbg_hash_instantiate() argument
255 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data; in drbg_hash_instantiate()
262 && hash_df(drbg, hash->V, INBYTE_IGNORE, in drbg_hash_instantiate()
265 && hash_df1(drbg, hash->C, 0x00, hash->V, drbg->seedlen); in drbg_hash_instantiate()
274 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_hash_instantiate_wrapper() local
277 if (drbg->lock != NULL && !CRYPTO_THREAD_write_lock(drbg->lock)) in drbg_hash_instantiate_wrapper()
281 || !drbg_hash_set_ctx_params_locked(drbg, params)) in drbg_hash_instantiate_wrapper()
283 ret = ossl_prov_drbg_instantiate(drbg, strength, prediction_resistance, in drbg_hash_instantiate_wrapper()
286 if (drbg->lock != NULL) in drbg_hash_instantiate_wrapper()
287 CRYPTO_THREAD_unlock(drbg->lock); in drbg_hash_instantiate_wrapper()
299 static int drbg_hash_reseed(PROV_DRBG *drbg, in drbg_hash_reseed() argument
303 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data; in drbg_hash_reseed()
307 if (!hash_df(drbg, hash->C, 0x01, hash->V, drbg->seedlen, ent, ent_len, in drbg_hash_reseed()
310 memcpy(hash->V, hash->C, drbg->seedlen); in drbg_hash_reseed()
312 return hash_df1(drbg, hash->C, 0x00, hash->V, drbg->seedlen); in drbg_hash_reseed()
319 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_hash_reseed_wrapper() local
321 return ossl_prov_drbg_reseed(drbg, prediction_resistance, ent, ent_len, in drbg_hash_reseed_wrapper()
334 static int drbg_hash_generate(PROV_DRBG *drbg, in drbg_hash_generate() argument
338 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data; in drbg_hash_generate()
340 int reseed_counter = drbg->generate_counter; in drbg_hash_generate()
351 || add_hash_to_v(drbg, 0x02, adin, adin_len)) in drbg_hash_generate()
353 && hash_gen(drbg, out, outlen) in drbg_hash_generate()
355 && add_hash_to_v(drbg, 0x03, NULL, 0) in drbg_hash_generate()
358 && add_bytes(drbg, hash->V, hash->C, drbg->seedlen) in drbg_hash_generate()
360 && add_bytes(drbg, hash->V, counter, 4); in drbg_hash_generate()
367 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_hash_generate_wrapper() local
369 return ossl_prov_drbg_generate(drbg, out, outlen, strength, in drbg_hash_generate_wrapper()
373 static int drbg_hash_uninstantiate(PROV_DRBG *drbg) in drbg_hash_uninstantiate() argument
375 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data; in drbg_hash_uninstantiate()
380 return ossl_prov_drbg_uninstantiate(drbg); in drbg_hash_uninstantiate()
385 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_hash_uninstantiate_wrapper() local
388 if (drbg->lock != NULL && !CRYPTO_THREAD_write_lock(drbg->lock)) in drbg_hash_uninstantiate_wrapper()
391 ret = drbg_hash_uninstantiate(drbg); in drbg_hash_uninstantiate_wrapper()
393 if (drbg->lock != NULL) in drbg_hash_uninstantiate_wrapper()
394 CRYPTO_THREAD_unlock(drbg->lock); in drbg_hash_uninstantiate_wrapper()
401 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_hash_verify_zeroization() local
402 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data; in drbg_hash_verify_zeroization()
405 if (drbg->lock != NULL && !CRYPTO_THREAD_read_lock(drbg->lock)) in drbg_hash_verify_zeroization()
414 if (drbg->lock != NULL) in drbg_hash_verify_zeroization()
415 CRYPTO_THREAD_unlock(drbg->lock); in drbg_hash_verify_zeroization()
452 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_hash_free() local
455 if (drbg != NULL && (hash = (PROV_DRBG_HASH *)drbg->data) != NULL) { in drbg_hash_free()
460 ossl_rand_drbg_free(drbg); in drbg_hash_free()
465 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_hash_get_ctx_params() local
466 PROV_DRBG_HASH *hash = (PROV_DRBG_HASH *)drbg->data; in drbg_hash_get_ctx_params()
471 if (!ossl_drbg_get_ctx_params_no_lock(drbg, params, &complete)) in drbg_hash_get_ctx_params()
477 if (drbg->lock != NULL && !CRYPTO_THREAD_read_lock(drbg->lock)) in drbg_hash_get_ctx_params()
487 ret = ossl_drbg_get_ctx_params(drbg, params); in drbg_hash_get_ctx_params()
489 if (drbg->lock != NULL) in drbg_hash_get_ctx_params()
490 CRYPTO_THREAD_unlock(drbg->lock); in drbg_hash_get_ctx_params()
550 PROV_DRBG *drbg = (PROV_DRBG *)vctx; in drbg_hash_set_ctx_params() local
553 if (drbg->lock != NULL && !CRYPTO_THREAD_write_lock(drbg->lock)) in drbg_hash_set_ctx_params()
558 if (drbg->lock != NULL) in drbg_hash_set_ctx_params()
559 CRYPTO_THREAD_unlock(drbg->lock); in drbg_hash_set_ctx_params()