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

Side by Side Diff: net/cert/internal/parse_certificate_unittest.cc

Issue 2881023003: X509CertificateBytes: Allow invalid serial numbers for now. (Closed)
Patch Set: review changes 2 Created 3 years, 7 months 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/BUILD.gn ('k') | net/cert/internal/parsed_certificate_unittest.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 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
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
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
OLDNEW
« no previous file with comments | « net/BUILD.gn ('k') | net/cert/internal/parsed_certificate_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698