#include "chrome/browser/internal_auth.h"
#include <stddef.h>
#include <stdint.h>
#include <algorithm>
#include <limits>
#include <memory>
#include "base/base64.h"
#include "base/check.h"
#include "base/containers/circular_deque.h"
#include "base/containers/contains.h"
#include "base/lazy_instance.h"
#include "base/notreached.h"
#include "base/rand_util.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
#include "base/strings/string_util.h"
#include "base/synchronization/lock.h"
#include "base/threading/thread_checker.h"
#include "base/time/time.h"
#include "base/values.h"
#include "crypto/hmac.h"
namespace {
VarValueMap;
const int64_t kTickUs = …;
const int kVerificationWindowTicks = …;
const int kGenerationWindowTicks = …;
static_assert …;
static_assert …;
const int kKeyRegenerationSoftTicks = …;
const int kKeyRegenerationHardTicks = …;
const size_t kVarsLimit = …;
const size_t kStringLengthLimit = …;
const char kItemSeparator = …;
const char kVarValueSeparator = …;
const size_t kKeySizeInBytes = …;
const size_t kHMACSizeInBytes = …;
#define BASE64_PER_RAW(X) …
const size_t kTickStringLength = …;
const size_t kPassportSize = …;
int64_t GetCurrentTick() { … }
bool IsDomainSane(const std::string& domain) { … }
bool IsVarSane(const std::string& var) { … }
bool IsValueSane(const std::string& value) { … }
bool IsVarValueMapSane(const VarValueMap& map) { … }
void ConvertVarValueMapToBlob(const VarValueMap& map, std::string* out) { … }
void CreatePassport(const std::string& domain,
const VarValueMap& map,
int64_t tick,
const crypto::HMAC* engine,
std::string* out) { … }
}
class InternalAuthVerificationService { … };
namespace {
static base::LazyInstance<InternalAuthVerificationService>::DestructorAtExit
g_verification_service = …;
static base::LazyInstance<base::Lock>::Leaky
g_verification_service_lock = …;
}
class InternalAuthGenerationService : public base::ThreadChecker { … };
namespace {
static base::LazyInstance<InternalAuthGenerationService>::DestructorAtExit
g_generation_service = …;
}
bool InternalAuthVerification::VerifyPassport(
const std::string& passport,
const std::string& domain,
const VarValueMap& var_value_map) { … }
void InternalAuthVerification::ChangeKey(const std::string& key) { … }
int InternalAuthVerification::get_verification_window_ticks() { … }
int InternalAuthVerification::verification_window_seconds_ = …;
std::string InternalAuthGeneration::GeneratePassport(
const std::string& domain, const VarValueMap& var_value_map) { … }
void InternalAuthGeneration::GenerateNewKey() { … }