Add details (where missing) for histograms and remove a few that are not worth provid...
[chromium-blink-merge.git] / net / quic / crypto / proof_verifier.h
blob779d63f9bfffc6ae2fe8234a961b50800239d6bf
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_
8 #include <string>
9 #include <vector>
11 #include "base/memory/scoped_ptr.h"
12 #include "net/base/net_export.h"
14 namespace net {
16 // ProofVerifyDetails is an abstract class that acts as a container for any
17 // implementation specific details that a ProofVerifier wishes to return. These
18 // details are saved in the CachedState for the origin in question.
19 class NET_EXPORT_PRIVATE ProofVerifyDetails {
20 public:
21 virtual ~ProofVerifyDetails() {}
24 // ProofVerifyContext is an abstract class that acts as a container for any
25 // implementation specific context that a ProofVerifier needs.
26 class NET_EXPORT_PRIVATE ProofVerifyContext {
27 public:
28 virtual ~ProofVerifyContext() {}
31 // ProofVerifierCallback provides a generic mechanism for a ProofVerifier to
32 // call back after an asynchronous verification.
33 class NET_EXPORT_PRIVATE ProofVerifierCallback {
34 public:
35 virtual ~ProofVerifierCallback() {}
37 // Run is called on the original thread to mark the completion of an
38 // asynchonous verification. If |ok| is true then the certificate is valid
39 // and |*error_details| is unused. Otherwise, |*error_details| contains a
40 // description of the error. |details| contains implementation-specific
41 // details of the verification. |Run| may take ownership of |details| by
42 // calling |release| on it.
43 virtual void Run(bool ok,
44 const std::string& error_details,
45 scoped_ptr<ProofVerifyDetails>* details) = 0;
48 // A ProofVerifier checks the signature on a server config, and the certificate
49 // chain that backs the public key.
50 class NET_EXPORT_PRIVATE ProofVerifier {
51 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,
61 virtual ~ProofVerifier() {}
63 // VerifyProof checks that |signature| is a valid signature of
64 // |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
66 // SUCCESS. On failure, it returns ERROR and sets |*error_details| to a
67 // description of the problem. In either case it may set |*details|, which the
68 // caller takes ownership of.
70 // |context| specifies an implementation specific struct (which may be NULL
71 // for some implementations) that provides useful information for the
72 // verifier, e.g. logging handles.
74 // This function may also return PENDING, in which case the ProofVerifier
75 // will call back, on the original thread, via |callback| when complete.
76 // In this case, the ProofVerifier will take ownership of |callback|.
78 // The signature uses SHA-256 as the hash function and PSS padding in the
79 // case of RSA.
80 virtual Status VerifyProof(const std::string& hostname,
81 const std::string& server_config,
82 const std::vector<std::string>& certs,
83 const std::string& signature,
84 const ProofVerifyContext* context,
85 std::string* error_details,
86 scoped_ptr<ProofVerifyDetails>* details,
87 ProofVerifierCallback* callback) = 0;
90 } // namespace net
92 #endif // NET_QUIC_CRYPTO_PROOF_VERIFIER_H_