diff options
author | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-18 03:31:35 +0000 |
---|---|---|
committer | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-18 03:31:35 +0000 |
commit | 00fdd17f17c0d9a602b077b85630dd3d76634a4b (patch) | |
tree | 5ce6bb9c6a7087895291d301a358ce7b08066def | |
parent | 06d089241a0cd7d460112a2c70051bc92f165a40 (diff) | |
download | chromium_src-00fdd17f17c0d9a602b077b85630dd3d76634a4b.zip chromium_src-00fdd17f17c0d9a602b077b85630dd3d76634a4b.tar.gz chromium_src-00fdd17f17c0d9a602b077b85630dd3d76634a4b.tar.bz2 |
QUIC: add GetBase64SHA256ClientChannelID
Merge internal change: 48627486
R=agl@chromium.org
Review URL: https://chromiumcodereview.appspot.com/19282006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@212223 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | net/quic/quic_crypto_server_stream.cc | 21 | ||||
-rw-r--r-- | net/quic/quic_crypto_server_stream.h | 5 |
2 files changed, 26 insertions, 0 deletions
diff --git a/net/quic/quic_crypto_server_stream.cc b/net/quic/quic_crypto_server_stream.cc index 9b0d989..6b74cc2 100644 --- a/net/quic/quic_crypto_server_stream.cc +++ b/net/quic/quic_crypto_server_stream.cc @@ -4,6 +4,8 @@ #include "net/quic/quic_crypto_server_stream.h" +#include "base/base64.h" +#include "crypto/secure_hash.h" #include "net/quic/crypto/crypto_protocol.h" #include "net/quic/crypto/crypto_server_config.h" #include "net/quic/crypto/crypto_utils.h" @@ -91,6 +93,25 @@ void QuicCryptoServerStream::OnHandshakeMessage( session()->OnCryptoHandshakeEvent(QuicSession::HANDSHAKE_CONFIRMED); } +bool QuicCryptoServerStream::GetBase64SHA256ClientChannelID( + string* output) const { + if (!encryption_established_ || + crypto_negotiated_params_.channel_id.empty()) { + return false; + } + + const string& channel_id(crypto_negotiated_params_.channel_id); + scoped_ptr<crypto::SecureHash> hash( + crypto::SecureHash::Create(crypto::SecureHash::SHA256)); + hash->Update(channel_id.data(), channel_id.size()); + uint8 digest[32]; + hash->Finish(digest, sizeof(digest)); + + base::Base64Encode(string( + reinterpret_cast<const char*>(digest), sizeof(digest)), output); + return true; +} + QuicErrorCode QuicCryptoServerStream::ProcessClientHello( const CryptoHandshakeMessage& message, CryptoHandshakeMessage* reply, diff --git a/net/quic/quic_crypto_server_stream.h b/net/quic/quic_crypto_server_stream.h index 7287659..e4a5a6e 100644 --- a/net/quic/quic_crypto_server_stream.h +++ b/net/quic/quic_crypto_server_stream.h @@ -32,6 +32,11 @@ class NET_EXPORT_PRIVATE QuicCryptoServerStream : public QuicCryptoStream { virtual void OnHandshakeMessage( const CryptoHandshakeMessage& message) OVERRIDE; + // GetBase64SHA256ClientChannelID sets |*output| to the base64 encoded, + // SHA-256 hash of the client's ChannelID key and returns true, if the client + // presented a ChannelID. Otherwise it returns false. + bool GetBase64SHA256ClientChannelID(string* output) const; + protected: virtual QuicErrorCode ProcessClientHello( const CryptoHandshakeMessage& message, |