summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 03:31:35 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-07-18 03:31:35 +0000
commit00fdd17f17c0d9a602b077b85630dd3d76634a4b (patch)
tree5ce6bb9c6a7087895291d301a358ce7b08066def
parent06d089241a0cd7d460112a2c70051bc92f165a40 (diff)
downloadchromium_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.cc21
-rw-r--r--net/quic/quic_crypto_server_stream.h5
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,