OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/quic/quic_crypto_client_stream.h" | 5 #include "net/quic/quic_crypto_client_stream.h" |
6 | 6 |
7 #include "net/quic/crypto/crypto_protocol.h" | 7 #include "net/quic/crypto/crypto_protocol.h" |
| 8 #include "net/quic/crypto/quic_random.h" |
| 9 #include "net/quic/quic_clock.h" |
8 #include "net/quic/quic_protocol.h" | 10 #include "net/quic/quic_protocol.h" |
| 11 #include "net/quic/quic_session.h" |
| 12 #include "net/quic/quic_utils.h" |
| 13 |
| 14 using base::StringPiece; |
9 | 15 |
10 namespace net { | 16 namespace net { |
11 | 17 |
12 QuicCryptoClientStream::QuicCryptoClientStream(QuicSession* session) | 18 QuicCryptoClientStream::QuicCryptoClientStream(QuicSession* session) |
13 : QuicCryptoStream(session) { | 19 : QuicCryptoStream(session) { |
14 } | 20 } |
15 | 21 |
16 | 22 |
17 void QuicCryptoClientStream::OnHandshakeMessage( | 23 void QuicCryptoClientStream::OnHandshakeMessage( |
18 const CryptoHandshakeMessage& message) { | 24 const CryptoHandshakeMessage& message) { |
19 // Do not process handshake messages after the handshake is complete. | 25 // Do not process handshake messages after the handshake is complete. |
20 if (handshake_complete()) { | 26 if (handshake_complete()) { |
21 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); | 27 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); |
22 return; | 28 return; |
23 } | 29 } |
24 | 30 |
25 if (message.tag != kSHLO) { | 31 if (message.tag != kSHLO) { |
26 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE); | 32 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE); |
27 return; | 33 return; |
28 } | 34 } |
29 | 35 |
30 // TODO(rch): correctly validate the message | 36 // TODO(rch): correctly validate the message |
31 SetHandshakeComplete(QUIC_NO_ERROR); | 37 SetHandshakeComplete(QUIC_NO_ERROR); |
32 return; | 38 return; |
33 } | 39 } |
34 | 40 |
| 41 bool QuicCryptoClientStream::CryptoConnect() { |
| 42 QuicUtils::GenerateNonce(session()->connection()->clock(), |
| 43 session()->connection()->random_generator(), |
| 44 &nonce_); |
| 45 CryptoHandshakeMessage message; |
| 46 QuicUtils::FillClientHelloMessage(client_hello_config_, nonce_, &message); |
| 47 SendHandshakeMessage(message); |
| 48 return true; |
| 49 } |
| 50 |
35 } // namespace net | 51 } // namespace net |
OLD | NEW |