| OLD | NEW |
| 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/test/fake_sync_encryption_handler.h" | 5 #include "sync/test/fake_sync_encryption_handler.h" |
| 6 | 6 |
| 7 #include "sync/protocol/nigori_specifics.pb.h" | 7 #include "sync/protocol/nigori_specifics.pb.h" |
| 8 #include "sync/syncable/nigori_util.h" | 8 #include "sync/syncable/nigori_util.h" |
| 9 | 9 |
| 10 namespace syncer { | 10 namespace syncer { |
| 11 | 11 |
| 12 FakeSyncEncryptionHandler::FakeSyncEncryptionHandler() | 12 FakeSyncEncryptionHandler::FakeSyncEncryptionHandler() |
| 13 : encrypted_types_(SensitiveTypes()), | 13 : encrypted_types_(SensitiveTypes()), |
| 14 encrypt_everything_(false), | 14 encrypt_everything_(false), |
| 15 passphrase_state_(IMPLICIT_PASSPHRASE), | 15 passphrase_state_(IMPLICIT_PASSPHRASE), |
| 16 cryptographer_(&encryptor_) { | 16 cryptographer_(&encryptor_) { |
| 17 } | 17 } |
| 18 FakeSyncEncryptionHandler::~FakeSyncEncryptionHandler() {} | 18 FakeSyncEncryptionHandler::~FakeSyncEncryptionHandler() {} |
| 19 | 19 |
| 20 void FakeSyncEncryptionHandler::Init() { | 20 void FakeSyncEncryptionHandler::Init() { |
| 21 // Do nothing. | 21 // Do nothing. |
| 22 } | 22 } |
| 23 | 23 |
| 24 void FakeSyncEncryptionHandler::ApplyNigoriUpdate( | 24 void FakeSyncEncryptionHandler::ApplyNigoriUpdate( |
| 25 const sync_pb::NigoriSpecifics& nigori, | 25 const sync_pb::NigoriSpecifics& nigori, |
| 26 syncable::BaseTransaction* const trans) { | 26 syncable::BaseTransaction* const trans) { |
| 27 if (nigori.encrypt_everything()) | 27 if (nigori.encrypt_everything()) |
| 28 EnableEncryptEverything(); | 28 EnableEncryptEverything(); |
| 29 if (nigori.using_explicit_passphrase()) | 29 if (nigori.frozen_keybag()) |
| 30 passphrase_state_ = CUSTOM_PASSPHRASE; | 30 passphrase_state_ = CUSTOM_PASSPHRASE; |
| 31 | 31 |
| 32 if (cryptographer_.CanDecrypt(nigori.encrypted())) | 32 // TODO(zea): consider adding fake support for migration. |
| 33 cryptographer_.InstallKeys(nigori.encrypted()); | 33 if (cryptographer_.CanDecrypt(nigori.encryption_keybag())) |
| 34 else if (nigori.has_encrypted()) | 34 cryptographer_.InstallKeys(nigori.encryption_keybag()); |
| 35 cryptographer_.SetPendingKeys(nigori.encrypted()); | 35 else if (nigori.has_encryption_keybag()) |
| 36 cryptographer_.SetPendingKeys(nigori.encryption_keybag()); |
| 36 | 37 |
| 37 if (cryptographer_.has_pending_keys()) { | 38 if (cryptographer_.has_pending_keys()) { |
| 38 DVLOG(1) << "OnPassPhraseRequired Sent"; | 39 DVLOG(1) << "OnPassPhraseRequired Sent"; |
| 39 sync_pb::EncryptedData pending_keys = cryptographer_.GetPendingKeys(); | 40 sync_pb::EncryptedData pending_keys = cryptographer_.GetPendingKeys(); |
| 40 FOR_EACH_OBSERVER(SyncEncryptionHandler::Observer, observers_, | 41 FOR_EACH_OBSERVER(SyncEncryptionHandler::Observer, observers_, |
| 41 OnPassphraseRequired(REASON_DECRYPTION, | 42 OnPassphraseRequired(REASON_DECRYPTION, |
| 42 pending_keys)); | 43 pending_keys)); |
| 43 } else if (!cryptographer_.is_ready()) { | 44 } else if (!cryptographer_.is_ready()) { |
| 44 DVLOG(1) << "OnPassphraseRequired sent because cryptographer is not " | 45 DVLOG(1) << "OnPassphraseRequired sent because cryptographer is not " |
| 45 << "ready"; | 46 << "ready"; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 | 114 |
| 114 bool FakeSyncEncryptionHandler::EncryptEverythingEnabled() const { | 115 bool FakeSyncEncryptionHandler::EncryptEverythingEnabled() const { |
| 115 return encrypt_everything_; | 116 return encrypt_everything_; |
| 116 } | 117 } |
| 117 | 118 |
| 118 PassphraseState FakeSyncEncryptionHandler::GetPassphraseState() const { | 119 PassphraseState FakeSyncEncryptionHandler::GetPassphraseState() const { |
| 119 return passphrase_state_; | 120 return passphrase_state_; |
| 120 } | 121 } |
| 121 | 122 |
| 122 } // namespace syncer | 123 } // namespace syncer |
| OLD | NEW |