Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 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_STAPLE_H | |
| 6 #define NET_CERT_OCSP_STAPLE_H | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/macros.h" | |
| 11 #include "base/time/time.h" | |
| 12 #include "net/base/net_export.h" | |
| 13 #include "net/cert/internal/parse_ocsp.h" | |
| 14 #include "net/cert/x509_certificate.h" | |
| 15 | |
| 16 namespace net { | |
| 17 | |
| 18 class NET_EXPORT ExpectStapleReport { | |
|
estark
2016/06/14 02:10:28
Probably should document this class with a comment
dadrian
2016/06/14 18:40:01
Done.
| |
| 19 public: | |
| 20 ExpectStapleReport(); | |
| 21 ~ExpectStapleReport(); | |
| 22 | |
| 23 // Stores the validity of a single stapled response. | |
| 24 struct SingleResult { | |
| 25 bool is_date_valid = false; | |
| 26 bool is_correct_certificate = false; | |
| 27 OCSPCertStatus::Status status = OCSPCertStatus::Status::UNKNOWN; | |
| 28 }; | |
| 29 | |
| 30 // Represents where the staple verification an error occured. | |
|
estark
2016/06/14 02:10:28
typo; extra "an"?
dadrian
2016/06/14 18:40:01
Done.
| |
| 31 enum class StapleError { | |
| 32 OK = 0, | |
| 33 PARSE_RESPONSE = 1, | |
| 34 BAD_RESPONSE = 2, | |
| 35 PARSE_RESPONSE_DATA = 3, | |
| 36 PARSE_SINGLE_RESPONSE = 4, | |
| 37 NO_MATCHING_RESPONSE = 5 | |
| 38 }; | |
| 39 | |
| 40 // Creates an ExpectStapleReport from an unparsed OCSP response. | |
| 41 // This compares the serial number of the certificate, and verifies that | |
| 42 // |verify_time| is within thisUpdate and nextUpdate, and that thisUpdate is | |
| 43 // at least as recent as |verify_time - max_age|. | |
| 44 // | |
| 45 // TODO(dadrian): Check issuer and signatures | |
|
estark
2016/06/14 02:10:28
add a bug number please
dadrian
2016/06/14 18:40:01
Done.
| |
| 46 static std::unique_ptr<ExpectStapleReport> FromRawOCSPResponse( | |
| 47 const std::string raw_response, | |
|
estark
2016/06/14 02:10:28
pass by reference here
dadrian
2016/06/14 18:40:01
Done.
| |
| 48 const base::Time& verify_time, | |
| 49 const base::TimeDelta& max_age, | |
| 50 const X509Certificate& server_certificate); | |
| 51 | |
| 52 StapleError staple_error() const { return staple_error_; } | |
| 53 | |
| 54 const std::vector<SingleResult>& stapled_responses() const { | |
| 55 return stapled_responses_; | |
| 56 } | |
| 57 | |
| 58 const base::Time& verify_time() const { return verify_time_; } | |
| 59 | |
| 60 private: | |
| 61 base::Time verify_time_; | |
| 62 StapleError staple_error_; | |
| 63 std::vector<SingleResult> stapled_responses_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(ExpectStapleReport); | |
| 66 }; | |
| 67 | |
| 68 } // namespace net | |
| 69 | |
| 70 #endif /* NET_CERT_OCSP_STAPLE_H */ | |
| OLD | NEW |