#include "chrome/browser/extensions/install_signer.h"
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <utility>
#include "base/base64.h"
#include "base/command_line.h"
#include "base/containers/to_value_list.h"
#include "base/json/json_reader.h"
#include "base/json/json_writer.h"
#include "base/json/values_util.h"
#include "base/stl_util.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/time/time.h"
#include "base/values.h"
#include "build/build_config.h"
#include "chrome/common/chrome_switches.h"
#include "crypto/random.h"
#include "crypto/secure_hash.h"
#include "crypto/sha2.h"
#include "crypto/signature_verifier.h"
#include "extensions/common/extension.h"
#include "net/traffic_annotation/network_traffic_annotation.h"
#include "rlz/buildflags/buildflags.h"
#include "services/network/public/cpp/resource_request.h"
#include "services/network/public/cpp/shared_url_loader_factory.h"
#include "services/network/public/cpp/simple_url_loader.h"
#include "url/gurl.h"
#if BUILDFLAG(ENABLE_RLZ)
#include "rlz/lib/machine_id.h"
#endif
namespace {
ExtensionIdSet;
const char kExpireDateKey[] = …;
const char kExpiryKey[] = …;
const char kHashKey[] = …;
const char kIdsKey[] = …;
const char kInvalidIdsKey[] = …;
const char kProtocolVersionKey[] = …;
const char kSaltKey[] = …;
const char kSignatureKey[] = …;
const char kSignatureFormatVersionKey[] = …;
const char kTimestampKey[] = …;
const char kContentTypeJSON[] = …;
const int kSignatureFormatVersion = …;
const size_t kSaltBytes = …;
const char kBackendUrl[] = …;
const char kPublicKeyPEM[] = …;
GURL GetBackendUrl() { … }
bool HashWithMachineId(const std::string& salt, std::string* result) { … }
bool ValidateExpireDateFormat(const std::string& input) { … }
[[nodiscard]] std::optional<ExtensionIdSet> ExtensionIdSetFromList(
const base::Value::List& list) { … }
}
namespace extensions {
InstallSignature::InstallSignature() = default;
InstallSignature::InstallSignature(const InstallSignature& other) = default;
InstallSignature::~InstallSignature() = default;
base::Value::Dict InstallSignature::ToDict() const { … }
std::unique_ptr<InstallSignature> InstallSignature::FromDict(
const base::Value::Dict& dict) { … }
InstallSigner::InstallSigner(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
const ExtensionIdSet& ids)
: … { … }
InstallSigner::~InstallSigner() = default;
bool InstallSigner::VerifySignature(const InstallSignature& signature) { … }
ExtensionIdSet InstallSigner::GetForcedNotFromWebstore() { … }
void InstallSigner::GetSignature(SignatureCallback callback) { … }
void InstallSigner::ReportErrorViaCallback() { … }
void InstallSigner::ParseFetchResponse(
std::unique_ptr<std::string> response_body) { … }
void InstallSigner::HandleSignatureResult(const std::string& signature,
const std::string& expire_date,
const ExtensionIdSet& invalid_ids) { … }
}