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_EXPECT_STAPLE_REPORT_H | |
6 #define NET_CERT_EXPECT_STAPLE_REPORT_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 // An ExpectStapleReport is used to determine if a stapled OCSP response is | |
19 // valid for a given certificate, and contains all the information needed to | |
20 // construct a report payload for sites opting into Expect-Staple. | |
21 class NET_EXPORT ExpectStapleReport { | |
22 public: | |
23 ExpectStapleReport(); | |
24 ~ExpectStapleReport(); | |
25 | |
26 // Stores the validity of a single stapled response. | |
27 struct SingleResult { | |
28 bool is_date_valid = false; | |
29 bool is_correct_certificate = false; | |
30 OCSPCertStatus::Status status = OCSPCertStatus::Status::UNKNOWN; | |
31 }; | |
32 | |
33 // Represents where during the staple verification an error occurred. | |
34 enum class StapleError { | |
35 OK, | |
36 PARSE_RESPONSE, | |
37 BAD_RESPONSE, | |
38 PARSE_RESPONSE_DATA, | |
39 PARSE_SINGLE_RESPONSE, | |
40 NO_MATCHING_RESPONSE, | |
41 }; | |
42 | |
43 // Creates an ExpectStapleReport from an unparsed OCSP response. | |
44 // This compares the serial number of the certificate, and verifies that | |
45 // |verify_time| is within thisUpdate and nextUpdate, and that thisUpdate is | |
46 // at least as recent as |verify_time - max_age|. | |
47 // | |
48 // TODO(dadrian): Check issuer and signatures. https://crbug.com/620005 | |
49 static std::unique_ptr<ExpectStapleReport> FromRawOCSPResponse( | |
50 const std::string& raw_response, | |
51 const base::Time& verify_time, | |
52 const base::TimeDelta& max_age, | |
53 const X509Certificate& server_certificate); | |
54 | |
55 StapleError staple_error() const { return staple_error_; } | |
56 | |
57 const std::vector<SingleResult>& stapled_responses() const { | |
58 return stapled_responses_; | |
59 } | |
60 | |
svaldez
2016/06/16 11:14:38
nit: You probably want the accessors in the same o
dadrian
2016/06/16 19:20:18
Done.
| |
61 const base::Time& verify_time() const { return verify_time_; } | |
62 | |
63 private: | |
64 base::Time verify_time_; | |
65 StapleError staple_error_; | |
66 std::vector<SingleResult> stapled_responses_; | |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(ExpectStapleReport); | |
69 }; | |
70 | |
71 } // namespace net | |
72 | |
73 #endif /* NET_CERT_EXPECT_STAPLE_REPORT_H */ | |
OLD | NEW |