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 #include "base/crypto/symmetric_key.h" | 5 #include "base/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 |
11 #include "base/crypto/cssm_init.h" | 11 #include "base/crypto/cssm_init.h" |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/rand_util.h" | |
14 | 13 |
15 namespace { | 14 namespace { |
16 | 15 |
17 CSSM_KEY_TYPE CheckKeyParams(base::SymmetricKey::Algorithm algorithm, | 16 CSSM_KEY_TYPE CheckKeyParams(base::SymmetricKey::Algorithm algorithm, |
18 size_t key_size_in_bits) { | 17 size_t key_size_in_bits) { |
19 if (algorithm == base::SymmetricKey::AES) { | 18 if (algorithm == base::SymmetricKey::AES) { |
20 CHECK(key_size_in_bits == 128 || | 19 CHECK(key_size_in_bits == 128 || |
21 key_size_in_bits == 192 || | 20 key_size_in_bits == 192 || |
22 key_size_in_bits == 256) | 21 key_size_in_bits == 256) |
23 << "Invalid key size " << key_size_in_bits << " bits"; | 22 << "Invalid key size " << key_size_in_bits << " bits"; |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 bool SymmetricKey::GetRawKey(std::string* raw_key) { | 146 bool SymmetricKey::GetRawKey(std::string* raw_key) { |
148 *raw_key = key_; | 147 *raw_key = key_; |
149 return true; | 148 return true; |
150 } | 149 } |
151 | 150 |
152 CSSM_DATA SymmetricKey::cssm_data() const { | 151 CSSM_DATA SymmetricKey::cssm_data() const { |
153 return StringToData(key_); | 152 return StringToData(key_); |
154 } | 153 } |
155 | 154 |
156 } // namespace base | 155 } // namespace base |
OLD | NEW |