updated build system
Some checks reported errors
BlockStorage/repertory/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
2024-10-19 11:10:36 -05:00
parent c72dec6369
commit 2fb53e34af
24 changed files with 1330 additions and 831 deletions

View File

@ -25,6 +25,8 @@
#include "utils/config.hpp"
#include "utils/error.hpp"
namespace repertory::utils::encryption {
using hash_256_t = std::array<unsigned char, 32U>;
using hash_384_t = std::array<unsigned char, 48U>;
@ -83,28 +85,39 @@ template <typename hash_t>
template <typename hash_t>
auto create_hash_blake2b_t(const unsigned char *data,
std::size_t data_size) -> hash_t {
REPERTORY_USES_FUNCTION_NAME();
hash_t hash{};
crypto_generichash_blake2b_state state{};
auto res = crypto_generichash_blake2b_init(&state, nullptr, 0U, hash.size());
if (res != 0) {
throw std::runtime_error("failed to initialize blake2b-" +
std::to_string(hash.size() * 8U) + "|" +
std::to_string(res));
throw utils::error::create_exception({
function_name,
"failed to initialize blake2b",
std::to_string(hash.size() * 8U),
std::to_string(res),
});
}
res = crypto_generichash_blake2b_update(&state, data, data_size);
if (res != 0) {
throw std::runtime_error("failed to update blake2b-" +
std::to_string(hash.size() * 8U) + "|" +
std::to_string(res));
throw utils::error::create_exception({
function_name,
"failed to update blake2b",
std::to_string(hash.size() * 8U),
std::to_string(res),
});
}
res = crypto_generichash_blake2b_final(&state, hash.data(), hash.size());
if (res != 0) {
throw std::runtime_error("failed to finalize blake2b-" +
std::to_string(hash.size() * 8U) + "|" +
std::to_string(res));
throw utils::error::create_exception({
function_name,
"failed to finalize blake2b",
std::to_string(hash.size() * 8U),
std::to_string(res),
});
}
return hash;