From 6476d4d4966f6efcfd84c5d1c9c4e90d83aa9f14 Mon Sep 17 00:00:00 2001 From: Dmitry Belyavskiy Date: Fri, 31 Aug 2018 13:02:52 +0300 Subject: [PATCH] Some fixes of OMAC processing --- gost_omac.c | 3 +-- gost_omac_acpkm.c | 7 +++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/gost_omac.c b/gost_omac.c index 49113a5..daf5750 100644 --- a/gost_omac.c +++ b/gost_omac.c @@ -72,8 +72,7 @@ int omac_imit_final(EVP_MD_CTX *ctx, unsigned char *md) CMAC_Final(c->cmac_ctx, mac, &mac_size); - int md_size = EVP_MD_meth_get_result_size(EVP_MD_CTX_md(ctx)); - memcpy(md, mac, min(md_size, c->dgst_size)); + memcpy(md, mac, c->dgst_size); return 1; } diff --git a/gost_omac_acpkm.c b/gost_omac_acpkm.c index 9bdb05f..3061e36 100644 --- a/gost_omac_acpkm.c +++ b/gost_omac_acpkm.c @@ -475,6 +475,13 @@ int omac_acpkm_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr) } c->dgst_size = arg; break; + case NID_magma_cbc: + if (arg < 1 || arg > 8) { + GOSTerr(GOST_F_OMAC_ACPKM_IMIT_CTRL, GOST_R_INVALID_MAC_SIZE); + return 0; + } + c->dgst_size = arg; + break; default: return 0; } -- 2.39.2