| OLD | NEW |
| 1 /* ***** BEGIN LICENSE BLOCK ***** | 1 /* ***** BEGIN LICENSE BLOCK ***** |
| 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 | 2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
| 3 * | 3 * |
| 4 * The contents of this file are subject to the Mozilla Public License Version | 4 * The contents of this file are subject to the Mozilla Public License Version |
| 5 * 1.1 (the "License"); you may not use this file except in compliance with | 5 * 1.1 (the "License"); you may not use this file except in compliance with |
| 6 * the License. You may obtain a copy of the License at | 6 * the License. You may obtain a copy of the License at |
| 7 * http://www.mozilla.org/MPL/ | 7 * http://www.mozilla.org/MPL/ |
| 8 * | 8 * |
| 9 * Software distributed under the License is distributed on an "AS IS" basis, | 9 * Software distributed under the License is distributed on an "AS IS" basis, |
| 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License | 10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 #include <keyhi.h> | 43 #include <keyhi.h> |
| 44 #include <prprf.h> | 44 #include <prprf.h> |
| 45 #include <unicode/uidna.h> | 45 #include <unicode/uidna.h> |
| 46 | 46 |
| 47 #include "base/i18n/number_formatting.h" | 47 #include "base/i18n/number_formatting.h" |
| 48 #include "base/string_number_conversions.h" | 48 #include "base/string_number_conversions.h" |
| 49 #include "base/stringprintf.h" | 49 #include "base/stringprintf.h" |
| 50 #include "base/utf_string_conversions.h" | 50 #include "base/utf_string_conversions.h" |
| 51 #include "chrome/common/net/x509_certificate_model.h" | 51 #include "chrome/common/net/x509_certificate_model.h" |
| 52 #include "crypto/scoped_nss_types.h" |
| 52 #include "grit/generated_resources.h" | 53 #include "grit/generated_resources.h" |
| 53 #include "net/base/net_util.h" | 54 #include "net/base/net_util.h" |
| 54 #include "net/third_party/mozilla_security_manager/nsNSSCertTrust.h" | 55 #include "net/third_party/mozilla_security_manager/nsNSSCertTrust.h" |
| 55 #include "ui/base/l10n/l10n_util.h" | 56 #include "ui/base/l10n/l10n_util.h" |
| 56 | 57 |
| 57 namespace { | 58 namespace { |
| 58 | 59 |
| 59 std::string BMPtoUTF8(PRArenaPool* arena, unsigned char* data, | 60 std::string BMPtoUTF8(PRArenaPool* arena, unsigned char* data, |
| 60 unsigned int len) { | 61 unsigned int len) { |
| 61 if (len % 2 != 0) | 62 if (len % 2 != 0) |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 break; | 577 break; |
| 577 rv += text; | 578 rv += text; |
| 578 current = CERT_GetNextGeneralName(current); | 579 current = CERT_GetNextGeneralName(current); |
| 579 } while (current != name_list); | 580 } while (current != name_list); |
| 580 return rv; | 581 return rv; |
| 581 } | 582 } |
| 582 | 583 |
| 583 std::string ProcessAltName(SECItem* extension_data) { | 584 std::string ProcessAltName(SECItem* extension_data) { |
| 584 CERTGeneralName* name_list; | 585 CERTGeneralName* name_list; |
| 585 | 586 |
| 586 ScopedPRArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); | 587 crypto::ScopedPLArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); |
| 587 CHECK(arena.get()); | 588 CHECK(arena.get()); |
| 588 | 589 |
| 589 name_list = CERT_DecodeAltNameExtension(arena.get(), extension_data); | 590 name_list = CERT_DecodeAltNameExtension(arena.get(), extension_data); |
| 590 if (!name_list) | 591 if (!name_list) |
| 591 return l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); | 592 return l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); |
| 592 | 593 |
| 593 return ProcessGeneralNames(arena.get(), name_list); | 594 return ProcessGeneralNames(arena.get(), name_list); |
| 594 } | 595 } |
| 595 | 596 |
| 596 std::string ProcessSubjectKeyId(SECItem* extension_data) { | 597 std::string ProcessSubjectKeyId(SECItem* extension_data) { |
| 597 SECItem decoded; | 598 SECItem decoded; |
| 598 ScopedPRArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); | 599 crypto::ScopedPLArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); |
| 599 CHECK(arena.get()); | 600 CHECK(arena.get()); |
| 600 | 601 |
| 601 std::string rv; | 602 std::string rv; |
| 602 if (SEC_QuickDERDecodeItem(arena.get(), &decoded, | 603 if (SEC_QuickDERDecodeItem(arena.get(), &decoded, |
| 603 SEC_ASN1_GET(SEC_OctetStringTemplate), | 604 SEC_ASN1_GET(SEC_OctetStringTemplate), |
| 604 extension_data) != SECSuccess) { | 605 extension_data) != SECSuccess) { |
| 605 rv = l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); | 606 rv = l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); |
| 606 return rv; | 607 return rv; |
| 607 } | 608 } |
| 608 | 609 |
| 609 rv = l10n_util::GetStringFUTF8(IDS_CERT_KEYID_FORMAT, | 610 rv = l10n_util::GetStringFUTF8(IDS_CERT_KEYID_FORMAT, |
| 610 ASCIIToUTF16(ProcessRawBytes(&decoded))); | 611 ASCIIToUTF16(ProcessRawBytes(&decoded))); |
| 611 return rv; | 612 return rv; |
| 612 } | 613 } |
| 613 | 614 |
| 614 std::string ProcessAuthKeyId(SECItem* extension_data) { | 615 std::string ProcessAuthKeyId(SECItem* extension_data) { |
| 615 CERTAuthKeyID* ret; | 616 CERTAuthKeyID* ret; |
| 616 ScopedPRArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); | 617 crypto::ScopedPLArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); |
| 617 std::string rv; | 618 std::string rv; |
| 618 | 619 |
| 619 CHECK(arena.get()); | 620 CHECK(arena.get()); |
| 620 | 621 |
| 621 ret = CERT_DecodeAuthKeyID(arena.get(), extension_data); | 622 ret = CERT_DecodeAuthKeyID(arena.get(), extension_data); |
| 622 | 623 |
| 623 if (ret->keyID.len > 0) { | 624 if (ret->keyID.len > 0) { |
| 624 rv += l10n_util::GetStringFUTF8(IDS_CERT_KEYID_FORMAT, | 625 rv += l10n_util::GetStringFUTF8(IDS_CERT_KEYID_FORMAT, |
| 625 ASCIIToUTF16(ProcessRawBytes(&ret->keyID))); | 626 ASCIIToUTF16(ProcessRawBytes(&ret->keyID))); |
| 626 rv += '\n'; | 627 rv += '\n'; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 {RF_UNUSED, IDS_CERT_REVOCATION_REASON_UNUSED}, | 771 {RF_UNUSED, IDS_CERT_REVOCATION_REASON_UNUSED}, |
| 771 {RF_KEY_COMPROMISE, IDS_CERT_REVOCATION_REASON_KEY_COMPROMISE}, | 772 {RF_KEY_COMPROMISE, IDS_CERT_REVOCATION_REASON_KEY_COMPROMISE}, |
| 772 {RF_CA_COMPROMISE, IDS_CERT_REVOCATION_REASON_CA_COMPROMISE}, | 773 {RF_CA_COMPROMISE, IDS_CERT_REVOCATION_REASON_CA_COMPROMISE}, |
| 773 {RF_AFFILIATION_CHANGED, IDS_CERT_REVOCATION_REASON_AFFILIATION_CHANGED}, | 774 {RF_AFFILIATION_CHANGED, IDS_CERT_REVOCATION_REASON_AFFILIATION_CHANGED}, |
| 774 {RF_SUPERSEDED, IDS_CERT_REVOCATION_REASON_SUPERSEDED}, | 775 {RF_SUPERSEDED, IDS_CERT_REVOCATION_REASON_SUPERSEDED}, |
| 775 {RF_CESSATION_OF_OPERATION, | 776 {RF_CESSATION_OF_OPERATION, |
| 776 IDS_CERT_REVOCATION_REASON_CESSATION_OF_OPERATION}, | 777 IDS_CERT_REVOCATION_REASON_CESSATION_OF_OPERATION}, |
| 777 {RF_CERTIFICATE_HOLD, IDS_CERT_REVOCATION_REASON_CERTIFICATE_HOLD}, | 778 {RF_CERTIFICATE_HOLD, IDS_CERT_REVOCATION_REASON_CERTIFICATE_HOLD}, |
| 778 }; | 779 }; |
| 779 | 780 |
| 780 ScopedPRArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); | 781 crypto::ScopedPLArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); |
| 781 CHECK(arena.get()); | 782 CHECK(arena.get()); |
| 782 | 783 |
| 783 crldp = CERT_DecodeCRLDistributionPoints(arena.get(), extension_data); | 784 crldp = CERT_DecodeCRLDistributionPoints(arena.get(), extension_data); |
| 784 if (!crldp || !crldp->distPoints) { | 785 if (!crldp || !crldp->distPoints) { |
| 785 rv = l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); | 786 rv = l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); |
| 786 return rv; | 787 return rv; |
| 787 } | 788 } |
| 788 | 789 |
| 789 for (points = crldp->distPoints; *points; ++points) { | 790 for (points = crldp->distPoints; *points; ++points) { |
| 790 point = *points; | 791 point = *points; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 817 UTF8ToUTF16(ProcessGeneralNames(arena.get(), point->crlIssuer))); | 818 UTF8ToUTF16(ProcessGeneralNames(arena.get(), point->crlIssuer))); |
| 818 } | 819 } |
| 819 } | 820 } |
| 820 return rv; | 821 return rv; |
| 821 } | 822 } |
| 822 | 823 |
| 823 std::string ProcessAuthInfoAccess(SECItem* extension_data) { | 824 std::string ProcessAuthInfoAccess(SECItem* extension_data) { |
| 824 std::string rv; | 825 std::string rv; |
| 825 CERTAuthInfoAccess** aia; | 826 CERTAuthInfoAccess** aia; |
| 826 CERTAuthInfoAccess* desc; | 827 CERTAuthInfoAccess* desc; |
| 827 ScopedPRArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); | 828 crypto::ScopedPLArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); |
| 828 CHECK(arena.get()); | 829 CHECK(arena.get()); |
| 829 | 830 |
| 830 aia = CERT_DecodeAuthInfoAccessExtension(arena.get(), extension_data); | 831 aia = CERT_DecodeAuthInfoAccessExtension(arena.get(), extension_data); |
| 831 if (aia == NULL) | 832 if (aia == NULL) |
| 832 return l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); | 833 return l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); |
| 833 | 834 |
| 834 while (*aia != NULL) { | 835 while (*aia != NULL) { |
| 835 desc = *aia++; | 836 desc = *aia++; |
| 836 string16 location_str = UTF8ToUTF16(ProcessGeneralName(arena.get(), | 837 string16 location_str = UTF8ToUTF16(ProcessGeneralName(arena.get(), |
| 837 desc->location)); | 838 desc->location)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 860 extension_data) != SECSuccess) | 861 extension_data) != SECSuccess) |
| 861 return l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); | 862 return l10n_util::GetStringUTF8(IDS_CERT_EXTENSION_DUMP_ERROR); |
| 862 std::string rv((char*)item.data, item.len); // ASCII data. | 863 std::string rv((char*)item.data, item.len); // ASCII data. |
| 863 PORT_Free(item.data); | 864 PORT_Free(item.data); |
| 864 return rv; | 865 return rv; |
| 865 } | 866 } |
| 866 | 867 |
| 867 std::string ProcessBMPString(SECItem* extension_data) { | 868 std::string ProcessBMPString(SECItem* extension_data) { |
| 868 std::string rv; | 869 std::string rv; |
| 869 SECItem item; | 870 SECItem item; |
| 870 ScopedPRArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); | 871 crypto::ScopedPLArenaPool arena(PORT_NewArena(DER_DEFAULT_CHUNKSIZE)); |
| 871 CHECK(arena.get()); | 872 CHECK(arena.get()); |
| 872 | 873 |
| 873 if (SEC_ASN1DecodeItem(arena.get(), &item, | 874 if (SEC_ASN1DecodeItem(arena.get(), &item, |
| 874 SEC_ASN1_GET(SEC_BMPStringTemplate), extension_data) == | 875 SEC_ASN1_GET(SEC_BMPStringTemplate), extension_data) == |
| 875 SECSuccess) | 876 SECSuccess) |
| 876 rv = BMPtoUTF8(arena.get(), item.data, item.len); | 877 rv = BMPtoUTF8(arena.get(), item.data, item.len); |
| 877 return rv; | 878 return rv; |
| 878 } | 879 } |
| 879 | 880 |
| 880 struct MaskIdPair { | 881 struct MaskIdPair { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1058 if (trust.HasAnyCA()) | 1059 if (trust.HasAnyCA()) |
| 1059 return net::CA_CERT; | 1060 return net::CA_CERT; |
| 1060 if (trust.HasPeer(PR_TRUE, PR_FALSE, PR_FALSE)) | 1061 if (trust.HasPeer(PR_TRUE, PR_FALSE, PR_FALSE)) |
| 1061 return net::SERVER_CERT; | 1062 return net::SERVER_CERT; |
| 1062 if (CERT_IsCACert(cert, NULL)) | 1063 if (CERT_IsCACert(cert, NULL)) |
| 1063 return net::CA_CERT; | 1064 return net::CA_CERT; |
| 1064 return net::UNKNOWN_CERT; | 1065 return net::UNKNOWN_CERT; |
| 1065 } | 1066 } |
| 1066 | 1067 |
| 1067 } // namespace mozilla_security_manager | 1068 } // namespace mozilla_security_manager |
| OLD | NEW |