| 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 "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "net/base/net_export.h" | 12 #include "net/base/net_export.h" |
| 13 #include "net/quic/quic_types.h" |
| 13 | 14 |
| 14 namespace net { | 15 namespace net { |
| 15 | 16 |
| 16 // ProofVerifyDetails is an abstract class that acts as a container for any | 17 // ProofVerifyDetails is an abstract class that acts as a container for any |
| 17 // implementation specific details that a ProofVerifier wishes to return. These | 18 // implementation specific details that a ProofVerifier wishes to return. These |
| 18 // details are saved in the CachedState for the origin in question. | 19 // details are saved in the CachedState for the origin in question. |
| 19 class NET_EXPORT_PRIVATE ProofVerifyDetails { | 20 class NET_EXPORT_PRIVATE ProofVerifyDetails { |
| 20 public: | 21 public: |
| 21 virtual ~ProofVerifyDetails() {} | 22 virtual ~ProofVerifyDetails() {} |
| 22 }; | 23 }; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 42 // calling |release| on it. | 43 // calling |release| on it. |
| 43 virtual void Run(bool ok, | 44 virtual void Run(bool ok, |
| 44 const std::string& error_details, | 45 const std::string& error_details, |
| 45 scoped_ptr<ProofVerifyDetails>* details) = 0; | 46 scoped_ptr<ProofVerifyDetails>* details) = 0; |
| 46 }; | 47 }; |
| 47 | 48 |
| 48 // A ProofVerifier checks the signature on a server config, and the certificate | 49 // A ProofVerifier checks the signature on a server config, and the certificate |
| 49 // chain that backs the public key. | 50 // chain that backs the public key. |
| 50 class NET_EXPORT_PRIVATE ProofVerifier { | 51 class NET_EXPORT_PRIVATE ProofVerifier { |
| 51 public: | 52 public: |
| 52 // Status enumerates the possible results of verifying a proof. | |
| 53 enum Status { | |
| 54 SUCCESS = 0, | |
| 55 FAILURE = 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() {} | 53 virtual ~ProofVerifier() {} |
| 62 | 54 |
| 63 // VerifyProof checks that |signature| is a valid signature of | 55 // VerifyProof checks that |signature| is a valid signature of |
| 64 // |server_config| by the public key in the leaf certificate of |certs|, and | 56 // |server_config| by the public key in the leaf certificate of |certs|, and |
| 65 // that |certs| is a valid chain for |hostname|. On success, it returns | 57 // that |certs| is a valid chain for |hostname|. On success, it returns |
| 66 // SUCCESS. On failure, it returns ERROR and sets |*error_details| to a | 58 // QUIC_SUCCESS. On failure, it returns QUIC_ERROR and sets |*error_details| |
| 67 // description of the problem. In either case it may set |*details|, which the | 59 // to a description of the problem. In either case it may set |*details|, |
| 68 // caller takes ownership of. | 60 // which the caller takes ownership of. |
| 69 // | 61 // |
| 70 // |context| specifies an implementation specific struct (which may be NULL | 62 // |context| specifies an implementation specific struct (which may be NULL |
| 71 // for some implementations) that provides useful information for the | 63 // for some implementations) that provides useful information for the |
| 72 // verifier, e.g. logging handles. | 64 // verifier, e.g. logging handles. |
| 73 // | 65 // |
| 74 // This function may also return PENDING, in which case the ProofVerifier | 66 // This function may also return QUIC_PENDING, in which case the ProofVerifier |
| 75 // will call back, on the original thread, via |callback| when complete. | 67 // will call back, on the original thread, via |callback| when complete. |
| 76 // In this case, the ProofVerifier will take ownership of |callback|. | 68 // In this case, the ProofVerifier will take ownership of |callback|. |
| 77 // | 69 // |
| 78 // The signature uses SHA-256 as the hash function and PSS padding in the | 70 // The signature uses SHA-256 as the hash function and PSS padding in the |
| 79 // case of RSA. | 71 // case of RSA. |
| 80 virtual Status VerifyProof(const std::string& hostname, | 72 virtual QuicAsyncStatus VerifyProof(const std::string& hostname, |
| 81 const std::string& server_config, | 73 const std::string& server_config, |
| 82 const std::vector<std::string>& certs, | 74 const std::vector<std::string>& certs, |
| 83 const std::string& signature, | 75 const std::string& signature, |
| 84 const ProofVerifyContext* context, | 76 const ProofVerifyContext* context, |
| 85 std::string* error_details, | 77 std::string* error_details, |
| 86 scoped_ptr<ProofVerifyDetails>* details, | 78 scoped_ptr<ProofVerifyDetails>* details, |
| 87 ProofVerifierCallback* callback) = 0; | 79 ProofVerifierCallback* callback) = 0; |
| 88 }; | 80 }; |
| 89 | 81 |
| 90 } // namespace net | 82 } // namespace net |
| 91 | 83 |
| 92 #endif // NET_QUIC_CRYPTO_PROOF_VERIFIER_H_ | 84 #endif // NET_QUIC_CRYPTO_PROOF_VERIFIER_H_ |
| OLD | NEW |