OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013 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_QUIC_CRYPTO_PROOF_VERIFIER_H_ | |
6 #define NET_QUIC_CRYPTO_PROOF_VERIFIER_H_ | |
7 | |
8 #include <memory> | |
9 #include <string> | |
10 #include <vector> | |
11 | |
12 #include "net/base/net_export.h" | |
13 #include "net/quic/quic_protocol.h" | |
14 #include "net/quic/quic_types.h" | |
15 | |
16 namespace net { | |
17 | |
18 // ProofVerifyDetails is an abstract class that acts as a container for any | |
19 // implementation specific details that a ProofVerifier wishes to return. These | |
20 // details are saved in the CachedState for the origin in question. | |
21 class NET_EXPORT_PRIVATE ProofVerifyDetails { | |
22 public: | |
23 virtual ~ProofVerifyDetails() {} | |
24 | |
25 // Returns an new ProofVerifyDetails object with the same contents | |
26 // as this one. | |
27 virtual ProofVerifyDetails* Clone() const = 0; | |
28 }; | |
29 | |
30 // ProofVerifyContext is an abstract class that acts as a container for any | |
31 // implementation specific context that a ProofVerifier needs. | |
32 class NET_EXPORT_PRIVATE ProofVerifyContext { | |
33 public: | |
34 virtual ~ProofVerifyContext() {} | |
35 }; | |
36 | |
37 // ProofVerifierCallback provides a generic mechanism for a ProofVerifier to | |
38 // call back after an asynchronous verification. | |
39 class NET_EXPORT_PRIVATE ProofVerifierCallback { | |
40 public: | |
41 virtual ~ProofVerifierCallback() {} | |
42 | |
43 // Run is called on the original thread to mark the completion of an | |
44 // asynchonous verification. If |ok| is true then the certificate is valid | |
45 // and |error_details| is unused. Otherwise, |error_details| contains a | |
46 // description of the error. |details| contains implementation-specific | |
47 // details of the verification. |Run| may take ownership of |details| by | |
48 // calling |release| on it. | |
49 virtual void Run(bool ok, | |
50 const std::string& error_details, | |
51 std::unique_ptr<ProofVerifyDetails>* details) = 0; | |
52 }; | |
53 | |
54 // A ProofVerifier checks the signature on a server config, and the certificate | |
55 // chain that backs the public key. | |
56 class NET_EXPORT_PRIVATE ProofVerifier { | |
57 public: | |
58 virtual ~ProofVerifier() {} | |
59 | |
60 // VerifyProof checks that |signature| is a valid signature of | |
61 // |server_config| by the public key in the leaf certificate of |certs|, and | |
62 // that |certs| is a valid chain for |hostname|. On success, it returns | |
63 // QUIC_SUCCESS. On failure, it returns QUIC_FAILURE and sets |*error_details| | |
64 // to a description of the problem. In either case it may set |*details|, | |
65 // which the caller takes ownership of. | |
66 // | |
67 // |context| specifies an implementation specific struct (which may be nullptr | |
68 // for some implementations) that provides useful information for the | |
69 // verifier, e.g. logging handles. | |
70 // | |
71 // This function may also return QUIC_PENDING, in which case the ProofVerifier | |
72 // will call back, on the original thread, via |callback| when complete. | |
73 // | |
74 // The signature uses SHA-256 as the hash function and PSS padding in the | |
75 // case of RSA. | |
76 virtual QuicAsyncStatus VerifyProof( | |
77 const std::string& hostname, | |
78 const uint16_t port, | |
79 const std::string& server_config, | |
80 QuicVersion quic_version, | |
81 base::StringPiece chlo_hash, | |
82 const std::vector<std::string>& certs, | |
83 const std::string& cert_sct, | |
84 const std::string& signature, | |
85 const ProofVerifyContext* context, | |
86 std::string* error_details, | |
87 std::unique_ptr<ProofVerifyDetails>* details, | |
88 std::unique_ptr<ProofVerifierCallback> callback) = 0; | |
89 }; | |
90 | |
91 } // namespace net | |
92 | |
93 #endif // NET_QUIC_CRYPTO_PROOF_VERIFIER_H_ | |
OLD | NEW |