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_SERVER_STREAM_H_
6 #define NET_QUIC_QUIC_CRYPTO_SERVER_STREAM_H_
10 #include "net/quic/crypto/crypto_handshake.h"
11 #include "net/quic/crypto/quic_crypto_server_config.h"
12 #include "net/quic/quic_config.h"
13 #include "net/quic/quic_crypto_stream.h"
17 class CryptoHandshakeMessage
;
18 class QuicCryptoServerConfig
;
22 class CryptoTestUtils
;
25 class NET_EXPORT_PRIVATE QuicCryptoServerStream
: public QuicCryptoStream
{
27 QuicCryptoServerStream(const QuicCryptoServerConfig
& crypto_config
,
28 QuicSession
* session
);
29 explicit QuicCryptoServerStream(QuicSession
* session
);
30 virtual ~QuicCryptoServerStream();
32 // CryptoFramerVisitorInterface implementation
33 virtual void OnHandshakeMessage(
34 const CryptoHandshakeMessage
& message
) OVERRIDE
;
36 // GetBase64SHA256ClientChannelID sets |*output| to the base64 encoded,
37 // SHA-256 hash of the client's ChannelID key and returns true, if the client
38 // presented a ChannelID. Otherwise it returns false.
39 bool GetBase64SHA256ClientChannelID(std::string
* output
) const;
42 virtual QuicErrorCode
ProcessClientHello(
43 const CryptoHandshakeMessage
& message
,
44 const ValidateClientHelloResultCallback::Result
& result
,
45 CryptoHandshakeMessage
* reply
,
46 std::string
* error_details
);
49 friend class test::CryptoTestUtils
;
51 class ValidateCallback
: public ValidateClientHelloResultCallback
{
53 explicit ValidateCallback(QuicCryptoServerStream
* parent
);
54 // To allow the parent to detach itself from the callback before deletion.
57 // From ValidateClientHelloResultCallback
58 virtual void RunImpl(const CryptoHandshakeMessage
& client_hello
,
59 const Result
& result
) OVERRIDE
;
62 QuicCryptoServerStream
* parent_
;
64 DISALLOW_COPY_AND_ASSIGN(ValidateCallback
);
67 // Invoked by ValidateCallback::RunImpl once initial validation of
68 // the client hello is complete. Finishes processing of the client
69 // hello message and handles handshake success/failure.
70 void FinishProcessingHandshakeMessage(
71 const CryptoHandshakeMessage
& message
,
72 const ValidateClientHelloResultCallback::Result
& result
);
74 // crypto_config_ contains crypto parameters for the handshake.
75 const QuicCryptoServerConfig
& crypto_config_
;
77 // Pointer to the active callback that will receive the result of
78 // the client hello validation request and forward it to
79 // FinishProcessingHandshakeMessage for processing. NULL if no
80 // handshake message is being validated.
81 ValidateCallback
* validate_client_hello_cb_
;
86 #endif // NET_QUIC_QUIC_CRYPTO_SERVER_STREAM_H_