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

Side by Side Diff: net/cert/x509_certificate_mac.cc

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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/cert/x509_certificate_ios.cc ('k') | net/cert/x509_certificate_nss.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 (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 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 case CSSM_ALGID_DH: 524 case CSSM_ALGID_DH:
525 *type = kPublicKeyTypeDH; 525 *type = kPublicKeyTypeDH;
526 break; 526 break;
527 default: 527 default:
528 *type = kPublicKeyTypeUnknown; 528 *type = kPublicKeyTypeUnknown;
529 *size_bits = 0; 529 *size_bits = 0;
530 break; 530 break;
531 } 531 }
532 } 532 }
533 533
534 // static
535 bool X509Certificate::IsSelfSigned(OSCertHandle cert_handle) {
536 x509_util::CSSMCachedCertificate cached_cert;
537 OSStatus status = cached_cert.Init(cert_handle);
538 if (status != noErr)
539 return false;
540
541 x509_util::CSSMFieldValue subject;
542 status = cached_cert.GetField(&CSSMOID_X509V1SubjectNameStd, &subject);
543 if (status != CSSM_OK || !subject.field())
544 return false;
545
546 x509_util::CSSMFieldValue issuer;
547 status = cached_cert.GetField(&CSSMOID_X509V1IssuerNameStd, &issuer);
548 if (status != CSSM_OK || !issuer.field())
549 return false;
550
551 if (subject.field()->Length != issuer.field()->Length ||
552 memcmp(subject.field()->Data, issuer.field()->Data,
553 issuer.field()->Length) != 0) {
554 return false;
555 }
556
557 CSSM_CL_HANDLE cl_handle = CSSM_INVALID_HANDLE;
558 status = SecCertificateGetCLHandle(cert_handle, &cl_handle);
559 if (status)
560 return false;
561 CSSM_DATA cert_data;
562 status = SecCertificateGetData(cert_handle, &cert_data);
563 if (status)
564 return false;
565
566 if (CSSM_CL_CertVerify(cl_handle, 0, &cert_data, &cert_data, NULL, 0))
567 return false;
568 return true;
569 }
570
534 } // namespace net 571 } // namespace net
OLDNEW
« no previous file with comments | « net/cert/x509_certificate_ios.cc ('k') | net/cert/x509_certificate_nss.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698