chromium/components/sync/service/sync_service_crypto.cc

// Copyright 2017 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/sync/service/sync_service_crypto.h"

#include <utility>

#include "base/base64.h"
#include "base/functional/bind.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/task/sequenced_task_runner.h"
#include "components/os_crypt/sync/os_crypt.h"
#include "components/sync/base/passphrase_enums.h"
#include "components/sync/engine/nigori/nigori.h"
#include "components/sync/engine/sync_string_conversions.h"
#include "components/sync/protocol/nigori_specifics.pb.h"
#include "components/sync/service/sync_service.h"
#include "components/sync/service/trusted_vault_histograms.h"

namespace syncer {

namespace {

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused. Keep in sync with
// TrustedVaultFetchKeysAttempt in
// tools/metrics/histograms/metadata/sync/enums.xml.
// LINT.IfChange(TrustedVaultFetchKeysAttempt)
enum class TrustedVaultFetchKeysAttemptForUMA {};
// LINT.ThenChange(/tools/metrics/histograms/metadata/sync/enums.xml:TrustedVaultFetchKeysAttempt)

// A SyncEncryptionHandler::Observer implementation that simply posts all calls
// to another task runner.
class SyncEncryptionObserverProxy : public SyncEncryptionHandler::Observer {};

// Checks if |nigori| can be used to decrypt the given pending keys. Returns
// true if decryption was successful. Returns false otherwise. Must be called
// with non-empty pending keys cache.
bool CheckNigoriAgainstPendingKeys(const Nigori& nigori,
                                   const sync_pb::EncryptedData& pending_keys) {}

// Reads Nigori from bootstrap token. Returns nullptr if bootstrap token empty
// or corrupted.
std::unique_ptr<Nigori> ReadNigoriFromBootstrapToken(
    const std::string& bootstrap_token) {}

// Serializes |nigori| as bootstrap token. Returns empty string in case of
// crypto/serialization failures.
std::string SerializeNigoriAsBootstrapToken(const Nigori& nigori) {}

}  // namespace

SyncServiceCrypto::State::State() = default;

SyncServiceCrypto::State::~State() = default;

SyncServiceCrypto::SyncServiceCrypto(
    Delegate* delegate,
    trusted_vault::TrustedVaultClient* trusted_vault_client)
    :{}

SyncServiceCrypto::~SyncServiceCrypto() = default;

void SyncServiceCrypto::Reset() {}

void SyncServiceCrypto::StopObservingTrustedVaultClient() {}

base::Time SyncServiceCrypto::GetExplicitPassphraseTime() const {}

bool SyncServiceCrypto::IsPassphraseRequired() const {}

bool SyncServiceCrypto::IsTrustedVaultKeyRequired() const {}

bool SyncServiceCrypto::IsTrustedVaultRecoverabilityDegraded() const {}

bool SyncServiceCrypto::IsEncryptEverythingEnabled() const {}

void SyncServiceCrypto::SetEncryptionPassphrase(const std::string& passphrase) {}

bool SyncServiceCrypto::SetDecryptionPassphrase(const std::string& passphrase) {}

void SyncServiceCrypto::SetExplicitPassphraseDecryptionNigoriKey(
    std::unique_ptr<Nigori> nigori) {}

std::unique_ptr<Nigori>
SyncServiceCrypto::GetExplicitPassphraseDecryptionNigoriKey() const {}

bool SyncServiceCrypto::IsTrustedVaultKeyRequiredStateKnown() const {}

std::optional<PassphraseType> SyncServiceCrypto::GetPassphraseType() const {}

void SyncServiceCrypto::SetSyncEngine(const CoreAccountInfo& account_info,
                                      SyncEngine* engine) {}

std::unique_ptr<SyncEncryptionHandler::Observer>
SyncServiceCrypto::GetEncryptionObserverProxy() {}

DataTypeSet SyncServiceCrypto::GetAllEncryptedDataTypes() const {}

bool SyncServiceCrypto::HasCryptoError() const {}

void SyncServiceCrypto::OnPassphraseRequired(
    const KeyDerivationParams& key_derivation_params,
    const sync_pb::EncryptedData& pending_keys) {}

void SyncServiceCrypto::OnPassphraseAccepted() {}

void SyncServiceCrypto::OnTrustedVaultKeyRequired() {}

void SyncServiceCrypto::OnTrustedVaultKeyAccepted() {}

void SyncServiceCrypto::OnEncryptedTypesChanged(DataTypeSet encrypted_types,
                                                bool encrypt_everything) {}

void SyncServiceCrypto::OnCryptographerStateChanged(
    Cryptographer* cryptographer,
    bool has_pending_keys) {}

void SyncServiceCrypto::OnPassphraseTypeChanged(PassphraseType type,
                                                base::Time passphrase_time) {}

void SyncServiceCrypto::OnTrustedVaultKeysChanged() {}

void SyncServiceCrypto::OnTrustedVaultRecoverabilityChanged() {}

void SyncServiceCrypto::FetchTrustedVaultKeys(bool is_second_fetch_attempt) {}

void SyncServiceCrypto::TrustedVaultKeysFetchedFromClient(
    bool is_second_fetch_attempt,
    const std::vector<std::vector<uint8_t>>& keys) {}

void SyncServiceCrypto::TrustedVaultKeysAdded(bool is_second_fetch_attempt) {}

void SyncServiceCrypto::TrustedVaultKeysMarkedAsStale(
    bool is_second_fetch_attempt,
    bool result) {}

void SyncServiceCrypto::FetchTrustedVaultKeysCompletedButInsufficient() {}

void SyncServiceCrypto::UpdateRequiredUserActionAndNotify(
    RequiredUserAction new_required_user_action) {}

void SyncServiceCrypto::RefreshIsRecoverabilityDegraded() {}

void SyncServiceCrypto::GetIsRecoverabilityDegradedCompleted(
    bool is_recoverability_degraded) {}

bool SyncServiceCrypto::SetDecryptionKeyWithoutUpdatingBootstrapToken(
    std::unique_ptr<Nigori> nigori) {}

void SyncServiceCrypto::MaybeSetDecryptionKeyFromBootstrapToken() {}

}  // namespace syncer