| 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 <CommonCrypto/CommonDigest.h> | 7 #include <CommonCrypto/CommonDigest.h> |
| 8 #include <CoreServices/CoreServices.h> | 8 #include <CoreServices/CoreServices.h> |
| 9 #include <Security/Security.h> | 9 #include <Security/Security.h> |
| 10 | 10 |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 293 return SecCertificateGetData(a, &a_data) == noErr && | 293 return SecCertificateGetData(a, &a_data) == noErr && |
| 294 SecCertificateGetData(b, &b_data) == noErr && | 294 SecCertificateGetData(b, &b_data) == noErr && |
| 295 a_data.Length == b_data.Length && | 295 a_data.Length == b_data.Length && |
| 296 memcmp(a_data.Data, b_data.Data, a_data.Length) == 0; | 296 memcmp(a_data.Data, b_data.Data, a_data.Length) == 0; |
| 297 } | 297 } |
| 298 | 298 |
| 299 // static | 299 // static |
| 300 X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes( | 300 X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes( |
| 301 const char* data, int length) { | 301 const char* data, int length) { |
| 302 CSSM_DATA cert_data; | 302 CSSM_DATA cert_data; |
| 303 cert_data.Data = const_cast<uint8*>(reinterpret_cast<const uint8*>(data)); | 303 cert_data.Data = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(data)); |
| 304 cert_data.Length = length; | 304 cert_data.Length = length; |
| 305 | 305 |
| 306 OSCertHandle cert_handle = NULL; | 306 OSCertHandle cert_handle = NULL; |
| 307 OSStatus status = SecCertificateCreateFromData(&cert_data, | 307 OSStatus status = SecCertificateCreateFromData(&cert_data, |
| 308 CSSM_CERT_X_509v3, | 308 CSSM_CERT_X_509v3, |
| 309 CSSM_CERT_ENCODING_DER, | 309 CSSM_CERT_ENCODING_DER, |
| 310 &cert_handle); | 310 &cert_handle); |
| 311 if (status != noErr) | 311 if (status != noErr) |
| 312 return NULL; | 312 return NULL; |
| 313 if (!IsValidOSCertHandle(cert_handle)) { | 313 if (!IsValidOSCertHandle(cert_handle)) { |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 status = SecCertificateGetData(cert_handle, &cert_data); | 564 status = SecCertificateGetData(cert_handle, &cert_data); |
| 565 if (status) | 565 if (status) |
| 566 return false; | 566 return false; |
| 567 | 567 |
| 568 if (CSSM_CL_CertVerify(cl_handle, 0, &cert_data, &cert_data, NULL, 0)) | 568 if (CSSM_CL_CertVerify(cl_handle, 0, &cert_data, &cert_data, NULL, 0)) |
| 569 return false; | 569 return false; |
| 570 return true; | 570 return true; |
| 571 } | 571 } |
| 572 | 572 |
| 573 } // namespace net | 573 } // namespace net |
| OLD | NEW |