From: Dmitry Belyavskiy Date: Wed, 4 Sep 2019 19:45:37 +0000 (+0300) Subject: Get rid of EVP_MD_CTRL_MAC_LEN X-Git-Tag: v3.0.0~272 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=a418dfa28b4c3432a6da7d01adc1038789ce209c;p=openssl-gost%2Fengine.git Get rid of EVP_MD_CTRL_MAC_LEN --- diff --git a/gost_crypt.c b/gost_crypt.c index 930d40a..16fb661 100644 --- a/gost_crypt.c +++ b/gost_crypt.c @@ -302,7 +302,7 @@ EVP_MD *imit_gost_cpa(void) || !EVP_MD_meth_set_input_blocksize(md, 8) || !EVP_MD_meth_set_app_datasize(md, sizeof(struct ossl_gost_imit_ctx)) - || !EVP_MD_meth_set_flags(md, 0) + || !EVP_MD_meth_set_flags(md, EVP_MD_FLAG_XOF) || !EVP_MD_meth_set_init(md, gost_imit_init_cpa) || !EVP_MD_meth_set_update(md, gost_imit_update) || !EVP_MD_meth_set_final(md, gost_imit_final) @@ -333,7 +333,7 @@ EVP_MD *imit_gost_cp_12(void) || !EVP_MD_meth_set_input_blocksize(md, 8) || !EVP_MD_meth_set_app_datasize(md, sizeof(struct ossl_gost_imit_ctx)) - || !EVP_MD_meth_set_flags(md, 0) + || !EVP_MD_meth_set_flags(md, EVP_MD_FLAG_XOF) || !EVP_MD_meth_set_init(md, gost_imit_init_cp_12) || !EVP_MD_meth_set_update(md, gost_imit_update) || !EVP_MD_meth_set_final(md, gost_imit_final) @@ -1180,7 +1180,7 @@ int gost_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr) GOSTerr(GOST_F_GOST_IMIT_CTRL, GOST_R_INVALID_MAC_KEY_SIZE); return 0; } - case EVP_MD_CTRL_MAC_LEN: + case EVP_MD_CTRL_XOF_LEN: { struct ossl_gost_imit_ctx *c = EVP_MD_CTX_md_data(ctx); if (arg < 1 || arg > 8) { diff --git a/gost_keyexpimp.c b/gost_keyexpimp.c index 6df1b2a..e8ee1eb 100644 --- a/gost_keyexpimp.c +++ b/gost_keyexpimp.c @@ -46,11 +46,11 @@ int gost_kexp15(const unsigned char *shared_key, const int shared_len, if (EVP_DigestInit_ex(mac, EVP_get_digestbynid(mac_nid), NULL) <= 0 || omac_imit_ctrl(mac, EVP_MD_CTRL_SET_KEY, 32, mac_key) <= 0 - || omac_imit_ctrl(mac, EVP_MD_CTRL_MAC_LEN, mac_len, NULL) <= 0 + || omac_imit_ctrl(mac, EVP_MD_CTRL_XOF_LEN, mac_len, NULL) <= 0 || EVP_DigestUpdate(mac, iv, ivlen) <= 0 || EVP_DigestUpdate(mac, shared_key, shared_len) <= 0 /* As we set MAC length directly, we should not allow overwriting it */ - || EVP_DigestFinal_ex(mac, mac_buf, NULL) <= 0) { + || EVP_DigestFinalXOF(mac, mac_buf, mac_len) <= 0) { GOSTerr(GOST_F_GOST_KEXP15, ERR_R_INTERNAL_ERROR); goto err; } @@ -139,11 +139,11 @@ int gost_kimp15(const unsigned char *expkey, const size_t expkeylen, if (EVP_DigestInit_ex(mac, EVP_get_digestbynid(mac_nid), NULL) <= 0 || omac_imit_ctrl(mac, EVP_MD_CTRL_SET_KEY, 32, mac_key) <= 0 - || omac_imit_ctrl(mac, EVP_MD_CTRL_MAC_LEN, mac_len, NULL) <= 0 + || omac_imit_ctrl(mac, EVP_MD_CTRL_XOF_LEN, mac_len, NULL) <= 0 || EVP_DigestUpdate(mac, iv, ivlen) <= 0 || EVP_DigestUpdate(mac, out, shared_len) <= 0 /* As we set MAC length directly, we should not allow overwriting it */ - || EVP_DigestFinal_ex(mac, mac_buf, NULL) <= 0) { + || EVP_DigestFinalXOF(mac, mac_buf, mac_len) <= 0) { GOSTerr(GOST_F_GOST_KIMP15, ERR_R_INTERNAL_ERROR); goto err; } diff --git a/gost_lcl.h b/gost_lcl.h index 6623d6d..15ff31e 100644 --- a/gost_lcl.h +++ b/gost_lcl.h @@ -245,7 +245,6 @@ void inc_counter(unsigned char *buffer, size_t buf_len); # define EVP_MD_CTRL_KEY_LEN (EVP_MD_CTRL_ALG_CTRL+3) # define EVP_MD_CTRL_SET_KEY (EVP_MD_CTRL_ALG_CTRL+4) -# define EVP_MD_CTRL_MAC_LEN (EVP_MD_CTRL_ALG_CTRL+5) /* EVP_PKEY_METHOD key encryption callbacks */ /* From gost_ec_keyx.c */ int pkey_gost_encrypt(EVP_PKEY_CTX *ctx, unsigned char *out, diff --git a/gost_omac.c b/gost_omac.c index 075c26f..97fb5c0 100644 --- a/gost_omac.c +++ b/gost_omac.c @@ -202,7 +202,6 @@ int omac_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr) GOSTerr(GOST_F_OMAC_IMIT_CTRL, GOST_R_INVALID_MAC_KEY_SIZE); return 0; } - case EVP_MD_CTRL_MAC_LEN: case EVP_MD_CTRL_XOF_LEN: /* Supported in OpenSSL */ { OMAC_CTX *c = EVP_MD_CTX_md_data(ctx); diff --git a/gost_omac_acpkm.c b/gost_omac_acpkm.c index 7447a67..3820c90 100644 --- a/gost_omac_acpkm.c +++ b/gost_omac_acpkm.c @@ -465,7 +465,6 @@ int omac_acpkm_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr) } return 1; } - case EVP_MD_CTRL_MAC_LEN: case EVP_MD_CTRL_XOF_LEN: /* Supported in OpenSSL */ { OMAC_ACPKM_CTX *c = EVP_MD_CTX_md_data(ctx); diff --git a/gost_pmeth.c b/gost_pmeth.c index 2b94e36..41e53b6 100644 --- a/gost_pmeth.c +++ b/gost_pmeth.c @@ -967,7 +967,7 @@ static int pkey_gost_mac_signctx(EVP_PKEY_CTX *ctx, unsigned char *sig, } EVP_MD_meth_get_ctrl(EVP_MD_CTX_md(mctx)) - (mctx, EVP_MD_CTRL_MAC_LEN, data->mac_size, NULL); + (mctx, EVP_MD_CTRL_XOF_LEN, data->mac_size, NULL); ret = EVP_DigestFinal_ex(mctx, sig, &tmpsiglen); *siglen = data->mac_size; return ret;