new_build_system (#18)
All checks were successful
BlockStorage/repertory/pipeline/head This commit looks good

Reviewed-on: #18
This commit is contained in:
2024-09-06 15:05:48 +00:00
parent 9d3e4b8767
commit a7239558bd
191 changed files with 10683 additions and 10598 deletions

View File

@ -35,219 +35,132 @@ using hash_512_t = std::array<unsigned char, 64U>;
[[nodiscard]] auto
create_hash_blake2b_256(std::wstring_view data) -> hash_256_t;
[[nodiscard]] auto
create_hash_blake2b_256(const data_buffer &data) -> hash_256_t;
[[nodiscard]] auto create_hash_blake2b_384(std::string_view data) -> hash_384_t;
[[nodiscard]] auto
create_hash_blake2b_384(std::wstring_view data) -> hash_384_t;
[[nodiscard]] auto create_hash_blake2b_512(std::string_view data) -> hash_512_t;
[[nodiscard]] auto
create_hash_blake2b_384(const data_buffer &data) -> hash_384_t;
[[nodiscard]] auto
create_hash_blake2b_512(std::wstring_view data) -> hash_512_t;
template <typename char_t, typename hash_t>
[[nodiscard]] auto
create_hash_blake2b_t(std::basic_string_view<char_t> data) -> hash_t;
create_hash_blake2b_512(const data_buffer &data) -> hash_512_t;
[[nodiscard]] auto create_hash_blake2b_512(std::string_view data) -> hash_512_t;
template <typename hash_t>
[[nodiscard]] auto create_hash_blake2b_t(const data_buffer &data) -> hash_t;
template <typename char_t, typename hash_t>
[[nodiscard]] auto create_hash_blake2b_t(
const std::vector<std::basic_string<char_t>> &data) -> hash_t;
template <typename arr_t, std::size_t arr_size>
[[nodiscard]] auto
create_hash_blake2b_t(const std::vector<std::array<arr_t, arr_size>> &data)
-> std::array<arr_t, arr_size>;
[[nodiscard]] auto create_hash_blake2b_t(const unsigned char *data,
std::size_t data_size) -> hash_t;
[[nodiscard]] auto create_hash_sha256(std::string_view data) -> hash_256_t;
[[nodiscard]] auto create_hash_sha256(std::wstring_view data) -> hash_256_t;
[[nodiscard]] auto create_hash_sha256(const data_buffer &data) -> hash_256_t;
[[nodiscard]] auto create_hash_sha256(const unsigned char *data,
std::size_t data_size) -> hash_256_t;
[[nodiscard]] auto create_hash_sha512(std::string_view data) -> hash_512_t;
[[nodiscard]] auto create_hash_sha512(std::wstring_view data) -> hash_512_t;
template <typename char_t>
[[nodiscard]] auto
create_hash_sha256_t(std::basic_string_view<char_t> data) -> hash_256_t;
[[nodiscard]] auto create_hash_sha512(const data_buffer &data) -> hash_512_t;
template <typename char_t>
[[nodiscard]] auto create_hash_sha512_t(std::basic_string_view<char_t> data)
-> repertory::utils::encryption::hash_512_t;
[[nodiscard]] auto create_hash_sha512(const unsigned char *data,
std::size_t data_size) -> hash_512_t;
template <typename hash_t>
auto create_hash_blake2b_t(const data_buffer &data) -> hash_t {
[[nodiscard]] inline auto default_create_hash() -> const
std::function<hash_t(const unsigned char *data, std::size_t size)> &;
template <typename hash_t>
auto create_hash_blake2b_t(const unsigned char *data,
std::size_t data_size) -> hash_t {
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|" +
throw std::runtime_error("failed to initialize blake2b-" +
std::to_string(hash.size() * 8U) + "|" +
std::to_string(res));
}
res = crypto_generichash_blake2b_update(
&state, reinterpret_cast<const unsigned char *>(data.data()),
data.size() * sizeof(data_buffer::value_type));
res = crypto_generichash_blake2b_update(&state, data, data_size);
if (res != 0) {
throw std::runtime_error("failed to update blake2b|" + std::to_string(res));
throw std::runtime_error("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|" +
throw std::runtime_error("failed to finalize blake2b-" +
std::to_string(hash.size() * 8U) + "|" +
std::to_string(res));
}
return hash;
}
template <typename arr_t, std::size_t arr_size>
auto create_hash_blake2b_t(const std::vector<std::array<arr_t, arr_size>> &data)
-> std::array<arr_t, arr_size> {
using hash_t = std::array<arr_t, arr_size>;
hash_t hash{};
inline const std::function<hash_256_t(const unsigned char *data,
std::size_t size)>
blake2b_256_hasher =
[](const unsigned char *data, std::size_t data_size) -> hash_256_t {
return create_hash_blake2b_t<hash_256_t>(data, data_size);
};
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(res));
}
inline const std::function<hash_384_t(const unsigned char *data,
std::size_t size)>
blake2b_384_hasher =
[](const unsigned char *data, std::size_t data_size) -> hash_384_t {
return create_hash_blake2b_t<hash_384_t>(data, data_size);
};
for (const auto &item : data) {
res = crypto_generichash_blake2b_update(
&state, reinterpret_cast<const unsigned char *>(item.data()),
item.size());
if (res != 0) {
throw std::runtime_error("failed to update blake2b|" +
std::to_string(res));
}
}
inline const std::function<hash_512_t(const unsigned char *data,
std::size_t size)>
blake2b_512_hasher =
[](const unsigned char *data, std::size_t data_size) -> hash_512_t {
return create_hash_blake2b_t<hash_512_t>(data, data_size);
};
res = crypto_generichash_blake2b_final(&state, hash.data(), hash.size());
if (res != 0) {
throw std::runtime_error("failed to finalize blake2b|" +
std::to_string(res));
}
inline const std::function<hash_256_t(const unsigned char *data,
std::size_t size)>
sha256_hasher =
[](const unsigned char *data, std::size_t data_size) -> hash_256_t {
return create_hash_sha256(data, data_size);
};
return hash;
inline const std::function<hash_512_t(const unsigned char *data,
std::size_t size)>
sha512_hasher =
[](const unsigned char *data, std::size_t data_size) -> hash_512_t {
return create_hash_sha512(data, data_size);
};
template <>
[[nodiscard]] inline auto default_create_hash<hash_256_t>() -> const
std::function<hash_256_t(const unsigned char *data, std::size_t size)> & {
return blake2b_256_hasher;
}
template <typename char_t, typename hash_t>
auto create_hash_blake2b_t(const std::vector<std::basic_string<char_t>> &data)
-> hash_t {
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(res));
}
for (const auto &item : data) {
res = crypto_generichash_blake2b_update(
&state, reinterpret_cast<const unsigned char *>(item.data()),
item.size() * sizeof(char_t));
if (res != 0) {
throw std::runtime_error("failed to update blake2b|" +
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(res));
}
return hash;
template <>
[[nodiscard]] inline auto default_create_hash<hash_384_t>() -> const
std::function<hash_384_t(const unsigned char *data, std::size_t size)> & {
return blake2b_384_hasher;
}
template <typename char_t, typename hash_t>
auto create_hash_blake2b_t(std::basic_string_view<char_t> data) -> hash_t {
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(res));
}
res = crypto_generichash_blake2b_update(
&state, reinterpret_cast<const unsigned char *>(data.data()),
data.size() * sizeof(char_t));
if (res != 0) {
throw std::runtime_error("failed to update blake2b|" + 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(res));
}
return hash;
}
template <typename char_t>
auto create_hash_sha256_t(std::basic_string_view<char_t> data)
-> repertory::utils::encryption::hash_256_t {
repertory::utils::encryption::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 sha256|" +
std::to_string(res));
}
res = crypto_hash_sha256_update(
&state, reinterpret_cast<const unsigned char *>(data.data()),
data.size() * sizeof(char_t));
if (res != 0) {
throw std::runtime_error("failed to update sha256|" + std::to_string(res));
}
res = crypto_hash_sha256_final(&state, hash.data());
if (res != 0) {
throw std::runtime_error("failed to finalize sha256|" +
std::to_string(res));
}
return hash;
}
template <typename char_t>
auto create_hash_sha512_t(std::basic_string_view<char_t> data)
-> repertory::utils::encryption::hash_512_t {
repertory::utils::encryption::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 sha512|" +
std::to_string(res));
}
res = crypto_hash_sha512_update(
&state, reinterpret_cast<const unsigned char *>(data.data()),
data.size() * sizeof(char_t));
if (res != 0) {
throw std::runtime_error("failed to update sha512|" + std::to_string(res));
}
res = crypto_hash_sha512_final(&state, hash.data());
if (res != 0) {
throw std::runtime_error("failed to finalize sha512|" +
std::to_string(res));
}
return hash;
template <>
[[nodiscard]] inline auto default_create_hash<hash_512_t>() -> const
std::function<hash_512_t(const unsigned char *data, std::size_t size)> & {
return blake2b_512_hasher;
}
} // namespace repertory::utils::encryption