OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 CHROME_BROWSER_SYNC_UTIL_CRYPTOGRAPHER_H_ | 5 #ifndef CHROME_BROWSER_SYNC_UTIL_CRYPTOGRAPHER_H_ |
6 #define CHROME_BROWSER_SYNC_UTIL_CRYPTOGRAPHER_H_ | 6 #define CHROME_BROWSER_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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // Note that encryption will fail if |message| isn't valid (eg. a required | 64 // Note that encryption will fail if |message| isn't valid (eg. a required |
65 // field isn't set). | 65 // field isn't set). |
66 bool Encrypt(const ::google::protobuf::MessageLite& message, | 66 bool Encrypt(const ::google::protobuf::MessageLite& message, |
67 sync_pb::EncryptedData* encrypted) const; | 67 sync_pb::EncryptedData* encrypted) const; |
68 | 68 |
69 // Decrypts |encrypted| into |message|. Returns true unless decryption fails, | 69 // Decrypts |encrypted| into |message|. Returns true unless decryption fails, |
70 // or |message| fails to parse the decrypted data. | 70 // or |message| fails to parse the decrypted data. |
71 bool Decrypt(const sync_pb::EncryptedData& encrypted, | 71 bool Decrypt(const sync_pb::EncryptedData& encrypted, |
72 ::google::protobuf::MessageLite* message) const; | 72 ::google::protobuf::MessageLite* message) const; |
73 | 73 |
| 74 // Decrypts |encrypted| and returns plaintext decrypted data. If decryption |
| 75 // fails, returns empty string. |
| 76 std::string DecryptToString(const sync_pb::EncryptedData& encrypted) const; |
| 77 |
74 // Encrypts the set of currently known keys into |encrypted|. Returns true if | 78 // Encrypts the set of currently known keys into |encrypted|. Returns true if |
75 // successful. | 79 // successful. |
76 bool GetKeys(sync_pb::EncryptedData* encrypted) const; | 80 bool GetKeys(sync_pb::EncryptedData* encrypted) const; |
77 | 81 |
78 // Creates a new Nigori instance using |params|. If successful, |params| will | 82 // Creates a new Nigori instance using |params|. If successful, |params| will |
79 // become the default encryption key and be used for all future calls to | 83 // become the default encryption key and be used for all future calls to |
80 // Encrypt. | 84 // Encrypt. |
81 bool AddKey(const KeyParams& params); | 85 bool AddKey(const KeyParams& params); |
82 | 86 |
83 // Decrypts |encrypted| and uses its contents to initialize Nigori instances. | 87 // Decrypts |encrypted| and uses its contents to initialize Nigori instances. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 NigoriMap::value_type* default_nigori_; // The Nigori used for encryption. | 131 NigoriMap::value_type* default_nigori_; // The Nigori used for encryption. |
128 | 132 |
129 scoped_ptr<sync_pb::EncryptedData> pending_keys_; | 133 scoped_ptr<sync_pb::EncryptedData> pending_keys_; |
130 | 134 |
131 DISALLOW_COPY_AND_ASSIGN(Cryptographer); | 135 DISALLOW_COPY_AND_ASSIGN(Cryptographer); |
132 }; | 136 }; |
133 | 137 |
134 } // namespace browser_sync | 138 } // namespace browser_sync |
135 | 139 |
136 #endif // CHROME_BROWSER_SYNC_UTIL_CRYPTOGRAPHER_H_ | 140 #endif // CHROME_BROWSER_SYNC_UTIL_CRYPTOGRAPHER_H_ |
OLD | NEW |