diff options
author | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-13 03:23:57 +0000 |
---|---|---|
committer | rch@chromium.org <rch@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-03-13 03:23:57 +0000 |
commit | 72818ea6b7334c2a4b94aa78c4907c01e9720c1c (patch) | |
tree | 43520232e1d1a3a2d834d102af8984a67ecd61ce /net/quic/quic_crypto_server_stream.cc | |
parent | 1ba66adaad90e014692e02290cdb83c7b038a286 (diff) | |
download | chromium_src-72818ea6b7334c2a4b94aa78c4907c01e9720c1c.zip chromium_src-72818ea6b7334c2a4b94aa78c4907c01e9720c1c.tar.gz chromium_src-72818ea6b7334c2a4b94aa78c4907c01e9720c1c.tar.bz2 |
Add QuicCryptoServerStream (and test) and get CryptoUtils working.
Review URL: https://chromiumcodereview.appspot.com/12452007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187757 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/quic/quic_crypto_server_stream.cc')
-rw-r--r-- | net/quic/quic_crypto_server_stream.cc | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/net/quic/quic_crypto_server_stream.cc b/net/quic/quic_crypto_server_stream.cc new file mode 100644 index 0000000..0f4d4f4 --- /dev/null +++ b/net/quic/quic_crypto_server_stream.cc @@ -0,0 +1,73 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "net/quic/quic_crypto_server_stream.h" + +#include "net/quic/crypto/crypto_protocol.h" +#include "net/quic/crypto/crypto_utils.h" +#include "net/quic/quic_protocol.h" +#include "net/quic/quic_session.h" + +namespace net { + +QuicCryptoServerStream::QuicCryptoServerStream(QuicSession* session) + : QuicCryptoStream(session) { + config_.SetDefaults(); + // Use hardcoded crypto parameters for now. + CryptoHandshakeMessage extra_tags; + config_.ToHandshakeMessage(&extra_tags); + // TODO(agl): AddTestingConfig generates a new, random config. In the future + // this will be replaced with a real source of configs. + scoped_ptr<CryptoTagValueMap> config_tags( + crypto_config_.AddTestingConfig(session->connection()->random_generator(), + session->connection()->clock(), + extra_tags)); + // If we were using the same config in many servers then we would have to + // parse a QuicConfig from config_tags here. +} + +QuicCryptoServerStream::~QuicCryptoServerStream() { +} + +void QuicCryptoServerStream::OnHandshakeMessage( + const CryptoHandshakeMessage& message) { + // Do not process handshake messages after the handshake is complete. + if (handshake_complete()) { + CloseConnection(QUIC_CRYPTO_MESSAGE_AFTER_HANDSHAKE_COMPLETE); + return; + } + + if (message.tag != kCHLO) { + CloseConnection(QUIC_INVALID_CRYPTO_MESSAGE_TYPE); + return; + } + + string error_details; + QuicErrorCode error = config_.ProcessPeerHandshake( + message, CryptoUtils::LOCAL_PRIORITY, &negotiated_params_, + &error_details); + if (error != QUIC_NO_ERROR) { + CloseConnectionWithDetails(error, "negotiated params"); + return; + } + + CryptoHandshakeMessage shlo; + CryptoUtils::GenerateNonce(session()->connection()->clock(), + session()->connection()->random_generator(), + &server_nonce_); + QuicCryptoNegotiatedParams params; + crypto_config_.ProcessClientHello(message, server_nonce_, &shlo, ¶ms, + &error_details); + if (!error_details.empty()) { + DLOG(INFO) << "Rejecting CHLO: " << error_details; + } + config_.ToHandshakeMessage(&shlo); + SendHandshakeMessage(shlo); + + // TODO(rch): correctly validate the message + SetHandshakeComplete(QUIC_NO_ERROR); + return; +} + +} // namespace net |