Title: [160228] trunk/Source
Revision
160228
Author
[email protected]
Date
2013-12-06 10:54:00 -0800 (Fri, 06 Dec 2013)

Log Message

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 <[email protected]> on 2013-12-06
Reviewed by Darin Adler.

Use SHA1::hashSize instead of local variables.

Source/_javascript_Core:

* 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

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (160227 => 160228)


--- trunk/Source/_javascript_Core/ChangeLog	2013-12-06 18:21:05 UTC (rev 160227)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-12-06 18:54:00 UTC (rev 160228)
@@ -1,3 +1,15 @@
+2013-12-06  Laszlo Vidacs  <[email protected]>
+
+        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  <[email protected]>
 
         REGRESSION(r160213): Crash in js/dom/JSON-parse.html

Modified: trunk/Source/_javascript_Core/bytecode/CodeBlockHash.cpp (160227 => 160228)


--- trunk/Source/_javascript_Core/bytecode/CodeBlockHash.cpp	2013-12-06 18:21:05 UTC (rev 160227)
+++ trunk/Source/_javascript_Core/bytecode/CodeBlockHash.cpp	2013-12-06 18:54:00 UTC (rev 160228)
@@ -42,7 +42,7 @@
 {
     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);

Modified: trunk/Source/WTF/ChangeLog (160227 => 160228)


--- trunk/Source/WTF/ChangeLog	2013-12-06 18:21:05 UTC (rev 160227)
+++ trunk/Source/WTF/ChangeLog	2013-12-06 18:54:00 UTC (rev 160228)
@@ -1,3 +1,14 @@
+2013-12-06  Laszlo Vidacs  <[email protected]>
+
+        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  <[email protected]>
 
         Remove USE(LOCKFREE_THREADSAFEREFCOUNTED) from Atomics.cpp since it is

Modified: trunk/Source/WTF/wtf/SHA1.h (160227 => 160228)


--- trunk/Source/WTF/wtf/SHA1.h	2013-12-06 18:21:05 UTC (rev 160227)
+++ trunk/Source/WTF/wtf/SHA1.h	2013-12-06 18:54:00 UTC (rev 160228)
@@ -64,7 +64,10 @@
     
     // 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();

Modified: trunk/Source/WebCore/ChangeLog (160227 => 160228)


--- trunk/Source/WebCore/ChangeLog	2013-12-06 18:21:05 UTC (rev 160227)
+++ trunk/Source/WebCore/ChangeLog	2013-12-06 18:54:00 UTC (rev 160228)
@@ -1,3 +1,17 @@
+2013-12-06  Laszlo Vidacs  <[email protected]>
+
+        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  <[email protected]>
 
         [Cocoa] Add load delegate methods for responding to authentication challenges

Modified: trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp (160227 => 160228)


--- trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp	2013-12-06 18:21:05 UTC (rev 160227)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp	2013-12-06 18:54:00 UTC (rev 160228)
@@ -109,14 +109,13 @@
 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)

Modified: trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp (160227 => 160228)


--- trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2013-12-06 18:21:05 UTC (rev 160227)
+++ trunk/Source/WebCore/platform/network/soup/ResourceHandleSoup.cpp	2013-12-06 18:54:00 UTC (rev 160228)
@@ -205,14 +205,13 @@
         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;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to