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

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: Self review 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 state is set.
74 // 2. Migration time is set. 74 // 2. Migration time is set.
pavely 2015/07/21 18:08:46 Item 2. from comment should be removed too.
Nicolas Zea 2015/07/21 19:41:26 Done.
75 // 3. Frozen keybag is true 75 // 3. Frozen keybag is true
76 // 4. 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) { 77 bool IsNigoriMigratedToKeystore(const sync_pb::NigoriSpecifics& nigori) {
78 if (!nigori.has_passphrase_type()) 78 if (!nigori.has_passphrase_type())
79 return false; 79 return false;
80 if (!nigori.has_keystore_migration_time())
81 return false;
82 if (!nigori.keybag_is_frozen()) 80 if (!nigori.keybag_is_frozen())
83 return false; 81 return false;
84 if (nigori.passphrase_type() == 82 if (nigori.passphrase_type() ==
85 sync_pb::NigoriSpecifics::IMPLICIT_PASSPHRASE) 83 sync_pb::NigoriSpecifics::IMPLICIT_PASSPHRASE)
86 return false; 84 return false;
87 if (nigori.passphrase_type() == 85 if (nigori.passphrase_type() ==
88 sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE && 86 sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE &&
89 nigori.keystore_decryptor_token().blob().empty()) 87 nigori.keystore_decryptor_token().blob().empty())
90 return false; 88 return false;
91 if (!nigori.has_keystore_migration_time())
92 return false;
93 return true; 89 return true;
94 } 90 }
95 91
96 PassphraseType ProtoPassphraseTypeToEnum( 92 PassphraseType ProtoPassphraseTypeToEnum(
97 sync_pb::NigoriSpecifics::PassphraseType type) { 93 sync_pb::NigoriSpecifics::PassphraseType type) {
98 switch(type) { 94 switch(type) {
99 case sync_pb::NigoriSpecifics::IMPLICIT_PASSPHRASE: 95 case sync_pb::NigoriSpecifics::IMPLICIT_PASSPHRASE:
100 return IMPLICIT_PASSPHRASE; 96 return IMPLICIT_PASSPHRASE;
101 case sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE: 97 case sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE:
102 return KEYSTORE_PASSPHRASE; 98 return KEYSTORE_PASSPHRASE;
(...skipping 786 matching lines...) Expand 10 before | Expand all | Expand 10 after
889 DVLOG(1) << "Applying nigori node update."; 885 DVLOG(1) << "Applying nigori node update.";
890 bool nigori_types_need_update = !UpdateEncryptedTypesFromNigori(nigori, 886 bool nigori_types_need_update = !UpdateEncryptedTypesFromNigori(nigori,
891 trans); 887 trans);
892 888
893 if (nigori.custom_passphrase_time() != 0) { 889 if (nigori.custom_passphrase_time() != 0) {
894 custom_passphrase_time_ = 890 custom_passphrase_time_ =
895 ProtoTimeToTime(nigori.custom_passphrase_time()); 891 ProtoTimeToTime(nigori.custom_passphrase_time());
896 } 892 }
897 bool is_nigori_migrated = IsNigoriMigratedToKeystore(nigori); 893 bool is_nigori_migrated = IsNigoriMigratedToKeystore(nigori);
898 if (is_nigori_migrated) { 894 if (is_nigori_migrated) {
899 DCHECK(nigori.has_keystore_migration_time());
900 migration_time_ = ProtoTimeToTime(nigori.keystore_migration_time()); 895 migration_time_ = ProtoTimeToTime(nigori.keystore_migration_time());
pavely 2015/07/21 18:08:46 Do we use migration_time_ anywhere other than disp
Nicolas Zea 2015/07/21 19:41:26 It's only in about:sync. And yeah, I'm okay with i
901 PassphraseType nigori_passphrase_type = 896 PassphraseType nigori_passphrase_type =
902 ProtoPassphraseTypeToEnum(nigori.passphrase_type()); 897 ProtoPassphraseTypeToEnum(nigori.passphrase_type());
903 898
904 // Only update the local passphrase state if it's a valid transition: 899 // Only update the local passphrase state if it's a valid transition:
905 // - implicit -> keystore 900 // - implicit -> keystore
906 // - implicit -> frozen implicit 901 // - implicit -> frozen implicit
907 // - implicit -> custom 902 // - implicit -> custom
908 // - keystore -> custom 903 // - keystore -> custom
909 // Note: frozen implicit -> custom is not technically a valid transition, 904 // Note: frozen implicit -> custom is not technically a valid transition,
910 // but we let it through here as well in case future versions do add support 905 // but we let it through here as well in case future versions do add support
(...skipping 795 matching lines...) Expand 10 before | Expand all | Expand 10 after
1706 void SyncEncryptionHandlerImpl::UpdateNigoriForTransitionToPassphraseEncryption( 1701 void SyncEncryptionHandlerImpl::UpdateNigoriForTransitionToPassphraseEncryption(
1707 WriteTransaction* trans) { 1702 WriteTransaction* trans) {
1708 DCHECK(trans); 1703 DCHECK(trans);
1709 if (clear_data_option_ != PASSPHRASE_TRANSITION_CLEAR_DATA) 1704 if (clear_data_option_ != PASSPHRASE_TRANSITION_CLEAR_DATA)
1710 return; 1705 return;
1711 // TODO(maniscalco): Update the Nigori node to record the fact the user has 1706 // TODO(maniscalco): Update the Nigori node to record the fact the user has
1712 // begun the transition to passphrase encryption (crbug.com/505917). 1707 // begun the transition to passphrase encryption (crbug.com/505917).
1713 } 1708 }
1714 1709
1715 } // namespace browser_sync 1710 } // 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