From: Vitaly Chikunov Date: Tue, 12 May 2020 22:17:10 +0000 (+0300) Subject: gost_omac_acpkm: Rework registration of kuznyechik_ctracpkm_omac X-Git-Tag: v3.0.0~101^2~8 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=18fd03a780b6f71305bb4af7ae8d74b9bc40293e;p=openssl-gost%2Fengine.git gost_omac_acpkm: Rework registration of kuznyechik_ctracpkm_omac --- diff --git a/gost_omac_acpkm.c b/gost_omac_acpkm.c index c22524a..43fd6a8 100644 --- a/gost_omac_acpkm.c +++ b/gost_omac_acpkm.c @@ -496,36 +496,26 @@ int omac_acpkm_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr) } } -static EVP_MD *_hidden_grasshopper_omac_acpkm_md = NULL; +GOST_digest kuznyechik_ctracpkm_omac_digest = { + .nid = NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac, + .result_size = MAX_GOST_OMAC_ACPKM_SIZE, + .input_blocksize = GRASSHOPPER_BLOCK_SIZE, + .app_datasize = sizeof(OMAC_ACPKM_CTX), + .flags = EVP_MD_FLAG_XOF, + .init = grasshopper_omac_acpkm_init, + .update = omac_acpkm_imit_update, + .final = omac_acpkm_imit_final, + .copy = omac_acpkm_imit_copy, + .cleanup = omac_acpkm_imit_cleanup, + .ctrl = omac_acpkm_imit_ctrl, +}; EVP_MD *grasshopper_omac_acpkm(void) { - if (_hidden_grasshopper_omac_acpkm_md == NULL) { - EVP_MD *md; - - if ((md = - EVP_MD_meth_new(NID_id_tc26_cipher_gostr3412_2015_kuznyechik_ctracpkm_omac, - NID_undef)) == NULL - || !EVP_MD_meth_set_result_size(md, MAX_GOST_OMAC_ACPKM_SIZE) - || !EVP_MD_meth_set_input_blocksize(md, GRASSHOPPER_BLOCK_SIZE) - || !EVP_MD_meth_set_app_datasize(md, sizeof(OMAC_ACPKM_CTX)) - || !EVP_MD_meth_set_flags(md, EVP_MD_FLAG_XOF) - || !EVP_MD_meth_set_init(md, grasshopper_omac_acpkm_init) - || !EVP_MD_meth_set_update(md, omac_acpkm_imit_update) - || !EVP_MD_meth_set_final(md, omac_acpkm_imit_final) - || !EVP_MD_meth_set_copy(md, omac_acpkm_imit_copy) - || !EVP_MD_meth_set_cleanup(md, omac_acpkm_imit_cleanup) - || !EVP_MD_meth_set_ctrl(md, omac_acpkm_imit_ctrl)) { - EVP_MD_meth_free(md); - md = NULL; - } - _hidden_grasshopper_omac_acpkm_md = md; - } - return _hidden_grasshopper_omac_acpkm_md; + return GOST_init_digest(&kuznyechik_ctracpkm_omac_digest); } void grasshopper_omac_acpkm_destroy(void) { - EVP_MD_meth_free(_hidden_grasshopper_omac_acpkm_md); - _hidden_grasshopper_omac_acpkm_md = NULL; + GOST_deinit_digest(&kuznyechik_ctracpkm_omac_digest); }