Index: net/cert/ocsp_parser.h |
diff --git a/net/cert/ocsp_parser.h b/net/cert/ocsp_parser.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..34043a09550984a4e3e064b48d7bfcec013c4060 |
--- /dev/null |
+++ b/net/cert/ocsp_parser.h |
@@ -0,0 +1,137 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
eroman
2016/02/03 22:54:45
can change to 2016
svaldez
2016/02/04 19:03:25
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef NET_CERT_OCSP_PARSER_H_ |
eroman
2016/02/03 22:54:45
Any reason to put this in cert as opposed to cert/
svaldez
2016/02/04 19:03:25
Done.
|
+#define NET_CERT_OCSP_PARSER_H_ |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/memory/scoped_ptr.h" |
+#include "net/base/hash_value.h" |
+#include "net/cert/internal/parse_certificate.h" |
+#include "net/cert/internal/signature_algorithm.h" |
+#include "net/der/input.h" |
+#include "net/der/parse_values.h" |
+#include "net/der/parser.h" |
+#include "net/der/tag.h" |
+ |
+namespace net { |
+ |
+namespace cert { |
+ |
+struct OCSPSingleResponse { |
+ enum CertStatus { |
eroman
2016/02/03 22:54:45
Not sure that our style guide enshrines one way or
svaldez
2016/02/04 19:03:25
Done.
|
+ CERT_GOOD, |
+ CERT_REVOKED, |
+ CERT_UNKNOWN, |
+ }; |
+ |
+ enum RevocationReason { |
+ UNSPECIFIED, |
+ KEY_COMPROMISE, |
+ CA_COMPROMISE, |
+ AFFILIATION_CHANGED, |
+ SUPERSEDED, |
+ CESSATION_OF_OPERATION, |
+ CERTIFICATE_HOLD, |
+ UNUSED, |
+ REMOVE_FROM_CRL, |
+ PRIVILEGE_WITHDRAWN, |
+ A_COMPROMISE, |
+ }; |
+ |
+ OCSPSingleResponse(); |
+ ~OCSPSingleResponse(); |
+ |
+ std::string cert_id; |
eroman
2016/02/03 22:54:45
Why a std::string for cert_id but der::Input for e
svaldez
2016/02/04 19:03:25
Done.
|
+ CertStatus cert_status; |
+ der::GeneralizedTime revocation_time; |
+ RevocationReason revocation_reason; |
+ der::GeneralizedTime this_update; |
+ der::GeneralizedTime next_update; |
+ der::Input extensions; |
+}; |
+ |
+struct OCSPResponseData { |
eroman
2016/02/03 22:54:45
Please provide documentation for these structures
svaldez
2016/02/04 19:03:25
Done.
|
+ enum ResponderType { NAME, KEY_HASH }; |
+ |
+ struct ResponderID { |
+ ResponderType type; |
+ der::Input name; |
+ HashValue key_hash; |
+ }; |
+ |
+ OCSPResponseData(); |
+ ~OCSPResponseData(); |
+ |
+ uint8_t version; |
+ OCSPResponseData::ResponderID responder_id; |
+ der::GeneralizedTime produced_at; |
+ std::vector<der::Input> responses; |
+ der::Input extensions; |
+}; |
+ |
+struct NET_EXPORT OCSPResponse { |
+ enum ResponseStatus { |
+ SUCCESSFUL, |
+ MALFORMED_REQUEST, |
+ INTERNAL_ERROR, |
+ TRY_LATER, |
+ SIG_REQUIRED, |
+ UNAUTHORIZED, |
+ }; |
+ |
+ OCSPResponse(); |
+ ~OCSPResponse(); |
+ |
+ ResponseStatus status; |
+ der::Input data; |
+ scoped_ptr<SignatureAlgorithm> signature_algorithm; |
+ der::BitString signature; |
+ std::vector<ParsedCertificate> certs; |
+}; |
+ |
+// From RFC 6960: |
+// |
+// id-pkix-ocsp OBJECT IDENTIFIER ::= { id-ad-ocsp } |
+// id-pkix-ocsp-basic OBJECT IDENTIFIER ::= { id-pkix-ocsp 1 } |
+// |
+// In dotted notation: 1.3.6.1.5.5.7.48.1.1 |
+NET_EXPORT der::Input BasicOCSPResponseOid(); |
+ |
+// Parses a DER-encoded OCSP "SingleResponse" as specified by RFC 6960. Returns |
+// true on success and sets the results in |out|. |
+// |
+// On failure |out| has an undefined state. Some of its fields may have been |
+// updated during parsing, whereas others may not have been changed. |
eroman
2016/02/03 22:54:45
Worth mentioning that |out| references data from |
svaldez
2016/02/04 19:03:25
Done.
|
+NET_EXPORT_PRIVATE bool ParseOCSPSingleResponse(der::Input raw_tlv, |
+ OCSPSingleResponse* out); |
+ |
+// Parses a DER-encoded OCSP "ResponseData" as specified by RFC 6960. Returns |
+// true on success and sets the results in |out|. |
+// |
+// On failure |out| has an undefined state. Some of its fields may have been |
+// updated during parsing, whereas others may not have been changed. |
+NET_EXPORT_PRIVATE bool ParseOCSPResponseData(der::Input raw_tlv, |
+ OCSPResponseData* out); |
+ |
+// Parses a DER-encoded "OCSPResponse" as specified by RFC 6960. Returns true |
+// on success and sets the results in |out|. |
+// |
+// On failure |out| has an undefined state. Some of its fields may have been |
+// updated during parsing, whereas others may not have been changed. |
+NET_EXPORT_PRIVATE bool ParseOCSPResponse(der::Input ocsp_response, |
+ OCSPResponse* out); |
+ |
+// Verifies that the OCSP Response |response| is signed and has a valid trust |
+// path to the issuer |cert|. |
+NET_EXPORT_PRIVATE bool VerifyOCSPResponse(OCSPResponse* response, |
eroman
2016/02/03 22:54:45
Why are these non-const pointers? Are they expecte
svaldez
2016/02/04 19:03:25
Done.
|
+ ParsedCertificate* cert); |
+ |
+} // namespace cert |
+ |
+} // namespace net |
+ |
+#endif // NET_CERT_OCSP_PARSER_H_ |