OLD | NEW |
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 <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/json/json_string_value_serializer.h" | 10 #include "base/json/json_string_value_serializer.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 const std::string& passphrase) { | 139 const std::string& passphrase) { |
140 VerifyMigratedNigoriWithTimestamp(0, passphrase_type, passphrase); | 140 VerifyMigratedNigoriWithTimestamp(0, passphrase_type, passphrase); |
141 } | 141 } |
142 | 142 |
143 void VerifyMigratedNigoriWithTimestamp( | 143 void VerifyMigratedNigoriWithTimestamp( |
144 int64 migration_time, | 144 int64 migration_time, |
145 PassphraseType passphrase_type, | 145 PassphraseType passphrase_type, |
146 const std::string& passphrase) { | 146 const std::string& passphrase) { |
147 ReadTransaction trans(FROM_HERE, user_share()); | 147 ReadTransaction trans(FROM_HERE, user_share()); |
148 ReadNode nigori_node(&trans); | 148 ReadNode nigori_node(&trans); |
149 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 149 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
150 const sync_pb::NigoriSpecifics& nigori = nigori_node.GetNigoriSpecifics(); | 150 const sync_pb::NigoriSpecifics& nigori = nigori_node.GetNigoriSpecifics(); |
151 if (migration_time > 0) | 151 if (migration_time > 0) |
152 EXPECT_EQ(migration_time, nigori.keystore_migration_time()); | 152 EXPECT_EQ(migration_time, nigori.keystore_migration_time()); |
153 else | 153 else |
154 EXPECT_TRUE(nigori.has_keystore_migration_time()); | 154 EXPECT_TRUE(nigori.has_keystore_migration_time()); |
155 EXPECT_TRUE(nigori.keybag_is_frozen()); | 155 EXPECT_TRUE(nigori.keybag_is_frozen()); |
156 if (passphrase_type == CUSTOM_PASSPHRASE || | 156 if (passphrase_type == CUSTOM_PASSPHRASE || |
157 passphrase_type == FROZEN_IMPLICIT_PASSPHRASE) { | 157 passphrase_type == FROZEN_IMPLICIT_PASSPHRASE) { |
158 EXPECT_TRUE(nigori.encrypt_everything()); | 158 EXPECT_TRUE(nigori.encrypt_everything()); |
159 EXPECT_TRUE(nigori.keystore_decryptor_token().blob().empty()); | 159 EXPECT_TRUE(nigori.keystore_decryptor_token().blob().empty()); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 } | 232 } |
233 | 233 |
234 // Build a migrated nigori node with the specified default passphrase | 234 // Build a migrated nigori node with the specified default passphrase |
235 // and keystore key and initialize the encryption handler with it. | 235 // and keystore key and initialize the encryption handler with it. |
236 void InitKeystoreMigratedNigori(int64 migration_time, | 236 void InitKeystoreMigratedNigori(int64 migration_time, |
237 const std::string& default_passphrase, | 237 const std::string& default_passphrase, |
238 const std::string& keystore_key) { | 238 const std::string& keystore_key) { |
239 { | 239 { |
240 WriteTransaction trans(FROM_HERE, user_share()); | 240 WriteTransaction trans(FROM_HERE, user_share()); |
241 WriteNode nigori_node(&trans); | 241 WriteNode nigori_node(&trans); |
242 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 242 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
243 sync_pb::NigoriSpecifics nigori = BuildMigratedNigori( | 243 sync_pb::NigoriSpecifics nigori = BuildMigratedNigori( |
244 KEYSTORE_PASSPHRASE, | 244 KEYSTORE_PASSPHRASE, |
245 migration_time, | 245 migration_time, |
246 default_passphrase, | 246 default_passphrase, |
247 keystore_key); | 247 keystore_key); |
248 nigori_node.SetNigoriSpecifics(nigori); | 248 nigori_node.SetNigoriSpecifics(nigori); |
249 } | 249 } |
250 | 250 |
251 EXPECT_CALL(*observer(), | 251 EXPECT_CALL(*observer(), |
252 OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE, _)); | 252 OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE, _)); |
(...skipping 12 matching lines...) Expand all Loading... |
265 Mock::VerifyAndClearExpectations(observer()); | 265 Mock::VerifyAndClearExpectations(observer()); |
266 } | 266 } |
267 | 267 |
268 // Build a migrated nigori node with the specified default passphrase | 268 // Build a migrated nigori node with the specified default passphrase |
269 // as a custom passphrase. | 269 // as a custom passphrase. |
270 void InitCustomPassMigratedNigori(int64 migration_time, | 270 void InitCustomPassMigratedNigori(int64 migration_time, |
271 const std::string& default_passphrase) { | 271 const std::string& default_passphrase) { |
272 { | 272 { |
273 WriteTransaction trans(FROM_HERE, user_share()); | 273 WriteTransaction trans(FROM_HERE, user_share()); |
274 WriteNode nigori_node(&trans); | 274 WriteNode nigori_node(&trans); |
275 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 275 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
276 sync_pb::NigoriSpecifics nigori = BuildMigratedNigori( | 276 sync_pb::NigoriSpecifics nigori = BuildMigratedNigori( |
277 CUSTOM_PASSPHRASE, | 277 CUSTOM_PASSPHRASE, |
278 migration_time, | 278 migration_time, |
279 default_passphrase, | 279 default_passphrase, |
280 kKeystoreKey); | 280 kKeystoreKey); |
281 nigori_node.SetNigoriSpecifics(nigori); | 281 nigori_node.SetNigoriSpecifics(nigori); |
282 } | 282 } |
283 | 283 |
284 EXPECT_CALL(*observer(), | 284 EXPECT_CALL(*observer(), |
285 OnPassphraseTypeChanged(CUSTOM_PASSPHRASE, _)); | 285 OnPassphraseTypeChanged(CUSTOM_PASSPHRASE, _)); |
(...skipping 16 matching lines...) Expand all Loading... |
302 PassphraseType passphrase_type) { | 302 PassphraseType passphrase_type) { |
303 DCHECK_NE(passphrase_type, FROZEN_IMPLICIT_PASSPHRASE); | 303 DCHECK_NE(passphrase_type, FROZEN_IMPLICIT_PASSPHRASE); |
304 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); | 304 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); |
305 KeyParams default_key = {"localhost", "dummy", default_passphrase}; | 305 KeyParams default_key = {"localhost", "dummy", default_passphrase}; |
306 other_cryptographer.AddKey(default_key); | 306 other_cryptographer.AddKey(default_key); |
307 EXPECT_TRUE(other_cryptographer.is_ready()); | 307 EXPECT_TRUE(other_cryptographer.is_ready()); |
308 | 308 |
309 { | 309 { |
310 WriteTransaction trans(FROM_HERE, user_share()); | 310 WriteTransaction trans(FROM_HERE, user_share()); |
311 WriteNode nigori_node(&trans); | 311 WriteNode nigori_node(&trans); |
312 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 312 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
313 sync_pb::NigoriSpecifics nigori; | 313 sync_pb::NigoriSpecifics nigori; |
314 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 314 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
315 nigori.set_keybag_is_frozen(passphrase_type == CUSTOM_PASSPHRASE); | 315 nigori.set_keybag_is_frozen(passphrase_type == CUSTOM_PASSPHRASE); |
316 nigori_node.SetNigoriSpecifics(nigori); | 316 nigori_node.SetNigoriSpecifics(nigori); |
317 } | 317 } |
318 | 318 |
319 if (passphrase_type != IMPLICIT_PASSPHRASE) { | 319 if (passphrase_type != IMPLICIT_PASSPHRASE) { |
320 EXPECT_CALL(*observer(), | 320 EXPECT_CALL(*observer(), |
321 OnPassphraseTypeChanged(passphrase_type, _)); | 321 OnPassphraseTypeChanged(passphrase_type, _)); |
322 } | 322 } |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 // specifics. | 580 // specifics. |
581 PumpLoop(); | 581 PumpLoop(); |
582 | 582 |
583 { | 583 { |
584 // The cryptographer should be able to decrypt both sets of keys and still | 584 // The cryptographer should be able to decrypt both sets of keys and still |
585 // be encrypting with the newest, and the encrypted types should be the | 585 // be encrypting with the newest, and the encrypted types should be the |
586 // most recent. | 586 // most recent. |
587 // In addition, the nigori node should match the current encryption state. | 587 // In addition, the nigori node should match the current encryption state. |
588 ReadTransaction trans(FROM_HERE, user_share()); | 588 ReadTransaction trans(FROM_HERE, user_share()); |
589 ReadNode nigori_node(&trans); | 589 ReadNode nigori_node(&trans); |
590 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 590 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
591 const sync_pb::NigoriSpecifics& nigori = nigori_node.GetNigoriSpecifics(); | 591 const sync_pb::NigoriSpecifics& nigori = nigori_node.GetNigoriSpecifics(); |
592 EXPECT_TRUE(GetCryptographer()->CanDecryptUsingDefaultKey( | 592 EXPECT_TRUE(GetCryptographer()->CanDecryptUsingDefaultKey( |
593 our_encrypted_specifics.encrypted())); | 593 our_encrypted_specifics.encrypted())); |
594 EXPECT_TRUE(GetCryptographer()->CanDecrypt( | 594 EXPECT_TRUE(GetCryptographer()->CanDecrypt( |
595 other_encrypted_specifics.encrypted())); | 595 other_encrypted_specifics.encrypted())); |
596 EXPECT_TRUE(GetCryptographer()->CanDecrypt(nigori.encryption_keybag())); | 596 EXPECT_TRUE(GetCryptographer()->CanDecrypt(nigori.encryption_keybag())); |
597 EXPECT_TRUE(nigori.encrypt_everything()); | 597 EXPECT_TRUE(nigori.encrypt_everything()); |
598 EXPECT_TRUE( | 598 EXPECT_TRUE( |
599 GetCryptographer()->CanDecryptUsingDefaultKey( | 599 GetCryptographer()->CanDecryptUsingDefaultKey( |
600 nigori.encryption_keybag())); | 600 nigori.encryption_keybag())); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 encryption_handler()->SetKeystoreKeys(BuildEncryptionKeyProto( | 723 encryption_handler()->SetKeystoreKeys(BuildEncryptionKeyProto( |
724 kRawKeystoreKey), | 724 kRawKeystoreKey), |
725 trans.GetWrappedTrans()); | 725 trans.GetWrappedTrans()); |
726 Mock::VerifyAndClearExpectations(observer()); | 726 Mock::VerifyAndClearExpectations(observer()); |
727 } | 727 } |
728 EXPECT_FALSE(encryption_handler()->MigratedToKeystore()); | 728 EXPECT_FALSE(encryption_handler()->MigratedToKeystore()); |
729 | 729 |
730 { | 730 { |
731 WriteTransaction trans(FROM_HERE, user_share()); | 731 WriteTransaction trans(FROM_HERE, user_share()); |
732 WriteNode nigori_node(&trans); | 732 WriteNode nigori_node(&trans); |
733 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 733 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
734 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); | 734 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); |
735 KeyParams other_key = {"localhost", "dummy", kOtherKey}; | 735 KeyParams other_key = {"localhost", "dummy", kOtherKey}; |
736 other_cryptographer.AddKey(other_key); | 736 other_cryptographer.AddKey(other_key); |
737 | 737 |
738 sync_pb::NigoriSpecifics nigori; | 738 sync_pb::NigoriSpecifics nigori; |
739 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 739 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
740 nigori.set_keybag_is_frozen(false); | 740 nigori.set_keybag_is_frozen(false); |
741 nigori.set_encrypt_everything(false); | 741 nigori.set_encrypt_everything(false); |
742 EXPECT_CALL(*observer(), | 742 EXPECT_CALL(*observer(), |
743 OnCryptographerStateChanged(_)).Times(AnyNumber()); | 743 OnCryptographerStateChanged(_)).Times(AnyNumber()); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 encryption_handler()->SetKeystoreKeys(BuildEncryptionKeyProto( | 780 encryption_handler()->SetKeystoreKeys(BuildEncryptionKeyProto( |
781 kRawKeystoreKey), | 781 kRawKeystoreKey), |
782 trans.GetWrappedTrans()); | 782 trans.GetWrappedTrans()); |
783 Mock::VerifyAndClearExpectations(observer()); | 783 Mock::VerifyAndClearExpectations(observer()); |
784 } | 784 } |
785 EXPECT_FALSE(encryption_handler()->MigratedToKeystore()); | 785 EXPECT_FALSE(encryption_handler()->MigratedToKeystore()); |
786 | 786 |
787 { | 787 { |
788 WriteTransaction trans(FROM_HERE, user_share()); | 788 WriteTransaction trans(FROM_HERE, user_share()); |
789 WriteNode nigori_node(&trans); | 789 WriteNode nigori_node(&trans); |
790 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 790 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
791 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); | 791 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); |
792 KeyParams other_key = {"localhost", "dummy", kOtherKey}; | 792 KeyParams other_key = {"localhost", "dummy", kOtherKey}; |
793 other_cryptographer.AddKey(other_key); | 793 other_cryptographer.AddKey(other_key); |
794 | 794 |
795 sync_pb::NigoriSpecifics nigori; | 795 sync_pb::NigoriSpecifics nigori; |
796 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 796 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
797 nigori.set_keybag_is_frozen(true); | 797 nigori.set_keybag_is_frozen(true); |
798 nigori.set_encrypt_everything(false); | 798 nigori.set_encrypt_everything(false); |
799 EXPECT_CALL(*observer(), | 799 EXPECT_CALL(*observer(), |
800 OnCryptographerStateChanged(_)).Times(AnyNumber()); | 800 OnCryptographerStateChanged(_)).Times(AnyNumber()); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1028 EXPECT_FALSE(encryption_handler()->MigratedToKeystore()); | 1028 EXPECT_FALSE(encryption_handler()->MigratedToKeystore()); |
1029 EXPECT_FALSE(GetCryptographer()->is_ready()); | 1029 EXPECT_FALSE(GetCryptographer()->is_ready()); |
1030 EXPECT_NE(encryption_handler()->GetPassphraseType(), KEYSTORE_PASSPHRASE); | 1030 EXPECT_NE(encryption_handler()->GetPassphraseType(), KEYSTORE_PASSPHRASE); |
1031 | 1031 |
1032 // Now build a nigori node with the generated keystore decryptor token and | 1032 // Now build a nigori node with the generated keystore decryptor token and |
1033 // initialize the encryption handler with it. The cryptographer should be | 1033 // initialize the encryption handler with it. The cryptographer should be |
1034 // initialized properly to decrypt both kCurKey and kKeystoreKey. | 1034 // initialized properly to decrypt both kCurKey and kKeystoreKey. |
1035 { | 1035 { |
1036 WriteTransaction trans(FROM_HERE, user_share()); | 1036 WriteTransaction trans(FROM_HERE, user_share()); |
1037 WriteNode nigori_node(&trans); | 1037 WriteNode nigori_node(&trans); |
1038 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1038 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1039 sync_pb::NigoriSpecifics nigori; | 1039 sync_pb::NigoriSpecifics nigori; |
1040 nigori.mutable_keystore_decryptor_token()->CopyFrom( | 1040 nigori.mutable_keystore_decryptor_token()->CopyFrom( |
1041 keystore_decryptor_token); | 1041 keystore_decryptor_token); |
1042 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 1042 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
1043 nigori.set_keybag_is_frozen(true); | 1043 nigori.set_keybag_is_frozen(true); |
1044 nigori.set_keystore_migration_time(1); | 1044 nigori.set_keystore_migration_time(1); |
1045 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); | 1045 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); |
1046 | 1046 |
1047 EXPECT_CALL(*observer(), OnPassphraseAccepted()); | 1047 EXPECT_CALL(*observer(), OnPassphraseAccepted()); |
1048 EXPECT_CALL(*observer(), | 1048 EXPECT_CALL(*observer(), |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 EXPECT_CALL(*observer(), | 1108 EXPECT_CALL(*observer(), |
1109 OnPassphraseTypeChanged(FROZEN_IMPLICIT_PASSPHRASE, _)); | 1109 OnPassphraseTypeChanged(FROZEN_IMPLICIT_PASSPHRASE, _)); |
1110 EXPECT_CALL(*observer(), | 1110 EXPECT_CALL(*observer(), |
1111 OnPassphraseRequired(_, _)); | 1111 OnPassphraseRequired(_, _)); |
1112 EXPECT_CALL(*observer(), | 1112 EXPECT_CALL(*observer(), |
1113 OnCryptographerStateChanged(_)).Times(AnyNumber()); | 1113 OnCryptographerStateChanged(_)).Times(AnyNumber()); |
1114 EXPECT_CALL(*observer(), | 1114 EXPECT_CALL(*observer(), |
1115 OnEncryptedTypesChanged(_, true)); | 1115 OnEncryptedTypesChanged(_, true)); |
1116 WriteTransaction trans(FROM_HERE, user_share()); | 1116 WriteTransaction trans(FROM_HERE, user_share()); |
1117 WriteNode nigori_node(&trans); | 1117 WriteNode nigori_node(&trans); |
1118 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1118 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1119 sync_pb::NigoriSpecifics nigori; | 1119 sync_pb::NigoriSpecifics nigori; |
1120 nigori.set_keybag_is_frozen(true); | 1120 nigori.set_keybag_is_frozen(true); |
1121 nigori.set_passphrase_type( | 1121 nigori.set_passphrase_type( |
1122 sync_pb::NigoriSpecifics::FROZEN_IMPLICIT_PASSPHRASE); | 1122 sync_pb::NigoriSpecifics::FROZEN_IMPLICIT_PASSPHRASE); |
1123 nigori.set_keystore_migration_time(1); | 1123 nigori.set_keystore_migration_time(1); |
1124 nigori.set_encrypt_everything(true); | 1124 nigori.set_encrypt_everything(true); |
1125 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 1125 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
1126 encryption_handler()->ApplyNigoriUpdate(nigori, trans.GetWrappedTrans()); | 1126 encryption_handler()->ApplyNigoriUpdate(nigori, trans.GetWrappedTrans()); |
1127 nigori_node.SetNigoriSpecifics(nigori); | 1127 nigori_node.SetNigoriSpecifics(nigori); |
1128 } | 1128 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 EXPECT_CALL(*observer(), | 1188 EXPECT_CALL(*observer(), |
1189 OnPassphraseTypeChanged(CUSTOM_PASSPHRASE, _)); | 1189 OnPassphraseTypeChanged(CUSTOM_PASSPHRASE, _)); |
1190 EXPECT_CALL(*observer(), | 1190 EXPECT_CALL(*observer(), |
1191 OnPassphraseRequired(_, _)); | 1191 OnPassphraseRequired(_, _)); |
1192 EXPECT_CALL(*observer(), | 1192 EXPECT_CALL(*observer(), |
1193 OnCryptographerStateChanged(_)).Times(AnyNumber()); | 1193 OnCryptographerStateChanged(_)).Times(AnyNumber()); |
1194 EXPECT_CALL(*observer(), | 1194 EXPECT_CALL(*observer(), |
1195 OnEncryptedTypesChanged(_, true)); | 1195 OnEncryptedTypesChanged(_, true)); |
1196 WriteTransaction trans(FROM_HERE, user_share()); | 1196 WriteTransaction trans(FROM_HERE, user_share()); |
1197 WriteNode nigori_node(&trans); | 1197 WriteNode nigori_node(&trans); |
1198 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1198 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1199 sync_pb::NigoriSpecifics nigori; | 1199 sync_pb::NigoriSpecifics nigori; |
1200 nigori.set_keybag_is_frozen(true); | 1200 nigori.set_keybag_is_frozen(true); |
1201 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE); | 1201 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE); |
1202 nigori.set_keystore_migration_time(1); | 1202 nigori.set_keystore_migration_time(1); |
1203 nigori.set_encrypt_everything(true); | 1203 nigori.set_encrypt_everything(true); |
1204 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 1204 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
1205 encryption_handler()->ApplyNigoriUpdate(nigori, trans.GetWrappedTrans()); | 1205 encryption_handler()->ApplyNigoriUpdate(nigori, trans.GetWrappedTrans()); |
1206 nigori_node.SetNigoriSpecifics(nigori); | 1206 nigori_node.SetNigoriSpecifics(nigori); |
1207 } | 1207 } |
1208 // Run any tasks posted via AppplyNigoriUpdate. | 1208 // Run any tasks posted via AppplyNigoriUpdate. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 sync_pb::EncryptedData encrypted; | 1250 sync_pb::EncryptedData encrypted; |
1251 KeyParams old_key = {"localhost", "dummy", kOldKey}; | 1251 KeyParams old_key = {"localhost", "dummy", kOldKey}; |
1252 KeyParams cur_key = {"localhost", "dummy", kCurKey}; | 1252 KeyParams cur_key = {"localhost", "dummy", kCurKey}; |
1253 GetCryptographer()->AddKey(old_key); | 1253 GetCryptographer()->AddKey(old_key); |
1254 GetCryptographer()->AddKey(cur_key); | 1254 GetCryptographer()->AddKey(cur_key); |
1255 | 1255 |
1256 // Build a migrated nigori with full encryption. | 1256 // Build a migrated nigori with full encryption. |
1257 { | 1257 { |
1258 WriteTransaction trans(FROM_HERE, user_share()); | 1258 WriteTransaction trans(FROM_HERE, user_share()); |
1259 WriteNode nigori_node(&trans); | 1259 WriteNode nigori_node(&trans); |
1260 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1260 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1261 sync_pb::NigoriSpecifics nigori; | 1261 sync_pb::NigoriSpecifics nigori; |
1262 GetCryptographer()->GetKeys(nigori.mutable_encryption_keybag()); | 1262 GetCryptographer()->GetKeys(nigori.mutable_encryption_keybag()); |
1263 nigori.set_keybag_is_frozen(true); | 1263 nigori.set_keybag_is_frozen(true); |
1264 nigori.set_keystore_migration_time(1); | 1264 nigori.set_keystore_migration_time(1); |
1265 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE); | 1265 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE); |
1266 nigori.set_encrypt_everything(true); | 1266 nigori.set_encrypt_everything(true); |
1267 nigori_node.SetNigoriSpecifics(nigori); | 1267 nigori_node.SetNigoriSpecifics(nigori); |
1268 } | 1268 } |
1269 | 1269 |
1270 EXPECT_CALL(*observer(), | 1270 EXPECT_CALL(*observer(), |
(...skipping 24 matching lines...) Expand all Loading... |
1295 // Now build an old unmigrated nigori node with old encrypted types. We should | 1295 // Now build an old unmigrated nigori node with old encrypted types. We should |
1296 // properly overwrite it with the migrated + encrypt everything state. | 1296 // properly overwrite it with the migrated + encrypt everything state. |
1297 EXPECT_CALL(*observer(), | 1297 EXPECT_CALL(*observer(), |
1298 OnCryptographerStateChanged(_)).Times(AnyNumber()); | 1298 OnCryptographerStateChanged(_)).Times(AnyNumber()); |
1299 EXPECT_CALL(*observer(), OnEncryptionComplete()); | 1299 EXPECT_CALL(*observer(), OnEncryptionComplete()); |
1300 { | 1300 { |
1301 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); | 1301 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); |
1302 other_cryptographer.AddKey(old_key); | 1302 other_cryptographer.AddKey(old_key); |
1303 WriteTransaction trans(FROM_HERE, user_share()); | 1303 WriteTransaction trans(FROM_HERE, user_share()); |
1304 WriteNode nigori_node(&trans); | 1304 WriteNode nigori_node(&trans); |
1305 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1305 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1306 sync_pb::NigoriSpecifics nigori; | 1306 sync_pb::NigoriSpecifics nigori; |
1307 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 1307 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
1308 nigori.set_keybag_is_frozen(false); | 1308 nigori.set_keybag_is_frozen(false); |
1309 nigori.set_encrypt_everything(false); | 1309 nigori.set_encrypt_everything(false); |
1310 encryption_handler()->ApplyNigoriUpdate(nigori, trans.GetWrappedTrans()); | 1310 encryption_handler()->ApplyNigoriUpdate(nigori, trans.GetWrappedTrans()); |
1311 nigori_node.SetNigoriSpecifics(nigori); | 1311 nigori_node.SetNigoriSpecifics(nigori); |
1312 } | 1312 } |
1313 PumpLoop(); | 1313 PumpLoop(); |
1314 | 1314 |
1315 // Verify we're still migrated and have proper encryption state. | 1315 // Verify we're still migrated and have proper encryption state. |
(...skipping 13 matching lines...) Expand all Loading... |
1329 sync_pb::EncryptedData encrypted; | 1329 sync_pb::EncryptedData encrypted; |
1330 KeyParams old_key = {"localhost", "dummy", kOldKey}; | 1330 KeyParams old_key = {"localhost", "dummy", kOldKey}; |
1331 KeyParams cur_key = {"localhost", "dummy", kCurKey}; | 1331 KeyParams cur_key = {"localhost", "dummy", kCurKey}; |
1332 GetCryptographer()->AddKey(old_key); | 1332 GetCryptographer()->AddKey(old_key); |
1333 GetCryptographer()->AddKey(cur_key); | 1333 GetCryptographer()->AddKey(cur_key); |
1334 | 1334 |
1335 // Build a migrated nigori with full encryption. | 1335 // Build a migrated nigori with full encryption. |
1336 { | 1336 { |
1337 WriteTransaction trans(FROM_HERE, user_share()); | 1337 WriteTransaction trans(FROM_HERE, user_share()); |
1338 WriteNode nigori_node(&trans); | 1338 WriteNode nigori_node(&trans); |
1339 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1339 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1340 sync_pb::NigoriSpecifics nigori; | 1340 sync_pb::NigoriSpecifics nigori; |
1341 GetCryptographer()->GetKeys(nigori.mutable_encryption_keybag()); | 1341 GetCryptographer()->GetKeys(nigori.mutable_encryption_keybag()); |
1342 nigori.set_keybag_is_frozen(true); | 1342 nigori.set_keybag_is_frozen(true); |
1343 nigori.set_keystore_migration_time(1); | 1343 nigori.set_keystore_migration_time(1); |
1344 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE); | 1344 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::CUSTOM_PASSPHRASE); |
1345 nigori.set_encrypt_everything(true); | 1345 nigori.set_encrypt_everything(true); |
1346 nigori_node.SetNigoriSpecifics(nigori); | 1346 nigori_node.SetNigoriSpecifics(nigori); |
1347 } | 1347 } |
1348 | 1348 |
1349 EXPECT_CALL(*observer(), | 1349 EXPECT_CALL(*observer(), |
(...skipping 22 matching lines...) Expand all Loading... |
1372 Mock::VerifyAndClearExpectations(observer()); | 1372 Mock::VerifyAndClearExpectations(observer()); |
1373 | 1373 |
1374 // Now build an old keystore nigori node with old encrypted types. We should | 1374 // Now build an old keystore nigori node with old encrypted types. We should |
1375 // properly overwrite it with the migrated + encrypt everything state. | 1375 // properly overwrite it with the migrated + encrypt everything state. |
1376 EXPECT_CALL(*observer(), | 1376 EXPECT_CALL(*observer(), |
1377 OnCryptographerStateChanged(_)).Times(AnyNumber()); | 1377 OnCryptographerStateChanged(_)).Times(AnyNumber()); |
1378 EXPECT_CALL(*observer(), OnEncryptionComplete()); | 1378 EXPECT_CALL(*observer(), OnEncryptionComplete()); |
1379 { | 1379 { |
1380 WriteTransaction trans(FROM_HERE, user_share()); | 1380 WriteTransaction trans(FROM_HERE, user_share()); |
1381 WriteNode nigori_node(&trans); | 1381 WriteNode nigori_node(&trans); |
1382 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1382 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1383 sync_pb::NigoriSpecifics nigori; | 1383 sync_pb::NigoriSpecifics nigori; |
1384 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); | 1384 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); |
1385 other_cryptographer.AddKey(old_key); | 1385 other_cryptographer.AddKey(old_key); |
1386 encryption_handler()->GetKeystoreDecryptor( | 1386 encryption_handler()->GetKeystoreDecryptor( |
1387 other_cryptographer, | 1387 other_cryptographer, |
1388 kKeystoreKey, | 1388 kKeystoreKey, |
1389 nigori.mutable_keystore_decryptor_token()); | 1389 nigori.mutable_keystore_decryptor_token()); |
1390 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 1390 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
1391 nigori.set_keybag_is_frozen(true); | 1391 nigori.set_keybag_is_frozen(true); |
1392 nigori.set_encrypt_everything(false); | 1392 nigori.set_encrypt_everything(false); |
(...skipping 28 matching lines...) Expand all Loading... |
1421 EXPECT_FALSE(encryption_handler()->MigratedToKeystore()); | 1421 EXPECT_FALSE(encryption_handler()->MigratedToKeystore()); |
1422 EXPECT_FALSE(GetCryptographer()->is_ready()); | 1422 EXPECT_FALSE(GetCryptographer()->is_ready()); |
1423 EXPECT_NE(encryption_handler()->GetPassphraseType(), KEYSTORE_PASSPHRASE); | 1423 EXPECT_NE(encryption_handler()->GetPassphraseType(), KEYSTORE_PASSPHRASE); |
1424 | 1424 |
1425 // Now build a nigori node with the generated keystore decryptor token and | 1425 // Now build a nigori node with the generated keystore decryptor token and |
1426 // initialize the encryption handler with it. The cryptographer should be | 1426 // initialize the encryption handler with it. The cryptographer should be |
1427 // initialized properly to decrypt both kCurKey and kKeystoreKey. | 1427 // initialized properly to decrypt both kCurKey and kKeystoreKey. |
1428 { | 1428 { |
1429 WriteTransaction trans(FROM_HERE, user_share()); | 1429 WriteTransaction trans(FROM_HERE, user_share()); |
1430 WriteNode nigori_node(&trans); | 1430 WriteNode nigori_node(&trans); |
1431 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1431 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1432 sync_pb::NigoriSpecifics nigori; | 1432 sync_pb::NigoriSpecifics nigori; |
1433 nigori.mutable_keystore_decryptor_token()->CopyFrom( | 1433 nigori.mutable_keystore_decryptor_token()->CopyFrom( |
1434 keystore_decryptor_token); | 1434 keystore_decryptor_token); |
1435 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 1435 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
1436 nigori.set_keybag_is_frozen(true); | 1436 nigori.set_keybag_is_frozen(true); |
1437 nigori.set_keystore_migration_time(1); | 1437 nigori.set_keystore_migration_time(1); |
1438 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); | 1438 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); |
1439 | 1439 |
1440 EXPECT_CALL(*observer(), | 1440 EXPECT_CALL(*observer(), |
1441 OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE, _)); | 1441 OnPassphraseTypeChanged(KEYSTORE_PASSPHRASE, _)); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1502 other_cryptographer, | 1502 other_cryptographer, |
1503 kKeystoreKey, | 1503 kKeystoreKey, |
1504 &keystore_decryptor_token)); | 1504 &keystore_decryptor_token)); |
1505 | 1505 |
1506 // Build a nigori node with the generated keystore decryptor token and | 1506 // Build a nigori node with the generated keystore decryptor token and |
1507 // initialize the encryption handler with it. The cryptographer should be | 1507 // initialize the encryption handler with it. The cryptographer should be |
1508 // initialized properly to decrypt both kOldKey and kKeystoreKey. | 1508 // initialized properly to decrypt both kOldKey and kKeystoreKey. |
1509 { | 1509 { |
1510 WriteTransaction trans(FROM_HERE, user_share()); | 1510 WriteTransaction trans(FROM_HERE, user_share()); |
1511 WriteNode nigori_node(&trans); | 1511 WriteNode nigori_node(&trans); |
1512 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1512 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1513 sync_pb::NigoriSpecifics nigori; | 1513 sync_pb::NigoriSpecifics nigori; |
1514 nigori.mutable_keystore_decryptor_token()->CopyFrom( | 1514 nigori.mutable_keystore_decryptor_token()->CopyFrom( |
1515 keystore_decryptor_token); | 1515 keystore_decryptor_token); |
1516 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 1516 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
1517 nigori.set_keybag_is_frozen(true); | 1517 nigori.set_keybag_is_frozen(true); |
1518 nigori.set_keystore_migration_time(1); | 1518 nigori.set_keystore_migration_time(1); |
1519 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); | 1519 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); |
1520 nigori_node.SetNigoriSpecifics(nigori); | 1520 nigori_node.SetNigoriSpecifics(nigori); |
1521 EXPECT_CALL(*observer(), | 1521 EXPECT_CALL(*observer(), |
1522 OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN)); | 1522 OnBootstrapTokenUpdated(_, KEYSTORE_BOOTSTRAP_TOKEN)); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1604 other_cryptographer, | 1604 other_cryptographer, |
1605 kKeystoreKey, | 1605 kKeystoreKey, |
1606 &keystore_decryptor_token)); | 1606 &keystore_decryptor_token)); |
1607 | 1607 |
1608 // Build a nigori node with the generated keystore decryptor token and | 1608 // Build a nigori node with the generated keystore decryptor token and |
1609 // initialize the encryption handler with it. The cryptographer will have | 1609 // initialize the encryption handler with it. The cryptographer will have |
1610 // pending keys until we provide the decryption passphrase. | 1610 // pending keys until we provide the decryption passphrase. |
1611 { | 1611 { |
1612 WriteTransaction trans(FROM_HERE, user_share()); | 1612 WriteTransaction trans(FROM_HERE, user_share()); |
1613 WriteNode nigori_node(&trans); | 1613 WriteNode nigori_node(&trans); |
1614 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1614 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1615 sync_pb::NigoriSpecifics nigori; | 1615 sync_pb::NigoriSpecifics nigori; |
1616 nigori.mutable_keystore_decryptor_token()->CopyFrom( | 1616 nigori.mutable_keystore_decryptor_token()->CopyFrom( |
1617 keystore_decryptor_token); | 1617 keystore_decryptor_token); |
1618 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 1618 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
1619 nigori.set_keybag_is_frozen(true); | 1619 nigori.set_keybag_is_frozen(true); |
1620 nigori.set_keystore_migration_time(1); | 1620 nigori.set_keystore_migration_time(1); |
1621 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); | 1621 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); |
1622 nigori_node.SetNigoriSpecifics(nigori); | 1622 nigori_node.SetNigoriSpecifics(nigori); |
1623 } | 1623 } |
1624 | 1624 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1711 other_cryptographer, | 1711 other_cryptographer, |
1712 kKeystoreKey, | 1712 kKeystoreKey, |
1713 &keystore_decryptor_token)); | 1713 &keystore_decryptor_token)); |
1714 | 1714 |
1715 // Build a nigori node with the generated keystore decryptor token and | 1715 // Build a nigori node with the generated keystore decryptor token and |
1716 // initialize the encryption handler with it. The cryptographer will have | 1716 // initialize the encryption handler with it. The cryptographer will have |
1717 // pending keys until we provide the decryption passphrase. | 1717 // pending keys until we provide the decryption passphrase. |
1718 { | 1718 { |
1719 WriteTransaction trans(FROM_HERE, user_share()); | 1719 WriteTransaction trans(FROM_HERE, user_share()); |
1720 WriteNode nigori_node(&trans); | 1720 WriteNode nigori_node(&trans); |
1721 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1721 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1722 sync_pb::NigoriSpecifics nigori; | 1722 sync_pb::NigoriSpecifics nigori; |
1723 nigori.mutable_keystore_decryptor_token()->CopyFrom( | 1723 nigori.mutable_keystore_decryptor_token()->CopyFrom( |
1724 keystore_decryptor_token); | 1724 keystore_decryptor_token); |
1725 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 1725 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
1726 nigori.set_keybag_is_frozen(true); | 1726 nigori.set_keybag_is_frozen(true); |
1727 nigori.set_keystore_migration_time(1); | 1727 nigori.set_keystore_migration_time(1); |
1728 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); | 1728 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); |
1729 nigori_node.SetNigoriSpecifics(nigori); | 1729 nigori_node.SetNigoriSpecifics(nigori); |
1730 } | 1730 } |
1731 | 1731 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 other_cryptographer, | 1806 other_cryptographer, |
1807 kKeystoreKey, | 1807 kKeystoreKey, |
1808 &keystore_decryptor_token)); | 1808 &keystore_decryptor_token)); |
1809 | 1809 |
1810 // Build a nigori node with the generated keystore decryptor token and | 1810 // Build a nigori node with the generated keystore decryptor token and |
1811 // initialize the encryption handler with it. The cryptographer will have | 1811 // initialize the encryption handler with it. The cryptographer will have |
1812 // pending keys until we provide the decryption passphrase. | 1812 // pending keys until we provide the decryption passphrase. |
1813 { | 1813 { |
1814 WriteTransaction trans(FROM_HERE, user_share()); | 1814 WriteTransaction trans(FROM_HERE, user_share()); |
1815 WriteNode nigori_node(&trans); | 1815 WriteNode nigori_node(&trans); |
1816 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1816 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1817 sync_pb::NigoriSpecifics nigori; | 1817 sync_pb::NigoriSpecifics nigori; |
1818 nigori.mutable_keystore_decryptor_token()->CopyFrom( | 1818 nigori.mutable_keystore_decryptor_token()->CopyFrom( |
1819 keystore_decryptor_token); | 1819 keystore_decryptor_token); |
1820 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 1820 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
1821 nigori.set_keybag_is_frozen(true); | 1821 nigori.set_keybag_is_frozen(true); |
1822 nigori.set_keystore_migration_time(1); | 1822 nigori.set_keystore_migration_time(1); |
1823 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); | 1823 nigori.set_passphrase_type(sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE); |
1824 nigori_node.SetNigoriSpecifics(nigori); | 1824 nigori_node.SetNigoriSpecifics(nigori); |
1825 } | 1825 } |
1826 EXPECT_CALL(*observer(), | 1826 EXPECT_CALL(*observer(), |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1924 EXPECT_EQ(encryption_handler()->GetPassphraseType(), KEYSTORE_PASSPHRASE); | 1924 EXPECT_EQ(encryption_handler()->GetPassphraseType(), KEYSTORE_PASSPHRASE); |
1925 VerifyMigratedNigori(KEYSTORE_PASSPHRASE, kCurKey); | 1925 VerifyMigratedNigori(KEYSTORE_PASSPHRASE, kCurKey); |
1926 | 1926 |
1927 // Now build an old keystore passphrase nigori node. | 1927 // Now build an old keystore passphrase nigori node. |
1928 EXPECT_CALL(*observer(), | 1928 EXPECT_CALL(*observer(), |
1929 OnCryptographerStateChanged(_)).Times(AnyNumber()); | 1929 OnCryptographerStateChanged(_)).Times(AnyNumber()); |
1930 EXPECT_CALL(*observer(), OnEncryptionComplete()); | 1930 EXPECT_CALL(*observer(), OnEncryptionComplete()); |
1931 { | 1931 { |
1932 WriteTransaction trans(FROM_HERE, user_share()); | 1932 WriteTransaction trans(FROM_HERE, user_share()); |
1933 WriteNode nigori_node(&trans); | 1933 WriteNode nigori_node(&trans); |
1934 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1934 ASSERT_EQ(nigori_node.InitTypeRoot(NIGORI), BaseNode::INIT_OK); |
1935 sync_pb::NigoriSpecifics nigori; | 1935 sync_pb::NigoriSpecifics nigori; |
1936 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); | 1936 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); |
1937 other_cryptographer.AddKey(old_key); | 1937 other_cryptographer.AddKey(old_key); |
1938 encryption_handler()->GetKeystoreDecryptor( | 1938 encryption_handler()->GetKeystoreDecryptor( |
1939 other_cryptographer, | 1939 other_cryptographer, |
1940 kKeystoreKey, | 1940 kKeystoreKey, |
1941 nigori.mutable_keystore_decryptor_token()); | 1941 nigori.mutable_keystore_decryptor_token()); |
1942 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); | 1942 other_cryptographer.GetKeys(nigori.mutable_encryption_keybag()); |
1943 nigori.set_keybag_is_frozen(true); | 1943 nigori.set_keybag_is_frozen(true); |
1944 nigori.set_encrypt_everything(false); | 1944 nigori.set_encrypt_everything(false); |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2273 encryption_handler()->SetKeystoreKeys(keys, | 2273 encryption_handler()->SetKeystoreKeys(keys, |
2274 trans.GetWrappedTrans()); | 2274 trans.GetWrappedTrans()); |
2275 } | 2275 } |
2276 PumpLoop(); | 2276 PumpLoop(); |
2277 Mock::VerifyAndClearExpectations(observer()); | 2277 Mock::VerifyAndClearExpectations(observer()); |
2278 | 2278 |
2279 VerifyMigratedNigoriWithTimestamp(1, CUSTOM_PASSPHRASE, kCustomPass); | 2279 VerifyMigratedNigoriWithTimestamp(1, CUSTOM_PASSPHRASE, kCustomPass); |
2280 } | 2280 } |
2281 | 2281 |
2282 } // namespace syncer | 2282 } // namespace syncer |
OLD | NEW |