| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/internal/parse_certificate.h" | 5 #include "net/cert/internal/parse_certificate.h" |
| 6 | 6 |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "net/cert/internal/cert_errors.h" | 8 #include "net/cert/internal/cert_errors.h" |
| 9 #include "net/cert/internal/test_helpers.h" | 9 #include "net/cert/internal/test_helpers.h" |
| 10 #include "net/der/input.h" | 10 #include "net/der/input.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 // Tests parsing a TBSCertificate for v3 that contains no optional fields. | 207 // Tests parsing a TBSCertificate for v3 that contains no optional fields. |
| 208 TEST(ParseTbsCertificateTest, Version3NoOptionals) { | 208 TEST(ParseTbsCertificateTest, Version3NoOptionals) { |
| 209 RunTbsCertificateTest("tbs_v3_no_optionals.pem"); | 209 RunTbsCertificateTest("tbs_v3_no_optionals.pem"); |
| 210 } | 210 } |
| 211 | 211 |
| 212 // Tests parsing a TBSCertificate for v3 that contains extensions. | 212 // Tests parsing a TBSCertificate for v3 that contains extensions. |
| 213 TEST(ParseTbsCertificateTest, Version3WithExtensions) { | 213 TEST(ParseTbsCertificateTest, Version3WithExtensions) { |
| 214 RunTbsCertificateTest("tbs_v3_extensions.pem"); | 214 RunTbsCertificateTest("tbs_v3_extensions.pem"); |
| 215 } | 215 } |
| 216 | 216 |
| 217 // Tests parsing a TBSCertificate for v3 that contains no optional fields, and | |
| 218 // has a negative serial number. | |
| 219 // | |
| 220 // CAs are not supposed to include negative serial numbers, however RFC 5280 | |
| 221 // expects consumers to deal with it anyway). | |
| 222 TEST(ParseTbsCertificateTest, NegativeSerialNumber) { | |
| 223 RunTbsCertificateTest("tbs_negative_serial_number.pem"); | |
| 224 } | |
| 225 | |
| 226 // Tests parsing a TBSCertificate with a serial number that is 21 octets long | |
| 227 // (and the first byte is 0). | |
| 228 TEST(ParseTbCertificateTest, SerialNumber21OctetsLeading0) { | |
| 229 RunTbsCertificateTest("tbs_serial_number_21_octets_leading_0.pem"); | |
| 230 } | |
| 231 | |
| 232 // Tests parsing a TBSCertificate with a serial number that is 26 octets long | |
| 233 // (and does not contain a leading 0). | |
| 234 TEST(ParseTbsCertificateTest, SerialNumber26Octets) { | |
| 235 RunTbsCertificateTest("tbs_serial_number_26_octets.pem"); | |
| 236 } | |
| 237 | |
| 238 // Tests parsing a TBSCertificate which lacks a version number (causing it to | 217 // Tests parsing a TBSCertificate which lacks a version number (causing it to |
| 239 // default to v1). | 218 // default to v1). |
| 240 TEST(ParseTbsCertificateTest, Version1) { | 219 TEST(ParseTbsCertificateTest, Version1) { |
| 241 RunTbsCertificateTestGivenVersion("tbs_v1.pem", CertificateVersion::V1); | 220 RunTbsCertificateTestGivenVersion("tbs_v1.pem", CertificateVersion::V1); |
| 242 } | 221 } |
| 243 | 222 |
| 244 // The version was set to v1 explicitly rather than omitting the version field. | 223 // The version was set to v1 explicitly rather than omitting the version field. |
| 245 TEST(ParseTbsCertificateTest, ExplicitVersion1) { | 224 TEST(ParseTbsCertificateTest, ExplicitVersion1) { |
| 246 RunTbsCertificateTest("tbs_explicit_v1.pem"); | 225 RunTbsCertificateTest("tbs_explicit_v1.pem"); |
| 247 } | 226 } |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 0x00, // Number of unused bits | 405 0x00, // Number of unused bits |
| 427 }; | 406 }; |
| 428 | 407 |
| 429 der::BitString key_usage; | 408 der::BitString key_usage; |
| 430 ASSERT_FALSE(ParseKeyUsage(der::Input(der), &key_usage)); | 409 ASSERT_FALSE(ParseKeyUsage(der::Input(der), &key_usage)); |
| 431 } | 410 } |
| 432 | 411 |
| 433 } // namespace | 412 } // namespace |
| 434 | 413 |
| 435 } // namespace net | 414 } // namespace net |
| OLD | NEW |