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 BASE_CRYPTO_SYMMETRIC_KEY_H_ | 5 #ifndef BASE_CRYPTO_SYMMETRIC_KEY_H_ |
6 #define BASE_CRYPTO_SYMMETRIC_KEY_H_ | 6 #define BASE_CRYPTO_SYMMETRIC_KEY_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 const std::string& salt, | 44 const std::string& salt, |
45 size_t iterations, | 45 size_t iterations, |
46 size_t key_size_in_bits); | 46 size_t key_size_in_bits); |
47 | 47 |
48 // Imports a raw key. For this call to be successful, |raw_key| must have been | 48 // Imports a raw key. For this call to be successful, |raw_key| must have been |
49 // generated by either GenerateRandomKey or DeriveKeyFromPassword, and | 49 // generated by either GenerateRandomKey or DeriveKeyFromPassword, and |
50 // must have been exported with GetRawKey. The caller owns the returned | 50 // must have been exported with GetRawKey. The caller owns the returned |
51 // SymmetricKey. | 51 // SymmetricKey. |
52 static SymmetricKey* Import(Algorithm algorithm, const std::string& raw_key); | 52 static SymmetricKey* Import(Algorithm algorithm, const std::string& raw_key); |
53 | 53 |
54 #if defined(USE_NSS) | 54 #if defined(USE_OPENSSL) |
| 55 const std::string& key() { return key_; } |
| 56 #elif defined(USE_NSS) |
55 PK11SymKey* key() const { return key_.get(); } | 57 PK11SymKey* key() const { return key_.get(); } |
56 #elif defined(OS_MACOSX) | 58 #elif defined(OS_MACOSX) |
57 CSSM_DATA cssm_data() const; | 59 CSSM_DATA cssm_data() const; |
58 #elif defined(OS_WIN) | 60 #elif defined(OS_WIN) |
59 HCRYPTKEY key() const { return key_.get(); } | 61 HCRYPTKEY key() const { return key_.get(); } |
60 #endif | 62 #endif |
61 | 63 |
62 // Extracts the raw key from the platform specific data. | 64 // Extracts the raw key from the platform specific data. |
63 // Warning: |raw_key| holds the raw key as bytes and thus must be handled | 65 // Warning: |raw_key| holds the raw key as bytes and thus must be handled |
64 // carefully. | 66 // carefully. |
(...skipping 24 matching lines...) Expand all Loading... |
89 // fails with NTE_BAD_KEY/NTE_BAD_LEN | 91 // fails with NTE_BAD_KEY/NTE_BAD_LEN |
90 std::string raw_key_; | 92 std::string raw_key_; |
91 #endif | 93 #endif |
92 | 94 |
93 DISALLOW_COPY_AND_ASSIGN(SymmetricKey); | 95 DISALLOW_COPY_AND_ASSIGN(SymmetricKey); |
94 }; | 96 }; |
95 | 97 |
96 } // namespace base | 98 } // namespace base |
97 | 99 |
98 #endif // BASE_CRYPTO_SYMMETRIC_KEY_H_ | 100 #endif // BASE_CRYPTO_SYMMETRIC_KEY_H_ |
OLD | NEW |