aboutsummaryrefslogtreecommitdiff
path: root/tests/unit_tests
diff options
context:
space:
mode:
authorBastian Germann <bage@debian.org>2024-11-20 16:00:00 +0100
committertobtoht <tob@featherwallet.org>2025-03-14 14:00:16 +0100
commitfe1a10d70ea7fcebca0085bb7b68669072875e68 (patch)
tree6b7c406df17bb33adbdaf960585a4e2f416f2c15 /tests/unit_tests
parent88a5d076822f39cdd897d3f962346f30e4901244 (diff)
downloadmonzero-core-fe1a10d70ea7fcebca0085bb7b68669072875e68.tar.gz
monzero-core-fe1a10d70ea7fcebca0085bb7b68669072875e68.tar.xz
monzero-core-fe1a10d70ea7fcebca0085bb7b68669072875e68.zip
Replace in-tree MD5 with OpenSSL
This uses OpenSSL's non-deprecated EVP digest facility to calculate MD5 in HTTP digest authentication.
Diffstat (limited to 'tests/unit_tests')
-rw-r--r--tests/unit_tests/http.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/tests/unit_tests/http.cpp b/tests/unit_tests/http.cpp
index 60afe788e..f8eb0127b 100644
--- a/tests/unit_tests/http.cpp
+++ b/tests/unit_tests/http.cpp
@@ -53,12 +53,12 @@
#include <boost/spirit/include/qi_string.hpp>
#include <cstdint>
#include <iterator>
+#include <openssl/evp.h>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
-#include "md5_l.h"
#include "string_tools.h"
#include "crypto/crypto.h"
@@ -201,16 +201,16 @@ auth_responses parse_response(const http::http_response_info& response)
std::string md5_hex(const std::string& in)
{
- md5::MD5_CTX ctx{};
- md5::MD5Init(std::addressof(ctx));
- md5::MD5Update(
- std::addressof(ctx),
+ std::unique_ptr<EVP_MD_CTX, decltype(&EVP_MD_CTX_free)> ctx(EVP_MD_CTX_new(), &EVP_MD_CTX_free);
+ EVP_DigestInit(ctx.get(), EVP_md5());
+ EVP_DigestUpdate(
+ ctx.get(),
reinterpret_cast<const std::uint8_t*>(in.data()),
in.size()
);
std::array<std::uint8_t, 16> digest{{}};
- md5::MD5Final(digest.data(), std::addressof(ctx));
+ EVP_DigestFinal(ctx.get(), digest.data(), NULL);
return epee::string_tools::pod_to_hex(digest);
}