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 NET_EXPORT_PRIVATE 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. |Run| may take ownership of |details| by |
| 37 // calling |release| on it. |
| 38 virtual void Run(bool ok, |
| 39 const std::string& error_details, |
| 40 scoped_ptr<ProofVerifyDetails>* details) = 0; |
| 41 }; |
| 42 |
18 // A ProofVerifier checks the signature on a server config, and the certificate | 43 // A ProofVerifier checks the signature on a server config, and the certificate |
19 // chain that backs the public key. | 44 // chain that backs the public key. |
20 class NET_EXPORT_PRIVATE ProofVerifier { | 45 class NET_EXPORT_PRIVATE ProofVerifier { |
21 public: | 46 public: |
22 virtual ~ProofVerifier() {} | 47 // Status enumerates the possible results of verifying a proof. |
| 48 enum Status { |
| 49 SUCCESS = 0, |
| 50 FAILURE = 1, |
| 51 // PENDING results from a verification which will occur asynchonously. When |
| 52 // the verification is complete, |callback|'s |Run| method will be called. |
| 53 PENDING = 2, |
| 54 }; |
| 55 |
| 56 virtual ~ProofVerifier(); |
23 | 57 |
24 // VerifyProof checks that |signature| is a valid signature of | 58 // VerifyProof checks that |signature| is a valid signature of |
25 // |server_config| by the public key in the leaf certificate of |certs|, and | 59 // |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. | 60 // that |certs| is a valid chain for |hostname|. On success, it returns |
27 // On failure, it returns ERR_FAILED and sets |*error_details| to a | 61 // SUCCESS. On failure, it returns ERROR and sets |*error_details| to a |
28 // description of the problem. This function may also return ERR_IO_PENDING, | 62 // description of the problem. In either case it may set |*details|, which the |
29 // in which case the |callback| will be run on the calling thread with the | 63 // caller takes ownership of. |
30 // final OK/ERR_FAILED result when the proof is verified. | 64 // |
| 65 // This function may also return PENDING, in which case the ProofVerifier |
| 66 // will call back, on the original thread, via |callback| when complete. |
| 67 // |
| 68 // This function takes ownership of |callback|. It will be deleted even if |
| 69 // the call returns immediately. |
31 // | 70 // |
32 // The signature uses SHA-256 as the hash function and PSS padding in the | 71 // The signature uses SHA-256 as the hash function and PSS padding in the |
33 // case of RSA. | 72 // case of RSA. |
34 // | 73 virtual Status VerifyProof(const std::string& hostname, |
35 // Note: this is just for testing. The CN of the certificate is ignored and | 74 const std::string& server_config, |
36 // wildcards in the SANs are not supported. | 75 const std::vector<std::string>& certs, |
37 virtual int VerifyProof(const std::string& hostname, | 76 const std::string& signature, |
38 const std::string& server_config, | 77 std::string* error_details, |
39 const std::vector<std::string>& certs, | 78 scoped_ptr<ProofVerifyDetails>* details, |
40 const std::string& signature, | 79 ProofVerifierCallback* callback) = 0; |
41 std::string* error_details, | |
42 CertVerifyResult* cert_verify_result, | |
43 const CompletionCallback& callback) = 0; | |
44 }; | 80 }; |
45 | 81 |
46 } // namespace net | 82 } // namespace net |
47 | 83 |
48 #endif // NET_QUIC_CRYPTO_PROOF_VERIFIER_H_ | 84 #endif // NET_QUIC_CRYPTO_PROOF_VERIFIER_H_ |
OLD | NEW |