#include "components/sync/engine/nigori/nigori.h"
#include <stdint.h>
#include <sstream>
#include <vector>
#include "base/base64.h"
#include "base/check_op.h"
#include "base/containers/span.h"
#include "base/feature_list.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_functions.h"
#include "base/notreached.h"
#include "base/numerics/byte_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "base/time/default_tick_clock.h"
#include "components/sync/base/passphrase_enums.h"
#include "components/sync/engine/nigori/key_derivation_params.h"
#include "crypto/encryptor.h"
#include "crypto/hmac.h"
#include "crypto/random.h"
#include "crypto/symmetric_key.h"
Base64Decode;
Base64Encode;
HMAC;
SymmetricKey;
const size_t kDerivedKeySizeInBits = …;
const size_t kDerivedKeySizeInBytes = …;
const size_t kHashSize = …;
const size_t kDefaultScryptCostParameter = …;
namespace syncer {
namespace {
class NigoriStream { … };
const char* GetHistogramSuffixForKeyDerivationMethod(
KeyDerivationMethod method) { … }
size_t& GetScryptCostParameter() { … }
}
Nigori::Keys::Keys() = default;
Nigori::Keys::~Keys() = default;
void Nigori::SetUseScryptCostParameterForTesting(bool use_low_scrypt_cost) { … }
void Nigori::Keys::InitByDerivationUsingPbkdf2(const std::string& password) { … }
void Nigori::Keys::InitByDerivationUsingScrypt(const std::string& salt,
const std::string& password) { … }
bool Nigori::Keys::InitByImport(const std::string& user_key_str,
const std::string& encryption_key_str,
const std::string& mac_key_str) { … }
Nigori::~Nigori() = default;
std::unique_ptr<Nigori> Nigori::CreateByDerivation(
const KeyDerivationParams& key_derivation_params,
const std::string& password) { … }
std::unique_ptr<Nigori> Nigori::CreateByImport(
const std::string& user_key,
const std::string& encryption_key,
const std::string& mac_key) { … }
std::string Nigori::GetKeyName() const { … }
std::string Nigori::Encrypt(const std::string& value) const { … }
bool Nigori::Decrypt(const std::string& encrypted, std::string* value) const { … }
void Nigori::ExportKeys(std::string* user_key,
std::string* encryption_key,
std::string* mac_key) const { … }
std::string Nigori::GenerateScryptSalt() { … }
std::unique_ptr<Nigori> Nigori::CreateByDerivationForTesting(
const KeyDerivationParams& key_derivation_params,
const std::string& password,
const base::TickClock* tick_clock) { … }
Nigori::Nigori() = default;
std::unique_ptr<Nigori> Nigori::CreateByDerivationImpl(
const KeyDerivationParams& key_derivation_params,
const std::string& password,
const base::TickClock* tick_clock) { … }
}