Implement secure key via KDF for transparent data encryption/decryption #60

This commit is contained in:
2025-08-30 14:18:27 -05:00
parent 55b7afc023
commit f04d4d531a
2 changed files with 16 additions and 12 deletions

View File

@@ -1268,11 +1268,12 @@ auto s3_provider::read_file_bytes(const std::string &api_path, std::size_t size,
for (std::uint32_t retry{0U}; for (std::uint32_t retry{0U};
not(stop_requested || app_config::get_stop_requested()) && not(stop_requested || app_config::get_stop_requested()) &&
res != api_error::success && res != api_error::success &&
retry < get_config().get_retry_read_count() + 1U; retry < (static_cast<std::uint32_t>(
get_config().get_retry_read_count()) +
1U);
++retry) { ++retry) {
if (retry > 0U) { if (retry > 0U) {
read_buffer.clear(); read_buffer.clear();
std::this_thread::sleep_for(1s); std::this_thread::sleep_for(1s);
} }

View File

@@ -661,7 +661,7 @@ void sia_provider::iterate_objects(
auto sia_provider::read_file_bytes(const std::string &api_path, auto sia_provider::read_file_bytes(const std::string &api_path,
std::size_t size, std::uint64_t offset, std::size_t size, std::uint64_t offset,
data_buffer &buffer, data_buffer &read_buffer,
stop_type &stop_requested) -> api_error { stop_type &stop_requested) -> api_error {
REPERTORY_USES_FUNCTION_NAME(); REPERTORY_USES_FUNCTION_NAME();
@@ -674,26 +674,29 @@ auto sia_provider::read_file_bytes(const std::string &api_path,
.begin = offset, .begin = offset,
.end = offset + size - 1U, .end = offset + size - 1U,
}}; }};
get.response_handler = [&buffer](auto &&data, long /* response_code */) { get.response_handler = [&read_buffer](auto &&data,
buffer = data; long /* response_code */) {
read_buffer = data;
}; };
auto res{api_error::comm_error}; auto res{api_error::comm_error};
for (std::uint32_t idx = 0U; for (std::uint32_t retry{0U};
not(stop_requested || app_config::get_stop_requested()) && not(stop_requested || app_config::get_stop_requested()) &&
res != api_error::success && res != api_error::success &&
idx < get_config().get_retry_read_count() + 1U; retry <
++idx) { (static_cast<std::uint32_t>(get_config().get_retry_read_count()) +
if (idx > 0U) { 1U);
buffer.clear(); ++retry) {
if (retry > 0U) {
read_buffer.clear();
std::this_thread::sleep_for(1s); std::this_thread::sleep_for(1s);
} }
const auto notify_retry = [=](long response_code) { const auto notify_retry = [&](long response_code) {
auto msg = auto msg =
fmt::format("read file bytes failed|offset|{}|size|{}|retry|{}", fmt::format("read file bytes failed|offset|{}|size|{}|retry|{}",
std::to_string(offset), std::to_string(size), std::to_string(offset), std::to_string(size),
std::to_string(idx + 1U)); std::to_string(retry + 1U));
if (response_code == 0) { if (response_code == 0) {
utils::error::raise_api_path_error(function_name, api_path, utils::error::raise_api_path_error(function_name, api_path,
api_error::comm_error, msg); api_error::comm_error, msg);