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

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

Issue 1288193003: Add a function for parsing RFC 5280's "Certificate". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@test_helpers
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
new file mode 100644
index 0000000000000000000000000000000000000000..d4968435826820e73b718d176e3ff3449a403744
--- /dev/null
+++ b/net/cert/internal/parse_certificate.h
@@ -0,0 +1,62 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_
+#define NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_
+
+#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "net/base/net_export.h"
+#include "net/der/input.h"
+#include "net/der/parse_values.h"
+
+namespace net {
+
+struct ParsedCertificate;
davidben 2015/08/14 17:14:50 Any reason for the forward-decl like this? You cou
eroman 2015/08/14 17:41:00 It was just an aesthetic decision (I can move thin
davidben 2015/08/14 17:45:39 Mmm, that's true. Do we typically do that? I don't
+
+// Parses a DER-encoded "Certificate" as specified by RFC 5280. Returns true on
+// success and sets the results in |out|.
+//
+// Refer to the per-field documention of the ParsedCertificate structure for
+// details on what validity checks parsing performs.
+//
+// Certificate ::= SEQUENCE {
+// tbsCertificate TBSCertificate,
+// signatureAlgorithm AlgorithmIdentifier,
+// signatureValue BIT STRING }
+NET_EXPORT bool ParseCertificate(const der::Input& certificate_tlv,
+ ParsedCertificate* out) WARN_UNUSED_RESULT;
davidben 2015/08/14 17:45:39 Oh transplanting my comment from the other CL sinc
eroman 2015/08/14 17:57:48 I am not sure the best way to handle this either.
+
+// ParsedCertificate contains pointers to the main fields of a DER-encoded RFC
+// 5280 "Certificate".
+//
+// ParsedCertificate is expected to be filled by ParseCertificate(), so
+// subsequent field descriptions are in terms of what ParseCertificate() sets.
+struct NET_EXPORT ParsedCertificate {
+ // Corresponds with "tbsCertificate" from RFC 5280:
+ // tbsCertificate TBSCertificate,
+ //
+ // This contains the full (unverified) Tag-Length-Value for a SEQUENCE. No
+ // guarantees are made regarding the value of this SEQUENCE.
+ der::Input tbs_certificate_tlv;
+
+ // Corresponds with "signatureAlgorithm" from RFC 5280:
+ // signatureAlgorithm AlgorithmIdentifier,
+ //
+ // 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 SignatureValue::CreateFromDer().
+ der::Input signature_algorithm_tlv;
+
+ // Corresponds with "signatureValue" from RFC 5280:
+ // signatureValue BIT STRING }
+ //
+ // Parsing guarantees that this is a valid BIT STRING.
+ der::BitString signature_value;
+};
+
+} // namespace net
+
+#endif // NET_CERT_INTERNAL_PARSE_CERTIFICATE_H_
« 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