1 // Copyright (c) 2012 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_QUIC_CRYPTO_CLIENT_STREAM_H_
6 #define NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_
10 #include "net/cert/cert_verify_result.h"
11 #include "net/cert/x509_certificate.h"
12 #include "net/quic/crypto/proof_verifier.h"
13 #include "net/quic/crypto/quic_crypto_client_config.h"
14 #include "net/quic/quic_config.h"
15 #include "net/quic/quic_crypto_stream.h"
19 class ProofVerifyDetails;
24 class CryptoTestUtils;
27 class NET_EXPORT_PRIVATE QuicCryptoClientStream : public QuicCryptoStream {
29 QuicCryptoClientStream(const string& server_hostname,
31 QuicCryptoClientConfig* crypto_config);
32 virtual ~QuicCryptoClientStream();
34 // CryptoFramerVisitorInterface implementation
35 virtual void OnHandshakeMessage(
36 const CryptoHandshakeMessage& message) OVERRIDE;
38 // Performs a crypto handshake with the server. Returns true if the crypto
39 // handshake is started successfully.
40 // TODO(agl): this should probably return void.
41 virtual bool CryptoConnect();
43 // num_sent_client_hellos returns the number of client hello messages that
44 // have been sent. If the handshake has completed then this is one greater
45 // than the number of round-trips needed for the handshake.
46 int num_sent_client_hellos() const;
48 // Gets the SSL connection information.
49 bool GetSSLInfo(SSLInfo* ssl_info);
52 // ProofVerifierCallbackImpl is passed as the callback method to VerifyProof.
53 // The ProofVerifier calls this class with the result of proof verification
54 // when verification is performed asynchronously.
55 class ProofVerifierCallbackImpl : public ProofVerifierCallback {
57 explicit ProofVerifierCallbackImpl(QuicCryptoClientStream* stream);
58 virtual ~ProofVerifierCallbackImpl();
60 // ProofVerifierCallback interface.
61 virtual void Run(bool ok,
62 const string& error_details,
63 scoped_ptr<ProofVerifyDetails>* details) OVERRIDE;
65 // Cancel causes any future callbacks to be ignored. It must be called on
66 // the same thread as the callback will be made on.
70 QuicCryptoClientStream* stream_;
73 friend class test::CryptoTestUtils;
74 friend class ProofVerifierCallbackImpl;
81 STATE_VERIFY_PROOF_COMPLETE,
85 // DoHandshakeLoop performs a step of the handshake state machine. Note that
86 // |in| may be NULL if the call did not result from a received message
87 void DoHandshakeLoop(const CryptoHandshakeMessage* in);
90 // num_client_hellos_ contains the number of client hello messages that this
91 // connection has sent.
92 int num_client_hellos_;
94 QuicCryptoClientConfig* const crypto_config_;
96 // Client's connection nonce (4-byte timestamp + 28 random bytes)
99 std::string server_hostname_;
101 // Generation counter from QuicCryptoClientConfig's CachedState.
102 uint64 generation_counter_;
104 // proof_verify_callback_ contains the callback object that we passed to an
105 // asynchronous proof verification. The ProofVerifier owns this object.
106 ProofVerifierCallbackImpl* proof_verify_callback_;
108 // These members are used to store the result of an asynchronous proof
109 // verification. These members must not be used after
110 // STATE_VERIFY_PROOF_COMPLETE.
112 string verify_error_details_;
113 scoped_ptr<ProofVerifyDetails> verify_details_;
115 // The result of certificate verification.
116 scoped_ptr<CertVerifyResult> cert_verify_result_;
118 DISALLOW_COPY_AND_ASSIGN(QuicCryptoClientStream);
123 #endif // NET_QUIC_QUIC_CRYPTO_CLIENT_STREAM_H_