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/crypto_utils.h" |
8 #include "net/quic/quic_protocol.h" | 9 #include "net/quic/quic_protocol.h" |
| 10 #include "net/quic/quic_session.h" |
9 | 11 |
10 namespace net { | 12 namespace net { |
11 | 13 |
12 QuicCryptoClientStream::QuicCryptoClientStream(QuicSession* session) | 14 QuicCryptoClientStream::QuicCryptoClientStream(QuicSession* session) |
13 : QuicCryptoStream(session) { | 15 : QuicCryptoStream(session) { |
14 } | 16 } |
15 | 17 |
16 | 18 |
17 void QuicCryptoClientStream::OnHandshakeMessage( | 19 void QuicCryptoClientStream::OnHandshakeMessage( |
18 const CryptoHandshakeMessage& message) { | 20 const CryptoHandshakeMessage& message) { |
19 // Do not process handshake messages after the handshake is complete. | 21 // Do not process handshake messages after the handshake is complete. |
20 if (handshake_complete()) { | 22 if (handshake_complete()) { |
21 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); | 23 CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); |
22 return; | 24 return; |
23 } | 25 } |
24 | 26 |
25 if (message.tag != kSHLO) { | 27 if (message.tag != kSHLO) { |
26 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE); | 28 CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE); |
27 return; | 29 return; |
28 } | 30 } |
29 | 31 |
30 // TODO(rch): correctly validate the message | 32 // TODO(rch): correctly validate the message |
31 SetHandshakeComplete(QUIC_NO_ERROR); | 33 SetHandshakeComplete(QUIC_NO_ERROR); |
32 return; | 34 return; |
33 } | 35 } |
34 | 36 |
| 37 bool QuicCryptoClientStream::CryptoConnect() { |
| 38 client_crypto_config_.SetDefaults(); |
| 39 CryptoUtils::GenerateNonce(session()->connection()->clock(), |
| 40 session()->connection()->random_generator(), |
| 41 &nonce_); |
| 42 CryptoHandshakeMessage message; |
| 43 CryptoUtils::FillClientHelloMessage(client_crypto_config_, nonce_, &message); |
| 44 SendHandshakeMessage(message); |
| 45 return true; |
| 46 } |
| 47 |
35 } // namespace net | 48 } // namespace net |
OLD | NEW |