Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // 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.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #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.
| |
| 6 #define NET_CERT_OCSP_PARSER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "net/base/hash_value.h" | |
| 13 #include "net/cert/internal/parse_certificate.h" | |
| 14 #include "net/cert/internal/signature_algorithm.h" | |
| 15 #include "net/der/input.h" | |
| 16 #include "net/der/parse_values.h" | |
| 17 #include "net/der/parser.h" | |
| 18 #include "net/der/tag.h" | |
| 19 | |
| 20 namespace net { | |
| 21 | |
| 22 namespace cert { | |
| 23 | |
| 24 struct OCSPSingleResponse { | |
| 25 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.
| |
| 26 CERT_GOOD, | |
| 27 CERT_REVOKED, | |
| 28 CERT_UNKNOWN, | |
| 29 }; | |
| 30 | |
| 31 enum RevocationReason { | |
| 32 UNSPECIFIED, | |
| 33 KEY_COMPROMISE, | |
| 34 CA_COMPROMISE, | |
| 35 AFFILIATION_CHANGED, | |
| 36 SUPERSEDED, | |
| 37 CESSATION_OF_OPERATION, | |
| 38 CERTIFICATE_HOLD, | |
| 39 UNUSED, | |
| 40 REMOVE_FROM_CRL, | |
| 41 PRIVILEGE_WITHDRAWN, | |
| 42 A_COMPROMISE, | |
| 43 }; | |
| 44 | |
| 45 OCSPSingleResponse(); | |
| 46 ~OCSPSingleResponse(); | |
| 47 | |
| 48 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.
| |
| 49 CertStatus cert_status; | |
| 50 der::GeneralizedTime revocation_time; | |
| 51 RevocationReason revocation_reason; | |
| 52 der::GeneralizedTime this_update; | |
| 53 der::GeneralizedTime next_update; | |
| 54 der::Input extensions; | |
| 55 }; | |
| 56 | |
| 57 struct OCSPResponseData { | |
|
eroman
2016/02/03 22:54:45
Please provide documentation for these structures
svaldez
2016/02/04 19:03:25
Done.
| |
| 58 enum ResponderType { NAME, KEY_HASH }; | |
| 59 | |
| 60 struct ResponderID { | |
| 61 ResponderType type; | |
| 62 der::Input name; | |
| 63 HashValue key_hash; | |
| 64 }; | |
| 65 | |
| 66 OCSPResponseData(); | |
| 67 ~OCSPResponseData(); | |
| 68 | |
| 69 uint8_t version; | |
| 70 OCSPResponseData::ResponderID responder_id; | |
| 71 der::GeneralizedTime produced_at; | |
| 72 std::vector<der::Input> responses; | |
| 73 der::Input extensions; | |
| 74 }; | |
| 75 | |
| 76 struct NET_EXPORT OCSPResponse { | |
| 77 enum ResponseStatus { | |
| 78 SUCCESSFUL, | |
| 79 MALFORMED_REQUEST, | |
| 80 INTERNAL_ERROR, | |
| 81 TRY_LATER, | |
| 82 SIG_REQUIRED, | |
| 83 UNAUTHORIZED, | |
| 84 }; | |
| 85 | |
| 86 OCSPResponse(); | |
| 87 ~OCSPResponse(); | |
| 88 | |
| 89 ResponseStatus status; | |
| 90 der::Input data; | |
| 91 scoped_ptr<SignatureAlgorithm> signature_algorithm; | |
| 92 der::BitString signature; | |
| 93 std::vector<ParsedCertificate> certs; | |
| 94 }; | |
| 95 | |
| 96 // From RFC 6960: | |
| 97 // | |
| 98 // id-pkix-ocsp OBJECT IDENTIFIER ::= { id-ad-ocsp } | |
| 99 // id-pkix-ocsp-basic OBJECT IDENTIFIER ::= { id-pkix-ocsp 1 } | |
| 100 // | |
| 101 // In dotted notation: 1.3.6.1.5.5.7.48.1.1 | |
| 102 NET_EXPORT der::Input BasicOCSPResponseOid(); | |
| 103 | |
| 104 // Parses a DER-encoded OCSP "SingleResponse" as specified by RFC 6960. Returns | |
| 105 // true on success and sets the results in |out|. | |
| 106 // | |
| 107 // On failure |out| has an undefined state. Some of its fields may have been | |
| 108 // 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.
| |
| 109 NET_EXPORT_PRIVATE bool ParseOCSPSingleResponse(der::Input raw_tlv, | |
| 110 OCSPSingleResponse* out); | |
| 111 | |
| 112 // Parses a DER-encoded OCSP "ResponseData" as specified by RFC 6960. Returns | |
| 113 // true on success and sets the results in |out|. | |
| 114 // | |
| 115 // On failure |out| has an undefined state. Some of its fields may have been | |
| 116 // updated during parsing, whereas others may not have been changed. | |
| 117 NET_EXPORT_PRIVATE bool ParseOCSPResponseData(der::Input raw_tlv, | |
| 118 OCSPResponseData* out); | |
| 119 | |
| 120 // Parses a DER-encoded "OCSPResponse" as specified by RFC 6960. Returns true | |
| 121 // on success and sets the results in |out|. | |
| 122 // | |
| 123 // On failure |out| has an undefined state. Some of its fields may have been | |
| 124 // updated during parsing, whereas others may not have been changed. | |
| 125 NET_EXPORT_PRIVATE bool ParseOCSPResponse(der::Input ocsp_response, | |
| 126 OCSPResponse* out); | |
| 127 | |
| 128 // Verifies that the OCSP Response |response| is signed and has a valid trust | |
| 129 // path to the issuer |cert|. | |
| 130 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.
| |
| 131 ParsedCertificate* cert); | |
| 132 | |
| 133 } // namespace cert | |
| 134 | |
| 135 } // namespace net | |
| 136 | |
| 137 #endif // NET_CERT_OCSP_PARSER_H_ | |
| OLD | NEW |