From 0c924836cf9ae04cd12e2647e6edd5c0f896ff7b Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 13 Aug 2024 15:36:13 -0400 Subject: [PATCH] fixed AEAD verification for LibreSSL --- libi2pd/Crypto.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libi2pd/Crypto.cpp b/libi2pd/Crypto.cpp index 960c400c..2f9677c1 100644 --- a/libi2pd/Crypto.cpp +++ b/libi2pd/Crypto.cpp @@ -997,6 +997,15 @@ namespace crypto } else { +#if defined(LIBRESSL_VERSION_NUMBER) + std::vector m(msgLen + 16); + if (msg == buf) + { + // we have to use different buffers otherwise verification fails + memcpy (m.data (), msg, msgLen + 16); + msg = m.data (); + } +#endif EVP_DecryptInit_ex(ctx, EVP_chacha20_poly1305(), 0, 0, 0); EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_IVLEN, 12, 0); EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_SET_TAG, 16, (uint8_t *)(msg + msgLen));