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 "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 EXPECT_TRUE(google_cert->IsIssuedByEncoded(issuers)); | 690 EXPECT_TRUE(google_cert->IsIssuedByEncoded(issuers)); |
691 | 691 |
692 // Check that they both pass when given a list of the two issuers. | 692 // Check that they both pass when given a list of the two issuers. |
693 issuers.clear(); | 693 issuers.clear(); |
694 issuers.push_back(mit_issuer); | 694 issuers.push_back(mit_issuer); |
695 issuers.push_back(thawte_issuer); | 695 issuers.push_back(thawte_issuer); |
696 EXPECT_TRUE(mit_davidben_cert->IsIssuedByEncoded(issuers)); | 696 EXPECT_TRUE(mit_davidben_cert->IsIssuedByEncoded(issuers)); |
697 EXPECT_TRUE(google_cert->IsIssuedByEncoded(issuers)); | 697 EXPECT_TRUE(google_cert->IsIssuedByEncoded(issuers)); |
698 } | 698 } |
699 | 699 |
| 700 TEST(X509CertificateTest, IsSelfSigned) { |
| 701 base::FilePath certs_dir = GetTestCertsDirectory(); |
| 702 |
| 703 scoped_refptr<X509Certificate> cert( |
| 704 ImportCertFromFile(certs_dir, "mit.davidben.der")); |
| 705 ASSERT_NE(static_cast<X509Certificate*>(NULL), cert.get()); |
| 706 EXPECT_FALSE(X509Certificate::IsSelfSigned(cert->os_cert_handle())); |
| 707 |
| 708 scoped_refptr<X509Certificate> self_signed( |
| 709 ImportCertFromFile(certs_dir, "aia-root.pem")); |
| 710 ASSERT_NE(static_cast<X509Certificate*>(NULL), self_signed.get()); |
| 711 EXPECT_TRUE(X509Certificate::IsSelfSigned(self_signed->os_cert_handle())); |
| 712 } |
| 713 |
700 TEST(X509CertificateTest, IsIssuedByEncodedWithIntermediates) { | 714 TEST(X509CertificateTest, IsIssuedByEncodedWithIntermediates) { |
701 static const unsigned char kPolicyRootDN[] = { | 715 static const unsigned char kPolicyRootDN[] = { |
702 0x30, 0x1e, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, | 716 0x30, 0x1e, 0x31, 0x1c, 0x30, 0x1a, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, |
703 0x13, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74, | 717 0x13, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74, |
704 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41 | 718 0x20, 0x52, 0x6f, 0x6f, 0x74, 0x20, 0x43, 0x41 |
705 }; | 719 }; |
706 static const unsigned char kPolicyIntermediateDN[] = { | 720 static const unsigned char kPolicyIntermediateDN[] = { |
707 0x30, 0x26, 0x31, 0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, | 721 0x30, 0x26, 0x31, 0x24, 0x30, 0x22, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, |
708 0x1b, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74, | 722 0x1b, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x20, 0x54, 0x65, 0x73, 0x74, |
709 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, | 723 0x20, 0x49, 0x6e, 0x74, 0x65, 0x72, 0x6d, 0x65, 0x64, 0x69, 0x61, 0x74, |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 &actual_type); | 1176 &actual_type); |
1163 | 1177 |
1164 EXPECT_EQ(data.expected_bits, actual_bits); | 1178 EXPECT_EQ(data.expected_bits, actual_bits); |
1165 EXPECT_EQ(data.expected_type, actual_type); | 1179 EXPECT_EQ(data.expected_type, actual_type); |
1166 } | 1180 } |
1167 | 1181 |
1168 INSTANTIATE_TEST_CASE_P(, X509CertificatePublicKeyInfoTest, | 1182 INSTANTIATE_TEST_CASE_P(, X509CertificatePublicKeyInfoTest, |
1169 testing::ValuesIn(kPublicKeyInfoTestData)); | 1183 testing::ValuesIn(kPublicKeyInfoTestData)); |
1170 | 1184 |
1171 } // namespace net | 1185 } // namespace net |
OLD | NEW |