Lines Matching refs:drbg
261 __owur static int ctr_update(PROV_DRBG *drbg, in ctr_update() argument
266 PROV_DRBG_CTR *ctr = (PROV_DRBG_CTR *)drbg->data; in ctr_update()
295 ctr_XOR(ctr, ctr->KX, drbg->seedlen); in ctr_update()
307 static int drbg_ctr_instantiate(PROV_DRBG *drbg, in drbg_ctr_instantiate() argument
312 PROV_DRBG_CTR *ctr = (PROV_DRBG_CTR *)drbg->data; in drbg_ctr_instantiate()
323 if (!ctr_update(drbg, entropy, entropylen, pers, perslen, nonce, noncelen)) in drbg_ctr_instantiate()
334 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_ctr_instantiate_wrapper() local
337 if (drbg->lock != NULL && !CRYPTO_THREAD_write_lock(drbg->lock)) in drbg_ctr_instantiate_wrapper()
341 || !drbg_ctr_set_ctx_params_locked(drbg, params)) in drbg_ctr_instantiate_wrapper()
343 ret = ossl_prov_drbg_instantiate(drbg, strength, prediction_resistance, in drbg_ctr_instantiate_wrapper()
346 if (drbg->lock != NULL) in drbg_ctr_instantiate_wrapper()
347 CRYPTO_THREAD_unlock(drbg->lock); in drbg_ctr_instantiate_wrapper()
351 static int drbg_ctr_reseed(PROV_DRBG *drbg, in drbg_ctr_reseed() argument
355 PROV_DRBG_CTR *ctr = (PROV_DRBG_CTR *)drbg->data; in drbg_ctr_reseed()
361 if (!ctr_update(drbg, entropy, entropylen, adin, adinlen, NULL, 0)) in drbg_ctr_reseed()
370 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_ctr_reseed_wrapper() local
372 return ossl_prov_drbg_reseed(drbg, prediction_resistance, ent, ent_len, in drbg_ctr_reseed_wrapper()
388 static int drbg_ctr_generate(PROV_DRBG *drbg, in drbg_ctr_generate() argument
392 PROV_DRBG_CTR *ctr = (PROV_DRBG_CTR *)drbg->data; in drbg_ctr_generate()
399 if (!ctr_update(drbg, adin, adinlen, NULL, 0, NULL, 0)) in drbg_ctr_generate()
415 if (!ctr_update(drbg, adin, adinlen, NULL, 0, NULL, 0)) in drbg_ctr_generate()
457 if (!ctr_update(drbg, adin, adinlen, NULL, 0, NULL, 0)) in drbg_ctr_generate()
467 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_ctr_generate_wrapper() local
469 return ossl_prov_drbg_generate(drbg, out, outlen, strength, in drbg_ctr_generate_wrapper()
473 static int drbg_ctr_uninstantiate(PROV_DRBG *drbg) in drbg_ctr_uninstantiate() argument
475 PROV_DRBG_CTR *ctr = (PROV_DRBG_CTR *)drbg->data; in drbg_ctr_uninstantiate()
482 return ossl_prov_drbg_uninstantiate(drbg); in drbg_ctr_uninstantiate()
487 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_ctr_uninstantiate_wrapper() local
490 if (drbg->lock != NULL && !CRYPTO_THREAD_write_lock(drbg->lock)) in drbg_ctr_uninstantiate_wrapper()
493 ret = drbg_ctr_uninstantiate(drbg); in drbg_ctr_uninstantiate_wrapper()
495 if (drbg->lock != NULL) in drbg_ctr_uninstantiate_wrapper()
496 CRYPTO_THREAD_unlock(drbg->lock); in drbg_ctr_uninstantiate_wrapper()
503 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_ctr_verify_zeroization() local
504 PROV_DRBG_CTR *ctr = (PROV_DRBG_CTR *)drbg->data; in drbg_ctr_verify_zeroization()
507 if (drbg->lock != NULL && !CRYPTO_THREAD_read_lock(drbg->lock)) in drbg_ctr_verify_zeroization()
519 if (drbg->lock != NULL) in drbg_ctr_verify_zeroization()
520 CRYPTO_THREAD_unlock(drbg->lock); in drbg_ctr_verify_zeroization()
524 static int drbg_ctr_init_lengths(PROV_DRBG *drbg) in drbg_ctr_init_lengths() argument
526 PROV_DRBG_CTR *ctr = (PROV_DRBG_CTR *)drbg->data; in drbg_ctr_init_lengths()
530 drbg->max_request = 1 << 16; in drbg_ctr_init_lengths()
532 drbg->min_entropylen = 0; in drbg_ctr_init_lengths()
533 drbg->max_entropylen = DRBG_MAX_LENGTH; in drbg_ctr_init_lengths()
534 drbg->min_noncelen = 0; in drbg_ctr_init_lengths()
535 drbg->max_noncelen = DRBG_MAX_LENGTH; in drbg_ctr_init_lengths()
536 drbg->max_perslen = DRBG_MAX_LENGTH; in drbg_ctr_init_lengths()
537 drbg->max_adinlen = DRBG_MAX_LENGTH; in drbg_ctr_init_lengths()
540 drbg->min_entropylen = ctr->keylen; in drbg_ctr_init_lengths()
541 drbg->min_noncelen = drbg->min_entropylen / 2; in drbg_ctr_init_lengths()
544 const size_t len = ctr->keylen > 0 ? drbg->seedlen : DRBG_MAX_LENGTH; in drbg_ctr_init_lengths()
546 drbg->min_entropylen = len; in drbg_ctr_init_lengths()
547 drbg->max_entropylen = len; in drbg_ctr_init_lengths()
549 drbg->min_noncelen = 0; in drbg_ctr_init_lengths()
550 drbg->max_noncelen = 0; in drbg_ctr_init_lengths()
551 drbg->max_perslen = len; in drbg_ctr_init_lengths()
552 drbg->max_adinlen = len; in drbg_ctr_init_lengths()
557 static int drbg_ctr_init(PROV_DRBG *drbg) in drbg_ctr_init() argument
559 PROV_DRBG_CTR *ctr = (PROV_DRBG_CTR *)drbg->data; in drbg_ctr_init()
584 drbg->strength = keylen * 8; in drbg_ctr_init()
585 drbg->seedlen = keylen + 16; in drbg_ctr_init()
609 return drbg_ctr_init_lengths(drbg); in drbg_ctr_init()
618 static int drbg_ctr_new(PROV_DRBG *drbg) in drbg_ctr_new() argument
627 drbg->data = ctr; in drbg_ctr_new()
628 OSSL_FIPS_IND_INIT(drbg) in drbg_ctr_new()
629 return drbg_ctr_init_lengths(drbg); in drbg_ctr_new()
643 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_ctr_free() local
646 if (drbg != NULL && (ctr = (PROV_DRBG_CTR *)drbg->data) != NULL) { in drbg_ctr_free()
655 ossl_rand_drbg_free(drbg); in drbg_ctr_free()
660 PROV_DRBG *drbg = (PROV_DRBG *)vdrbg; in drbg_ctr_get_ctx_params() local
661 PROV_DRBG_CTR *ctr = (PROV_DRBG_CTR *)drbg->data; in drbg_ctr_get_ctx_params()
665 if (!ossl_drbg_get_ctx_params_no_lock(drbg, params, &complete)) in drbg_ctr_get_ctx_params()
671 if (drbg->lock != NULL && !CRYPTO_THREAD_read_lock(drbg->lock)) in drbg_ctr_get_ctx_params()
686 ret = ossl_drbg_get_ctx_params(drbg, params); in drbg_ctr_get_ctx_params()
688 if (drbg->lock != NULL) in drbg_ctr_get_ctx_params()
689 CRYPTO_THREAD_unlock(drbg->lock); in drbg_ctr_get_ctx_params()
766 PROV_DRBG *drbg = (PROV_DRBG *)vctx; in drbg_ctr_set_ctx_params() local
769 if (drbg->lock != NULL && !CRYPTO_THREAD_write_lock(drbg->lock)) in drbg_ctr_set_ctx_params()
774 if (drbg->lock != NULL) in drbg_ctr_set_ctx_params()
775 CRYPTO_THREAD_unlock(drbg->lock); in drbg_ctr_set_ctx_params()