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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // should be prompted for the new passphrase and DecryptPendingKeys be called. | 44 // should be prompted for the new passphrase and DecryptPendingKeys be called. |
45 // | 45 // |
46 // Whenever a update to an encrypted node is received from the server, | 46 // Whenever a update to an encrypted node is received from the server, |
47 // CanDecrypt should be used to verify whether the Cryptographer can decrypt | 47 // CanDecrypt should be used to verify whether the Cryptographer can decrypt |
48 // that node. If it cannot, then the application of that update should be | 48 // that node. If it cannot, then the application of that update should be |
49 // delayed until after it can be decrypted. | 49 // delayed until after it can be decrypted. |
50 class SYNC_EXPORT Cryptographer { | 50 class SYNC_EXPORT Cryptographer { |
51 public: | 51 public: |
52 // Does not take ownership of |encryptor|. | 52 // Does not take ownership of |encryptor|. |
53 explicit Cryptographer(Encryptor* encryptor); | 53 explicit Cryptographer(Encryptor* encryptor); |
| 54 explicit Cryptographer(const Cryptographer& other); |
54 ~Cryptographer(); | 55 ~Cryptographer(); |
55 | 56 |
56 // |restored_bootstrap_token| can be provided via this method to bootstrap | 57 // |restored_bootstrap_token| can be provided via this method to bootstrap |
57 // Cryptographer instance into the ready state (is_ready will be true). | 58 // Cryptographer instance into the ready state (is_ready will be true). |
58 // It must be a string that was previously built by the | 59 // It must be a string that was previously built by the |
59 // GetSerializedBootstrapToken function. It is possible that the token is no | 60 // GetSerializedBootstrapToken function. It is possible that the token is no |
60 // longer valid (due to server key change), in which case the normal | 61 // longer valid (due to server key change), in which case the normal |
61 // decryption code paths will fail and the user will need to provide a new | 62 // decryption code paths will fail and the user will need to provide a new |
62 // passphrase. | 63 // passphrase. |
63 // It is an error to call this if is_ready() == true, though it is fair to | 64 // It is an error to call this if is_ready() == true, though it is fair to |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 // default as well. | 200 // default as well. |
200 bool AddKeyImpl(scoped_ptr<Nigori> nigori, bool set_as_default); | 201 bool AddKeyImpl(scoped_ptr<Nigori> nigori, bool set_as_default); |
201 | 202 |
202 // Helper to unencrypt a bootstrap token into a serialized sync_pb::NigoriKey. | 203 // Helper to unencrypt a bootstrap token into a serialized sync_pb::NigoriKey. |
203 std::string UnpackBootstrapToken(const std::string& token) const; | 204 std::string UnpackBootstrapToken(const std::string& token) const; |
204 | 205 |
205 Encryptor* const encryptor_; | 206 Encryptor* const encryptor_; |
206 | 207 |
207 // The Nigoris we know about, mapped by key name. | 208 // The Nigoris we know about, mapped by key name. |
208 NigoriMap nigoris_; | 209 NigoriMap nigoris_; |
| 210 |
209 // The key name associated with the default nigori. If non-empty, must | 211 // The key name associated with the default nigori. If non-empty, must |
210 // correspond to a nigori within |nigoris_|. | 212 // correspond to a nigori within |nigoris_|. |
211 std::string default_nigori_name_; | 213 std::string default_nigori_name_; |
212 | 214 |
213 scoped_ptr<sync_pb::EncryptedData> pending_keys_; | 215 scoped_ptr<sync_pb::EncryptedData> pending_keys_; |
214 | 216 |
215 DISALLOW_COPY_AND_ASSIGN(Cryptographer); | 217 DISALLOW_ASSIGN(Cryptographer); |
216 }; | 218 }; |
217 | 219 |
218 } // namespace syncer | 220 } // namespace syncer |
219 | 221 |
220 #endif // SYNC_UTIL_CRYPTOGRAPHER_H_ | 222 #endif // SYNC_UTIL_CRYPTOGRAPHER_H_ |
OLD | NEW |