Fix compilation on OpenSSL 1.1.0

This commit is contained in:
blankie 2023-12-08 22:44:56 +11:00
parent 9b21060b3a
commit 9b718459d1
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 1 additions and 3 deletions

View File

@ -1,4 +1,3 @@
#include <memory>
#include <stdexcept>
#include <openssl/hmac.h>
@ -22,8 +21,7 @@ std::array<char, 32> hmac_sha3_256(const std::vector<char>& key, const std::vect
char hmac[32];
unsigned int md_len;
std::unique_ptr<EVP_MD, decltype(&EVP_MD_free)> md(EVP_MD_fetch(nullptr, "SHA3-256", nullptr), EVP_MD_free);
if (HMAC(md.get(), key.data(), static_cast<int>(key.size()), reinterpret_cast<const unsigned char*>(data.data()), data.size(), reinterpret_cast<unsigned char*>(hmac), &md_len)) {
if (HMAC(EVP_sha3_256(), key.data(), static_cast<int>(key.size()), reinterpret_cast<const unsigned char*>(data.data()), data.size(), reinterpret_cast<unsigned char*>(hmac), &md_len)) {
if (md_len != 32) {
throw std::runtime_error("hmac_sha3_256(): HMAC() returned an unexpected size");
}