| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ct_objects_extractor.h" | 5 #include "net/cert/ct_objects_extractor.h" |
| 6 | 6 |
| 7 #include <string.h> | 7 #include <string.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/sha1.h" | 10 #include "base/sha1.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 0xD6, 0x79, 0x02, 0x04, 0x05}; | 34 0xD6, 0x79, 0x02, 0x04, 0x05}; |
| 35 | 35 |
| 36 bool StringEqualToCBS(const std::string& value1, const CBS* value2) { | 36 bool StringEqualToCBS(const std::string& value1, const CBS* value2) { |
| 37 if (CBS_len(value2) != value1.size()) | 37 if (CBS_len(value2) != value1.size()) |
| 38 return false; | 38 return false; |
| 39 return memcmp(value1.data(), CBS_data(value2), CBS_len(value2)) == 0; | 39 return memcmp(value1.data(), CBS_data(value2), CBS_len(value2)) == 0; |
| 40 } | 40 } |
| 41 | 41 |
| 42 bssl::UniquePtr<X509> OSCertHandleToOpenSSL( | 42 bssl::UniquePtr<X509> OSCertHandleToOpenSSL( |
| 43 X509Certificate::OSCertHandle os_handle) { | 43 X509Certificate::OSCertHandle os_handle) { |
| 44 #if BUILDFLAG(USE_BYTE_CERTS) | 44 #if defined(USE_OPENSSL_CERTS) |
| 45 return bssl::UniquePtr<X509>(X509_parse_from_buffer(os_handle)); | |
| 46 #elif defined(USE_OPENSSL_CERTS) | |
| 47 return bssl::UniquePtr<X509>(X509Certificate::DupOSCertHandle(os_handle)); | 45 return bssl::UniquePtr<X509>(X509Certificate::DupOSCertHandle(os_handle)); |
| 48 #else | 46 #else |
| 49 std::string der_encoded; | 47 std::string der_encoded; |
| 50 if (!X509Certificate::GetDEREncoded(os_handle, &der_encoded)) | 48 if (!X509Certificate::GetDEREncoded(os_handle, &der_encoded)) |
| 51 return bssl::UniquePtr<X509>(); | 49 return bssl::UniquePtr<X509>(); |
| 52 const uint8_t* bytes = reinterpret_cast<const uint8_t*>(der_encoded.data()); | 50 const uint8_t* bytes = reinterpret_cast<const uint8_t*>(der_encoded.data()); |
| 53 return bssl::UniquePtr<X509>(d2i_X509(NULL, &bytes, der_encoded.size())); | 51 return bssl::UniquePtr<X509>(d2i_X509(NULL, &bytes, der_encoded.size())); |
| 54 #endif | 52 #endif |
| 55 } | 53 } |
| 56 | 54 |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 if (!x509_exts || ptr != CBS_data(&extensions) + CBS_len(&extensions)) | 342 if (!x509_exts || ptr != CBS_data(&extensions) + CBS_len(&extensions)) |
| 345 return false; | 343 return false; |
| 346 | 344 |
| 347 return GetSCTListFromX509_EXTENSIONS(x509_exts.get(), kOCSPExtensionOid, | 345 return GetSCTListFromX509_EXTENSIONS(x509_exts.get(), kOCSPExtensionOid, |
| 348 sizeof(kOCSPExtensionOid), sct_list); | 346 sizeof(kOCSPExtensionOid), sct_list); |
| 349 } | 347 } |
| 350 | 348 |
| 351 } // namespace ct | 349 } // namespace ct |
| 352 | 350 |
| 353 } // namespace net | 351 } // namespace net |
| OLD | NEW |