| 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_UTIL_CRYPTOGRAPHER_H_ | 5 #ifndef SYNC_UTIL_CRYPTOGRAPHER_H_ |
| 6 #define SYNC_UTIL_CRYPTOGRAPHER_H_ | 6 #define SYNC_UTIL_CRYPTOGRAPHER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // Will decrypt the pending keys and install them if possible (pending key | 110 // Will decrypt the pending keys and install them if possible (pending key |
| 111 // will not overwrite default). | 111 // will not overwrite default). |
| 112 bool AddKey(const KeyParams& params); | 112 bool AddKey(const KeyParams& params); |
| 113 | 113 |
| 114 // Same as AddKey(..), but builds the new Nigori from a previously persisted | 114 // Same as AddKey(..), but builds the new Nigori from a previously persisted |
| 115 // bootstrap token. This can be useful when consuming a bootstrap token | 115 // bootstrap token. This can be useful when consuming a bootstrap token |
| 116 // with a cryptographer that has already been initialized. | 116 // with a cryptographer that has already been initialized. |
| 117 // Updates the default key. | 117 // Updates the default key. |
| 118 // Will decrypt the pending keys and install them if possible (pending key | 118 // Will decrypt the pending keys and install them if possible (pending key |
| 119 // will not overwrite default). | 119 // will not overwrite default). |
| 120 bool AddKeyFromBootstrapToken(const std::string restored_bootstrap_token); | 120 bool AddKeyFromBootstrapToken(const std::string& restored_bootstrap_token); |
| 121 | 121 |
| 122 // Creates a new Nigori instance using |params|. If successful, |params| | 122 // Creates a new Nigori instance using |params|. If successful, |params| |
| 123 // will be added to the nigori keybag, but will not be the default encryption | 123 // will be added to the nigori keybag, but will not be the default encryption |
| 124 // key (default_nigori_ will remain the same). | 124 // key (default_nigori_ will remain the same). |
| 125 // Prereq: is_initialized() must be true. | 125 // Prereq: is_initialized() must be true. |
| 126 // Will decrypt the pending keys and install them if possible (pending key | 126 // Will decrypt the pending keys and install them if possible (pending key |
| 127 // will become the new default). | 127 // will become the new default). |
| 128 bool AddNonDefaultKey(const KeyParams& params); | 128 bool AddNonDefaultKey(const KeyParams& params); |
| 129 | 129 |
| 130 // Decrypts |encrypted| and uses its contents to initialize Nigori instances. | 130 // Decrypts |encrypted| and uses its contents to initialize Nigori instances. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 | 179 |
| 180 // Returns the name of the Nigori key currently used for encryption. | 180 // Returns the name of the Nigori key currently used for encryption. |
| 181 std::string GetDefaultNigoriKeyName() const; | 181 std::string GetDefaultNigoriKeyName() const; |
| 182 | 182 |
| 183 // Returns a serialized sync_pb::NigoriKey version of current default | 183 // Returns a serialized sync_pb::NigoriKey version of current default |
| 184 // encryption key. | 184 // encryption key. |
| 185 std::string GetDefaultNigoriKeyData() const; | 185 std::string GetDefaultNigoriKeyData() const; |
| 186 | 186 |
| 187 // Generates a new Nigori from |serialized_nigori_key|, and if successful | 187 // Generates a new Nigori from |serialized_nigori_key|, and if successful |
| 188 // installs the new nigori as the default key. | 188 // installs the new nigori as the default key. |
| 189 bool ImportNigoriKey(const std::string serialized_nigori_key); | 189 bool ImportNigoriKey(const std::string& serialized_nigori_key); |
| 190 | 190 |
| 191 private: | 191 private: |
| 192 typedef std::map<std::string, linked_ptr<const Nigori> > NigoriMap; | 192 typedef std::map<std::string, linked_ptr<const Nigori> > NigoriMap; |
| 193 | 193 |
| 194 // Helper method to instantiate Nigori instances for each set of key | 194 // Helper method to instantiate Nigori instances for each set of key |
| 195 // parameters in |bag|. | 195 // parameters in |bag|. |
| 196 // Does not update the default nigori. | 196 // Does not update the default nigori. |
| 197 void InstallKeyBag(const sync_pb::NigoriKeyBag& bag); | 197 void InstallKeyBag(const sync_pb::NigoriKeyBag& bag); |
| 198 | 198 |
| 199 // Helper method to add a nigori to the keybag, optionally making it the | 199 // Helper method to add a nigori to the keybag, optionally making it the |
| (...skipping 13 matching lines...) Expand all Loading... |
| 213 std::string default_nigori_name_; | 213 std::string default_nigori_name_; |
| 214 | 214 |
| 215 scoped_ptr<sync_pb::EncryptedData> pending_keys_; | 215 scoped_ptr<sync_pb::EncryptedData> pending_keys_; |
| 216 | 216 |
| 217 DISALLOW_ASSIGN(Cryptographer); | 217 DISALLOW_ASSIGN(Cryptographer); |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 } // namespace syncer | 220 } // namespace syncer |
| 221 | 221 |
| 222 #endif // SYNC_UTIL_CRYPTOGRAPHER_H_ | 222 #endif // SYNC_UTIL_CRYPTOGRAPHER_H_ |
| OLD | NEW |