Commit b4fc7e93 authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Enable TRUSTED_VAULT_PASSPHRASE behind feature toggle

This introduces basic functionality related to this passphrase type,
which behaves similarly to KEYSTORE_PASSPHRASE but is designed to
receive the encryption key by means other than the sync protocol.

Bug: 1000146
Change-Id: I0a3f093ae47a8efcb79794572c6e7ac30b335d95
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1806874Reviewed-by: default avatarMaksim Moskvitin <mmoskvitin@google.com>
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697203}
parent 084c3fd0
...@@ -25,4 +25,7 @@ const base::Feature kSyncResetPollIntervalOnStart{ ...@@ -25,4 +25,7 @@ const base::Feature kSyncResetPollIntervalOnStart{
const base::Feature kSyncUseScryptForNewCustomPassphrases{ const base::Feature kSyncUseScryptForNewCustomPassphrases{
"SyncUseScryptForNewCustomPassphrases", base::FEATURE_ENABLED_BY_DEFAULT}; "SyncUseScryptForNewCustomPassphrases", base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kSyncSupportTrustedVaultPassphrase{
"SyncSupportTrustedVaultPassphrase", base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace switches } // namespace switches
...@@ -13,6 +13,7 @@ extern const char kSyncEnableGetUpdatesBeforeCommit[]; ...@@ -13,6 +13,7 @@ extern const char kSyncEnableGetUpdatesBeforeCommit[];
extern const base::Feature kSyncResetPollIntervalOnStart; extern const base::Feature kSyncResetPollIntervalOnStart;
extern const base::Feature kSyncUseScryptForNewCustomPassphrases; extern const base::Feature kSyncUseScryptForNewCustomPassphrases;
extern const base::Feature kSyncSupportTrustedVaultPassphrase;
} // namespace switches } // namespace switches
......
...@@ -263,8 +263,8 @@ bool IsValidNigoriSpecifics(const NigoriSpecifics& specifics) { ...@@ -263,8 +263,8 @@ bool IsValidNigoriSpecifics(const NigoriSpecifics& specifics) {
} }
break; break;
case NigoriSpecifics::TRUSTED_VAULT_PASSPHRASE: case NigoriSpecifics::TRUSTED_VAULT_PASSPHRASE:
NOTIMPLEMENTED(); return base::FeatureList::IsEnabled(
return false; switches::kSyncSupportTrustedVaultPassphrase);
} }
return true; return true;
} }
...@@ -290,7 +290,8 @@ bool IsValidPassphraseTransition( ...@@ -290,7 +290,8 @@ bool IsValidPassphraseTransition(
NOTREACHED(); NOTREACHED();
return false; return false;
case NigoriSpecifics::KEYSTORE_PASSPHRASE: case NigoriSpecifics::KEYSTORE_PASSPHRASE:
return new_passphrase_type == NigoriSpecifics::CUSTOM_PASSPHRASE; return new_passphrase_type == NigoriSpecifics::CUSTOM_PASSPHRASE ||
new_passphrase_type == NigoriSpecifics::TRUSTED_VAULT_PASSPHRASE;
case NigoriSpecifics::FROZEN_IMPLICIT_PASSPHRASE: case NigoriSpecifics::FROZEN_IMPLICIT_PASSPHRASE:
// There is no client side code which can cause such transition, but // There is no client side code which can cause such transition, but
// technically it's a valid one and can be implemented in the future. // technically it's a valid one and can be implemented in the future.
...@@ -509,7 +510,11 @@ NigoriSyncBridgeImpl::NigoriSyncBridgeImpl( ...@@ -509,7 +510,11 @@ NigoriSyncBridgeImpl::NigoriSyncBridgeImpl(
// verifications, taking into account sensitivity of this data. // verifications, taking into account sensitivity of this data.
base::Optional<sync_pb::NigoriLocalData> deserialized_data = base::Optional<sync_pb::NigoriLocalData> deserialized_data =
storage_->RestoreData(); storage_->RestoreData();
if (!deserialized_data) { if (!deserialized_data ||
(deserialized_data->nigori_model().passphrase_type() ==
NigoriSpecifics::TRUSTED_VAULT_PASSPHRASE &&
!base::FeatureList::IsEnabled(
switches::kSyncSupportTrustedVaultPassphrase))) {
// We either have no Nigori node stored locally or it was corrupted. // We either have no Nigori node stored locally or it was corrupted.
processor_->ModelReadyToSync(this, NigoriMetadataBatch()); processor_->ModelReadyToSync(this, NigoriMetadataBatch());
return; return;
...@@ -1054,6 +1059,15 @@ const Cryptographer& NigoriSyncBridgeImpl::GetCryptographerForTesting() const { ...@@ -1054,6 +1059,15 @@ const Cryptographer& NigoriSyncBridgeImpl::GetCryptographerForTesting() const {
return cryptographer_; return cryptographer_;
} }
sync_pb::NigoriSpecifics::PassphraseType
NigoriSyncBridgeImpl::GetPassphraseTypeForTesting() const {
return passphrase_type_;
}
ModelTypeSet NigoriSyncBridgeImpl::GetEncryptedTypesForTesting() const {
return GetEncryptedTypes(encrypt_everything_);
}
std::string NigoriSyncBridgeImpl::PackExplicitPassphraseKeyForTesting( std::string NigoriSyncBridgeImpl::PackExplicitPassphraseKeyForTesting(
const Encryptor& encryptor, const Encryptor& encryptor,
const Cryptographer& cryptographer) { const Cryptographer& cryptographer) {
...@@ -1108,6 +1122,9 @@ void NigoriSyncBridgeImpl::MaybeNotifyBootstrapTokenUpdated() const { ...@@ -1108,6 +1122,9 @@ void NigoriSyncBridgeImpl::MaybeNotifyBootstrapTokenUpdated() const {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return; return;
case NigoriSpecifics::TRUSTED_VAULT_PASSPHRASE: case NigoriSpecifics::TRUSTED_VAULT_PASSPHRASE:
// This may be problematic for the MIGRATION_DONE case because the local
// keybag will be cleared and it won't be automatically recovered from
// prefs.
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return; return;
case NigoriSpecifics::FROZEN_IMPLICIT_PASSPHRASE: case NigoriSpecifics::FROZEN_IMPLICIT_PASSPHRASE:
......
...@@ -82,6 +82,9 @@ class NigoriSyncBridgeImpl : public KeystoreKeysHandler, ...@@ -82,6 +82,9 @@ class NigoriSyncBridgeImpl : public KeystoreKeysHandler,
// tests and decide whether this method should be a part of // tests and decide whether this method should be a part of
// SyncEncryptionHandler interface. // SyncEncryptionHandler interface.
const Cryptographer& GetCryptographerForTesting() const; const Cryptographer& GetCryptographerForTesting() const;
sync_pb::NigoriSpecifics::PassphraseType GetPassphraseTypeForTesting() const;
ModelTypeSet GetEncryptedTypesForTesting() const;
static std::string PackExplicitPassphraseKeyForTesting( static std::string PackExplicitPassphraseKeyForTesting(
const Encryptor& encryptor, const Encryptor& encryptor,
const Cryptographer& cryptographer); const Cryptographer& cryptographer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment