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.
5 #ifndef NET_QUIC_CRYPTO_PROOF_VERIFIER_H_
6 #define NET_QUIC_CRYPTO_PROOF_VERIFIER_H_
11 #include "base/memory/scoped_ptr.h"
12 #include "net/base/net_export.h"
13 #include "net/quic/quic_types.h"
17 // ProofVerifyDetails is an abstract class that acts as a container for any
18 // implementation specific details that a ProofVerifier wishes to return. These
19 // details are saved in the CachedState for the origin in question.
20 class NET_EXPORT_PRIVATE ProofVerifyDetails
{
22 virtual ~ProofVerifyDetails() {}
25 // ProofVerifyContext is an abstract class that acts as a container for any
26 // implementation specific context that a ProofVerifier needs.
27 class NET_EXPORT_PRIVATE ProofVerifyContext
{
29 virtual ~ProofVerifyContext() {}
32 // ProofVerifierCallback provides a generic mechanism for a ProofVerifier to
33 // call back after an asynchronous verification.
34 class NET_EXPORT_PRIVATE ProofVerifierCallback
{
36 virtual ~ProofVerifierCallback() {}
38 // Run is called on the original thread to mark the completion of an
39 // asynchonous verification. If |ok| is true then the certificate is valid
40 // and |error_details| is unused. Otherwise, |error_details| contains a
41 // description of the error. |details| contains implementation-specific
42 // details of the verification. |Run| may take ownership of |details| by
43 // calling |release| on it.
44 virtual void Run(bool ok
,
45 const std::string
& error_details
,
46 scoped_ptr
<ProofVerifyDetails
>* details
) = 0;
49 // A ProofVerifier checks the signature on a server config, and the certificate
50 // chain that backs the public key.
51 class NET_EXPORT_PRIVATE ProofVerifier
{
53 virtual ~ProofVerifier() {}
55 // VerifyProof checks that |signature| is a valid signature of
56 // |server_config| by the public key in the leaf certificate of |certs|, and
57 // that |certs| is a valid chain for |hostname|. On success, it returns
58 // QUIC_SUCCESS. On failure, it returns QUIC_FAILURE and sets |*error_details|
59 // to a description of the problem. In either case it may set |*details|,
60 // which the caller takes ownership of.
62 // |context| specifies an implementation specific struct (which may be NULL
63 // for some implementations) that provides useful information for the
64 // verifier, e.g. logging handles.
66 // This function may also return QUIC_PENDING, in which case the ProofVerifier
67 // will call back, on the original thread, via |callback| when complete.
68 // In this case, the ProofVerifier will take ownership of |callback|.
70 // The signature uses SHA-256 as the hash function and PSS padding in the
72 virtual QuicAsyncStatus
VerifyProof(const std::string
& hostname
,
73 const std::string
& server_config
,
74 const std::vector
<std::string
>& certs
,
75 const std::string
& signature
,
76 const ProofVerifyContext
* context
,
77 std::string
* error_details
,
78 scoped_ptr
<ProofVerifyDetails
>* details
,
79 ProofVerifierCallback
* callback
) = 0;
84 #endif // NET_QUIC_CRYPTO_PROOF_VERIFIER_H_