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_STREAM_H_
6 #define NET_QUIC_QUIC_CRYPTO_STREAM_H_
8 #include "net/quic/crypto/crypto_framer.h"
9 #include "net/quic/crypto/crypto_utils.h"
10 #include "net/quic/quic_protocol.h"
11 #include "net/quic/reliable_quic_stream.h"
15 class CryptoHandshakeMessage
;
18 // Crypto handshake messages in QUIC take place over a reserved
19 // reliable stream with the id 1. Each endpoint (client and server)
20 // will allocate an instance of a subclass of QuicCryptoStream
21 // to send and receive handshake messages. (In the normal 1-RTT
22 // handshake, the client will send a client hello, CHLO, message.
23 // The server will receive this message and respond with a server
24 // hello message, SHLO. At this point both sides will have established
25 // a crypto context they can use to send encrypted messages.
27 // For more details: http://goto.google.com/quic-crypto
28 class NET_EXPORT_PRIVATE QuicCryptoStream
29 : public ReliableQuicStream
,
30 public CryptoFramerVisitorInterface
{
32 explicit QuicCryptoStream(QuicSession
* session
);
34 // CryptoFramerVisitorInterface implementation
35 virtual void OnError(CryptoFramer
* framer
) OVERRIDE
;
36 virtual void OnHandshakeMessage(const CryptoHandshakeMessage
& message
) = 0;
38 // ReliableQuicStream implementation
39 virtual uint32
ProcessData(const char* data
, uint32 data_len
) OVERRIDE
;
41 // Sends |message| to the peer.
42 // TODO(wtc): return a success/failure status.
43 void SendHandshakeMessage(const CryptoHandshakeMessage
& message
);
45 bool handshake_complete() { return handshake_complete_
; }
48 // Closes the connection
49 void CloseConnection(QuicErrorCode error
);
50 void CloseConnectionWithDetails(QuicErrorCode error
, const string
& details
);
52 void SetHandshakeComplete(QuicErrorCode error
);
55 CryptoFramer crypto_framer_
;
56 bool handshake_complete_
;
58 DISALLOW_COPY_AND_ASSIGN(QuicCryptoStream
);
63 #endif // NET_QUIC_QUIC_CRYPTO_STREAM_H_