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

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

Issue 10905191: [Sync] Add keystore migration conflict support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/bind.h" 10 #include "base/bind.h"
(...skipping 1086 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 if (passphrase_type_ != KEYSTORE_PASSPHRASE && 1097 if (passphrase_type_ != KEYSTORE_PASSPHRASE &&
1098 nigori.passphrase_type() == 1098 nigori.passphrase_type() ==
1099 sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE) { 1099 sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE) {
1100 return true; 1100 return true;
1101 } else if (IsExplicitPassphrase(passphrase_type_) && 1101 } else if (IsExplicitPassphrase(passphrase_type_) &&
1102 !encrypt_everything_) { 1102 !encrypt_everything_) {
1103 return true; 1103 return true;
1104 } else if (passphrase_type_ == KEYSTORE_PASSPHRASE && 1104 } else if (passphrase_type_ == KEYSTORE_PASSPHRASE &&
1105 encrypt_everything_) { 1105 encrypt_everything_) {
1106 return true; 1106 return true;
1107 } else if (
1108 cryptographer.is_ready() &&
1109 !cryptographer.CanDecryptUsingDefaultKey(nigori.encryption_keybag())) {
1110 // We need to overwrite the keybag. This might involve overwriting the
1111 // keystore decryptor too.
1112 return true;
1107 } else { 1113 } else {
1108 return false; 1114 return false;
1109 } 1115 }
1110 } else if (keystore_key_.empty()) { 1116 } else if (keystore_key_.empty()) {
1111 // If we haven't already migrated, we don't want to do anything unless 1117 // If we haven't already migrated, we don't want to do anything unless
1112 // a keystore key is available (so that those clients without keystore 1118 // a keystore key is available (so that those clients without keystore
1113 // encryption enabled aren't forced into new states, e.g. frozen implicit 1119 // encryption enabled aren't forced into new states, e.g. frozen implicit
1114 // passphrase). 1120 // passphrase).
1115 return false; 1121 return false;
1116 } 1122 }
(...skipping 24 matching lines...) Expand all
1141 DVLOG(1) << "Switching to frozen implicit passphrase due to already having " 1147 DVLOG(1) << "Switching to frozen implicit passphrase due to already having "
1142 << "full encryption."; 1148 << "full encryption.";
1143 new_passphrase_type = FROZEN_IMPLICIT_PASSPHRASE; 1149 new_passphrase_type = FROZEN_IMPLICIT_PASSPHRASE;
1144 migrated_nigori.clear_keystore_decryptor_token(); 1150 migrated_nigori.clear_keystore_decryptor_token();
1145 } else if (IsExplicitPassphrase(passphrase_type_)) { 1151 } else if (IsExplicitPassphrase(passphrase_type_)) {
1146 DVLOG_IF(1, !encrypt_everything_) << "Enabling encrypt everything due to " 1152 DVLOG_IF(1, !encrypt_everything_) << "Enabling encrypt everything due to "
1147 << "explicit passphrase"; 1153 << "explicit passphrase";
1148 new_encrypt_everything = true; 1154 new_encrypt_everything = true;
1149 migrated_nigori.clear_keystore_decryptor_token(); 1155 migrated_nigori.clear_keystore_decryptor_token();
1150 } else { 1156 } else {
1151 DCHECK_EQ(passphrase_type_, IMPLICIT_PASSPHRASE);
1152 DCHECK(!encrypt_everything_); 1157 DCHECK(!encrypt_everything_);
1153 new_passphrase_type = KEYSTORE_PASSPHRASE; 1158 new_passphrase_type = KEYSTORE_PASSPHRASE;
1154 DVLOG(1) << "Switching to keystore passphrase state."; 1159 DVLOG(1) << "Switching to keystore passphrase state.";
1155 } 1160 }
1156 migrated_nigori.set_encrypt_everything(new_encrypt_everything); 1161 migrated_nigori.set_encrypt_everything(new_encrypt_everything);
1157 migrated_nigori.set_passphrase_type( 1162 migrated_nigori.set_passphrase_type(
1158 EnumPassphraseTypeToProto(new_passphrase_type)); 1163 EnumPassphraseTypeToProto(new_passphrase_type));
1159 migrated_nigori.set_keybag_is_frozen(true); 1164 migrated_nigori.set_keybag_is_frozen(true);
1160 1165
1161 if (!keystore_key_.empty()) { 1166 if (!keystore_key_.empty()) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1281 SyncEncryptionHandler::Observer, 1286 SyncEncryptionHandler::Observer,
1282 observers_, 1287 observers_,
1283 OnCryptographerStateChanged(cryptographer)); 1288 OnCryptographerStateChanged(cryptographer));
1284 return true; 1289 return true;
1285 } 1290 }
1286 } 1291 }
1287 return false; 1292 return false;
1288 } 1293 }
1289 1294
1290 } // namespace browser_sync 1295 } // namespace browser_sync
OLDNEW
« no previous file with comments | « sync/internal_api/sync_encryption_handler_impl.h ('k') | sync/internal_api/sync_encryption_handler_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698