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/rsa_private_key.h" | 5 #include "crypto/rsa_private_key.h" |
6 | 6 |
7 #include <openssl/bn.h> | |
8 #include <openssl/bytestring.h> | |
9 #include <openssl/evp.h> | |
10 #include <openssl/mem.h> | |
11 #include <openssl/rsa.h> | |
12 #include <stdint.h> | 7 #include <stdint.h> |
13 | 8 |
14 #include <memory> | 9 #include <memory> |
15 #include <utility> | 10 #include <utility> |
16 | 11 |
17 #include "base/logging.h" | 12 #include "base/logging.h" |
18 #include "crypto/openssl_util.h" | 13 #include "crypto/openssl_util.h" |
| 14 #include "third_party/boringssl/src/include/openssl/bn.h" |
| 15 #include "third_party/boringssl/src/include/openssl/bytestring.h" |
| 16 #include "third_party/boringssl/src/include/openssl/evp.h" |
| 17 #include "third_party/boringssl/src/include/openssl/mem.h" |
| 18 #include "third_party/boringssl/src/include/openssl/rsa.h" |
19 | 19 |
20 namespace crypto { | 20 namespace crypto { |
21 | 21 |
22 // static | 22 // static |
23 std::unique_ptr<RSAPrivateKey> RSAPrivateKey::Create(uint16_t num_bits) { | 23 std::unique_ptr<RSAPrivateKey> RSAPrivateKey::Create(uint16_t num_bits) { |
24 OpenSSLErrStackTracer err_tracer(FROM_HERE); | 24 OpenSSLErrStackTracer err_tracer(FROM_HERE); |
25 | 25 |
26 bssl::UniquePtr<RSA> rsa_key(RSA_new()); | 26 bssl::UniquePtr<RSA> rsa_key(RSA_new()); |
27 bssl::UniquePtr<BIGNUM> bn(BN_new()); | 27 bssl::UniquePtr<BIGNUM> bn(BN_new()); |
28 if (!rsa_key.get() || !bn.get() || !BN_set_word(bn.get(), 65537L)) | 28 if (!rsa_key.get() || !bn.get() || !BN_set_word(bn.get(), 65537L)) |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 !EVP_marshal_public_key(cbb.get(), key_.get()) || | 105 !EVP_marshal_public_key(cbb.get(), key_.get()) || |
106 !CBB_finish(cbb.get(), &der, &der_len)) { | 106 !CBB_finish(cbb.get(), &der, &der_len)) { |
107 return false; | 107 return false; |
108 } | 108 } |
109 output->assign(der, der + der_len); | 109 output->assign(der, der + der_len); |
110 OPENSSL_free(der); | 110 OPENSSL_free(der); |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 } // namespace crypto | 114 } // namespace crypto |
OLD | NEW |