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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/free_deleter.h" | 10 #include "base/memory/free_deleter.h" |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 break; | 414 break; |
415 case CALG_ECDSA: | 415 case CALG_ECDSA: |
416 *type = kPublicKeyTypeECDSA; | 416 *type = kPublicKeyTypeECDSA; |
417 break; | 417 break; |
418 case CALG_ECDH: | 418 case CALG_ECDH: |
419 *type = kPublicKeyTypeECDH; | 419 *type = kPublicKeyTypeECDH; |
420 break; | 420 break; |
421 } | 421 } |
422 } | 422 } |
423 | 423 |
| 424 X509Certificate::SignatureHashAlgorithm |
| 425 X509Certificate::GetSignatureHashAlgorithm(OSCertHandle cert_handle) { |
| 426 const char* algorithm = cert_handle->pCertInfo->SignatureAlgorithm.pszObjId; |
| 427 if (strcmp(algorithm, szOID_RSA_MD5RSA) == 0) { |
| 428 // md5WithRSAEncryption: 1.2.840.113549.1.1.4 |
| 429 return kSignatureHashAlgorithmMd5; |
| 430 } |
| 431 if (strcmp(algorithm, szOID_RSA_MD2RSA) == 0) { |
| 432 // md2WithRSAEncryption: 1.2.840.113549.1.1.2 |
| 433 return kSignatureHashAlgorithmMd2; |
| 434 } |
| 435 if (strcmp(algorithm, szOID_RSA_MD4RSA) == 0) { |
| 436 // md4WithRSAEncryption: 1.2.840.113549.1.1.3 |
| 437 return kSignatureHashAlgorithmMd4; |
| 438 } |
| 439 if (strcmp(algorithm, szOID_RSA_SHA1RSA) == 0 || |
| 440 strcmp(algorithm, szOID_X957_SHA1DSA) == 0 || |
| 441 strcmp(algorithm, szOID_ECDSA_SHA1) == 0) { |
| 442 // sha1WithRSAEncryption: 1.2.840.113549.1.1.5 |
| 443 // id-dsa-with-sha1: 1.2.840.10040.4.3 |
| 444 // ecdsa-with-SHA1: 1.2.840.10045.4.1 |
| 445 return kSignatureHashAlgorithmSha1; |
| 446 } |
| 447 |
| 448 return kSignatureHashAlgorithmOther; |
| 449 } |
| 450 |
424 bool X509Certificate::IsIssuedByEncoded( | 451 bool X509Certificate::IsIssuedByEncoded( |
425 const std::vector<std::string>& valid_issuers) { | 452 const std::vector<std::string>& valid_issuers) { |
426 | 453 |
427 // If the certificate's issuer in the list? | 454 // If the certificate's issuer in the list? |
428 if (IsCertNameBlobInIssuerList(&cert_handle_->pCertInfo->Issuer, | 455 if (IsCertNameBlobInIssuerList(&cert_handle_->pCertInfo->Issuer, |
429 valid_issuers)) { | 456 valid_issuers)) { |
430 return true; | 457 return true; |
431 } | 458 } |
432 // Otherwise, is any of the intermediate CA subjects in the list? | 459 // Otherwise, is any of the intermediate CA subjects in the list? |
433 for (OSCertHandles::iterator it = intermediate_ca_certs_.begin(); | 460 for (OSCertHandles::iterator it = intermediate_ca_certs_.begin(); |
(...skipping 15 matching lines...) Expand all Loading... |
449 CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT, | 476 CRYPT_VERIFY_CERT_SIGN_ISSUER_CERT, |
450 reinterpret_cast<void*>(const_cast<PCERT_CONTEXT>(cert_handle)), 0, NULL); | 477 reinterpret_cast<void*>(const_cast<PCERT_CONTEXT>(cert_handle)), 0, NULL); |
451 if (!valid_signature) | 478 if (!valid_signature) |
452 return false; | 479 return false; |
453 return !!CertCompareCertificateName(X509_ASN_ENCODING, | 480 return !!CertCompareCertificateName(X509_ASN_ENCODING, |
454 &cert_handle->pCertInfo->Subject, | 481 &cert_handle->pCertInfo->Subject, |
455 &cert_handle->pCertInfo->Issuer); | 482 &cert_handle->pCertInfo->Issuer); |
456 } | 483 } |
457 | 484 |
458 } // namespace net | 485 } // namespace net |
OLD | NEW |