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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 return false; | 279 return false; |
280 encoded->assign(reinterpret_cast<char*>(der_data.Data), | 280 encoded->assign(reinterpret_cast<char*>(der_data.Data), |
281 der_data.Length); | 281 der_data.Length); |
282 return true; | 282 return true; |
283 } | 283 } |
284 | 284 |
285 // static | 285 // static |
286 bool X509Certificate::IsSameOSCert(X509Certificate::OSCertHandle a, | 286 bool X509Certificate::IsSameOSCert(X509Certificate::OSCertHandle a, |
287 X509Certificate::OSCertHandle b) { | 287 X509Certificate::OSCertHandle b) { |
288 DCHECK(a && b); | 288 DCHECK(a && b); |
289 if (a == b) | 289 return CFEqual(a, b); |
mattm
2017/03/17 01:15:53
was doing this check here before calling CFEqual a
Ryan Sleevi
2017/03/17 14:13:58
Yup
| |
290 return true; | |
291 if (CFEqual(a, b)) | |
292 return true; | |
293 CSSM_DATA a_data, b_data; | |
294 return SecCertificateGetData(a, &a_data) == noErr && | |
295 SecCertificateGetData(b, &b_data) == noErr && | |
296 a_data.Length == b_data.Length && | |
297 memcmp(a_data.Data, b_data.Data, a_data.Length) == 0; | |
298 } | 290 } |
299 | 291 |
300 // static | 292 // static |
301 X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes( | 293 X509Certificate::OSCertHandle X509Certificate::CreateOSCertHandleFromBytes( |
302 const char* data, | 294 const char* data, |
303 size_t length) { | 295 size_t length) { |
304 CSSM_DATA cert_data; | 296 CSSM_DATA cert_data; |
305 cert_data.Data = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(data)); | 297 cert_data.Data = const_cast<uint8_t*>(reinterpret_cast<const uint8_t*>(data)); |
306 cert_data.Length = length; | 298 cert_data.Length = length; |
307 | 299 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
551 return false; | 543 return false; |
552 | 544 |
553 if (CSSM_CL_CertVerify(cl_handle, 0, &cert_data, &cert_data, NULL, 0)) | 545 if (CSSM_CL_CertVerify(cl_handle, 0, &cert_data, &cert_data, NULL, 0)) |
554 return false; | 546 return false; |
555 return true; | 547 return true; |
556 } | 548 } |
557 | 549 |
558 #pragma clang diagnostic pop // "-Wdeprecated-declarations" | 550 #pragma clang diagnostic pop // "-Wdeprecated-declarations" |
559 | 551 |
560 } // namespace net | 552 } // namespace net |
OLD | NEW |