OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/child/webcrypto/openssl/util_openssl.h" | 5 #include "components/webcrypto/openssl/util_openssl.h" |
6 | 6 |
7 #include <openssl/evp.h> | 7 #include <openssl/evp.h> |
8 #include <openssl/pkcs12.h> | 8 #include <openssl/pkcs12.h> |
9 #include <openssl/rand.h> | 9 #include <openssl/rand.h> |
10 | 10 |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "content/child/webcrypto/crypto_data.h" | 12 #include "components/webcrypto/crypto_data.h" |
13 #include "content/child/webcrypto/generate_key_result.h" | 13 #include "components/webcrypto/generate_key_result.h" |
14 #include "content/child/webcrypto/openssl/key_openssl.h" | 14 #include "components/webcrypto/openssl/key_openssl.h" |
15 #include "content/child/webcrypto/platform_crypto.h" | 15 #include "components/webcrypto/platform_crypto.h" |
16 #include "content/child/webcrypto/status.h" | 16 #include "components/webcrypto/status.h" |
17 #include "content/child/webcrypto/webcrypto_util.h" | 17 #include "components/webcrypto/webcrypto_util.h" |
18 #include "crypto/openssl_util.h" | 18 #include "crypto/openssl_util.h" |
19 | 19 |
20 namespace content { | |
21 | |
22 namespace webcrypto { | 20 namespace webcrypto { |
23 | 21 |
24 namespace { | 22 namespace { |
25 | 23 |
26 // Exports an EVP_PKEY public key to the SPKI format. | 24 // Exports an EVP_PKEY public key to the SPKI format. |
27 Status ExportPKeySpki(EVP_PKEY* key, std::vector<uint8_t>* buffer) { | 25 Status ExportPKeySpki(EVP_PKEY* key, std::vector<uint8_t>* buffer) { |
28 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); | 26 crypto::OpenSSLErrStackTracer err_tracer(FROM_HERE); |
29 crypto::ScopedBIO bio(BIO_new(BIO_s_mem())); | 27 crypto::ScopedBIO bio(BIO_new(BIO_s_mem())); |
30 | 28 |
31 // TODO(eroman): Use the OID specified by webcrypto spec. | 29 // TODO(eroman): Use the OID specified by webcrypto spec. |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 return BN_bin2bn(reinterpret_cast<const uint8_t*>(n.data()), n.size(), NULL); | 242 return BN_bin2bn(reinterpret_cast<const uint8_t*>(n.data()), n.size(), NULL); |
245 } | 243 } |
246 | 244 |
247 std::vector<uint8_t> BIGNUMToVector(const BIGNUM* n) { | 245 std::vector<uint8_t> BIGNUMToVector(const BIGNUM* n) { |
248 std::vector<uint8_t> v(BN_num_bytes(n)); | 246 std::vector<uint8_t> v(BN_num_bytes(n)); |
249 BN_bn2bin(n, vector_as_array(&v)); | 247 BN_bn2bin(n, vector_as_array(&v)); |
250 return v; | 248 return v; |
251 } | 249 } |
252 | 250 |
253 } // namespace webcrypto | 251 } // namespace webcrypto |
254 | |
255 } // namespace content | |
OLD | NEW |