diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 02:51:54 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-30 02:51:54 +0000 |
commit | d3d15bfacd20d9e5cd6f23c34ab305029c0d50f6 (patch) | |
tree | fd0db21ea730ea547d2342c12f36dc554f946d96 /net | |
parent | 61df9d8dd488faa6a5d0f399f185003cdbe501b9 (diff) | |
download | chromium_src-d3d15bfacd20d9e5cd6f23c34ab305029c0d50f6.zip chromium_src-d3d15bfacd20d9e5cd6f23c34ab305029c0d50f6.tar.gz chromium_src-d3d15bfacd20d9e5cd6f23c34ab305029c0d50f6.tar.bz2 |
The first step of server-side crypto handshake: handle ClientHello,
negotiate parameters, and respond with ServerHello. Still incomplete.
Add the CloseConnectionWithDetails and SendConnectionCloseWithDetails
methods to allow specifying an error details string.
Merge internal CL: 41642399
R=rch@chromium.org
BUG=none
TEST=none
Review URL: https://chromiumcodereview.appspot.com/12078004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@179519 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/quic/crypto/crypto_framer.h | 5 | ||||
-rw-r--r-- | net/quic/crypto/crypto_protocol.cc | 65 | ||||
-rw-r--r-- | net/quic/crypto/crypto_protocol.h | 34 | ||||
-rw-r--r-- | net/quic/crypto/crypto_utils.cc | 71 | ||||
-rw-r--r-- | net/quic/crypto/crypto_utils.h | 24 | ||||
-rw-r--r-- | net/quic/quic_connection.cc | 7 | ||||
-rw-r--r-- | net/quic/quic_connection.h | 2 | ||||
-rw-r--r-- | net/quic/quic_crypto_client_stream.cc | 4 | ||||
-rw-r--r-- | net/quic/quic_crypto_client_stream.h | 2 | ||||
-rw-r--r-- | net/quic/quic_crypto_stream.cc | 5 | ||||
-rw-r--r-- | net/quic/quic_crypto_stream.h | 1 | ||||
-rw-r--r-- | net/quic/quic_protocol.h | 12 | ||||
-rw-r--r-- | net/quic/quic_utils.cc | 3 | ||||
-rw-r--r-- | net/quic/test_tools/quic_test_utils.cc | 45 | ||||
-rw-r--r-- | net/quic/test_tools/quic_test_utils.h | 5 |
15 files changed, 217 insertions, 68 deletions
diff --git a/net/quic/crypto/crypto_framer.h b/net/quic/crypto/crypto_framer.h index 894563d..34966fc 100644 --- a/net/quic/crypto/crypto_framer.h +++ b/net/quic/crypto/crypto_framer.h @@ -34,7 +34,8 @@ class NET_EXPORT_PRIVATE CryptoFramerVisitorInterface { const CryptoHandshakeMessage& message) = 0; }; -// A class for framing the crypto message that are exchanged in a QUIC session. +// A class for framing the crypto messages that are exchanged in a QUIC +// session. class NET_EXPORT_PRIVATE CryptoFramer { public: CryptoFramer(); @@ -75,7 +76,7 @@ class NET_EXPORT_PRIVATE CryptoFramer { error_ = error; } - // Represents the current state of the framing state machine. + // Represents the current state of the parsing state machine. enum CryptoFramerState { STATE_READING_TAG, STATE_READING_NUM_ENTRIES, diff --git a/net/quic/crypto/crypto_protocol.cc b/net/quic/crypto/crypto_protocol.cc index e9220ec..30a1cdc 100644 --- a/net/quic/crypto/crypto_protocol.cc +++ b/net/quic/crypto/crypto_protocol.cc @@ -9,15 +9,15 @@ namespace net { CryptoHandshakeMessage::CryptoHandshakeMessage() {} CryptoHandshakeMessage::~CryptoHandshakeMessage() {} -QuicClientCryptoConfig::QuicClientCryptoConfig() +QuicCryptoConfig::QuicCryptoConfig() : version(0), idle_connection_state_lifetime(QuicTime::Delta::Zero()), keepalive_timeout(QuicTime::Delta::Zero()) { } -QuicClientCryptoConfig::~QuicClientCryptoConfig() {} +QuicCryptoConfig::~QuicCryptoConfig() {} -void QuicClientCryptoConfig::SetDefaults() { +void QuicCryptoConfig::SetClientDefaults() { // Version must be 0. version = 0; @@ -32,14 +32,71 @@ void QuicClientCryptoConfig::SetDefaults() { aead[1] = kAESH; // Congestion control feedback types. + // TODO(wtc): add kINAR when inter-arrival is supported. congestion_control.resize(1); congestion_control[0] = kQBIC; // Idle connection state lifetime. - idle_connection_state_lifetime = QuicTime::Delta::FromMilliseconds(300000); + idle_connection_state_lifetime = QuicTime::Delta::FromSeconds(300); // Keepalive timeout. keepalive_timeout = QuicTime::Delta::Zero(); // Don't send keepalive probes. } +void QuicCryptoConfig::SetServerDefaults() { + // Version must be 0. + version = 0; + + // Key exchange methods. + // Add only NIST curve P-256 for now to ensure it is selected. + key_exchange.resize(1); + key_exchange[0] = kP256; + + // Authenticated encryption algorithms. + // Add only AES-GCM for now to ensure it is selected. + aead.resize(1); + aead[0] = kAESG; + + // Congestion control feedback types. + // TODO(wtc): add kINAR when inter-arrival is supported. + congestion_control.resize(1); + congestion_control[0] = kQBIC; + + // Idle connection state lifetime. + idle_connection_state_lifetime = QuicTime::Delta::FromSeconds(300); + + // Keepalive timeout. + keepalive_timeout = QuicTime::Delta::Zero(); // Don't send keepalive probes. +} + +QuicCryptoNegotiatedParams::QuicCryptoNegotiatedParams() + : version(0), + key_exchange(0), + aead(0), + congestion_control(0), + idle_connection_state_lifetime(QuicTime::Delta::Zero()) { +} + +QuicCryptoNegotiatedParams::~QuicCryptoNegotiatedParams() {} + +void QuicCryptoNegotiatedParams::SetDefaults() { + // TODO(wtc): actually negotiate the parameters using client defaults + // and server defaults. + + // Version must be 0. + version = 0; + + // Key exchange method. + key_exchange = kP256; + + // Authenticated encryption algorithm. + aead = kAESG; + + // Congestion control feedback type. + congestion_control = kQBIC; + + // Idle connection state lifetime. + idle_connection_state_lifetime = QuicTime::Delta::FromSeconds(300); +} + } // namespace net diff --git a/net/quic/crypto/crypto_protocol.h b/net/quic/crypto/crypto_protocol.h index b473160..f3fde8b 100644 --- a/net/quic/crypto/crypto_protocol.h +++ b/net/quic/crypto/crypto_protocol.h @@ -19,6 +19,8 @@ namespace net { typedef uint32 CryptoTag; typedef std::map<CryptoTag, std::string> CryptoTagValueMap; typedef std::vector<CryptoTag> CryptoTagVector; +// An intermediate format of a handshake message that's convenient for a +// CryptoFramer to serialize from or parse into. struct NET_EXPORT_PRIVATE CryptoHandshakeMessage { CryptoHandshakeMessage(); ~CryptoHandshakeMessage(); @@ -70,14 +72,15 @@ const size_t kMaxEntries = 16; // Max number of entries in a message. const size_t kNonceSize = 32; // Size in bytes of the connection nonce. -// Client-side crypto configuration settings. -struct NET_EXPORT_PRIVATE QuicClientCryptoConfig { +// Crypto configuration settings. +struct NET_EXPORT_PRIVATE QuicCryptoConfig { // Initializes the members to 0 or empty values. - QuicClientCryptoConfig(); - ~QuicClientCryptoConfig(); + QuicCryptoConfig(); + ~QuicCryptoConfig(); - // Sets the members to default values. - void SetDefaults(); + // Sets the members to client-side or server-side default values. + void SetClientDefaults(); + void SetServerDefaults(); // Protocol version uint16 version; @@ -91,8 +94,23 @@ struct NET_EXPORT_PRIVATE QuicClientCryptoConfig { QuicTime::Delta idle_connection_state_lifetime; // Keepalive timeout, or 0 to turn off keepalive probes QuicTime::Delta keepalive_timeout; - // Server's hostname - std::string server_hostname; +}; + +// Parameters negotiated by the crypto handshake. +struct NET_EXPORT_PRIVATE QuicCryptoNegotiatedParams { + // Initializes the members to 0 or empty values. + QuicCryptoNegotiatedParams(); + ~QuicCryptoNegotiatedParams(); + + // Sets the members to the values that would be negotiated from the default + // client-side and server-side configuration settings. + void SetDefaults(); + + uint16 version; + CryptoTag key_exchange; + CryptoTag aead; + CryptoTag congestion_control; + QuicTime::Delta idle_connection_state_lifetime; }; } // namespace net diff --git a/net/quic/crypto/crypto_utils.cc b/net/quic/crypto/crypto_utils.cc index 976e93d..b381682 100644 --- a/net/quic/crypto/crypto_utils.cc +++ b/net/quic/crypto/crypto_utils.cc @@ -28,44 +28,35 @@ void CryptoUtils::GenerateNonce(const QuicClock* clock, random_generator->RandBytes(&(*nonce)[time_size], kNonceSize - time_size); } -void CryptoUtils::FillClientHelloMessage(const QuicClientCryptoConfig& config, - const string& nonce, - const string& server_hostname, - CryptoHandshakeMessage* message) { +void CryptoUtils::FillClientHelloMessage( + const QuicCryptoConfig& client_config, + const string& nonce, + const string& server_hostname, + CryptoHandshakeMessage* message) { message->tag = kCHLO; - StringPiece value; - // Version. - value.set(&config.version, sizeof(config.version)); - message->tag_value_map[kVERS] = value.as_string(); + message->tag_value_map[kVERS] = EncodeSingleValue(client_config.version); // Key exchange methods. - value.set(&config.key_exchange[0], - config.key_exchange.size() * sizeof(config.key_exchange[0])); - message->tag_value_map[kKEXS] = value.as_string(); + message->tag_value_map[kKEXS] = EncodeVectorValue(client_config.key_exchange); // Authenticated encryption algorithms. - value.set(&config.aead[0], config.aead.size() * sizeof(config.aead[0])); - message->tag_value_map[kAEAD] = value.as_string(); + message->tag_value_map[kAEAD] = EncodeVectorValue(client_config.aead); // Congestion control feedback types. - value.set(&config.congestion_control[0], - config.congestion_control.size() * - sizeof(config.congestion_control[0])); - message->tag_value_map[kCGST] = value.as_string(); + message->tag_value_map[kCGST] = + EncodeVectorValue(client_config.congestion_control); // Idle connection state lifetime. uint32 idle_connection_state_lifetime_secs = - config.idle_connection_state_lifetime.ToSeconds(); - value.set(&idle_connection_state_lifetime_secs, - sizeof(idle_connection_state_lifetime_secs)); - message->tag_value_map[kICSL] = value.as_string(); + client_config.idle_connection_state_lifetime.ToSeconds(); + message->tag_value_map[kICSL] = + EncodeSingleValue(idle_connection_state_lifetime_secs); // Keepalive timeout. - uint32 keepalive_timeout_secs = config.keepalive_timeout.ToSeconds(); - value.set(&keepalive_timeout_secs, sizeof(keepalive_timeout_secs)); - message->tag_value_map[kKATO] = value.as_string(); + uint32 keepalive_timeout_secs = client_config.keepalive_timeout.ToSeconds(); + message->tag_value_map[kKATO] = EncodeSingleValue(keepalive_timeout_secs); // Connection nonce. message->tag_value_map[kNONC] = nonce; @@ -79,4 +70,36 @@ void CryptoUtils::FillClientHelloMessage(const QuicClientCryptoConfig& config, } } +void CryptoUtils::FillServerHelloMessage( + const QuicCryptoNegotiatedParams& negotiated_params, + const string& nonce, + CryptoHandshakeMessage* message) { + message->tag = kSHLO; + + // Version. + message->tag_value_map[kVERS] = EncodeSingleValue(negotiated_params.version); + + // Key exchange method. + message->tag_value_map[kKEXS] = + EncodeSingleValue(negotiated_params.key_exchange); + + // Authenticated encryption algorithm. + message->tag_value_map[kAEAD] = EncodeSingleValue(negotiated_params.aead); + + // Congestion control feedback type. + message->tag_value_map[kCGST] = + EncodeSingleValue(negotiated_params.congestion_control); + + // Idle connection state lifetime. + uint32 idle_connection_state_lifetime_secs = + negotiated_params.idle_connection_state_lifetime.ToSeconds(); + message->tag_value_map[kICSL] = + EncodeSingleValue(idle_connection_state_lifetime_secs); + + // Keepalive timeout? + + // Connection nonce. + message->tag_value_map[kNONC] = nonce; +} + } // namespace net diff --git a/net/quic/crypto/crypto_utils.h b/net/quic/crypto/crypto_utils.h index 90f5c96..496ad79 100644 --- a/net/quic/crypto/crypto_utils.h +++ b/net/quic/crypto/crypto_utils.h @@ -8,6 +8,7 @@ #define NET_QUIC_CRYPTO_CRYPTO_UTILS_H_ #include <string> +#include <vector> #include "net/base/net_export.h" @@ -16,19 +17,38 @@ namespace net { class QuicClock; class QuicRandom; struct CryptoHandshakeMessage; -struct QuicClientCryptoConfig; +struct QuicCryptoConfig; +struct QuicCryptoNegotiatedParams; class NET_EXPORT_PRIVATE CryptoUtils { public: + // Encodes a single value as a string for CryptoTagValueMap. + template <class T> + static std::string EncodeSingleValue(const T& value) { + return std::string(reinterpret_cast<const char*>(&value), sizeof(value)); + } + + // Encodes a vector value as a string for CryptoTagValueMap. + template <class T> + static std::string EncodeVectorValue(const std::vector<T>& value) { + return std::string(reinterpret_cast<const char*>(&value[0]), + value.size() * sizeof(value[0])); + } + // Generates the connection nonce. static void GenerateNonce(const QuicClock* clock, QuicRandom* random_generator, std::string* nonce); - static void FillClientHelloMessage(const QuicClientCryptoConfig& config, + static void FillClientHelloMessage(const QuicCryptoConfig& client_config, const std::string& nonce, const std::string& server_hostname, CryptoHandshakeMessage* message); + + static void FillServerHelloMessage( + const QuicCryptoNegotiatedParams& negotiated_params, + const std::string& nonce, + CryptoHandshakeMessage* message); }; } // namespace net diff --git a/net/quic/quic_connection.cc b/net/quic/quic_connection.cc index dcfcb1d..77d15f1 100644 --- a/net/quic/quic_connection.cc +++ b/net/quic/quic_connection.cc @@ -21,6 +21,7 @@ using std::make_pair; using std::min; using std::vector; using std::set; +using std::string; namespace net { @@ -882,10 +883,16 @@ QuicFecGroup* QuicConnection::GetFecGroup() { } void QuicConnection::SendConnectionClose(QuicErrorCode error) { + SendConnectionCloseWithDetails(error, string()); +} + +void QuicConnection::SendConnectionCloseWithDetails(QuicErrorCode error, + const string& details) { DLOG(INFO) << "Force closing with error " << QuicUtils::ErrorToString(error) << " (" << error << ")"; QuicConnectionCloseFrame frame; frame.error_code = error; + frame.error_details = details; frame.ack_frame = outgoing_ack_; PacketPair packetpair = packet_creator_.CloseConnection(&frame); diff --git a/net/quic/quic_connection.h b/net/quic/quic_connection.h index 97cc61c..b436f9c 100644 --- a/net/quic/quic_connection.h +++ b/net/quic/quic_connection.h @@ -156,6 +156,8 @@ class NET_EXPORT_PRIVATE QuicConnection : public QuicFramerVisitorInterface, // Sends a connection close frame to the peer, and closes the connection by // calling CloseConnection(notifying the visitor as it does so). virtual void SendConnectionClose(QuicErrorCode error); + virtual void SendConnectionCloseWithDetails(QuicErrorCode error, + const std::string& details); // Notifies the visitor of the close and marks the connection as disconnected. void CloseConnection(QuicErrorCode error, bool from_peer); diff --git a/net/quic/quic_crypto_client_stream.cc b/net/quic/quic_crypto_client_stream.cc index ce366a9..8f06abd 100644 --- a/net/quic/quic_crypto_client_stream.cc +++ b/net/quic/quic_crypto_client_stream.cc @@ -37,12 +37,12 @@ void QuicCryptoClientStream::OnHandshakeMessage( } bool QuicCryptoClientStream::CryptoConnect() { - client_crypto_config_.SetDefaults(); + crypto_config_.SetClientDefaults(); CryptoUtils::GenerateNonce(session()->connection()->clock(), session()->connection()->random_generator(), &nonce_); CryptoHandshakeMessage message; - CryptoUtils::FillClientHelloMessage(client_crypto_config_, nonce_, + CryptoUtils::FillClientHelloMessage(crypto_config_, nonce_, server_hostname_, &message); SendHandshakeMessage(message); return true; diff --git a/net/quic/quic_crypto_client_stream.h b/net/quic/quic_crypto_client_stream.h index 9eb112b..1bdcb2a 100644 --- a/net/quic/quic_crypto_client_stream.h +++ b/net/quic/quic_crypto_client_stream.h @@ -28,7 +28,7 @@ class NET_EXPORT_PRIVATE QuicCryptoClientStream : public QuicCryptoStream { bool CryptoConnect(); private: - QuicClientCryptoConfig client_crypto_config_; + QuicCryptoConfig crypto_config_; // Client's connection nonce (4-byte timestamp + 28 random bytes) std::string nonce_; // Server's hostname diff --git a/net/quic/quic_crypto_stream.cc b/net/quic/quic_crypto_stream.cc index bb6654d..b10f75c 100644 --- a/net/quic/quic_crypto_stream.cc +++ b/net/quic/quic_crypto_stream.cc @@ -37,6 +37,11 @@ void QuicCryptoStream::CloseConnection(QuicErrorCode error) { session()->connection()->SendConnectionClose(error); } +void QuicCryptoStream::CloseConnectionWithDetails(QuicErrorCode error, + const string& details) { + session()->connection()->SendConnectionCloseWithDetails(error, details); +} + void QuicCryptoStream::SetHandshakeComplete(QuicErrorCode error) { handshake_complete_ = true; session()->OnCryptoHandshakeComplete(error); diff --git a/net/quic/quic_crypto_stream.h b/net/quic/quic_crypto_stream.h index 584f7de..31bc4a9 100644 --- a/net/quic/quic_crypto_stream.h +++ b/net/quic/quic_crypto_stream.h @@ -47,6 +47,7 @@ class NET_EXPORT_PRIVATE QuicCryptoStream protected: // Closes the connection void CloseConnection(QuicErrorCode error); + void CloseConnectionWithDetails(QuicErrorCode error, const string& details); void SetHandshakeComplete(QuicErrorCode error); diff --git a/net/quic/quic_protocol.h b/net/quic/quic_protocol.h index 83f4ae8..9d641ee 100644 --- a/net/quic/quic_protocol.h +++ b/net/quic/quic_protocol.h @@ -191,9 +191,15 @@ enum QuicErrorCode { QUIC_CRYPTO_INVALID_VALUE_LENGTH, // A crypto message was received after the handshake was complete. QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE, - // A crypto message was receieved with an illegal message tag. + // A crypto message was received with an illegal message tag. QUIC_INVALID_CRYPTO_MESSAGE_TYPE, - + // A crypto message was received with an illegal parameter. + QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER, + // A crypto message was received with a mandatory parameter missing. + QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND, + // A crypto message was received with a parameter that has no overlap + // with the local parameter. + QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP, }; struct NET_EXPORT_PRIVATE QuicPacketPublicHeader { @@ -359,8 +365,8 @@ struct NET_EXPORT_PRIVATE QuicRstStreamFrame { struct NET_EXPORT_PRIVATE QuicConnectionCloseFrame { QuicErrorCode error_code; - QuicAckFrame ack_frame; std::string error_details; + QuicAckFrame ack_frame; }; struct NET_EXPORT_PRIVATE QuicFrame { diff --git a/net/quic/quic_utils.cc b/net/quic/quic_utils.cc index ee88289..5ae9c35 100644 --- a/net/quic/quic_utils.cc +++ b/net/quic/quic_utils.cc @@ -65,6 +65,9 @@ const char* QuicUtils::ErrorToString(QuicErrorCode error) { RETURN_STRING_LITERAL(QUIC_CRYPTO_INVALID_VALUE_LENGTH) RETURN_STRING_LITERAL(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); RETURN_STRING_LITERAL(QUIC_INVALID_CRYPTO_MESSAGE_TYPE); + RETURN_STRING_LITERAL(QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER); + RETURN_STRING_LITERAL(QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND); + RETURN_STRING_LITERAL(QUIC_CRYPTO_MESSAGE_PARAMETER_NO_OVERLAP); RETURN_STRING_LITERAL(QUIC_INVALID_STREAM_ID); RETURN_STRING_LITERAL(QUIC_TOO_MANY_OPEN_STREAMS); RETURN_STRING_LITERAL(QUIC_PUBLIC_RESET); diff --git a/net/quic/test_tools/quic_test_utils.cc b/net/quic/test_tools/quic_test_utils.cc index 8f7feeb..634218f 100644 --- a/net/quic/test_tools/quic_test_utils.cc +++ b/net/quic/test_tools/quic_test_utils.cc @@ -201,9 +201,9 @@ void CompareQuicDataWithHexError( expected->data(), expected->length()); } -QuicPacket* ConstructHandshakePacket(QuicGuid guid, CryptoTag tag) { - CryptoHandshakeMessage message; - message.tag = tag; +static QuicPacket* ConstructPacketFromHandshakeMessage( + QuicGuid guid, + const CryptoHandshakeMessage& message) { CryptoFramer crypto_framer; scoped_ptr<QuicData> data(crypto_framer.ConstructHandshakeMessage(message)); QuicFramer quic_framer(QuicDecrypter::Create(kNULL), @@ -225,37 +225,38 @@ QuicPacket* ConstructHandshakePacket(QuicGuid guid, CryptoTag tag) { return quic_framer.ConstructFrameDataPacket(header, frames); } +QuicPacket* ConstructHandshakePacket(QuicGuid guid, CryptoTag tag) { + CryptoHandshakeMessage message; + message.tag = tag; + return ConstructPacketFromHandshakeMessage(guid, message); +} + QuicPacket* ConstructClientHelloPacket(QuicGuid guid, const QuicClock* clock, QuicRandom* random_generator, const string& server_hostname) { - QuicClientCryptoConfig config; - config.SetDefaults(); + QuicCryptoConfig config; + config.SetClientDefaults(); string nonce; CryptoUtils::GenerateNonce(clock, random_generator, &nonce); CryptoHandshakeMessage message; CryptoUtils::FillClientHelloMessage(config, nonce, server_hostname, &message); - CryptoFramer crypto_framer; - scoped_ptr<QuicData> data(crypto_framer.ConstructHandshakeMessage(message)); - QuicFramer quic_framer(QuicDecrypter::Create(kNULL), - QuicEncrypter::Create(kNULL)); - - QuicPacketHeader header; - header.public_header.guid = guid; - header.public_header.flags = PACKET_PUBLIC_FLAGS_NONE; - header.packet_sequence_number = 1; - header.private_flags = PACKET_PRIVATE_FLAGS_NONE; - header.fec_group = 0; + return ConstructPacketFromHandshakeMessage(guid, message); +} - QuicStreamFrame stream_frame(kCryptoStreamId, false, 0, - data->AsStringPiece()); +QuicPacket* ConstructServerHelloPacket(QuicGuid guid, + const QuicClock* clock, + QuicRandom* random_generator) { + QuicCryptoNegotiatedParams negotiated_params; + negotiated_params.SetDefaults(); + string nonce; + CryptoUtils::GenerateNonce(clock, random_generator, &nonce); - QuicFrame frame(&stream_frame); - QuicFrames frames; - frames.push_back(frame); - return quic_framer.ConstructFrameDataPacket(header, frames); + CryptoHandshakeMessage message; + CryptoUtils::FillServerHelloMessage(negotiated_params, nonce, &message); + return ConstructPacketFromHandshakeMessage(guid, message); } } // namespace test diff --git a/net/quic/test_tools/quic_test_utils.h b/net/quic/test_tools/quic_test_utils.h index b15c480..0b2a67a 100644 --- a/net/quic/test_tools/quic_test_utils.h +++ b/net/quic/test_tools/quic_test_utils.h @@ -38,6 +38,11 @@ QuicPacket* ConstructClientHelloPacket(QuicGuid guid, QuicRandom* random_generator, const std::string& server_hostname); +// Constructs a ServerHello crypto handshake message +QuicPacket* ConstructServerHelloPacket(QuicGuid guid, + const QuicClock* clock, + QuicRandom* random_generator); + class MockFramerVisitor : public QuicFramerVisitorInterface { public: MockFramerVisitor(); |