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 #include "crypto/symmetric_key.h" | 5 #include "crypto/symmetric_key.h" |
6 | 6 |
7 #include <CommonCrypto/CommonCryptor.h> | 7 #include <CommonCrypto/CommonCryptor.h> |
8 #include <CoreFoundation/CFString.h> | 8 #include <CoreFoundation/CFString.h> |
9 #include <Security/cssm.h> | 9 #include <Security/cssm.h> |
10 | 10 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // static | 140 // static |
141 SymmetricKey* SymmetricKey::Import(Algorithm algorithm, | 141 SymmetricKey* SymmetricKey::Import(Algorithm algorithm, |
142 const std::string& raw_key) { | 142 const std::string& raw_key) { |
143 return new SymmetricKey(raw_key.data(), raw_key.size() * 8); | 143 return new SymmetricKey(raw_key.data(), raw_key.size() * 8); |
144 } | 144 } |
145 | 145 |
146 SymmetricKey::SymmetricKey(const void* key_data, size_t key_size_in_bits) | 146 SymmetricKey::SymmetricKey(const void* key_data, size_t key_size_in_bits) |
147 : key_(reinterpret_cast<const char*>(key_data), key_size_in_bits / 8) { | 147 : key_(reinterpret_cast<const char*>(key_data), key_size_in_bits / 8) { |
148 } | 148 } |
149 | 149 |
150 bool SymmetricKey::GetRawKey(std::string* raw_key) { | 150 bool SymmetricKey::GetRawKey(std::string* raw_key) const { |
151 *raw_key = key_; | 151 *raw_key = key_; |
152 return true; | 152 return true; |
153 } | 153 } |
154 | 154 |
155 CSSM_DATA SymmetricKey::cssm_data() const { | 155 CSSM_DATA SymmetricKey::cssm_data() const { |
156 return StringToData(key_); | 156 return StringToData(key_); |
157 } | 157 } |
158 | 158 |
159 } // namespace crypto | 159 } // namespace crypto |
OLD | NEW |