| 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 #ifndef SYNC_INTERNAL_API_SYNC_ENCRYPTION_HANDLER_IMPL_H_ | 5 #ifndef SYNC_INTERNAL_API_SYNC_ENCRYPTION_HANDLER_IMPL_H_ |
| 6 #define SYNC_INTERNAL_API_SYNC_ENCRYPTION_HANDLER_IMPL_H_ | 6 #define SYNC_INTERNAL_API_SYNC_ENCRYPTION_HANDLER_IMPL_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 | 81 |
| 82 // Unsafe getters. Use only if sync is not up and running and there is no risk | 82 // Unsafe getters. Use only if sync is not up and running and there is no risk |
| 83 // of other threads calling this. | 83 // of other threads calling this. |
| 84 Cryptographer* GetCryptographerUnsafe(); | 84 Cryptographer* GetCryptographerUnsafe(); |
| 85 ModelTypeSet GetEncryptedTypesUnsafe(); | 85 ModelTypeSet GetEncryptedTypesUnsafe(); |
| 86 | 86 |
| 87 bool MigratedToKeystore(); | 87 bool MigratedToKeystore(); |
| 88 base::Time migration_time() const; | 88 base::Time migration_time() const; |
| 89 base::Time custom_passphrase_time() const; | 89 base::Time custom_passphrase_time() const; |
| 90 | 90 |
| 91 // Restore a saved nigori obtained from OnLocalSetCustomPassphrase. |
| 92 // |
| 93 // Writes the nigori to the Directory and updates the Cryptographer. |
| 94 void RestoreNigori(const SyncEncryptionHandler::NigoriState& nigori_state); |
| 95 |
| 91 private: | 96 private: |
| 92 friend class SyncEncryptionHandlerImplTest; | 97 friend class SyncEncryptionHandlerImplTest; |
| 93 FRIEND_TEST_ALL_PREFIXES(SyncEncryptionHandlerImplTest, | 98 FRIEND_TEST_ALL_PREFIXES(SyncEncryptionHandlerImplTest, |
| 94 NigoriEncryptionTypes); | 99 NigoriEncryptionTypes); |
| 95 FRIEND_TEST_ALL_PREFIXES(SyncEncryptionHandlerImplTest, | 100 FRIEND_TEST_ALL_PREFIXES(SyncEncryptionHandlerImplTest, |
| 96 EncryptEverythingExplicit); | 101 EncryptEverythingExplicit); |
| 97 FRIEND_TEST_ALL_PREFIXES(SyncEncryptionHandlerImplTest, | 102 FRIEND_TEST_ALL_PREFIXES(SyncEncryptionHandlerImplTest, |
| 98 EncryptEverythingImplicit); | 103 EncryptEverythingImplicit); |
| 99 FRIEND_TEST_ALL_PREFIXES(SyncEncryptionHandlerImplTest, | 104 FRIEND_TEST_ALL_PREFIXES(SyncEncryptionHandlerImplTest, |
| 100 UnknownSensitiveTypes); | 105 UnknownSensitiveTypes); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // The set of types that require encryption. | 137 // The set of types that require encryption. |
| 133 ModelTypeSet encrypted_types; | 138 ModelTypeSet encrypted_types; |
| 134 | 139 |
| 135 private: | 140 private: |
| 136 DISALLOW_COPY_AND_ASSIGN(Vault); | 141 DISALLOW_COPY_AND_ASSIGN(Vault); |
| 137 }; | 142 }; |
| 138 | 143 |
| 139 // Iterate over all encrypted types ensuring each entry is properly encrypted. | 144 // Iterate over all encrypted types ensuring each entry is properly encrypted. |
| 140 void ReEncryptEverything(WriteTransaction* trans); | 145 void ReEncryptEverything(WriteTransaction* trans); |
| 141 | 146 |
| 142 // Apply a nigori update. Updates internal and cryptographer state. | 147 // Updates internal and cryptographer state. |
| 148 // |
| 149 // Assumes |nigori| is already present in the Sync Directory. |
| 150 // |
| 143 // Returns true on success, false if |nigori| was incompatible, and the | 151 // Returns true on success, false if |nigori| was incompatible, and the |
| 144 // nigori node must be corrected. | 152 // nigori node must be corrected. |
| 145 // Note: must be called from within a transaction. | 153 // Note: must be called from within a transaction. |
| 146 bool ApplyNigoriUpdateImpl(const sync_pb::NigoriSpecifics& nigori, | 154 bool ApplyNigoriUpdateImpl(const sync_pb::NigoriSpecifics& nigori, |
| 147 syncable::BaseTransaction* const trans); | 155 syncable::BaseTransaction* const trans); |
| 148 | 156 |
| 149 // Wrapper around WriteEncryptionStateToNigori that creates a new write | 157 // Wrapper around WriteEncryptionStateToNigori that creates a new write |
| 150 // transaction. | 158 // transaction. |
| 151 void RewriteNigori(); | 159 void RewriteNigori(); |
| 152 | 160 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 Cryptographer* cryptographer); | 262 Cryptographer* cryptographer); |
| 255 | 263 |
| 256 // Helper to enable encrypt everything, notifying observers if necessary. | 264 // Helper to enable encrypt everything, notifying observers if necessary. |
| 257 // Will not perform re-encryption. | 265 // Will not perform re-encryption. |
| 258 void EnableEncryptEverythingImpl(syncable::BaseTransaction* const trans); | 266 void EnableEncryptEverythingImpl(syncable::BaseTransaction* const trans); |
| 259 | 267 |
| 260 // If an explicit passphrase is in use, returns the time at which it was set | 268 // If an explicit passphrase is in use, returns the time at which it was set |
| 261 // (if known). Else return base::Time(). | 269 // (if known). Else return base::Time(). |
| 262 base::Time GetExplicitPassphraseTime() const; | 270 base::Time GetExplicitPassphraseTime() const; |
| 263 | 271 |
| 272 // Notify observers when a custom passphrase is set by this device. |
| 273 void NotifyObserversOfLocalCustomPassphrase(WriteTransaction* trans); |
| 274 |
| 264 base::ThreadChecker thread_checker_; | 275 base::ThreadChecker thread_checker_; |
| 265 | 276 |
| 266 base::ObserverList<SyncEncryptionHandler::Observer> observers_; | 277 base::ObserverList<SyncEncryptionHandler::Observer> observers_; |
| 267 | 278 |
| 268 // The current user share (for creating transactions). | 279 // The current user share (for creating transactions). |
| 269 UserShare* user_share_; | 280 UserShare* user_share_; |
| 270 | 281 |
| 271 // Container for all data that can be accessed from multiple threads. Do not | 282 // Container for all data that can be accessed from multiple threads. Do not |
| 272 // access this object directly. Instead access it via UnlockVault(..) and | 283 // access this object directly. Instead access it via UnlockVault(..) and |
| 273 // UnlockVaultMutable(..). | 284 // UnlockVaultMutable(..). |
| (...skipping 30 matching lines...) Expand all Loading... |
| 304 base::Time custom_passphrase_time_; | 315 base::Time custom_passphrase_time_; |
| 305 | 316 |
| 306 base::WeakPtrFactory<SyncEncryptionHandlerImpl> weak_ptr_factory_; | 317 base::WeakPtrFactory<SyncEncryptionHandlerImpl> weak_ptr_factory_; |
| 307 | 318 |
| 308 DISALLOW_COPY_AND_ASSIGN(SyncEncryptionHandlerImpl); | 319 DISALLOW_COPY_AND_ASSIGN(SyncEncryptionHandlerImpl); |
| 309 }; | 320 }; |
| 310 | 321 |
| 311 } // namespace syncer | 322 } // namespace syncer |
| 312 | 323 |
| 313 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_ENCRYPTION_HANDLER_IMPL_H_ | 324 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_ENCRYPTION_HANDLER_IMPL_H_ |
| OLD | NEW |