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 <openssl/evp.h> | |
8 #include <openssl/rand.h> | |
9 | |
10 #include <algorithm> | 7 #include <algorithm> |
11 | 8 |
12 #include "base/logging.h" | 9 #include "base/logging.h" |
13 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
14 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
15 #include "crypto/openssl_util.h" | 12 #include "crypto/openssl_util.h" |
| 13 #include "third_party/boringssl/src/include/openssl/evp.h" |
| 14 #include "third_party/boringssl/src/include/openssl/rand.h" |
16 | 15 |
17 namespace crypto { | 16 namespace crypto { |
18 | 17 |
19 SymmetricKey::~SymmetricKey() { | 18 SymmetricKey::~SymmetricKey() { |
20 std::fill(key_.begin(), key_.end(), '\0'); // Zero out the confidential key. | 19 std::fill(key_.begin(), key_.end(), '\0'); // Zero out the confidential key. |
21 } | 20 } |
22 | 21 |
23 // static | 22 // static |
24 SymmetricKey* SymmetricKey::GenerateRandomKey(Algorithm algorithm, | 23 SymmetricKey* SymmetricKey::GenerateRandomKey(Algorithm algorithm, |
25 size_t key_size_in_bits) { | 24 size_t key_size_in_bits) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 key->key_ = raw_key; | 94 key->key_ = raw_key; |
96 return key.release(); | 95 return key.release(); |
97 } | 96 } |
98 | 97 |
99 bool SymmetricKey::GetRawKey(std::string* raw_key) { | 98 bool SymmetricKey::GetRawKey(std::string* raw_key) { |
100 *raw_key = key_; | 99 *raw_key = key_; |
101 return true; | 100 return true; |
102 } | 101 } |
103 | 102 |
104 } // namespace crypto | 103 } // namespace crypto |
OLD | NEW |