Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: sync/internal_api/sync_encryption_handler_impl.cc

Issue 1250503002: [Sync] Don't require keystore migration time to be set in nigori node (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comment Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | sync/internal_api/sync_encryption_handler_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "sync/internal_api/sync_encryption_handler_impl.h" 5 #include "sync/internal_api/sync_encryption_handler_impl.h"
6 6
7 #include <queue> 7 #include <queue>
8 #include <string> 8 #include <string>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 MIGRATED, 63 MIGRATED,
64 NOT_MIGRATED_CRYPTO_NOT_READY, 64 NOT_MIGRATED_CRYPTO_NOT_READY,
65 NOT_MIGRATED_NO_KEYSTORE_KEY, 65 NOT_MIGRATED_NO_KEYSTORE_KEY,
66 NOT_MIGRATED_UNKNOWN_REASON, 66 NOT_MIGRATED_UNKNOWN_REASON,
67 MIGRATION_STATE_SIZE, 67 MIGRATION_STATE_SIZE,
68 }; 68 };
69 69
70 // The new passphrase state is sufficient to determine whether a nigori node 70 // The new passphrase state is sufficient to determine whether a nigori node
71 // is migrated to support keystore encryption. In addition though, we also 71 // is migrated to support keystore encryption. In addition though, we also
72 // want to verify the conditions for proper keystore encryption functionality. 72 // want to verify the conditions for proper keystore encryption functionality.
73 // 1. Passphrase state is set. 73 // 1. Passphrase type is set.
74 // 2. Migration time is set. 74 // 2. Frozen keybag is true
75 // 3. Frozen keybag is true 75 // 3. If passphrase state is keystore, keystore_decryptor_token is set.
76 // 4. If passphrase state is keystore, keystore_decryptor_token is set.
77 bool IsNigoriMigratedToKeystore(const sync_pb::NigoriSpecifics& nigori) { 76 bool IsNigoriMigratedToKeystore(const sync_pb::NigoriSpecifics& nigori) {
78 if (!nigori.has_passphrase_type()) 77 if (!nigori.has_passphrase_type())
79 return false; 78 return false;
80 if (!nigori.has_keystore_migration_time())
81 return false;
82 if (!nigori.keybag_is_frozen()) 79 if (!nigori.keybag_is_frozen())
83 return false; 80 return false;
84 if (nigori.passphrase_type() == 81 if (nigori.passphrase_type() ==
85 sync_pb::NigoriSpecifics::IMPLICIT_PASSPHRASE) 82 sync_pb::NigoriSpecifics::IMPLICIT_PASSPHRASE)
86 return false; 83 return false;
87 if (nigori.passphrase_type() == 84 if (nigori.passphrase_type() ==
88 sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE && 85 sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE &&
89 nigori.keystore_decryptor_token().blob().empty()) 86 nigori.keystore_decryptor_token().blob().empty())
90 return false; 87 return false;
91 if (!nigori.has_keystore_migration_time())
92 return false;
93 return true; 88 return true;
94 } 89 }
95 90
96 PassphraseType ProtoPassphraseTypeToEnum( 91 PassphraseType ProtoPassphraseTypeToEnum(
97 sync_pb::NigoriSpecifics::PassphraseType type) { 92 sync_pb::NigoriSpecifics::PassphraseType type) {
98 switch(type) { 93 switch(type) {
99 case sync_pb::NigoriSpecifics::IMPLICIT_PASSPHRASE: 94 case sync_pb::NigoriSpecifics::IMPLICIT_PASSPHRASE:
100 return IMPLICIT_PASSPHRASE; 95 return IMPLICIT_PASSPHRASE;
101 case sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE: 96 case sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE:
102 return KEYSTORE_PASSPHRASE; 97 return KEYSTORE_PASSPHRASE;
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 DVLOG(1) << "Applying nigori node update."; 884 DVLOG(1) << "Applying nigori node update.";
890 bool nigori_types_need_update = !UpdateEncryptedTypesFromNigori(nigori, 885 bool nigori_types_need_update = !UpdateEncryptedTypesFromNigori(nigori,
891 trans); 886 trans);
892 887
893 if (nigori.custom_passphrase_time() != 0) { 888 if (nigori.custom_passphrase_time() != 0) {
894 custom_passphrase_time_ = 889 custom_passphrase_time_ =
895 ProtoTimeToTime(nigori.custom_passphrase_time()); 890 ProtoTimeToTime(nigori.custom_passphrase_time());
896 } 891 }
897 bool is_nigori_migrated = IsNigoriMigratedToKeystore(nigori); 892 bool is_nigori_migrated = IsNigoriMigratedToKeystore(nigori);
898 if (is_nigori_migrated) { 893 if (is_nigori_migrated) {
899 DCHECK(nigori.has_keystore_migration_time());
900 migration_time_ = ProtoTimeToTime(nigori.keystore_migration_time()); 894 migration_time_ = ProtoTimeToTime(nigori.keystore_migration_time());
901 PassphraseType nigori_passphrase_type = 895 PassphraseType nigori_passphrase_type =
902 ProtoPassphraseTypeToEnum(nigori.passphrase_type()); 896 ProtoPassphraseTypeToEnum(nigori.passphrase_type());
903 897
904 // Only update the local passphrase state if it's a valid transition: 898 // Only update the local passphrase state if it's a valid transition:
905 // - implicit -> keystore 899 // - implicit -> keystore
906 // - implicit -> frozen implicit 900 // - implicit -> frozen implicit
907 // - implicit -> custom 901 // - implicit -> custom
908 // - keystore -> custom 902 // - keystore -> custom
909 // Note: frozen implicit -> custom is not technically a valid transition, 903 // Note: frozen implicit -> custom is not technically a valid transition,
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 void SyncEncryptionHandlerImpl::UpdateNigoriForTransitionToPassphraseEncryption( 1700 void SyncEncryptionHandlerImpl::UpdateNigoriForTransitionToPassphraseEncryption(
1707 WriteTransaction* trans) { 1701 WriteTransaction* trans) {
1708 DCHECK(trans); 1702 DCHECK(trans);
1709 if (clear_data_option_ != PASSPHRASE_TRANSITION_CLEAR_DATA) 1703 if (clear_data_option_ != PASSPHRASE_TRANSITION_CLEAR_DATA)
1710 return; 1704 return;
1711 // TODO(maniscalco): Update the Nigori node to record the fact the user has 1705 // TODO(maniscalco): Update the Nigori node to record the fact the user has
1712 // begun the transition to passphrase encryption (crbug.com/505917). 1706 // begun the transition to passphrase encryption (crbug.com/505917).
1713 } 1707 }
1714 1708
1715 } // namespace browser_sync 1709 } // namespace browser_sync
OLDNEW
« no previous file with comments | « no previous file | sync/internal_api/sync_encryption_handler_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698