From dd79348b356a2e74cceac3b2d3563909f4ba8058 Mon Sep 17 00:00:00 2001 From: orignal Date: Fri, 14 Apr 2017 22:08:43 -0400 Subject: [PATCH] delete used tag before update --- Garlic.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Garlic.cpp b/Garlic.cpp index 416b8f68..295fdd8a 100644 --- a/Garlic.cpp +++ b/Garlic.cpp @@ -437,17 +437,18 @@ namespace garlic if (it != m_Tags.end ()) { // tag found. Use AES + auto decryption = it->second; + m_Tags.erase (it); // tag might be used only once if (length >= 32) { uint8_t iv[32]; // IV is first 16 bytes SHA256(buf, 32, iv); - it->second->SetIV (iv); - it->second->Decrypt (buf + 32, length - 32, buf + 32); - HandleAESBlock (buf + 32, length - 32, it->second, msg->from); + decryption->SetIV (iv); + decryption->Decrypt (buf + 32, length - 32, buf + 32); + HandleAESBlock (buf + 32, length - 32, decryption, msg->from); } else LogPrint (eLogWarning, "Garlic: message length ", length, " is less than 32 bytes"); - m_Tags.erase (it); // tag might be used only once } else {