#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "components/crx_file/crx_verifier.h"
#include <algorithm>
#include <climits>
#include <cstring>
#include <iterator>
#include <memory>
#include <optional>
#include <set>
#include <utility>
#include "base/base64.h"
#include "base/files/file.h"
#include "base/files/file_path.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_number_conversions.h"
#include "components/crx_file/crx3.pb.h"
#include "components/crx_file/crx_file.h"
#include "components/crx_file/id_util.h"
#include "crypto/secure_hash.h"
#include "crypto/secure_util.h"
#include "crypto/sha2.h"
#include "crypto/signature_verifier.h"
namespace crx_file {
namespace {
constexpr uint8_t kPublisherKeyHash[] = …;
constexpr uint8_t kPublisherTestKeyHash[] = …;
constexpr uint8_t kEocd[] = …;
constexpr uint8_t kEocd64[] = …;
VerifierCollection;
RepeatedProof;
int ReadAndHashBuffer(uint8_t* buffer,
int length,
base::File* file,
crypto::SecureHash* hash) { … }
uint32_t ReadAndHashLittleEndianUInt32(base::File* file,
crypto::SecureHash* hash) { … }
bool ReadHashAndVerifyArchive(base::File* file,
crypto::SecureHash* hash,
const VerifierCollection& verifiers) { … }
VerifierResult VerifyCrx3(
base::File* file,
crypto::SecureHash* hash,
const std::vector<std::vector<uint8_t>>& required_key_hashes,
std::string* public_key,
std::string* crx_id,
std::vector<uint8_t>* compressed_verified_contents,
bool require_publisher_key,
bool accept_publisher_test_key) { … }
}
VerifierResult Verify(
const base::FilePath& crx_path,
const VerifierFormat& format,
const std::vector<std::vector<uint8_t>>& required_key_hashes,
const std::vector<uint8_t>& required_file_hash,
std::string* public_key,
std::string* crx_id,
std::vector<uint8_t>* compressed_verified_contents) { … }
}