aboutsummaryrefslogtreecommitdiff
path: root/gost_omac.c
diff options
context:
space:
mode:
authorDmitry Belyavskiy <beldmit@gmail.com>2018-06-15 13:30:47 +0300
committerDmitry Belyavskiy <beldmit@gmail.com>2018-06-15 13:30:47 +0300
commit920ae61478fa9fc91068910254ca130637ce045a (patch)
tree23628bed6267c5e30f4258a469e05309ab24c67a /gost_omac.c
parent02519bca598ef347958d0fd70b1c2210afe4a5e4 (diff)
downloadgost-engine-920ae61478fa9fc91068910254ca130637ce045a.zip
gost-engine-920ae61478fa9fc91068910254ca130637ce045a.tar.gz
gost-engine-920ae61478fa9fc91068910254ca130637ce045a.tar.bz2
Missing initialization
Diffstat (limited to 'gost_omac.c')
-rw-r--r--gost_omac.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/gost_omac.c b/gost_omac.c
index ad96662..23872bc 100644
--- a/gost_omac.c
+++ b/gost_omac.c
@@ -133,7 +133,23 @@ int omac_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr)
case EVP_MD_CTRL_SET_KEY:
{
OMAC_CTX *c = EVP_MD_CTX_md_data(ctx);
- const EVP_CIPHER *cipher = EVP_get_cipherbynid(c->cipher_nid);
+ const EVP_MD *md = EVP_MD_CTX_md(ctx);
+ const EVP_CIPHER *cipher = NULL;
+
+ if (c->cipher_nid == NID_undef)
+ {
+ switch (EVP_MD_nid(md))
+ {
+ case NID_magma_mac:
+ c->cipher_nid = NID_magma_cbc;
+ break;
+
+ case NID_grasshopper_mac:
+ c->cipher_nid = NID_grasshopper_cbc;
+ break;
+ }
+ }
+ cipher = EVP_get_cipherbynid(c->cipher_nid);
if (cipher == NULL)
{