Fix compilation on OpenSSL 1.1.0
This commit is contained in:
parent
9b21060b3a
commit
9b718459d1
|
@ -1,4 +1,3 @@
|
||||||
#include <memory>
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <openssl/hmac.h>
|
#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];
|
char hmac[32];
|
||||||
unsigned int md_len;
|
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(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 (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 (md_len != 32) {
|
if (md_len != 32) {
|
||||||
throw std::runtime_error("hmac_sha3_256(): HMAC() returned an unexpected size");
|
throw std::runtime_error("hmac_sha3_256(): HMAC() returned an unexpected size");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue