updated build system
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				BlockStorage/repertory/pipeline/head This commit looks good
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	BlockStorage/repertory/pipeline/head This commit looks good
				
			This commit is contained in:
		@@ -140,14 +140,51 @@ auto decrypt_file_name(std::string_view encryption_token, const kdf_config &cfg,
 | 
			
		||||
                                         file_name);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
constexpr auto resize_by(std::span<unsigned char> &data, std::size_t size)
 | 
			
		||||
    -> std::span<unsigned char> & {
 | 
			
		||||
  return data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static auto resize_by(data_buffer &data, std::size_t size) -> data_buffer & {
 | 
			
		||||
  data.resize(data.size() + size);
 | 
			
		||||
  return data;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
template <typename data_t>
 | 
			
		||||
auto read_encrypted_range(const http_range &range,
 | 
			
		||||
                          const utils::hash::hash_256_t &key,
 | 
			
		||||
                          reader_func_t reader_func, std::uint64_t total_size,
 | 
			
		||||
                          data_t &data, std::uint8_t file_header_size,
 | 
			
		||||
                          std::size_t &bytes_read) -> bool {
 | 
			
		||||
[[nodiscard]] auto
 | 
			
		||||
read_encrypted_range(http_range range, const utils::hash::hash_256_t &key,
 | 
			
		||||
                     reader_func_t reader_func, std::uint64_t total_size,
 | 
			
		||||
                     data_t &data, std::uint8_t file_header_size,
 | 
			
		||||
                     std::size_t &bytes_read) -> bool {
 | 
			
		||||
  bytes_read = 0U;
 | 
			
		||||
 | 
			
		||||
  {
 | 
			
		||||
    if (total_size == 0U) {
 | 
			
		||||
      return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    std::uint64_t begin = range.begin;
 | 
			
		||||
    std::uint64_t end = range.end;
 | 
			
		||||
 | 
			
		||||
    if (begin >= total_size) {
 | 
			
		||||
      return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    std::uint64_t last = total_size - 1U;
 | 
			
		||||
    if (end > last) {
 | 
			
		||||
      end = last;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (end < begin) {
 | 
			
		||||
      return true;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    range = http_range{
 | 
			
		||||
        .begin = begin,
 | 
			
		||||
        .end = end,
 | 
			
		||||
    };
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  auto encrypted_chunk_size =
 | 
			
		||||
      utils::encryption::encrypting_reader::get_encrypted_chunk_size();
 | 
			
		||||
  auto data_chunk_size =
 | 
			
		||||
@@ -159,25 +196,26 @@ auto read_encrypted_range(const http_range &range,
 | 
			
		||||
  auto source_offset = static_cast<std::size_t>(range.begin % data_chunk_size);
 | 
			
		||||
 | 
			
		||||
  for (std::size_t chunk = start_chunk; chunk <= end_chunk; chunk++) {
 | 
			
		||||
    data_buffer cypher;
 | 
			
		||||
    data_buffer cipher;
 | 
			
		||||
    auto start_offset = (chunk * encrypted_chunk_size) + file_header_size;
 | 
			
		||||
    auto end_offset = std::min(
 | 
			
		||||
        start_offset + (total_size - (chunk * data_chunk_size)) +
 | 
			
		||||
            encryption_header_size - 1U,
 | 
			
		||||
        static_cast<std::uint64_t>(start_offset + encrypted_chunk_size - 1U));
 | 
			
		||||
 | 
			
		||||
    if (not reader_func(cypher, start_offset, end_offset)) {
 | 
			
		||||
    if (not reader_func(cipher, start_offset, end_offset)) {
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    data_buffer source_buffer;
 | 
			
		||||
    if (not utils::encryption::decrypt_data(key, cypher, source_buffer)) {
 | 
			
		||||
    if (not utils::encryption::decrypt_data(key, cipher, source_buffer)) {
 | 
			
		||||
      return false;
 | 
			
		||||
    }
 | 
			
		||||
    cypher.clear();
 | 
			
		||||
    cipher.clear();
 | 
			
		||||
 | 
			
		||||
    auto data_size = static_cast<std::size_t>(std::min(
 | 
			
		||||
        remain, static_cast<std::uint64_t>(data_chunk_size - source_offset)));
 | 
			
		||||
    resize_by(data, data_size);
 | 
			
		||||
    std::copy(std::next(source_buffer.begin(),
 | 
			
		||||
                        static_cast<std::int64_t>(source_offset)),
 | 
			
		||||
              std::next(source_buffer.begin(),
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user