OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef NET_QUIC_CRYPTO_PROOF_VERIFIER_H_ | 5 #ifndef NET_QUIC_CRYPTO_PROOF_VERIFIER_H_ |
6 #define NET_QUIC_CRYPTO_PROOF_VERIFIER_H_ | 6 #define NET_QUIC_CRYPTO_PROOF_VERIFIER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "net/base/completion_callback.h" | 11 #include "net/base/completion_callback.h" |
12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 class CertVerifyResult; | 16 class CertVerifyResult; |
17 | 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 CachedInfo for the origin in question. | |
21 class ProofVerifyDetails { | |
22 public: | |
23 virtual ~ProofVerifyDetails(); | |
24 }; | |
25 | |
26 // ProofVerifierCallback provides a generic mechanism for a ProofVerifier to | |
27 // call back after an asynchronous verification. | |
28 class ProofVerifierCallback { | |
29 public: | |
30 virtual ~ProofVerifierCallback(); | |
31 | |
32 // Run is called on the original thread to mark the completion of an | |
33 // asynchonous verification. If |ok| is true then the certificate is valid | |
34 // and |*error_details| is unused. Otherwise, |*error_details| contains a | |
35 // description of the error. |details| contains implementation-specific | |
36 // details of the verification. | |
37 // | |
38 // |error_details| is owned by the ProofVerifier and is valid only for the | |
39 // duration of |Run|. | |
40 // | |
41 // |details| is owned by the callback and the callback must delete it if not | |
Ryan Hamilton
2013/07/23 18:40:50
Is |details| owned by the callback to avoid a buff
agl
2013/07/23 21:04:57
|details| is owned by the callback because the int
| |
42 // NULL. | |
43 virtual void Run(bool ok, | |
44 std::string* error_details, | |
45 ProofVerifyDetails* details) = 0; | |
46 }; | |
47 | |
18 // A ProofVerifier checks the signature on a server config, and the certificate | 48 // A ProofVerifier checks the signature on a server config, and the certificate |
19 // chain that backs the public key. | 49 // chain that backs the public key. |
20 class NET_EXPORT_PRIVATE ProofVerifier { | 50 class NET_EXPORT_PRIVATE ProofVerifier { |
21 public: | 51 public: |
22 virtual ~ProofVerifier() {} | 52 // Status enumerates the possible results of verifying a proof. |
53 enum Status { | |
54 OK = 0, | |
55 ERROR = 1, | |
56 // PENDING results from a verification which will occur asynchonously. When | |
57 // the verification is complete, |callback|'s |Run| method will be called. | |
58 PENDING = 2, | |
59 }; | |
60 | |
61 virtual ~ProofVerifier(); | |
23 | 62 |
24 // VerifyProof checks that |signature| is a valid signature of | 63 // VerifyProof checks that |signature| is a valid signature of |
25 // |server_config| by the public key in the leaf certificate of |certs|, and | 64 // |server_config| by the public key in the leaf certificate of |certs|, and |
26 // that |certs| is a valid chain for |hostname|. On success, it returns OK. | 65 // that |certs| is a valid chain for |hostname|. On success, it returns OK. |
27 // On failure, it returns ERR_FAILED and sets |*error_details| to a | 66 // On failure, it returns ERROR and sets |*error_details| to a description of |
28 // description of the problem. This function may also return ERR_IO_PENDING, | 67 // the problem. In either case it may set |*details|, which the caller takes |
29 // in which case the |callback| will be run on the calling thread with the | 68 // ownership of. |
30 // final OK/ERR_FAILED result when the proof is verified. | 69 // |
70 // This function may also return PENDING, in which case the ProofVerifier | |
71 // will call back, on the original thread, via |callback| when complete. | |
72 // | |
73 // This function takes ownership of |callback|. It will be deleted even if | |
74 // the call returns immediately. | |
31 // | 75 // |
32 // The signature uses SHA-256 as the hash function and PSS padding in the | 76 // The signature uses SHA-256 as the hash function and PSS padding in the |
33 // case of RSA. | 77 // case of RSA. |
34 // | 78 virtual Status VerifyProof(const std::string& hostname, |
35 // Note: this is just for testing. The CN of the certificate is ignored and | 79 const std::string& server_config, |
36 // wildcards in the SANs are not supported. | 80 const std::vector<std::string>& certs, |
37 virtual int VerifyProof(const std::string& hostname, | 81 const std::string& signature, |
38 const std::string& server_config, | 82 std::string* error_details, |
39 const std::vector<std::string>& certs, | 83 scoped_ptr<ProofVerifyDetails>* details, |
40 const std::string& signature, | 84 ProofVerifierCallback* callback) = 0; |
41 std::string* error_details, | |
42 CertVerifyResult* cert_verify_result, | |
43 const CompletionCallback& callback) = 0; | |
44 }; | 85 }; |
45 | 86 |
46 } // namespace net | 87 } // namespace net |
47 | 88 |
48 #endif // NET_QUIC_CRYPTO_PROOF_VERIFIER_H_ | 89 #endif // NET_QUIC_CRYPTO_PROOF_VERIFIER_H_ |
OLD | NEW |