From 53c8abfd80b3d131790f515a3d31ba5d3beeb731 Mon Sep 17 00:00:00 2001 From: Davide Beatrici Date: Thu, 27 Sep 2018 20:28:48 +0200 Subject: [PATCH] Encrypt.c: fix MdProcess()'s HMAC implementation --- src/Mayaqua/Encrypt.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Mayaqua/Encrypt.c b/src/Mayaqua/Encrypt.c index 249ab5ab..ca157a22 100644 --- a/src/Mayaqua/Encrypt.c +++ b/src/Mayaqua/Encrypt.c @@ -461,6 +461,13 @@ UINT MdProcess(MD *md, void *dest, void *src, UINT size) if (md->IsHMac) { + // WARNING: Do not remove the call to HMAC_Init_ex(), it's required even if the context is initialized by SetMdKey()! + if (HMAC_Init_ex(md->Ctx, NULL, 0, NULL, NULL) == false) + { + Debug("MdProcess(): HMAC_Init_ex() failed with error: %s\n", OpenSSL_Error()); + return 0; + } + if (HMAC_Update(md->Ctx, src, size) == false) { Debug("MdProcess(): HMAC_Update() failed with error: %s\n", OpenSSL_Error());