Lines Matching refs:hmac
51 static int do_hmac(PROV_DRBG_HMAC *hmac, unsigned char inbyte, in do_hmac() argument
56 EVP_MAC_CTX *ctx = hmac->ctx; in do_hmac()
58 if (!EVP_MAC_init(ctx, hmac->K, hmac->blocklen, NULL) in do_hmac()
60 || !EVP_MAC_update(ctx, hmac->V, hmac->blocklen) in do_hmac()
65 || !EVP_MAC_final(ctx, hmac->K, NULL, sizeof(hmac->K))) in do_hmac()
69 return EVP_MAC_init(ctx, hmac->K, hmac->blocklen, NULL) in do_hmac()
70 && EVP_MAC_update(ctx, hmac->V, hmac->blocklen) in do_hmac()
71 && EVP_MAC_final(ctx, hmac->V, NULL, sizeof(hmac->V)); in do_hmac()
88 static int drbg_hmac_update(PROV_DRBG_HMAC *hmac, in drbg_hmac_update() argument
94 if (!do_hmac(hmac, 0x00, in1, in1len, in2, in2len, in3, in3len)) in drbg_hmac_update()
100 return do_hmac(hmac, 0x01, in1, in1len, in2, in2len, in3, in3len); in drbg_hmac_update()
114 int ossl_drbg_hmac_init(PROV_DRBG_HMAC *hmac, in ossl_drbg_hmac_init() argument
119 if (hmac->ctx == NULL) { in ossl_drbg_hmac_init()
125 memset(hmac->K, 0x00, hmac->blocklen); in ossl_drbg_hmac_init()
127 memset(hmac->V, 0x01, hmac->blocklen); in ossl_drbg_hmac_init()
129 return drbg_hmac_update(hmac, ent, ent_len, nonce, nonce_len, pstr, in ossl_drbg_hmac_init()
179 PROV_DRBG_HMAC *hmac = (PROV_DRBG_HMAC *)drbg->data; in drbg_hmac_reseed() local
182 return drbg_hmac_update(hmac, ent, ent_len, adin, adin_len, NULL, 0); in drbg_hmac_reseed()
204 int ossl_drbg_hmac_generate(PROV_DRBG_HMAC *hmac, in ossl_drbg_hmac_generate() argument
208 EVP_MAC_CTX *ctx = hmac->ctx; in ossl_drbg_hmac_generate()
209 const unsigned char *temp = hmac->V; in ossl_drbg_hmac_generate()
214 && !drbg_hmac_update(hmac, adin, adin_len, NULL, 0, NULL, 0)) in ossl_drbg_hmac_generate()
225 if (!EVP_MAC_init(ctx, hmac->K, hmac->blocklen, NULL) in ossl_drbg_hmac_generate()
226 || !EVP_MAC_update(ctx, temp, hmac->blocklen)) in ossl_drbg_hmac_generate()
229 if (outlen > hmac->blocklen) { in ossl_drbg_hmac_generate()
234 if (!EVP_MAC_final(ctx, hmac->V, NULL, sizeof(hmac->V))) in ossl_drbg_hmac_generate()
236 memcpy(out, hmac->V, outlen); in ossl_drbg_hmac_generate()
239 out += hmac->blocklen; in ossl_drbg_hmac_generate()
240 outlen -= hmac->blocklen; in ossl_drbg_hmac_generate()
243 if (!drbg_hmac_update(hmac, adin, adin_len, NULL, 0, NULL, 0)) in ossl_drbg_hmac_generate()
269 PROV_DRBG_HMAC *hmac = (PROV_DRBG_HMAC *)drbg->data; in drbg_hmac_uninstantiate() local
271 OPENSSL_cleanse(hmac->K, sizeof(hmac->K)); in drbg_hmac_uninstantiate()
272 OPENSSL_cleanse(hmac->V, sizeof(hmac->V)); in drbg_hmac_uninstantiate()
295 PROV_DRBG_HMAC *hmac = (PROV_DRBG_HMAC *)drbg->data; in drbg_hmac_verify_zeroization() local
301 PROV_DRBG_VERIFY_ZEROIZATION(hmac->K); in drbg_hmac_verify_zeroization()
302 PROV_DRBG_VERIFY_ZEROIZATION(hmac->V); in drbg_hmac_verify_zeroization()
313 PROV_DRBG_HMAC *hmac; in drbg_hmac_new() local
315 hmac = OPENSSL_secure_zalloc(sizeof(*hmac)); in drbg_hmac_new()
316 if (hmac == NULL) in drbg_hmac_new()
321 drbg->data = hmac; in drbg_hmac_new()
345 PROV_DRBG_HMAC *hmac; in drbg_hmac_free() local
347 if (drbg != NULL && (hmac = (PROV_DRBG_HMAC *)drbg->data) != NULL) { in drbg_hmac_free()
348 EVP_MAC_CTX_free(hmac->ctx); in drbg_hmac_free()
349 ossl_prov_digest_reset(&hmac->digest); in drbg_hmac_free()
350 OPENSSL_secure_clear_free(hmac, sizeof(*hmac)); in drbg_hmac_free()
358 PROV_DRBG_HMAC *hmac = (PROV_DRBG_HMAC *)drbg->data; in drbg_hmac_get_ctx_params() local
375 if (hmac->ctx == NULL) in drbg_hmac_get_ctx_params()
377 name = EVP_MAC_get0_name(EVP_MAC_CTX_get0_mac(hmac->ctx)); in drbg_hmac_get_ctx_params()
384 md = ossl_prov_digest_md(&hmac->digest); in drbg_hmac_get_ctx_params()
413 PROV_DRBG_HMAC *hmac = (PROV_DRBG_HMAC *)ctx->data; in drbg_hmac_set_ctx_params_locked() local
422 if (!ossl_prov_digest_load_from_params(&hmac->digest, params, libctx)) in drbg_hmac_set_ctx_params_locked()
425 md = ossl_prov_digest_md(&hmac->digest); in drbg_hmac_set_ctx_params_locked()
429 if (!ossl_prov_macctx_load_from_params(&hmac->ctx, params, in drbg_hmac_set_ctx_params_locked()
433 if (md != NULL && hmac->ctx != NULL) { in drbg_hmac_set_ctx_params_locked()
438 hmac->blocklen = (size_t)md_size; in drbg_hmac_set_ctx_params_locked()
440 ctx->strength = 64 * (int)(hmac->blocklen >> 3); in drbg_hmac_set_ctx_params_locked()
443 ctx->seedlen = hmac->blocklen; in drbg_hmac_set_ctx_params_locked()