aboutsummaryrefslogtreecommitdiff
path: root/contrib/epee/src
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 /contrib/epee/src
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 'contrib/epee/src')
-rw-r--r--contrib/epee/src/http_auth.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/contrib/epee/src/http_auth.cpp b/contrib/epee/src/http_auth.cpp
index 98278cdfb..614004ffa 100644
--- a/contrib/epee/src/http_auth.cpp
+++ b/contrib/epee/src/http_auth.cpp
@@ -63,11 +63,11 @@
#include <cassert>
#include <iterator>
#include <limits>
+#include <openssl/evp.h>
#include <tuple>
#include <type_traits>
#include "hex.h"
-#include "md5_l.h"
#include "string_coding.h"
/* This file uses the `u8` prefix and specifies all chars by ASCII numeric
@@ -114,8 +114,8 @@ namespace
void operator()(const T& arg) const
{
const boost::iterator_range<const char*> data(boost::as_literal(arg));
- md5::MD5Update(
- std::addressof(ctx),
+ EVP_DigestUpdate(
+ ctx,
reinterpret_cast<const std::uint8_t*>(data.begin()),
data.size()
);
@@ -126,25 +126,25 @@ namespace
}
void operator()(const epee::wipeable_string& arg) const
{
- md5::MD5Update(
- std::addressof(ctx),
+ EVP_DigestUpdate(
+ ctx,
reinterpret_cast<const std::uint8_t*>(arg.data()),
arg.size()
);
}
- md5::MD5_CTX& ctx;
+ EVP_MD_CTX *ctx;
};
template<typename... T>
std::array<char, 32> operator()(const T&... args) const
{
- md5::MD5_CTX ctx{};
- md5::MD5Init(std::addressof(ctx));
- boost::fusion::for_each(std::tie(args...), update{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());
+ boost::fusion::for_each(std::tie(args...), update{ctx.get()});
std::array<std::uint8_t, 16> digest{{}};
- md5::MD5Final(digest.data(), std::addressof(ctx));
+ EVP_DigestFinal(ctx.get(), digest.data(), NULL);
return epee::to_hex::array(digest);
}
};