Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(394)

Side by Side Diff: net/ssl/openssl_ssl_util.cc

Issue 2824713002: Trim some dependencies on crypto/x509 headers. (Closed)
Patch Set: . Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/ssl/openssl_ssl_util.h ('k') | net/ssl/ssl_client_session_cache.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "net/ssl/openssl_ssl_util.h" 5 #include "net/ssl/openssl_ssl_util.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/lazy_instance.h" 11 #include "base/lazy_instance.h"
12 #include "base/location.h" 12 #include "base/location.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/values.h" 14 #include "base/values.h"
15 #include "crypto/openssl_util.h" 15 #include "crypto/openssl_util.h"
16 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
17 #include "net/ssl/ssl_connection_status_flags.h" 17 #include "net/ssl/ssl_connection_status_flags.h"
18 #include "third_party/boringssl/src/include/openssl/err.h" 18 #include "third_party/boringssl/src/include/openssl/err.h"
19 #include "third_party/boringssl/src/include/openssl/ssl.h" 19 #include "third_party/boringssl/src/include/openssl/ssl.h"
20 #include "third_party/boringssl/src/include/openssl/x509.h"
21 20
22 namespace net { 21 namespace net {
23 22
24 SslSetClearMask::SslSetClearMask() 23 SslSetClearMask::SslSetClearMask()
25 : set_mask(0), 24 : set_mask(0),
26 clear_mask(0) { 25 clear_mask(0) {
27 } 26 }
28 27
29 void SslSetClearMask::ConfigureFlag(long flag, bool state) { 28 void SslSetClearMask::ConfigureFlag(long flag, bool state) {
30 (state ? set_mask : clear_mask) |= flag; 29 (state ? set_mask : clear_mask) |= flag;
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 case TLS1_2_VERSION: 217 case TLS1_2_VERSION:
219 return SSL_CONNECTION_VERSION_TLS1_2; 218 return SSL_CONNECTION_VERSION_TLS1_2;
220 case TLS1_3_VERSION: 219 case TLS1_3_VERSION:
221 return SSL_CONNECTION_VERSION_TLS1_3; 220 return SSL_CONNECTION_VERSION_TLS1_3;
222 default: 221 default:
223 NOTREACHED(); 222 NOTREACHED();
224 return SSL_CONNECTION_VERSION_UNKNOWN; 223 return SSL_CONNECTION_VERSION_UNKNOWN;
225 } 224 }
226 } 225 }
227 226
228 bssl::UniquePtr<X509> OSCertHandleToOpenSSL(
229 X509Certificate::OSCertHandle os_handle) {
230 #if defined(USE_OPENSSL_CERTS)
231 return bssl::UniquePtr<X509>(X509Certificate::DupOSCertHandle(os_handle));
232 #else // !defined(USE_OPENSSL_CERTS)
233 std::string der_encoded;
234 if (!X509Certificate::GetDEREncoded(os_handle, &der_encoded))
235 return bssl::UniquePtr<X509>();
236 const uint8_t* bytes = reinterpret_cast<const uint8_t*>(der_encoded.data());
237 return bssl::UniquePtr<X509>(d2i_X509(NULL, &bytes, der_encoded.size()));
238 #endif // defined(USE_OPENSSL_CERTS)
239 }
240
241 bssl::UniquePtr<STACK_OF(X509)> OSCertHandlesToOpenSSL(
242 const X509Certificate::OSCertHandles& os_handles) {
243 bssl::UniquePtr<STACK_OF(X509)> stack(sk_X509_new_null());
244 for (size_t i = 0; i < os_handles.size(); i++) {
245 bssl::UniquePtr<X509> x509 = OSCertHandleToOpenSSL(os_handles[i]);
246 if (!x509)
247 return nullptr;
248 sk_X509_push(stack.get(), x509.release());
249 }
250 return stack;
251 }
252
253 } // namespace net 227 } // namespace net
OLDNEW
« no previous file with comments | « net/ssl/openssl_ssl_util.h ('k') | net/ssl/ssl_client_session_cache.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698