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

Unified Diff: net/cert/internal/parse_certificate.h

Issue 2093223002: Allow Cast certificates to have serial numbers greater than 20 bytes, as well as non-minimal INTEGE… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: net/cert/internal/parse_certificate.h
diff --git a/net/cert/internal/parse_certificate.h b/net/cert/internal/parse_certificate.h
index d3c4d975b260f1ae71140f4b2ef560371055f678..a7293503b2182e25cb23a72b26a0cc1451244e8b 100644
--- a/net/cert/internal/parse_certificate.h
+++ b/net/cert/internal/parse_certificate.h
@@ -45,6 +45,14 @@ struct ParsedTbsCertificate;
// gracefully handle such certificates.
NET_EXPORT bool VerifySerialNumber(const der::Input& value) WARN_UNUSED_RESULT;
+struct NET_EXPORT ParseCertificateOptions {
+ // If set to true, then parsing will skip checks on the certificate's serial
+ // number. The only requirement will be that the serial number is an INTEGER,
+ // however it is not required to be a valid DER-encoding (i.e. minimal
+ // encoding), nor is it required to be constrained to any particular length.
+ bool allow_invalid_serial_numbers = false;
+};
+
// Parses a DER-encoded "Certificate" as specified by RFC 5280. Returns true on
// success and sets the results in the |out_*| parameters.
//
@@ -86,7 +94,8 @@ NET_EXPORT bool ParseCertificate(const der::Input& certificate_tlv,
WARN_UNUSED_RESULT;
// Parses a DER-encoded "TBSCertificate" as specified by RFC 5280. Returns true
-// on success and sets the results in |out|.
+// on success and sets the results in |out|. Certain invalid inputs may
+// be accepted based on the provided |options|.
//
// Note that on success |out| aliases data from the input |tbs_tlv|.
// Hence the fields of the ParsedTbsCertificate are only valid as long as
@@ -114,6 +123,7 @@ NET_EXPORT bool ParseCertificate(const der::Input& certificate_tlv,
// -- If present, version MUST be v3
// }
NET_EXPORT bool ParseTbsCertificate(const der::Input& tbs_tlv,
+ const ParseCertificateOptions& options,
ParsedTbsCertificate* out)
WARN_UNUSED_RESULT;
@@ -148,7 +158,13 @@ struct NET_EXPORT ParsedTbsCertificate {
// instance if the serial number was 1000 then this would contain bytes
// {0x03, 0xE8}.
//
- // In addition to being a valid DER-encoded INTEGER, parsing guarantees that
+ // The serial number may or may not be a valid DER-encoded INTEGER:
+ //
+ // If the option |allow_invalid_serial_numbers=true| was used during
+ // parsing, then nothing further can be assumed about these bytes.
+ //
+ // Otherwise if |allow_invalid_serial_numbers=false| then in addition
+ // to being a valid DER-encoded INTEGER, parsing guarantees that
// the serial number is at most 20 bytes long. Parsing does NOT guarantee
// that the integer is positive (might be zero or negative).
der::Input serial_number;

Powered by Google App Engine
This is Rietveld 408576698