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 | |
78 // Encrypts the set of currently known keys into |encrypted|. Returns true if | 74 // Encrypts the set of currently known keys into |encrypted|. Returns true if |
79 // successful. | 75 // successful. |
80 bool GetKeys(sync_pb::EncryptedData* encrypted) const; | 76 bool GetKeys(sync_pb::EncryptedData* encrypted) const; |
81 | 77 |
82 // Creates a new Nigori instance using |params|. If successful, |params| will | 78 // Creates a new Nigori instance using |params|. If successful, |params| will |
83 // become the default encryption key and be used for all future calls to | 79 // become the default encryption key and be used for all future calls to |
84 // Encrypt. | 80 // Encrypt. |
85 bool AddKey(const KeyParams& params); | 81 bool AddKey(const KeyParams& params); |
86 | 82 |
87 // Decrypts |encrypted| and uses its contents to initialize Nigori instances. | 83 // Decrypts |encrypted| and uses its contents to initialize Nigori instances. |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 NigoriMap::value_type* default_nigori_; // The Nigori used for encryption. | 127 NigoriMap::value_type* default_nigori_; // The Nigori used for encryption. |
132 | 128 |
133 scoped_ptr<sync_pb::EncryptedData> pending_keys_; | 129 scoped_ptr<sync_pb::EncryptedData> pending_keys_; |
134 | 130 |
135 DISALLOW_COPY_AND_ASSIGN(Cryptographer); | 131 DISALLOW_COPY_AND_ASSIGN(Cryptographer); |
136 }; | 132 }; |
137 | 133 |
138 } // namespace browser_sync | 134 } // namespace browser_sync |
139 | 135 |
140 #endif // CHROME_BROWSER_SYNC_UTIL_CRYPTOGRAPHER_H_ | 136 #endif // CHROME_BROWSER_SYNC_UTIL_CRYPTOGRAPHER_H_ |
OLD | NEW |