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 1293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1304 | 1304 |
1305 // Test that if we have a migrated nigori with a custom passphrase, then receive | 1305 // Test that if we have a migrated nigori with a custom passphrase, then receive |
1306 // a migrated nigori with a keystore passphrase, we properly overwrite it with | 1306 // a migrated nigori with a keystore passphrase, we properly overwrite it with |
1307 // the current state. | 1307 // the current state. |
1308 TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldMigratedNigori) { | 1308 TEST_F(SyncEncryptionHandlerImplTest, ReceiveOldMigratedNigori) { |
1309 const char kOldKey[] = "old"; | 1309 const char kOldKey[] = "old"; |
1310 const char kCurKey[] = "cur"; | 1310 const char kCurKey[] = "cur"; |
1311 sync_pb::EncryptedData encrypted; | 1311 sync_pb::EncryptedData encrypted; |
1312 KeyParams old_key = {"localhost", "dummy", kOldKey}; | 1312 KeyParams old_key = {"localhost", "dummy", kOldKey}; |
1313 KeyParams cur_key = {"localhost", "dummy", kCurKey}; | 1313 KeyParams cur_key = {"localhost", "dummy", kCurKey}; |
1314 KeyParams keystore_key = {"localhost", "dummy", kKeystoreKey}; | |
1315 GetCryptographer()->AddKey(old_key); | 1314 GetCryptographer()->AddKey(old_key); |
1316 GetCryptographer()->AddKey(cur_key); | 1315 GetCryptographer()->AddKey(cur_key); |
1317 | 1316 |
1318 // Build a migrated nigori with full encryption. | 1317 // Build a migrated nigori with full encryption. |
1319 { | 1318 { |
1320 WriteTransaction trans(FROM_HERE, user_share()); | 1319 WriteTransaction trans(FROM_HERE, user_share()); |
1321 WriteNode nigori_node(&trans); | 1320 WriteNode nigori_node(&trans); |
1322 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); | 1321 ASSERT_EQ(nigori_node.InitByTagLookup(kNigoriTag), BaseNode::INIT_OK); |
1323 sync_pb::NigoriSpecifics nigori; | 1322 sync_pb::NigoriSpecifics nigori; |
1324 GetCryptographer()->GetKeys(nigori.mutable_encryption_keybag()); | 1323 GetCryptographer()->GetKeys(nigori.mutable_encryption_keybag()); |
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1867 // If we receive a nigori migrated and with a KEYSTORE_PASSPHRASE type, but | 1866 // If we receive a nigori migrated and with a KEYSTORE_PASSPHRASE type, but |
1868 // using an old default key (i.e. old GAIA password), we should overwrite the | 1867 // using an old default key (i.e. old GAIA password), we should overwrite the |
1869 // nigori, updating the keybag and keystore decryptor. | 1868 // nigori, updating the keybag and keystore decryptor. |
1870 TEST_F(SyncEncryptionHandlerImplTest, | 1869 TEST_F(SyncEncryptionHandlerImplTest, |
1871 ReceiveMigratedNigoriWithOldPassphrase) { | 1870 ReceiveMigratedNigoriWithOldPassphrase) { |
1872 const char kOldKey[] = "old"; | 1871 const char kOldKey[] = "old"; |
1873 const char kCurKey[] = "cur"; | 1872 const char kCurKey[] = "cur"; |
1874 sync_pb::EncryptedData encrypted; | 1873 sync_pb::EncryptedData encrypted; |
1875 KeyParams old_key = {"localhost", "dummy", kOldKey}; | 1874 KeyParams old_key = {"localhost", "dummy", kOldKey}; |
1876 KeyParams cur_key = {"localhost", "dummy", kCurKey}; | 1875 KeyParams cur_key = {"localhost", "dummy", kCurKey}; |
1877 KeyParams keystore_key = {"localhost", "dummy", kKeystoreKey}; | |
1878 GetCryptographer()->AddKey(old_key); | 1876 GetCryptographer()->AddKey(old_key); |
1879 GetCryptographer()->AddKey(cur_key); | 1877 GetCryptographer()->AddKey(cur_key); |
1880 | 1878 |
1881 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); | 1879 Cryptographer other_cryptographer(GetCryptographer()->encryptor()); |
1882 other_cryptographer.AddKey(old_key); | 1880 other_cryptographer.AddKey(old_key); |
1883 EXPECT_TRUE(other_cryptographer.is_ready()); | 1881 EXPECT_TRUE(other_cryptographer.is_ready()); |
1884 | 1882 |
1885 EXPECT_CALL(*observer(), | 1883 EXPECT_CALL(*observer(), |
1886 OnCryptographerStateChanged(_)).Times(AnyNumber()); | 1884 OnCryptographerStateChanged(_)).Times(AnyNumber()); |
1887 EXPECT_CALL(*observer(), | 1885 EXPECT_CALL(*observer(), |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2243 encryption_handler()->SetKeystoreKeys(keys, | 2241 encryption_handler()->SetKeystoreKeys(keys, |
2244 trans.GetWrappedTrans()); | 2242 trans.GetWrappedTrans()); |
2245 } | 2243 } |
2246 PumpLoop(); | 2244 PumpLoop(); |
2247 Mock::VerifyAndClearExpectations(observer()); | 2245 Mock::VerifyAndClearExpectations(observer()); |
2248 | 2246 |
2249 VerifyMigratedNigoriWithTimestamp(1, CUSTOM_PASSPHRASE, kCustomPass); | 2247 VerifyMigratedNigoriWithTimestamp(1, CUSTOM_PASSPHRASE, kCustomPass); |
2250 } | 2248 } |
2251 | 2249 |
2252 } // namespace syncer | 2250 } // namespace syncer |
OLD | NEW |