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

Side by Side Diff: sync/util/cryptographer.h

Issue 10696087: [Sync] Move ModelType and related classes to 'syncer' namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sort headers, update copyrights Created 8 years, 5 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
« no previous file with comments | « sync/tools/sync_listen_notifications.cc ('k') | sync/util/cryptographer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_UTIL_CRYPTOGRAPHER_H_ 5 #ifndef SYNC_UTIL_CRYPTOGRAPHER_H_
6 #define SYNC_UTIL_CRYPTOGRAPHER_H_ 6 #define SYNC_UTIL_CRYPTOGRAPHER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 // types. 58 // types.
59 // 59 //
60 // |encrypted_types| will always be a superset of 60 // |encrypted_types| will always be a superset of
61 // SensitiveTypes(). If |encrypt_everything| is true, 61 // SensitiveTypes(). If |encrypt_everything| is true,
62 // |encrypted_types| will be the set of all known types. 62 // |encrypted_types| will be the set of all known types.
63 // 63 //
64 // Until this function is called, observers can assume that the 64 // Until this function is called, observers can assume that the
65 // set of encrypted types is SensitiveTypes() and that the encrypt 65 // set of encrypted types is SensitiveTypes() and that the encrypt
66 // everything flag is false. 66 // everything flag is false.
67 virtual void OnEncryptedTypesChanged( 67 virtual void OnEncryptedTypesChanged(
68 syncable::ModelTypeSet encrypted_types, 68 syncer::ModelTypeSet encrypted_types,
69 bool encrypt_everything) = 0; 69 bool encrypt_everything) = 0;
70 70
71 protected: 71 protected:
72 virtual ~Observer(); 72 virtual ~Observer();
73 }; 73 };
74 74
75 // Does not take ownership of |encryptor|. 75 // Does not take ownership of |encryptor|.
76 explicit Cryptographer(Encryptor* encryptor); 76 explicit Cryptographer(Encryptor* encryptor);
77 ~Cryptographer(); 77 ~Cryptographer();
78 78
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // This updates both the encryption keys and the set of encrypted types. 174 // This updates both the encryption keys and the set of encrypted types.
175 // Returns NEEDS_PASSPHRASE if was unable to decrypt the pending keys, 175 // Returns NEEDS_PASSPHRASE if was unable to decrypt the pending keys,
176 // SUCCESS otherwise. 176 // SUCCESS otherwise.
177 // Note: will not change the default key. If the nigori's keybag 177 // Note: will not change the default key. If the nigori's keybag
178 // is decryptable, all keys are added to the local keybag and the current 178 // is decryptable, all keys are added to the local keybag and the current
179 // default is preserved. If the nigori's keybag is not decryptable, it is 179 // default is preserved. If the nigori's keybag is not decryptable, it is
180 // stored in the |pending_keys_|. 180 // stored in the |pending_keys_|.
181 UpdateResult Update(const sync_pb::NigoriSpecifics& nigori); 181 UpdateResult Update(const sync_pb::NigoriSpecifics& nigori);
182 182
183 // The set of types that are always encrypted. 183 // The set of types that are always encrypted.
184 static syncable::ModelTypeSet SensitiveTypes(); 184 static syncer::ModelTypeSet SensitiveTypes();
185 185
186 // Reset our set of encrypted types based on the contents of the nigori 186 // Reset our set of encrypted types based on the contents of the nigori
187 // specifics. 187 // specifics.
188 void UpdateEncryptedTypesFromNigori(const sync_pb::NigoriSpecifics& nigori); 188 void UpdateEncryptedTypesFromNigori(const sync_pb::NigoriSpecifics& nigori);
189 189
190 // Update the nigori to reflect the current set of encrypted types. 190 // Update the nigori to reflect the current set of encrypted types.
191 void UpdateNigoriFromEncryptedTypes(sync_pb::NigoriSpecifics* nigori) const; 191 void UpdateNigoriFromEncryptedTypes(sync_pb::NigoriSpecifics* nigori) const;
192 192
193 // Setter/getter for whether all current and future datatypes should 193 // Setter/getter for whether all current and future datatypes should
194 // be encrypted. Once set you cannot unset without reading from a 194 // be encrypted. Once set you cannot unset without reading from a
195 // new nigori node. set_encrypt_everything() emits a notification 195 // new nigori node. set_encrypt_everything() emits a notification
196 // the first time it's called. 196 // the first time it's called.
197 void set_encrypt_everything(); 197 void set_encrypt_everything();
198 bool encrypt_everything() const; 198 bool encrypt_everything() const;
199 199
200 // Return the set of encrypted types. 200 // Return the set of encrypted types.
201 syncable::ModelTypeSet GetEncryptedTypes() const; 201 syncer::ModelTypeSet GetEncryptedTypes() const;
202 202
203 // Forwards to MergeEncryptedTypes. 203 // Forwards to MergeEncryptedTypes.
204 void MergeEncryptedTypesForTest( 204 void MergeEncryptedTypesForTest(syncer::ModelTypeSet encrypted_types);
205 syncable::ModelTypeSet encrypted_types);
206 205
207 private: 206 private:
208 FRIEND_TEST_ALL_PREFIXES(SyncCryptographerTest, PackUnpack); 207 FRIEND_TEST_ALL_PREFIXES(SyncCryptographerTest, PackUnpack);
209 typedef std::map<std::string, linked_ptr<const Nigori> > NigoriMap; 208 typedef std::map<std::string, linked_ptr<const Nigori> > NigoriMap;
210 209
211 // Merges the given set of encrypted types with the existing set and emits a 210 // Merges the given set of encrypted types with the existing set and emits a
212 // notification if necessary. 211 // notification if necessary.
213 void MergeEncryptedTypes(syncable::ModelTypeSet encrypted_types); 212 void MergeEncryptedTypes(syncer::ModelTypeSet encrypted_types);
214 213
215 void EmitEncryptedTypesChangedNotification(); 214 void EmitEncryptedTypesChangedNotification();
216 215
217 // Decrypts |encrypted| and uses its contents to initialize Nigori instances. 216 // Decrypts |encrypted| and uses its contents to initialize Nigori instances.
218 // Returns true unless decryption of |encrypted| fails. The caller is 217 // Returns true unless decryption of |encrypted| fails. The caller is
219 // responsible for checking that CanDecrypt(encrypted) == true. 218 // responsible for checking that CanDecrypt(encrypted) == true.
220 // Does not update the default nigori. 219 // Does not update the default nigori.
221 void InstallKeys(const sync_pb::EncryptedData& encrypted); 220 void InstallKeys(const sync_pb::EncryptedData& encrypted);
222 221
223 // Helper method to instantiate Nigori instances for each set of key 222 // Helper method to instantiate Nigori instances for each set of key
(...skipping 11 matching lines...) Expand all
235 234
236 Encryptor* const encryptor_; 235 Encryptor* const encryptor_;
237 236
238 ObserverList<Observer> observers_; 237 ObserverList<Observer> observers_;
239 238
240 NigoriMap nigoris_; // The Nigoris we know about, mapped by key name. 239 NigoriMap nigoris_; // The Nigoris we know about, mapped by key name.
241 NigoriMap::value_type* default_nigori_; // The Nigori used for encryption. 240 NigoriMap::value_type* default_nigori_; // The Nigori used for encryption.
242 241
243 scoped_ptr<sync_pb::EncryptedData> pending_keys_; 242 scoped_ptr<sync_pb::EncryptedData> pending_keys_;
244 243
245 syncable::ModelTypeSet encrypted_types_; 244 syncer::ModelTypeSet encrypted_types_;
246 bool encrypt_everything_; 245 bool encrypt_everything_;
247 246
248 DISALLOW_COPY_AND_ASSIGN(Cryptographer); 247 DISALLOW_COPY_AND_ASSIGN(Cryptographer);
249 }; 248 };
250 249
251 } // namespace syncer 250 } // namespace syncer
252 251
253 #endif // SYNC_UTIL_CRYPTOGRAPHER_H_ 252 #endif // SYNC_UTIL_CRYPTOGRAPHER_H_
OLDNEW
« no previous file with comments | « sync/tools/sync_listen_notifications.cc ('k') | sync/util/cryptographer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698