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()); }