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

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

Issue 10878015: [Sync] Move keystore key handling to SyncEncryptionHandlerImpl (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 #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 26 matching lines...) Expand all
37 // 37 //
38 // Note: See sync_encryption_handler.h for a description of the chrome visible 38 // Note: See sync_encryption_handler.h for a description of the chrome visible
39 // methods and what they do, and nigori_handler.h for a description of the 39 // methods and what they do, and nigori_handler.h for a description of the
40 // sync methods. 40 // sync methods.
41 // All methods are non-thread-safe and should only be called from the sync 41 // All methods are non-thread-safe and should only be called from the sync
42 // thread unless explicitly noted otherwise. 42 // thread unless explicitly noted otherwise.
43 class SyncEncryptionHandlerImpl 43 class SyncEncryptionHandlerImpl
44 : public SyncEncryptionHandler, 44 : public SyncEncryptionHandler,
45 public syncable::NigoriHandler { 45 public syncable::NigoriHandler {
46 public: 46 public:
47 SyncEncryptionHandlerImpl(UserShare* user_share, 47 SyncEncryptionHandlerImpl(
48 Encryptor* encryptor); 48 UserShare* user_share,
49 Encryptor* encryptor,
50 const std::string& restored_key_for_bootstrapping,
51 const std::string& restored_keystore_key_for_bootstrapping);
49 virtual ~SyncEncryptionHandlerImpl(); 52 virtual ~SyncEncryptionHandlerImpl();
50 53
51 // SyncEncryptionHandler implementation. 54 // SyncEncryptionHandler implementation.
52 virtual void AddObserver(Observer* observer) OVERRIDE; 55 virtual void AddObserver(Observer* observer) OVERRIDE;
53 virtual void RemoveObserver(Observer* observer) OVERRIDE; 56 virtual void RemoveObserver(Observer* observer) OVERRIDE;
54 virtual void Init() OVERRIDE; 57 virtual void Init() OVERRIDE;
55 virtual void SetEncryptionPassphrase(const std::string& passphrase, 58 virtual void SetEncryptionPassphrase(const std::string& passphrase,
56 bool is_explicit) OVERRIDE; 59 bool is_explicit) OVERRIDE;
57 virtual void SetDecryptionPassphrase(const std::string& passphrase) OVERRIDE; 60 virtual void SetDecryptionPassphrase(const std::string& passphrase) OVERRIDE;
58 virtual void EnableEncryptEverything() OVERRIDE; 61 virtual void EnableEncryptEverything() OVERRIDE;
59 virtual bool EncryptEverythingEnabled() const OVERRIDE; 62 virtual bool EncryptEverythingEnabled() const OVERRIDE;
60 virtual PassphraseState GetPassphraseState() const OVERRIDE; 63 virtual PassphraseState GetPassphraseState() const OVERRIDE;
61 64
62 // NigoriHandler implementation. 65 // NigoriHandler implementation.
63 // Note: all methods are invoked while the caller holds a transaction. 66 // Note: all methods are invoked while the caller holds a transaction.
64 virtual void ApplyNigoriUpdate( 67 virtual void ApplyNigoriUpdate(
65 const sync_pb::NigoriSpecifics& nigori, 68 const sync_pb::NigoriSpecifics& nigori,
66 syncable::BaseTransaction* const trans) OVERRIDE; 69 syncable::BaseTransaction* const trans) OVERRIDE;
67 virtual void UpdateNigoriFromEncryptedTypes( 70 virtual void UpdateNigoriFromEncryptedTypes(
68 sync_pb::NigoriSpecifics* nigori, 71 sync_pb::NigoriSpecifics* nigori,
69 syncable::BaseTransaction* const trans) const OVERRIDE; 72 syncable::BaseTransaction* const trans) const OVERRIDE;
73 virtual bool NeedKeystoreKey(
74 syncable::BaseTransaction* const trans) const OVERRIDE;
75 virtual bool SetKeystoreKey(
76 const std::string& key,
77 syncable::BaseTransaction* const trans) OVERRIDE;
70 // Can be called from any thread. 78 // Can be called from any thread.
71 virtual ModelTypeSet GetEncryptedTypes( 79 virtual ModelTypeSet GetEncryptedTypes(
72 syncable::BaseTransaction* const trans) const OVERRIDE; 80 syncable::BaseTransaction* const trans) const OVERRIDE;
73 81
74 // 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
75 // of other threads calling this. 83 // of other threads calling this.
76 Cryptographer* GetCryptographerUnsafe(); 84 Cryptographer* GetCryptographerUnsafe();
77 ModelTypeSet GetEncryptedTypesUnsafe(); 85 ModelTypeSet GetEncryptedTypesUnsafe();
78 86
79 private: 87 private:
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 Vault vault_unsafe_; 183 Vault vault_unsafe_;
176 184
177 // Sync encryption state that is only modified and accessed from the sync 185 // Sync encryption state that is only modified and accessed from the sync
178 // thread. 186 // thread.
179 // Whether all current and future types should be encrypted. 187 // Whether all current and future types should be encrypted.
180 bool encrypt_everything_; 188 bool encrypt_everything_;
181 // The current state of the passphrase required to decrypt the encryption 189 // The current state of the passphrase required to decrypt the encryption
182 // keys stored in the nigori node. 190 // keys stored in the nigori node.
183 PassphraseState passphrase_state_; 191 PassphraseState passphrase_state_;
184 192
193 // The keystore key provided by the server.
194 std::string keystore_key_;
195
185 // The number of times we've automatically (i.e. not via SetPassphrase or 196 // The number of times we've automatically (i.e. not via SetPassphrase or
186 // conflict resolver) updated the nigori's encryption keys in this chrome 197 // conflict resolver) updated the nigori's encryption keys in this chrome
187 // instantiation. 198 // instantiation.
188 int nigori_overwrite_count_; 199 int nigori_overwrite_count_;
189 200
190 DISALLOW_COPY_AND_ASSIGN(SyncEncryptionHandlerImpl); 201 DISALLOW_COPY_AND_ASSIGN(SyncEncryptionHandlerImpl);
191 }; 202 };
192 203
193 } // namespace syncer 204 } // namespace syncer
194 205
195 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_ENCRYPTION_HANDLER_IMPL_H_ 206 #endif // SYNC_INTERNAL_API_PUBLIC_SYNC_ENCRYPTION_HANDLER_IMPL_H_
OLDNEW
« no previous file with comments | « sync/internal_api/public/util/sync_string_conversions.cc ('k') | sync/internal_api/sync_encryption_handler_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698