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. | |
Ryan Sleevi
2016/06/17 16:19:54
From simply reading the header, it's non-obvious w
| |
27 struct SingleResult { | |
Ryan Sleevi
2016/06/17 16:19:54
What is the API if a SingleResult couldn't be pars
dadrian
2016/06/17 23:17:36
Not currently exposed cleanly, I added some commen
| |
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|. | |
Ryan Sleevi
2016/06/16 21:49:29
DESIGN: This seems to violate the Single-Responsib
svaldez
2016/06/17 13:33:51
Its unclear what the division should be otherwise,
Ryan Sleevi
2016/06/17 16:19:54
I don't think that intrinsically argues it belongs
dadrian
2016/06/17 17:26:54
At some point ExpectStaple needs to have validatio
Ryan Sleevi
2016/06/17 18:54:25
That presupposes "ExpectStaple" is a thing. I'm ch
| |
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 const base::Time& verify_time() const { return verify_time_; } | |
56 | |
57 StapleError staple_error() const { return staple_error_; } | |
58 | |
59 const std::vector<SingleResult>& stapled_responses() const { | |
60 return stapled_responses_; | |
61 } | |
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 */ | |
Ryan Sleevi
2016/06/17 16:19:55
STYLE: Two spaces and use C++ comments
#endif //
| |
OLD | NEW |