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

@@ -23,6 +23,8 @@
#include "utils/hash.hpp"
#include "utils/error.hpp"
namespace repertory::utils::encryption {
auto create_hash_blake2b_256(std::string_view data) -> hash_256_t {
return create_hash_blake2b_t<hash_256_t>(
@@ -111,24 +113,36 @@ auto create_hash_sha512(const data_buffer &data) -> hash_512_t {
auto create_hash_sha512(const unsigned char *data,
std::size_t data_size) -> hash_512_t {
REPERTORY_USES_FUNCTION_NAME();
hash_512_t hash{};
crypto_hash_sha512_state state{};
auto res = crypto_hash_sha512_init(&state);
if (res != 0) {
throw std::runtime_error("failed to initialize sha-512|" +
std::to_string(res));
throw utils::error::create_exception({
function_name,
"failed to initialize sha-512",
std::to_string(res),
});
}
res = crypto_hash_sha512_update(&state, data, data_size);
if (res != 0) {
throw std::runtime_error("failed to update sha-512|" + std::to_string(res));
throw utils::error::create_exception({
function_name,
"failed to update sha-512",
std::to_string(res),
});
}
res = crypto_hash_sha512_final(&state, hash.data());
if (res != 0) {
throw std::runtime_error("failed to finalize sha-512|" +
std::to_string(res));
throw utils::error::create_exception({
function_name,
"failed to finalize sha-512",
std::to_string(res),
});
}
return hash;
@@ -136,24 +150,36 @@ auto create_hash_sha512(const unsigned char *data,
auto create_hash_sha256(const unsigned char *data,
std::size_t data_size) -> hash_256_t {
REPERTORY_USES_FUNCTION_NAME();
hash_256_t hash{};
crypto_hash_sha256_state state{};
auto res = crypto_hash_sha256_init(&state);
if (res != 0) {
throw std::runtime_error("failed to initialize sha-256|" +
std::to_string(res));
throw utils::error::create_exception({
function_name,
"failed to initialize sha-256",
std::to_string(res),
});
}
res = crypto_hash_sha256_update(&state, data, data_size);
if (res != 0) {
throw std::runtime_error("failed to update sha-256|" + std::to_string(res));
throw utils::error::create_exception({
function_name,
"failed to update sha-256",
std::to_string(res),
});
}
res = crypto_hash_sha256_final(&state, hash.data());
if (res != 0) {
throw std::runtime_error("failed to finalize sha-256|" +
std::to_string(res));
throw utils::error::create_exception({
function_name,
"failed to finalize sha-256",
std::to_string(res),
});
}
return hash;