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

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

Issue 1690123002: Reduce Certificate Parsing Strictness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removing 21 octet weakness. Created 4 years, 10 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
« no previous file with comments | « net/cert/internal/parse_certificate.h ('k') | net/cert/internal/signature_algorithm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/internal/parse_certificate.cc
diff --git a/net/cert/internal/parse_certificate.cc b/net/cert/internal/parse_certificate.cc
index 74222e8fde0a2cc5647ede754858044a4bfb1eb8..74538080c165f2415554ab918cef96a7106583ba 100644
--- a/net/cert/internal/parse_certificate.cc
+++ b/net/cert/internal/parse_certificate.cc
@@ -68,43 +68,6 @@ WARN_UNUSED_RESULT bool ParseVersion(const der::Input& in,
return !parser.HasMore();
}
-// Returns true if the given serial number (CertificateSerialNumber in RFC 5280)
-// is valid:
-//
-// CertificateSerialNumber ::= INTEGER
-//
-// The input to this function is the (unverified) value octets of the INTEGER.
-// This function will verify that:
-//
-// * The octets are a valid DER-encoding of an INTEGER (for instance, minimal
-// encoding length).
-//
-// * No more than 20 octets are used.
-//
-// Note that it DOES NOT reject non-positive values (zero or negative).
-//
-// For reference, here is what RFC 5280 section 4.1.2.2 says:
-//
-// Given the uniqueness requirements above, serial numbers can be
-// expected to contain long integers. Certificate users MUST be able to
-// handle serialNumber values up to 20 octets. Conforming CAs MUST NOT
-// use serialNumber values longer than 20 octets.
-//
-// Note: Non-conforming CAs may issue certificates with serial numbers
-// that are negative or zero. Certificate users SHOULD be prepared to
-// gracefully handle such certificates.
-WARN_UNUSED_RESULT bool VerifySerialNumber(const der::Input& value) {
- bool unused_negative;
- if (!der::IsValidInteger(value, &unused_negative))
- return false;
-
- // Check if the serial number is too long per RFC 5280.
- if (value.Length() > 20)
- return false;
-
- return true;
-}
-
// Consumes a "Time" value (as defined by RFC 5280) from |parser|. On success
// writes the result to |*out| and returns true. On failure no guarantees are
// made about the state of |parser|.
@@ -191,6 +154,18 @@ ParsedTbsCertificate::ParsedTbsCertificate() {}
ParsedTbsCertificate::~ParsedTbsCertificate() {}
+bool VerifySerialNumber(const der::Input& value) {
+ bool unused_negative;
+ if (!der::IsValidInteger(value, &unused_negative))
+ return false;
+
+ // Check if the serial number is too long per RFC 5280.
+ if (value.Length() > 20)
+ return false;
+
+ return true;
+}
+
bool ParseCertificate(const der::Input& certificate_tlv,
ParsedCertificate* out) {
der::Parser parser(certificate_tlv);
« no previous file with comments | « net/cert/internal/parse_certificate.h ('k') | net/cert/internal/signature_algorithm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698