| Index: net/cert/internal/parse_certificate.h
|
| diff --git a/net/cert/internal/parse_certificate.h b/net/cert/internal/parse_certificate.h
|
| index 6fde44821c27bf86c7e7c9e1a0db7305d809beb1..13409dc3be54896d4287629f933a9be90d269e5c 100644
|
| --- a/net/cert/internal/parse_certificate.h
|
| +++ b/net/cert/internal/parse_certificate.h
|
| @@ -46,6 +46,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.
|
| //
|
| @@ -87,7 +95,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
|
| @@ -115,6 +124,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;
|
|
|
| @@ -149,7 +159,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;
|
|
|