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

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

Issue 1285593003: Add parsing code for TBSCertificate's "validity" field. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cert_parsing
Patch Set: rebase onto master Created 5 years, 4 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 | « no previous file | net/cert/internal/parse_certificate.cc » ('j') | net/cert/internal/parse_certificate.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cert/internal/parse_certificate.h
diff --git a/net/cert/internal/parse_certificate.h b/net/cert/internal/parse_certificate.h
index cf8b431b69e6bf6d3c93f54a24ce06bd8b35c0cf..9372f936efeeb0797dd6fd7e2ac296eab6fc51bb 100644
--- a/net/cert/internal/parse_certificate.h
+++ b/net/cert/internal/parse_certificate.h
@@ -54,6 +54,19 @@ NET_EXPORT bool ParseTbsCertificate(const der::Input& tbs_tlv,
ParsedTbsCertificate* out)
WARN_UNUSED_RESULT;
+// Parses a DER-encoded "Validity" as specified by RFC 5280. Returns true on
+// success and sets the results in |not_before| and |not_after|:
+//
+// Validity ::= SEQUENCE {
+// notBefore Time,
+// notAfter Time }
+//
+// Note that upon success it is NOT guaranteed that |*not_before <= *not_after|.
+NET_EXPORT bool ParseValidity(const der::Input& validity_tlv,
+ der::GeneralizedTime* not_before,
+ der::GeneralizedTime* not_after)
+ WARN_UNUSED_RESULT;
+
// Represents a "Version" from RFC 5280:
// Version ::= INTEGER { v1(0), v2(1), v3(2) }
enum class CertificateVersion {
@@ -142,6 +155,8 @@ struct NET_EXPORT ParsedTbsCertificate {
//
// This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No
// guarantees are made regarding the value of this SEQUENCE.
+ //
+ // This can be further parsed using ParseValidity().
der::Input validity_tlv;
davidben 2015/08/14 18:23:10 Since it's just two fields, I wonder if you should
eroman 2015/08/14 18:37:04 I discuss the design overview in this message: htt
// Corresponds with "subject" from RFC 5280:
« no previous file with comments | « no previous file | net/cert/internal/parse_certificate.cc » ('j') | net/cert/internal/parse_certificate.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698