| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CRYPTO_SYMMETRIC_KEY_H_ | 5 #ifndef CRYPTO_SYMMETRIC_KEY_H_ |
| 6 #define CRYPTO_SYMMETRIC_KEY_H_ | 6 #define CRYPTO_SYMMETRIC_KEY_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 CSSM_DATA cssm_data() const; | 64 CSSM_DATA cssm_data() const; |
| 65 #elif defined(OS_WIN) | 65 #elif defined(OS_WIN) |
| 66 HCRYPTKEY key() const { return key_.get(); } | 66 HCRYPTKEY key() const { return key_.get(); } |
| 67 #endif | 67 #endif |
| 68 | 68 |
| 69 // Extracts the raw key from the platform specific data. | 69 // Extracts the raw key from the platform specific data. |
| 70 // Warning: |raw_key| holds the raw key as bytes and thus must be handled | 70 // Warning: |raw_key| holds the raw key as bytes and thus must be handled |
| 71 // carefully. | 71 // carefully. |
| 72 bool GetRawKey(std::string* raw_key); | 72 bool GetRawKey(std::string* raw_key); |
| 73 | 73 |
| 74 #if defined(OS_CHROMEOS) |
| 75 // Creates symmetric key from NSS key. Takes over the ownership of |key|. |
| 76 static SymmetricKey* CreateFromKey(PK11SymKey* key); |
| 77 #endif |
| 78 |
| 74 private: | 79 private: |
| 75 #if defined(USE_OPENSSL) | 80 #if defined(USE_OPENSSL) |
| 76 SymmetricKey() {} | 81 SymmetricKey() {} |
| 77 std::string key_; | 82 std::string key_; |
| 78 #elif defined(USE_NSS) | 83 #elif defined(USE_NSS) |
| 79 explicit SymmetricKey(PK11SymKey* key); | 84 explicit SymmetricKey(PK11SymKey* key); |
| 80 ScopedPK11SymKey key_; | 85 ScopedPK11SymKey key_; |
| 81 #elif defined(OS_MACOSX) | 86 #elif defined(OS_MACOSX) |
| 82 SymmetricKey(const void* key_data, size_t key_size_in_bits); | 87 SymmetricKey(const void* key_data, size_t key_size_in_bits); |
| 83 std::string key_; | 88 std::string key_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 96 // fails with NTE_BAD_KEY/NTE_BAD_LEN | 101 // fails with NTE_BAD_KEY/NTE_BAD_LEN |
| 97 std::string raw_key_; | 102 std::string raw_key_; |
| 98 #endif | 103 #endif |
| 99 | 104 |
| 100 DISALLOW_COPY_AND_ASSIGN(SymmetricKey); | 105 DISALLOW_COPY_AND_ASSIGN(SymmetricKey); |
| 101 }; | 106 }; |
| 102 | 107 |
| 103 } // namespace crypto | 108 } // namespace crypto |
| 104 | 109 |
| 105 #endif // CRYPTO_SYMMETRIC_KEY_H_ | 110 #endif // CRYPTO_SYMMETRIC_KEY_H_ |
| OLD | NEW |