From 4d874d2a0500929da9e441e700101efca5a66fb5 Mon Sep 17 00:00:00 2001 From: blankie Date: Fri, 8 Dec 2023 22:52:06 +1100 Subject: [PATCH] Fix compilation for compilers lacking std::to_array --- openssl_wrapper.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/openssl_wrapper.cpp b/openssl_wrapper.cpp index 2b063f5..051b45e 100644 --- a/openssl_wrapper.cpp +++ b/openssl_wrapper.cpp @@ -1,3 +1,4 @@ +#include #include #include @@ -18,7 +19,7 @@ std::vector secure_random_bytes(int num) { } std::array hmac_sha3_256(const std::vector& key, const std::vector& data) { - char hmac[32]; + char hmac[EVP_MAX_MD_SIZE]; unsigned int md_len; if (HMAC(EVP_sha3_256(), key.data(), static_cast(key.size()), reinterpret_cast(data.data()), data.size(), reinterpret_cast(hmac), &md_len)) { @@ -26,7 +27,9 @@ std::array hmac_sha3_256(const std::vector& key, const std::vect throw std::runtime_error("hmac_sha3_256(): HMAC() returned an unexpected size"); } - return std::to_array(hmac); + std::array ret; + memcpy(ret.data(), hmac, 32); + return ret; } else { throw OpenSSLException(ERR_get_error()); }