This commit is contained in:
2024-08-05 19:50:48 -05:00
parent dca0752189
commit cbb99c7b47
6 changed files with 19 additions and 11 deletions

View File

@ -90,7 +90,8 @@ public:
data_buffer data{};
const auto key =
utils::encryption::generate_key(request.decryption_token.value());
utils::encryption::generate_key<utils::encryption::hash_256_t>(
request.decryption_token.value());
const auto result = utils::encryption::read_encrypted_range(
request.range.value(), key,
[&](data_buffer &ct, std::uint64_t start_offset,

View File

@ -36,10 +36,11 @@ using reader_func = std::function<api_error(data_buffer &cypher_text,
[[nodiscard]] auto decrypt_file_name(std::string_view encryption_token,
std::string &file_name) -> api_error;
[[nodiscard]] auto read_encrypted_range(const http_range &range,
const key_type &key, reader_func reader,
std::uint64_t total_size,
data_buffer &data) -> api_error;
[[nodiscard]] auto
read_encrypted_range(const http_range &range,
const utils::encryption::hash_256_t &key &key,
reader_func reader, std::uint64_t total_size,
data_buffer &data) -> api_error;
} // namespace repertory::utils::encryption
#endif // INCLUDE_UTILS_ENCRYPT_HPP_

View File

@ -59,7 +59,7 @@ public:
using streambuf = std::basic_streambuf<char, std::char_traits<char>>;
private:
key_type key_;
utils::encryption::hash_256_t key_;
stop_type &stop_requested_;
size_t error_return_;
std::unordered_map<std::size_t, data_buffer> chunk_buffers_;