#include "components/sync/test/nigori_test_utils.h"
#include "base/base64.h"
#include "base/check.h"
#include "base/ranges/algorithm.h"
#include "components/sync/base/time.h"
#include "components/sync/engine/nigori/cross_user_sharing_public_key.h"
#include "components/sync/engine/nigori/key_derivation_params.h"
#include "components/sync/engine/nigori/nigori.h"
#include "components/sync/nigori/cross_user_sharing_keys.h"
#include "components/sync/nigori/cryptographer_impl.h"
#include "components/sync/nigori/nigori_key_bag.h"
#include "components/sync/protocol/bookmark_specifics.pb.h"
#include "components/sync/protocol/encryption.pb.h"
#include "components/sync/protocol/entity_specifics.pb.h"
#include "components/sync/protocol/nigori_local_data.pb.h"
#include "components/sync/protocol/nigori_specifics.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
sync_pb::CrossUserSharingPublicKey PublicKeyToProto(
const syncer::CrossUserSharingPublicKey& public_key,
uint32_t key_pair_version) { … }
}
namespace syncer {
KeyParamsForTesting KeystoreKeyParamsForTesting(
const std::vector<uint8_t>& raw_key) { … }
KeyParamsForTesting TrustedVaultKeyParamsForTesting(
const std::vector<uint8_t>& raw_key) { … }
KeyParamsForTesting Pbkdf2PassphraseKeyParamsForTesting(
const std::string& passphrase) { … }
KeyParamsForTesting ScryptPassphraseKeyParamsForTesting(
const std::string& passphrase) { … }
sync_pb::CrossUserSharingPublicKey CrossUserSharingKeysToPublicKeyProto(
const CrossUserSharingKeys& cross_user_sharing_keys,
size_t key_version) { … }
sync_pb::NigoriSpecifics BuildKeystoreNigoriSpecifics(
const std::vector<KeyParamsForTesting>& keybag_keys_params,
const KeyParamsForTesting& keystore_decryptor_params,
const KeyParamsForTesting& keystore_key_params,
const CrossUserSharingKeys& cross_user_sharing_keys) { … }
sync_pb::NigoriSpecifics BuildKeystoreNigoriSpecificsWithCrossUserSharingKeys(
const std::vector<KeyParamsForTesting>& keybag_keys_params,
const KeyParamsForTesting& keystore_decryptor_params,
const KeyParamsForTesting& keystore_key_params,
const CrossUserSharingKeys& cross_user_sharing_keys,
const CrossUserSharingPublicKey& cross_user_sharing_public_key,
const uint32_t cross_user_sharing_public_key_version) { … }
sync_pb::NigoriSpecifics BuildTrustedVaultNigoriSpecifics(
const std::vector<std::vector<uint8_t>>& trusted_vault_keys,
base::Time migration_time) { … }
sync_pb::NigoriSpecifics BuildCustomPassphraseNigoriSpecifics(
const KeyParamsForTesting& passphrase_key_params,
const std::optional<KeyParamsForTesting>& old_key_params) { … }
KeyDerivationParams InitCustomPassphraseKeyDerivationParamsFromNigori(
const sync_pb::NigoriSpecifics& nigori) { … }
std::unique_ptr<Cryptographer> InitCustomPassphraseCryptographerFromNigori(
const sync_pb::NigoriSpecifics& nigori,
const std::string& passphrase) { … }
sync_pb::EntitySpecifics GetEncryptedBookmarkEntitySpecifics(
const sync_pb::BookmarkSpecifics& bookmark_specifics,
const KeyParamsForTesting& key_params) { … }
}