#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "chrome/updater/certificate_tag.h"
#include <cstdint>
#include <cstring>
#include <memory>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include "base/check.h"
#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/notreached.h"
#include "chrome/updater/certificate_tag_internal.h"
#include "third_party/boringssl/src/include/openssl/bytestring.h"
#include "third_party/boringssl/src/include/openssl/crypto.h"
namespace updater::tagging {
namespace internal {
CBS CBSFromSpan(base::span<const uint8_t> span) { … }
base::span<const uint8_t> SpanFromCBS(const CBS* cbs) { … }
PEBinary::PEBinary(const PEBinary&) = default;
PEBinary::~PEBinary() = default;
std::unique_ptr<PEBinary> PEBinary::Parse(base::span<const uint8_t> binary) { … }
std::optional<std::vector<uint8_t>> PEBinary::tag() const { … }
bool AddName(CBB* cbb, const char* common_name) { … }
bool CopyASN1(CBB* out, CBS* in) { … }
ParseResult ParseTagImpl(base::span<const uint8_t> signed_data) { … }
std::optional<std::vector<uint8_t>> SetTagImpl(
base::span<const uint8_t> signed_data,
base::span<const uint8_t> tag) { … }
std::optional<std::vector<uint8_t>> PEBinary::SetTag(
base::span<const uint8_t> tag) { … }
PEBinary::PEBinary() = default;
bool PEBinary::ParseTag() { … }
std::optional<SectorFormat> NewSectorFormat(uint16_t sector_shift) { … }
bool IsLastInSector(const SectorFormat& format, int index) { … }
MSIDirEntry::MSIDirEntry(const MSIDirEntry&) = default;
MSIDirEntry::MSIDirEntry() = default;
MSIDirEntry::~MSIDirEntry() = default;
MSIHeader::MSIHeader(const MSIHeader&) = default;
MSIHeader::MSIHeader() = default;
MSIHeader::~MSIHeader() = default;
std::vector<uint8_t> MSIBinary::ReadStream(const std::string& name,
uint32_t start,
uint64_t stream_size,
bool force_fat,
bool free_data) { … }
void MSIBinary::PopulateFatEntries() { … }
void MSIBinary::PopulateDifatEntries() { … }
SignedDataDir MSIBinary::SignedDataDirFromSector(uint64_t dir_sector) { … }
bool MSIBinary::PopulateSignatureDirEntry() { … }
void MSIBinary::PopulateSignedData() { … }
void MSIBinary::AssignDifatEntry(uint64_t fat_sector) { … }
void MSIBinary::EnsureFreeDifatEntry() { … }
uint64_t MSIBinary::FirstFreeFatEntry(const std::vector<uint32_t>& entries) { … }
uint64_t MSIBinary::FirstFreeFatEntry() { … }
uint64_t MSIBinary::EnsureFreeFatEntries(uint64_t n) { … }
MSIBinary::MSIBinary(const MSIBinary&) = default;
MSIBinary::MSIBinary() = default;
MSIBinary::~MSIBinary() = default;
std::unique_ptr<MSIBinary> MSIBinary::Parse(
base::span<const uint8_t> file_contents) { … }
std::vector<uint8_t> MSIBinary::BuildBinary(
const std::vector<uint8_t>& signed_data) { … }
std::optional<std::vector<uint8_t>> MSIBinary::SetTag(
base::span<const uint8_t> tag) { … }
bool MSIBinary::ParseTag() { … }
std::optional<std::vector<uint8_t>> MSIBinary::tag() const { … }
}
std::unique_ptr<BinaryInterface> CreatePEBinary(
base::span<const uint8_t> contents) { … }
std::unique_ptr<BinaryInterface> CreateMSIBinary(
base::span<const uint8_t> contents) { … }
}