#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "content/browser/loader/merkle_integrity_source_stream.h"
#include <string.h>
#include <string_view>
#include "base/base64.h"
#include "base/numerics/byte_conversions.h"
#include "base/numerics/safe_conversions.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_util.h"
#include "net/base/io_buffer.h"
namespace content {
namespace {
constexpr uint64_t kMaxRecordSize = …;
constexpr char kMiSha256Header[] = …;
constexpr size_t kMiSha256HeaderLength = …;
size_t CopyClamped(base::span<const char>* input, base::span<char>* output) { … }
}
MerkleIntegritySourceStream::MerkleIntegritySourceStream(
std::string_view digest_header_value,
std::unique_ptr<SourceStream> upstream)
: … { … }
MerkleIntegritySourceStream::~MerkleIntegritySourceStream() = default;
base::expected<size_t, net::Error> MerkleIntegritySourceStream::FilterData(
net::IOBuffer* output_buffer,
size_t output_buffer_size,
net::IOBuffer* input_buffer,
size_t input_buffer_size,
size_t* consumed_bytes,
bool upstream_eof_reached) { … }
std::string MerkleIntegritySourceStream::GetTypeAsString() const { … }
bool MerkleIntegritySourceStream::FilterDataImpl(base::span<char>* output,
base::span<const char>* input,
bool upstream_eof_reached) { … }
bool MerkleIntegritySourceStream::CopyPartialOutput(base::span<char>* output) { … }
bool MerkleIntegritySourceStream::ConsumeBytes(base::span<const char>* input,
size_t len,
base::span<const char>* result,
std::string* storage) { … }
bool MerkleIntegritySourceStream::ProcessRecord(base::span<const char> record,
bool is_final,
base::span<char>* output) { … }
}