Lines Matching refs:kctx

156     struct kmac_data_st *kctx = vmacctx;  in kmac_free()  local
158 if (kctx != NULL) { in kmac_free()
159 EVP_MD_CTX_free(kctx->ctx); in kmac_free()
160 ossl_prov_digest_reset(&kctx->digest); in kmac_free()
161 OPENSSL_cleanse(kctx->key, kctx->key_len); in kmac_free()
162 OPENSSL_cleanse(kctx->custom, kctx->custom_len); in kmac_free()
163 OPENSSL_free(kctx); in kmac_free()
174 struct kmac_data_st *kctx; in kmac_new() local
179 if ((kctx = OPENSSL_zalloc(sizeof(*kctx))) == NULL in kmac_new()
180 || (kctx->ctx = EVP_MD_CTX_new()) == NULL) { in kmac_new()
181 kmac_free(kctx); in kmac_new()
184 kctx->provctx = provctx; in kmac_new()
185 OSSL_FIPS_IND_INIT(kctx) in kmac_new()
186 return kctx; in kmac_new()
191 struct kmac_data_st *kctx = kmac_new(provctx); in kmac_fetch_new() local
194 if (kctx == NULL) in kmac_fetch_new()
196 if (!ossl_prov_digest_load_from_params(&kctx->digest, params, in kmac_fetch_new()
198 kmac_free(kctx); in kmac_fetch_new()
202 md_size = EVP_MD_get_size(ossl_prov_digest_md(&kctx->digest)); in kmac_fetch_new()
204 kmac_free(kctx); in kmac_fetch_new()
207 kctx->out_len = (size_t)md_size; in kmac_fetch_new()
208 return kctx; in kmac_fetch_new()
262 static int kmac_setkey(struct kmac_data_st *kctx, const unsigned char *key, in kmac_setkey() argument
265 const EVP_MD *digest = ossl_prov_digest_md(&kctx->digest); in kmac_setkey()
277 if (!kctx->internal) { in kmac_setkey()
281 if (!OSSL_FIPS_IND_ON_UNAPPROVED(kctx, OSSL_FIPS_IND_SETTABLE1, in kmac_setkey()
282 PROV_LIBCTX_OF(kctx->provctx), in kmac_setkey()
295 if (!kmac_bytepad_encode_key(kctx->key, sizeof(kctx->key), &kctx->key_len, in kmac_setkey()
309 struct kmac_data_st *kctx = vmacctx; in kmac_init() local
310 EVP_MD_CTX *ctx = kctx->ctx; in kmac_init()
315 if (!ossl_prov_is_running() || !kmac_set_ctx_params(kctx, params)) in kmac_init()
319 if (!kmac_setkey(kctx, key, keylen)) in kmac_init()
321 } else if (kctx->key_len == 0) { in kmac_init()
326 if (!EVP_DigestInit_ex(kctx->ctx, ossl_prov_digest_md(&kctx->digest), in kmac_init()
330 t = EVP_MD_get_block_size(ossl_prov_digest_md(&kctx->digest)); in kmac_init()
338 if (kctx->custom_len == 0) { in kmac_init()
343 (void)kmac_set_ctx_params(kctx, cparams); in kmac_init()
347 kctx->custom, kctx->custom_len, block_len)) { in kmac_init()
355 kctx->custom, kctx->custom_len, block_len) in kmac_init()
357 && EVP_DigestUpdate(ctx, kctx->key, kctx->key_len); in kmac_init()
365 struct kmac_data_st *kctx = vmacctx; in kmac_update() local
367 return EVP_DigestUpdate(kctx->ctx, data, datalen); in kmac_update()
373 struct kmac_data_st *kctx = vmacctx; in kmac_final() local
374 EVP_MD_CTX *ctx = kctx->ctx; in kmac_final()
383 lbits = (kctx->xof_mode ? 0 : (kctx->out_len * 8)); in kmac_final()
387 && EVP_DigestFinalXOF(ctx, out, kctx->out_len); in kmac_final()
388 *outl = kctx->out_len; in kmac_final()
406 struct kmac_data_st *kctx = vmacctx; in kmac_get_ctx_params() local
411 && !OSSL_PARAM_set_size_t(p, kctx->out_len)) in kmac_get_ctx_params()
415 sz = EVP_MD_block_size(ossl_prov_digest_md(&kctx->digest)); in kmac_get_ctx_params()
420 if (!OSSL_FIPS_IND_GET_CTX_PARAM(kctx, params)) in kmac_get_ctx_params()
452 struct kmac_data_st *kctx = vmacctx; in kmac_set_ctx_params() local
458 if (!OSSL_FIPS_IND_SET_CTX_PARAM(kctx, OSSL_FIPS_IND_SETTABLE0, params, in kmac_set_ctx_params()
461 if (!OSSL_FIPS_IND_SET_CTX_PARAM(kctx, OSSL_FIPS_IND_SETTABLE1, params, in kmac_set_ctx_params()
466 && !OSSL_PARAM_get_int(p, &kctx->xof_mode)) in kmac_set_ctx_params()
480 if (!OSSL_FIPS_IND_ON_UNAPPROVED(kctx, OSSL_FIPS_IND_SETTABLE0, in kmac_set_ctx_params()
481 PROV_LIBCTX_OF(kctx->provctx), in kmac_set_ctx_params()
489 kctx->out_len = sz; in kmac_set_ctx_params()
492 && !kmac_setkey(kctx, p->data, p->data_size)) in kmac_set_ctx_params()
500 if (!encode_string(kctx->custom, sizeof(kctx->custom), &kctx->custom_len, in kmac_set_ctx_params()