diff options
Diffstat (limited to 'net')
-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, |