Define SHA1 hash size in SHA1.h and use it at various places.

https://bugs.webkit.org/show_bug.cgi?id=125345

Patch by Laszlo Vidacs <lac@inf.u-szeged.hu> on 2013-12-06
Reviewed by Darin Adler.

Use SHA1::hashSize instead of local variables.

Source/JavaScriptCore:

* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::CodeBlockHash): use SHA1::hashSize

Source/WebCore:

* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::getExpectedWebSocketAccept):
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::HostTLSCertificateSet::computeCertificateHash):

Source/WTF:

* wtf/SHA1.h: define SHA1 hash size

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@160228 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ae0fd005
2013-12-06 Laszlo Vidacs <lac@inf.u-szeged.hu>
Define SHA1 hash size in SHA1.h and use it at various places.
https://bugs.webkit.org/show_bug.cgi?id=125345
Reviewed by Darin Adler.
Use SHA1::hashSize instead of local variables.
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::CodeBlockHash): use SHA1::hashSize
2013-12-05 Michael Saboff <msaboff@apple.com>
REGRESSION(r160213): Crash in js/dom/JSON-parse.html
......
......@@ -42,7 +42,7 @@ CodeBlockHash::CodeBlockHash(const SourceCode& sourceCode, CodeSpecializationKin
{
SHA1 sha1;
sha1.addBytes(sourceCode.toUTF8());
Vector<uint8_t, 20> digest;
Vector<uint8_t, SHA1::hashSize> digest;
sha1.computeHash(digest);
m_hash += digest[0] | (digest[1] << 8) | (digest[2] << 16) | (digest[3] << 24);
m_hash ^= static_cast<unsigned>(kind);
......
2013-12-06 Laszlo Vidacs <lac@inf.u-szeged.hu>
Define SHA1 hash size in SHA1.h and use it at various places.
https://bugs.webkit.org/show_bug.cgi?id=125345
Reviewed by Darin Adler.
Use SHA1::hashSize instead of local variables.
* wtf/SHA1.h: define SHA1 hash size
2013-12-05 Iain Lane <iain.lane@canonical.com>
Remove USE(LOCKFREE_THREADSAFEREFCOUNTED) from Atomics.cpp since it is
......
......@@ -64,7 +64,10 @@ public:
// Compute the hex digest directly. Pass a limit less than 40 if you want a shorter digest.
WTF_EXPORT_PRIVATE CString computeHexDigest();
// Size of the SHA1 hash
WTF_EXPORT_PRIVATE static const size_t hashSize = 20;
private:
void finalize();
void processBlock();
......
2013-12-06 Laszlo Vidacs <lac@inf.u-szeged.hu>
Define SHA1 hash size in SHA1.h and use it at various places.
https://bugs.webkit.org/show_bug.cgi?id=125345
Reviewed by Darin Adler.
Use SHA1::hashSize instead of local variables.
* Modules/websockets/WebSocketHandshake.cpp:
(WebCore::WebSocketHandshake::getExpectedWebSocketAccept):
* platform/network/soup/ResourceHandleSoup.cpp:
(WebCore::HostTLSCertificateSet::computeCertificateHash):
2013-12-06 Dan Bernstein <mitz@apple.com>
[Cocoa] Add load delegate methods for responding to authentication challenges
......@@ -109,14 +109,13 @@ static String generateSecWebSocketKey()
String WebSocketHandshake::getExpectedWebSocketAccept(const String& secWebSocketKey)
{
static const char* const webSocketKeyGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
static const size_t sha1HashSize = 20; // FIXME: This should be defined in SHA1.h.
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, sha1HashSize> hash;
Vector<uint8_t, SHA1::hashSize> hash;
sha1.computeHash(hash);
return base64Encode(hash.data(), sha1HashSize);
return base64Encode(hash.data(), SHA1::hashSize);
}
WebSocketHandshake::WebSocketHandshake(const URL& url, const String& protocol, ScriptExecutionContext* context)
......
......@@ -205,14 +205,13 @@ private:
if (!certificateData)
return String();
static const size_t sha1HashSize = 20;
SHA1 sha1;
sha1.addBytes(certificateData->data, certificateData->len);
Vector<uint8_t, sha1HashSize> digest;
Vector<uint8_t, SHA1::hashSize> digest;
sha1.computeHash(digest);
return base64Encode(reinterpret_cast<const char*>(digest.data()), sha1HashSize);
return base64Encode(reinterpret_cast<const char*>(digest.data()), SHA1::hashSize);
}
HashSet<String> m_certificates;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment