Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1234)

Unified Diff: Source/modules/websockets/WebSocketHandshake.cpp

Issue 189373010: Get rid of WTF::SHA1. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase on ToT and fixed header guard collision. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/inspector/DOMPatchSupport.cpp ('k') | Source/platform/Crypto.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/websockets/WebSocketHandshake.cpp
diff --git a/Source/modules/websockets/WebSocketHandshake.cpp b/Source/modules/websockets/WebSocketHandshake.cpp
index b725909858a1b85ed4ab51b3beb19cce45cfe282..8def260211d99ec01d31d12fbaff82a571d8c784 100644
--- a/Source/modules/websockets/WebSocketHandshake.cpp
+++ b/Source/modules/websockets/WebSocketHandshake.cpp
@@ -38,13 +38,13 @@
#include "core/loader/CookieJar.h"
#include "modules/websockets/WebSocket.h"
#include "platform/Cookie.h"
+#include "platform/Crypto.h"
#include "platform/Logging.h"
#include "platform/network/HTTPHeaderMap.h"
#include "platform/network/HTTPParsers.h"
#include "platform/weborigin/SecurityOrigin.h"
#include "public/platform/Platform.h"
#include "wtf/CryptographicallyRandomNumber.h"
-#include "wtf/SHA1.h"
#include "wtf/StdLibExtras.h"
#include "wtf/StringExtras.h"
#include "wtf/Vector.h"
@@ -119,14 +119,16 @@ static String generateSecWebSocketKey()
String WebSocketHandshake::getExpectedWebSocketAccept(const String& secWebSocketKey)
{
static const char webSocketKeyGUID[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
- SHA1 sha1;
CString keyData = secWebSocketKey.ascii();
- sha1.addBytes(reinterpret_cast<const uint8_t*>(keyData.data()), keyData.length());
- sha1.addBytes(reinterpret_cast<const uint8_t*>(webSocketKeyGUID), strlen(webSocketKeyGUID));
- Vector<uint8_t, SHA1::outputSizeBytes> hash;
- sha1.computeHash(hash);
- return base64Encode(reinterpret_cast<const char*>(hash.data()),
- SHA1::outputSizeBytes);
+
+ StringBuilder digestable;
+ digestable.append(secWebSocketKey);
+ digestable.append(webSocketKeyGUID, strlen(webSocketKeyGUID));
+ CString digestableCString = digestable.toString().utf8();
+ DigestValue digest;
+ computeDigest(HashAlgorithmSha1, digestableCString.data(), digestableCString.length(), digest);
+
+ return base64Encode(reinterpret_cast<const char*>(digest.data()), sha1HashSize);
}
WebSocketHandshake::WebSocketHandshake(const KURL& url, const String& protocol, Document* document)
« no previous file with comments | « Source/core/inspector/DOMPatchSupport.cpp ('k') | Source/platform/Crypto.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698