Fix compilation for compilers lacking std::to_array
This commit is contained in:
parent
9b718459d1
commit
4d874d2a05
|
@ -1,3 +1,4 @@
|
|||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <openssl/hmac.h>
|
||||
|
@ -18,7 +19,7 @@ std::vector<char> secure_random_bytes(int num) {
|
|||
}
|
||||
|
||||
std::array<char, 32> hmac_sha3_256(const std::vector<char>& key, const std::vector<char>& data) {
|
||||
char hmac[32];
|
||||
char hmac[EVP_MAX_MD_SIZE];
|
||||
unsigned int 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)) {
|
||||
|
@ -26,7 +27,9 @@ std::array<char, 32> hmac_sha3_256(const std::vector<char>& key, const std::vect
|
|||
throw std::runtime_error("hmac_sha3_256(): HMAC() returned an unexpected size");
|
||||
}
|
||||
|
||||
return std::to_array(hmac);
|
||||
std::array<char, 32> ret;
|
||||
memcpy(ret.data(), hmac, 32);
|
||||
return ret;
|
||||
} else {
|
||||
throw OpenSSLException(ERR_get_error());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue