| 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 COMPONENTS_SYNC_BASE_NIGORI_H_ | 5 #ifndef COMPONENTS_SYNC_BASE_NIGORI_H_ |
| 6 #define COMPONENTS_SYNC_BASE_NIGORI_H_ | 6 #define COMPONENTS_SYNC_BASE_NIGORI_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 // Encrypts |value|. Note that on success, |encrypted| will be Base64 | 54 // Encrypts |value|. Note that on success, |encrypted| will be Base64 |
| 55 // encoded. | 55 // encoded. |
| 56 bool Encrypt(const std::string& value, std::string* encrypted) const; | 56 bool Encrypt(const std::string& value, std::string* encrypted) const; |
| 57 | 57 |
| 58 // Decrypts |value| into |decrypted|. It is assumed that |value| is Base64 | 58 // Decrypts |value| into |decrypted|. It is assumed that |value| is Base64 |
| 59 // encoded. | 59 // encoded. |
| 60 bool Decrypt(const std::string& value, std::string* decrypted) const; | 60 bool Decrypt(const std::string& value, std::string* decrypted) const; |
| 61 | 61 |
| 62 // Exports the raw derived keys. | 62 // Exports the raw derived keys. |
| 63 bool ExportKeys(std::string* user_key, | 63 void ExportKeys(std::string* user_key, |
| 64 std::string* encryption_key, | 64 std::string* encryption_key, |
| 65 std::string* mac_key) const; | 65 std::string* mac_key) const; |
| 66 | 66 |
| 67 static const char kSaltSalt[]; // The salt used to derive the user salt. | 67 static const char kSaltSalt[]; // The salt used to derive the user salt. |
| 68 static const size_t kSaltKeySizeInBits = 128; | 68 static const size_t kSaltKeySizeInBits = 128; |
| 69 static const size_t kDerivedKeySizeInBits = 128; | 69 static const size_t kDerivedKeySizeInBits = 128; |
| 70 static const size_t kIvSize = 16; | 70 static const size_t kIvSize = 16; |
| 71 static const size_t kHashSize = 32; | 71 static const size_t kHashSize = 32; |
| 72 | 72 |
| 73 static const size_t kSaltIterations = 1001; | 73 static const size_t kSaltIterations = 1001; |
| 74 static const size_t kUserIterations = 1002; | 74 static const size_t kUserIterations = 1002; |
| 75 static const size_t kEncryptionIterations = 1003; | 75 static const size_t kEncryptionIterations = 1003; |
| 76 static const size_t kSigningIterations = 1004; | 76 static const size_t kSigningIterations = 1004; |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 // user_key isn't used any more, but legacy clients will fail to import a | 79 // user_key isn't used any more, but legacy clients will fail to import a |
| 80 // nigori node without one. We preserve it for the sake of those clients, but | 80 // nigori node without one. We preserve it for the sake of those clients, but |
| 81 // it should be removed once enough clients have upgraded to code that doesn't | 81 // it should be removed once enough clients have upgraded to code that doesn't |
| 82 // enforce its presence. | 82 // enforce its presence. |
| 83 std::unique_ptr<crypto::SymmetricKey> user_key_; | 83 std::unique_ptr<crypto::SymmetricKey> user_key_; |
| 84 std::unique_ptr<crypto::SymmetricKey> encryption_key_; | 84 std::unique_ptr<crypto::SymmetricKey> encryption_key_; |
| 85 std::unique_ptr<crypto::SymmetricKey> mac_key_; | 85 std::unique_ptr<crypto::SymmetricKey> mac_key_; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 } // namespace syncer | 88 } // namespace syncer |
| 89 | 89 |
| 90 #endif // COMPONENTS_SYNC_BASE_NIGORI_H_ | 90 #endif // COMPONENTS_SYNC_BASE_NIGORI_H_ |
| OLD | NEW |