Lines Matching refs:macctx
78 struct hmac_data_st *macctx; in hmac_new() local
83 if ((macctx = OPENSSL_zalloc(sizeof(*macctx))) == NULL in hmac_new()
84 || (macctx->ctx = HMAC_CTX_new()) == NULL) { in hmac_new()
85 OPENSSL_free(macctx); in hmac_new()
88 macctx->provctx = provctx; in hmac_new()
89 OSSL_FIPS_IND_INIT(macctx) in hmac_new()
91 return macctx; in hmac_new()
96 struct hmac_data_st *macctx = vmacctx; in hmac_free() local
98 if (macctx != NULL) { in hmac_free()
99 HMAC_CTX_free(macctx->ctx); in hmac_free()
100 ossl_prov_digest_reset(&macctx->digest); in hmac_free()
101 OPENSSL_secure_clear_free(macctx->key, macctx->keylen); in hmac_free()
102 OPENSSL_free(macctx); in hmac_free()
141 static size_t hmac_size(struct hmac_data_st *macctx) in hmac_size() argument
143 return HMAC_size(macctx->ctx); in hmac_size()
146 static int hmac_block_size(struct hmac_data_st *macctx) in hmac_block_size() argument
148 const EVP_MD *md = ossl_prov_digest_md(&macctx->digest); in hmac_block_size()
155 static int hmac_setkey(struct hmac_data_st *macctx, in hmac_setkey() argument
165 if (!macctx->internal) { in hmac_setkey()
166 OSSL_LIB_CTX *libctx = PROV_LIBCTX_OF(macctx->provctx); in hmac_setkey()
170 if (!OSSL_FIPS_IND_ON_UNAPPROVED(macctx, OSSL_FIPS_IND_SETTABLE0, in hmac_setkey()
180 if (macctx->key != NULL) in hmac_setkey()
181 OPENSSL_secure_clear_free(macctx->key, macctx->keylen); in hmac_setkey()
183 macctx->key = OPENSSL_secure_malloc(keylen > 0 ? keylen : 1); in hmac_setkey()
184 if (macctx->key == NULL) in hmac_setkey()
187 memcpy(macctx->key, key, keylen); in hmac_setkey()
188 macctx->keylen = keylen; in hmac_setkey()
190 digest = ossl_prov_digest_md(&macctx->digest); in hmac_setkey()
192 if (key != NULL || (macctx->tls_data_size == 0 && digest != NULL)) in hmac_setkey()
193 return HMAC_Init_ex(macctx->ctx, key, keylen, digest, in hmac_setkey()
194 ossl_prov_digest_engine(&macctx->digest)); in hmac_setkey()
201 struct hmac_data_st *macctx = vmacctx; in hmac_init() local
203 if (!ossl_prov_is_running() || !hmac_set_ctx_params(macctx, params)) in hmac_init()
207 return hmac_setkey(macctx, key, keylen); in hmac_init()
210 return HMAC_Init_ex(macctx->ctx, NULL, 0, NULL, NULL); in hmac_init()
216 struct hmac_data_st *macctx = vmacctx; in hmac_update() local
218 if (macctx->tls_data_size > 0) { in hmac_update()
220 if (!macctx->tls_header_set) { in hmac_update()
222 if (datalen != sizeof(macctx->tls_header)) in hmac_update()
224 memcpy(macctx->tls_header, data, datalen); in hmac_update()
225 macctx->tls_header_set = 1; in hmac_update()
229 if (macctx->tls_data_size < datalen) in hmac_update()
232 return ssl3_cbc_digest_record(ossl_prov_digest_md(&macctx->digest), in hmac_update()
233 macctx->tls_mac_out, in hmac_update()
234 &macctx->tls_mac_out_size, in hmac_update()
235 macctx->tls_header, in hmac_update()
238 macctx->tls_data_size, in hmac_update()
239 macctx->key, in hmac_update()
240 macctx->keylen, in hmac_update()
244 return HMAC_Update(macctx->ctx, data, datalen); in hmac_update()
251 struct hmac_data_st *macctx = vmacctx; in hmac_final() local
255 if (macctx->tls_data_size > 0) { in hmac_final()
256 if (macctx->tls_mac_out_size == 0) in hmac_final()
259 *outl = macctx->tls_mac_out_size; in hmac_final()
260 memcpy(out, macctx->tls_mac_out, macctx->tls_mac_out_size); in hmac_final()
263 if (!HMAC_Final(macctx->ctx, out, &hlen)) in hmac_final()
283 struct hmac_data_st *macctx = vmacctx; in hmac_get_ctx_params() local
287 && !OSSL_PARAM_set_size_t(p, hmac_size(macctx))) in hmac_get_ctx_params()
291 && !OSSL_PARAM_set_int(p, hmac_block_size(macctx))) in hmac_get_ctx_params()
299 if (!macctx->internal) in hmac_get_ctx_params()
300 approved = OSSL_FIPS_IND_GET(macctx)->approved; in hmac_get_ctx_params()
329 struct hmac_data_st *macctx = vmacctx; in hmac_set_ctx_params() local
330 OSSL_LIB_CTX *ctx = PROV_LIBCTX_OF(macctx->provctx); in hmac_set_ctx_params()
336 if (!OSSL_FIPS_IND_SET_CTX_PARAM(macctx, OSSL_FIPS_IND_SETTABLE0, params, in hmac_set_ctx_params()
340 if (!ossl_prov_digest_load_from_params(&macctx->digest, params, ctx)) in hmac_set_ctx_params()
347 if (!hmac_setkey(macctx, p->data, p->data_size)) in hmac_set_ctx_params()
353 if (!OSSL_PARAM_get_size_t(p, &macctx->tls_data_size)) in hmac_set_ctx_params()
380 struct hmac_data_st *macctx = hmac_new(provctx); in hmac_internal_new() local
382 if (macctx != NULL) in hmac_internal_new()
383 macctx->internal = 1; in hmac_internal_new()
384 return macctx; in hmac_internal_new()