Chromium Code Reviews| Index: Source/modules/websockets/WebSocketHandshake.cpp |
| diff --git a/Source/modules/websockets/WebSocketHandshake.cpp b/Source/modules/websockets/WebSocketHandshake.cpp |
| index df0830cf7066e681bee4d94fb29bab71b5daf418..75735f8ff1fea866e582d1e75f286a6e26189c4e 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/CryptoUtilities.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(); |
| + CryptoUtil::DigestValue digest; |
| + CryptoUtil::computeDigest(CryptoUtil::HashAlgorithmSha1, digestableCString.data(), digestableCString.length(), digest); |
| + |
| + return base64Encode(reinterpret_cast<const char*>(digest.data()), CryptoUtil::sha1HashSize); |
|
eseidel
2014/03/12 06:50:29
Do we really need a reinterpret cast here?
jww
2014/04/01 23:29:09
Yes. As per your other comment, it's a vector of u
|
| } |
| WebSocketHandshake::WebSocketHandshake(const KURL& url, const String& protocol, Document* document) |