Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/cert/x509_certificate.h" | 5 #include "net/cert/x509_certificate.h" |
| 6 | 6 |
| 7 #include <openssl/asn1.h> | 7 #include <openssl/asn1.h> |
| 8 #include <openssl/bytestring.h> | 8 #include <openssl/bytestring.h> |
| 9 #include <openssl/crypto.h> | 9 #include <openssl/crypto.h> |
| 10 #include <openssl/obj_mac.h> | 10 #include <openssl/obj_mac.h> |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "base/logging.h" | 29 #include "base/logging.h" |
| 30 #include "net/android/network_library.h" | 30 #include "net/android/network_library.h" |
| 31 #endif | 31 #endif |
| 32 | 32 |
| 33 namespace net { | 33 namespace net { |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 typedef crypto::ScopedOpenSSL<GENERAL_NAMES, GENERAL_NAMES_free>::Type | 37 typedef crypto::ScopedOpenSSL<GENERAL_NAMES, GENERAL_NAMES_free>::Type |
| 38 ScopedGENERAL_NAMES; | 38 ScopedGENERAL_NAMES; |
| 39 typedef crypto::ScopedOpenSSL<X509, X509_free>::Type ScopedX509; | |
|
Ryan Sleevi
2014/10/27 23:33:13
Unnecessary
palmer
2014/10/28 23:13:41
Done.
| |
| 39 | 40 |
| 40 void CreateOSCertHandlesFromPKCS7Bytes( | 41 void CreateOSCertHandlesFromPKCS7Bytes( |
| 41 const char* data, int length, | 42 const char* data, int length, |
| 42 X509Certificate::OSCertHandles* handles) { | 43 X509Certificate::OSCertHandles* handles) { |
| 43 crypto::EnsureOpenSSLInit(); | 44 crypto::EnsureOpenSSLInit(); |
| 44 crypto::OpenSSLErrStackTracer err_cleaner(FROM_HERE); | 45 crypto::OpenSSLErrStackTracer err_cleaner(FROM_HERE); |
| 45 | 46 |
| 46 CBS der_data; | 47 CBS der_data; |
| 47 CBS_init(&der_data, reinterpret_cast<const uint8_t*>(data), length); | 48 CBS_init(&der_data, reinterpret_cast<const uint8_t*>(data), length); |
| 48 STACK_OF(X509)* certs = sk_X509_new_null(); | 49 STACK_OF(X509)* certs = sk_X509_new_null(); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 X509_NAME* issuer = sk_X509_NAME_value(issuer_names.get(), m); | 443 X509_NAME* issuer = sk_X509_NAME_value(issuer_names.get(), m); |
| 443 if (X509_NAME_cmp(issuer, cert_names[n]) == 0) { | 444 if (X509_NAME_cmp(issuer, cert_names[n]) == 0) { |
| 444 return true; | 445 return true; |
| 445 } | 446 } |
| 446 } | 447 } |
| 447 } | 448 } |
| 448 | 449 |
| 449 return false; | 450 return false; |
| 450 } | 451 } |
| 451 | 452 |
| 453 // static | |
| 454 bool X509Certificate::IsSelfSigned(OSCertHandle cert_handle) { | |
| 455 crypto::ScopedEVP_PKEY scoped_key(X509_get_pubkey(cert_handle)); | |
| 456 if (!scoped_key) | |
| 457 return false; | |
| 458 | |
| 459 // NOTE: X509_verify() returns 1 in case of success, 0 or -1 on error. | |
| 460 return X509_verify(cert_handle, scoped_key.get()) == 1; | |
| 461 } | |
| 462 | |
| 452 } // namespace net | 463 } // namespace net |
| OLD | NEW |