Remove WTF::MD5
https://bugs.webkit.org/show_bug.cgi?id=213766

Patch by Alex Christensen <achristensen@webkit.org> on 2020-06-30
Reviewed by Youenn Fablet.

Source/WebCore:

* Modules/websockets/WebSocketHandshake.cpp:
* platform/network/curl/CurlCacheEntry.cpp:
(WebCore::CurlCacheEntry::generateBaseFilename):

Source/WTF:

It was only used for CURL's cache file name generation.
If you want to use a broken hash function, use SHA1.

* WTF.xcodeproj/project.pbxproj:
* wtf/CMakeLists.txt:
* wtf/MD5.cpp: Removed.
* wtf/MD5.h: Removed.

Tools:

* DumpRenderTree/PlatformWin.cmake:
* TestWebKitAPI/CMakeLists.txt:
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WTF/MD5.cpp: Removed.
* WebKitTestRunner/cg/TestInvocationCG.cpp:
(WTR::computeSHA1HashStringForContext):
(WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
(WTR::computeMD5HashStringForContext): Deleted.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@263759 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog
index 0953728..8b666f8 100644
--- a/Source/WTF/ChangeLog
+++ b/Source/WTF/ChangeLog
@@ -1,3 +1,18 @@
+2020-06-30  Alex Christensen  <achristensen@webkit.org>
+
+        Remove WTF::MD5
+        https://bugs.webkit.org/show_bug.cgi?id=213766
+
+        Reviewed by Youenn Fablet.
+
+        It was only used for CURL's cache file name generation.
+        If you want to use a broken hash function, use SHA1.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/CMakeLists.txt:
+        * wtf/MD5.cpp: Removed.
+        * wtf/MD5.h: Removed.
+
 2020-06-30  Andy Estes  <aestes@apple.com>
 
         [Xcode] Enable the "My Mac (Mac Catalyst)" destination in WebKit Xcode projects
diff --git a/Source/WTF/WTF.xcodeproj/project.pbxproj b/Source/WTF/WTF.xcodeproj/project.pbxproj
index 8456e30..4e70c5e 100644
--- a/Source/WTF/WTF.xcodeproj/project.pbxproj
+++ b/Source/WTF/WTF.xcodeproj/project.pbxproj
@@ -138,7 +138,6 @@
 		A8A473D8151A825B004123FF /* HashTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472B8151A825A004123FF /* HashTable.cpp */; };
 		A8A473E4151A825B004123FF /* MainThreadCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = A8A472C5151A825A004123FF /* MainThreadCocoa.mm */; };
 		A8A473E5151A825B004123FF /* MainThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472C6151A825A004123FF /* MainThread.cpp */; };
-		A8A473E9151A825B004123FF /* MD5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472CA151A825B004123FF /* MD5.cpp */; };
 		A8A473EC151A825B004123FF /* MetaAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472CD151A825B004123FF /* MetaAllocator.cpp */; };
 		A8A473F4151A825B004123FF /* NumberOfCores.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472D5151A825B004123FF /* NumberOfCores.cpp */; };
 		A8A473F9151A825B004123FF /* OSRandomSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8A472DA151A825B004123FF /* OSRandomSource.cpp */; };
@@ -595,8 +594,6 @@
 		A8A472C6151A825A004123FF /* MainThread.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MainThread.cpp; sourceTree = "<group>"; };
 		A8A472C7151A825B004123FF /* MainThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainThread.h; sourceTree = "<group>"; };
 		A8A472C9151A825B004123FF /* MathExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MathExtras.h; sourceTree = "<group>"; };
-		A8A472CA151A825B004123FF /* MD5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MD5.cpp; sourceTree = "<group>"; };
-		A8A472CB151A825B004123FF /* MD5.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MD5.h; sourceTree = "<group>"; };
 		A8A472CC151A825B004123FF /* MessageQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MessageQueue.h; sourceTree = "<group>"; };
 		A8A472CD151A825B004123FF /* MetaAllocator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MetaAllocator.cpp; sourceTree = "<group>"; };
 		A8A472CE151A825B004123FF /* MetaAllocator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MetaAllocator.h; sourceTree = "<group>"; };
@@ -1103,8 +1100,6 @@
 				1A233C7C17DAA6E300A93ACF /* MallocPtr.h */,
 				304CA4E41375437EBE931D03 /* Markable.h */,
 				A8A472C9151A825B004123FF /* MathExtras.h */,
-				A8A472CA151A825B004123FF /* MD5.cpp */,
-				A8A472CB151A825B004123FF /* MD5.h */,
 				CD5497AA15857D0300B5BC30 /* MediaTime.cpp */,
 				CD5497AB15857D0300B5BC30 /* MediaTime.h */,
 				ADF2CE641E39F106006889DB /* MemoryFootprint.h */,
@@ -1693,7 +1688,6 @@
 				7A6EBA3420746C34004F9C44 /* MachSendRight.cpp in Sources */,
 				A8A473E5151A825B004123FF /* MainThread.cpp in Sources */,
 				A8A473E4151A825B004123FF /* MainThreadCocoa.mm in Sources */,
-				A8A473E9151A825B004123FF /* MD5.cpp in Sources */,
 				CD5497AC15857D0300B5BC30 /* MediaTime.cpp in Sources */,
 				ADF2CE671E39F106006889DB /* MemoryFootprintCocoa.cpp in Sources */,
 				AD89B6B71E6415080090707F /* MemoryPressureHandler.cpp in Sources */,
diff --git a/Source/WTF/wtf/CMakeLists.txt b/Source/WTF/wtf/CMakeLists.txt
index d220e6a..1a38088 100644
--- a/Source/WTF/wtf/CMakeLists.txt
+++ b/Source/WTF/wtf/CMakeLists.txt
@@ -124,7 +124,6 @@
     LoggingHashMap.h
     LoggingHashSet.h
     LoggingHashTraits.h
-    MD5.h
     MachSendRight.h
     MainThread.h
     MainThreadData.h
@@ -403,7 +402,6 @@
     Lock.cpp
     LockedPrintStream.cpp
     Logger.cpp
-    MD5.cpp
     MainThread.cpp
     MediaTime.cpp
     MemoryPressureHandler.cpp
diff --git a/Source/WTF/wtf/MD5.cpp b/Source/WTF/wtf/MD5.cpp
deleted file mode 100644
index ffe326c..0000000
--- a/Source/WTF/wtf/MD5.cpp
+++ /dev/null
@@ -1,291 +0,0 @@
-// The original file was copied from sqlite, and was in the public domain.
-// Modifications Copyright 2006 Google Inc. All Rights Reserved
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- * Copyright (C) 2015 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-/*
- * This code implements the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest.  This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- *
- * To compute the message digest of a chunk of bytes, construct an
- * MD5 instance, call addBytes as needed on buffers full of bytes,
- * and then call checksum, which will fill a supplied 16-byte array
- * with the digest.
- */
-
-#include "config.h"
-#include <wtf/MD5.h>
-
-#include <wtf/Assertions.h>
-#include <wtf/StdLibExtras.h>
-
-namespace WTF {
-
-#if PLATFORM(COCOA)
-
-MD5::MD5()
-{
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    CC_MD5_Init(&m_context);
-    ALLOW_DEPRECATED_DECLARATIONS_END
-}
-
-void MD5::addBytes(const uint8_t* input, size_t length)
-{
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    CC_MD5_Update(&m_context, input, length);
-    ALLOW_DEPRECATED_DECLARATIONS_END
-}
-
-void MD5::checksum(Digest& hash)
-{
-    ALLOW_DEPRECATED_DECLARATIONS_BEGIN
-    CC_MD5_Final(hash.data(), &m_context);
-    ALLOW_DEPRECATED_DECLARATIONS_END
-}
-    
-#else
-
-// Note: this code is harmless on little-endian machines.
-
-static void toLittleEndian(uint8_t* buf, unsigned longs)
-{
-    ASSERT(longs > 0);
-    do {
-        uint32_t t = static_cast<uint32_t>(buf[3] << 8 | buf[2]) << 16 | buf[1] << 8 | buf[0];
-        ASSERT_WITH_MESSAGE(!(reinterpret_cast<uintptr_t>(buf) % sizeof(t)), "alignment error of buf");
-        memcpy(buf, &t, sizeof(t));
-        buf += sizeof(t);
-    } while (--longs);
-}
-
-// The four core functions.
-// F1 is originally defined as (x & y | ~x & z), but optimized somewhat: 4 bit ops -> 3 bit ops.
-#define F1(x, y, z) (z ^ (x & (y ^ z)))
-#define F2(x, y, z) F1(z, x, y)
-#define F3(x, y, z) (x ^ y ^ z)
-#define F4(x, y, z) (y ^ (x | ~z))
-
-// This is the central step in the MD5 algorithm.
-#define MD5STEP(f, w, x, y, z, data, s) \
-    (w += f(x, y, z) + data, w = w << s | w >> (32 - s), w += x)
-
-static void MD5Transform(uint32_t buf[4], const uint32_t in[16])
-{
-    uint32_t a = buf[0];
-    uint32_t b = buf[1];
-    uint32_t c = buf[2];
-    uint32_t d = buf[3];
-
-    MD5STEP(F1, a, b, c, d, in[ 0]+0xd76aa478,  7);
-    MD5STEP(F1, d, a, b, c, in[ 1]+0xe8c7b756, 12);
-    MD5STEP(F1, c, d, a, b, in[ 2]+0x242070db, 17);
-    MD5STEP(F1, b, c, d, a, in[ 3]+0xc1bdceee, 22);
-    MD5STEP(F1, a, b, c, d, in[ 4]+0xf57c0faf,  7);
-    MD5STEP(F1, d, a, b, c, in[ 5]+0x4787c62a, 12);
-    MD5STEP(F1, c, d, a, b, in[ 6]+0xa8304613, 17);
-    MD5STEP(F1, b, c, d, a, in[ 7]+0xfd469501, 22);
-    MD5STEP(F1, a, b, c, d, in[ 8]+0x698098d8,  7);
-    MD5STEP(F1, d, a, b, c, in[ 9]+0x8b44f7af, 12);
-    MD5STEP(F1, c, d, a, b, in[10]+0xffff5bb1, 17);
-    MD5STEP(F1, b, c, d, a, in[11]+0x895cd7be, 22);
-    MD5STEP(F1, a, b, c, d, in[12]+0x6b901122,  7);
-    MD5STEP(F1, d, a, b, c, in[13]+0xfd987193, 12);
-    MD5STEP(F1, c, d, a, b, in[14]+0xa679438e, 17);
-    MD5STEP(F1, b, c, d, a, in[15]+0x49b40821, 22);
-
-    MD5STEP(F2, a, b, c, d, in[ 1]+0xf61e2562,  5);
-    MD5STEP(F2, d, a, b, c, in[ 6]+0xc040b340,  9);
-    MD5STEP(F2, c, d, a, b, in[11]+0x265e5a51, 14);
-    MD5STEP(F2, b, c, d, a, in[ 0]+0xe9b6c7aa, 20);
-    MD5STEP(F2, a, b, c, d, in[ 5]+0xd62f105d,  5);
-    MD5STEP(F2, d, a, b, c, in[10]+0x02441453,  9);
-    MD5STEP(F2, c, d, a, b, in[15]+0xd8a1e681, 14);
-    MD5STEP(F2, b, c, d, a, in[ 4]+0xe7d3fbc8, 20);
-    MD5STEP(F2, a, b, c, d, in[ 9]+0x21e1cde6,  5);
-    MD5STEP(F2, d, a, b, c, in[14]+0xc33707d6,  9);
-    MD5STEP(F2, c, d, a, b, in[ 3]+0xf4d50d87, 14);
-    MD5STEP(F2, b, c, d, a, in[ 8]+0x455a14ed, 20);
-    MD5STEP(F2, a, b, c, d, in[13]+0xa9e3e905,  5);
-    MD5STEP(F2, d, a, b, c, in[ 2]+0xfcefa3f8,  9);
-    MD5STEP(F2, c, d, a, b, in[ 7]+0x676f02d9, 14);
-    MD5STEP(F2, b, c, d, a, in[12]+0x8d2a4c8a, 20);
-
-    MD5STEP(F3, a, b, c, d, in[ 5]+0xfffa3942,  4);
-    MD5STEP(F3, d, a, b, c, in[ 8]+0x8771f681, 11);
-    MD5STEP(F3, c, d, a, b, in[11]+0x6d9d6122, 16);
-    MD5STEP(F3, b, c, d, a, in[14]+0xfde5380c, 23);
-    MD5STEP(F3, a, b, c, d, in[ 1]+0xa4beea44,  4);
-    MD5STEP(F3, d, a, b, c, in[ 4]+0x4bdecfa9, 11);
-    MD5STEP(F3, c, d, a, b, in[ 7]+0xf6bb4b60, 16);
-    MD5STEP(F3, b, c, d, a, in[10]+0xbebfbc70, 23);
-    MD5STEP(F3, a, b, c, d, in[13]+0x289b7ec6,  4);
-    MD5STEP(F3, d, a, b, c, in[ 0]+0xeaa127fa, 11);
-    MD5STEP(F3, c, d, a, b, in[ 3]+0xd4ef3085, 16);
-    MD5STEP(F3, b, c, d, a, in[ 6]+0x04881d05, 23);
-    MD5STEP(F3, a, b, c, d, in[ 9]+0xd9d4d039,  4);
-    MD5STEP(F3, d, a, b, c, in[12]+0xe6db99e5, 11);
-    MD5STEP(F3, c, d, a, b, in[15]+0x1fa27cf8, 16);
-    MD5STEP(F3, b, c, d, a, in[ 2]+0xc4ac5665, 23);
-
-    MD5STEP(F4, a, b, c, d, in[ 0]+0xf4292244,  6);
-    MD5STEP(F4, d, a, b, c, in[ 7]+0x432aff97, 10);
-    MD5STEP(F4, c, d, a, b, in[14]+0xab9423a7, 15);
-    MD5STEP(F4, b, c, d, a, in[ 5]+0xfc93a039, 21);
-    MD5STEP(F4, a, b, c, d, in[12]+0x655b59c3,  6);
-    MD5STEP(F4, d, a, b, c, in[ 3]+0x8f0ccc92, 10);
-    MD5STEP(F4, c, d, a, b, in[10]+0xffeff47d, 15);
-    MD5STEP(F4, b, c, d, a, in[ 1]+0x85845dd1, 21);
-    MD5STEP(F4, a, b, c, d, in[ 8]+0x6fa87e4f,  6);
-    MD5STEP(F4, d, a, b, c, in[15]+0xfe2ce6e0, 10);
-    MD5STEP(F4, c, d, a, b, in[ 6]+0xa3014314, 15);
-    MD5STEP(F4, b, c, d, a, in[13]+0x4e0811a1, 21);
-    MD5STEP(F4, a, b, c, d, in[ 4]+0xf7537e82,  6);
-    MD5STEP(F4, d, a, b, c, in[11]+0xbd3af235, 10);
-    MD5STEP(F4, c, d, a, b, in[ 2]+0x2ad7d2bb, 15);
-    MD5STEP(F4, b, c, d, a, in[ 9]+0xeb86d391, 21);
-
-    buf[0] += a;
-    buf[1] += b;
-    buf[2] += c;
-    buf[3] += d;
-}
-
-MD5::MD5()
-{
-    m_buf[0] = 0x67452301;
-    m_buf[1] = 0xefcdab89;
-    m_buf[2] = 0x98badcfe;
-    m_buf[3] = 0x10325476;
-    m_bits[0] = 0;
-    m_bits[1] = 0;
-    memset(m_in, 0, sizeof(m_in));
-    ASSERT_WITH_MESSAGE(!(reinterpret_cast<uintptr_t>(m_in) % sizeof(uint32_t)), "alignment error of m_in");
-}
-
-void MD5::addBytes(const uint8_t* input, size_t length)
-{
-    const uint8_t* buf = input;
-
-    // Update bitcount
-    uint32_t t = m_bits[0];
-    m_bits[0] = t + (length << 3);
-    if (m_bits[0] < t)
-        m_bits[1]++; // Carry from low to high
-    m_bits[1] += length >> 29;
-
-    t = (t >> 3) & 0x3f; // Bytes already in shsInfo->data
-
-    // Handle any leading odd-sized chunks
-
-    if (t) {
-        uint8_t* p = m_in + t;
-
-        t = 64 - t;
-        if (length < t) {
-            memcpy(p, buf, length);
-            return;
-        }
-        memcpy(p, buf, t);
-        toLittleEndian(m_in, 16);
-        MD5Transform(m_buf, reinterpret_cast_ptr<uint32_t*>(m_in)); // m_in is 4-byte aligned.
-        buf += t;
-        length -= t;
-    }
-
-    // Process data in 64-byte chunks
-
-    while (length >= 64) {
-        memcpy(m_in, buf, 64);
-        toLittleEndian(m_in, 16);
-        MD5Transform(m_buf, reinterpret_cast_ptr<uint32_t*>(m_in)); // m_in is 4-byte aligned.
-        buf += 64;
-        length -= 64;
-    }
-
-    // Handle any remaining bytes of data.
-    memcpy(m_in, buf, length);
-}
-
-void MD5::checksum(Digest& digest)
-{
-    // Compute number of bytes mod 64
-    unsigned count = (m_bits[0] >> 3) & 0x3F;
-
-    // Set the first char of padding to 0x80.  This is safe since there is
-    // always at least one byte free
-    uint8_t* p = m_in + count;
-    *p++ = 0x80;
-
-    // Bytes of padding needed to make 64 bytes
-    count = 64 - 1 - count;
-
-    // Pad out to 56 mod 64
-    if (count < 8) {
-        // Two lots of padding:  Pad the first block to 64 bytes
-        memset(p, 0, count);
-        toLittleEndian(m_in, 16);
-        MD5Transform(m_buf, reinterpret_cast_ptr<uint32_t *>(m_in)); // m_in is 4-byte aligned.
-
-        // Now fill the next block with 56 bytes
-        memset(m_in, 0, 56);
-    } else {
-        // Pad block to 56 bytes
-        memset(p, 0, count - 8);
-    }
-    toLittleEndian(m_in, 14);
-
-    // Append length in bits and transform
-    memcpy(m_in + 56, m_bits, sizeof(m_bits));
-
-    MD5Transform(m_buf, reinterpret_cast_ptr<uint32_t*>(m_in));
-    toLittleEndian(reinterpret_cast<uint8_t*>(m_buf), 4);
-
-    // Now, m_buf contains checksum result.
-    uint8_t* mBufUInt8 = reinterpret_cast<uint8_t*>(m_buf);
-    for (size_t i = 0; i < hashSize; ++i)
-        digest[i] = mBufUInt8[i];
-
-    // In case it's sensitive
-    memset(m_buf, 0, sizeof(m_buf));
-    memset(m_bits, 0, sizeof(m_bits));
-    memset(m_in, 0, sizeof(m_in));
-}
-
-#endif
-
-} // namespace WTF
diff --git a/Source/WTF/wtf/MD5.h b/Source/WTF/wtf/MD5.h
deleted file mode 100644
index cddd703..0000000
--- a/Source/WTF/wtf/MD5.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2010 Google Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- *     * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *     * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the following disclaimer
- * in the documentation and/or other materials provided with the
- * distribution.
- *     * Neither the name of Google Inc. nor the names of its
- * contributors may be used to endorse or promote products derived from
- * this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#include <array>
-#include <wtf/Vector.h>
-
-#if PLATFORM(COCOA)
-#include <CommonCrypto/CommonDigest.h>
-#endif
-
-namespace WTF {
-
-class MD5 {
-    WTF_MAKE_FAST_ALLOCATED;
-public:
-    WTF_EXPORT_PRIVATE MD5();
-
-    void addBytes(const Vector<uint8_t>& input)
-    {
-        addBytes(input.data(), input.size());
-    }
-    WTF_EXPORT_PRIVATE void addBytes(const uint8_t* input, size_t length);
-
-    // Size of the SHA1 hash
-    WTF_EXPORT_PRIVATE static constexpr size_t hashSize = 16;
-
-    // type for computing MD5 hash
-    typedef std::array<uint8_t, hashSize> Digest;
-
-    // checksum has a side effect of resetting the state of the object.
-    WTF_EXPORT_PRIVATE void checksum(Digest&);
-
-private:
-#if PLATFORM(COCOA)
-    CC_MD5_CTX m_context;
-#else
-    uint32_t m_buf[4];
-    uint32_t m_bits[2];
-    uint8_t m_in[64];
-#endif
-};
-
-} // namespace WTF
-
-using WTF::MD5;
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 42adcd8..3785c61 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,14 @@
+2020-06-30  Alex Christensen  <achristensen@webkit.org>
+
+        Remove WTF::MD5
+        https://bugs.webkit.org/show_bug.cgi?id=213766
+
+        Reviewed by Youenn Fablet.
+
+        * Modules/websockets/WebSocketHandshake.cpp:
+        * platform/network/curl/CurlCacheEntry.cpp:
+        (WebCore::CurlCacheEntry::generateBaseFilename):
+
 2020-06-30  Youenn Fablet  <youenn@apple.com>
 
         Set runtime flag m_isWebRTCPlatformCodecsInGPUProcessEnabled to false by default
diff --git a/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp b/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp
index e237497..3d2a526 100644
--- a/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp
+++ b/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp
@@ -48,7 +48,6 @@
 #include "WebSocket.h"
 #include <wtf/ASCIICType.h>
 #include <wtf/CryptographicallyRandomNumber.h>
-#include <wtf/MD5.h>
 #include <wtf/SHA1.h>
 #include <wtf/StdLibExtras.h>
 #include <wtf/StringExtras.h>
diff --git a/Source/WebCore/platform/network/curl/CurlCacheEntry.cpp b/Source/WebCore/platform/network/curl/CurlCacheEntry.cpp
index 2461093..9ef5079 100644
--- a/Source/WebCore/platform/network/curl/CurlCacheEntry.cpp
+++ b/Source/WebCore/platform/network/curl/CurlCacheEntry.cpp
@@ -42,7 +42,7 @@
 #include "SharedBuffer.h"
 #include <wtf/DateMath.h>
 #include <wtf/HexNumber.h>
-#include <wtf/MD5.h>
+#include <wtf/SHA1.h>
 
 namespace WebCore {
 
@@ -211,15 +211,15 @@
 
 void CurlCacheEntry::generateBaseFilename(const CString& url)
 {
-    MD5 md5;
-    md5.addBytes(reinterpret_cast<const uint8_t*>(url.data()), url.length());
+    SHA1 sha1;
+    sha1.addBytes(reinterpret_cast<const uint8_t*>(url.data()), url.length());
 
-    MD5::Digest sum;
-    md5.checksum(sum);
+    SHA1::Digest sum;
+    sha1.computeHash(sum);
     uint8_t* rawdata = sum.data();
 
     StringBuilder baseNameBuilder;
-    for (size_t i = 0; i < MD5::hashSize; i++)
+    for (size_t i = 0; i < 16; i++)
         baseNameBuilder.append(hex(rawdata[i], Lowercase));
     m_basename = baseNameBuilder.toString();
 }
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 41bafd0..0cff9e0 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,19 @@
+2020-06-30  Alex Christensen  <achristensen@webkit.org>
+
+        Remove WTF::MD5
+        https://bugs.webkit.org/show_bug.cgi?id=213766
+
+        Reviewed by Youenn Fablet.
+
+        * DumpRenderTree/PlatformWin.cmake:
+        * TestWebKitAPI/CMakeLists.txt:
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WTF/MD5.cpp: Removed.
+        * WebKitTestRunner/cg/TestInvocationCG.cpp:
+        (WTR::computeSHA1HashStringForContext):
+        (WTR::TestInvocation::dumpPixelsAndCompareWithExpected):
+        (WTR::computeMD5HashStringForContext): Deleted.
+
 2020-06-30  Jonathan Bedard  <jbedard@apple.com>
 
         [TestExpectations] Add architecture for Apple's ports
diff --git a/Tools/DumpRenderTree/PixelDumpSupport.cpp b/Tools/DumpRenderTree/PixelDumpSupport.cpp
index cd76bce..8d8a6ef 100644
--- a/Tools/DumpRenderTree/PixelDumpSupport.cpp
+++ b/Tools/DumpRenderTree/PixelDumpSupport.cpp
@@ -58,7 +58,7 @@
     
     // Compute the hash of the bitmap context pixels
     char actualHash[33];
-    computeMD5HashStringForBitmapContext(context.get(), actualHash);
+    computeSHA1HashStringForBitmapContext(context.get(), actualHash);
     fprintf(testResult, "\nActualHash: %s\n", actualHash); // FIXME: No need for the leading newline.
 
     // Check the computed hash against the expected one and dump image on mismatch
diff --git a/Tools/DumpRenderTree/PixelDumpSupport.h b/Tools/DumpRenderTree/PixelDumpSupport.h
index 1885b35..bd3b01e 100644
--- a/Tools/DumpRenderTree/PixelDumpSupport.h
+++ b/Tools/DumpRenderTree/PixelDumpSupport.h
@@ -33,7 +33,7 @@
 
 class BitmapContext;
 
-void computeMD5HashStringForBitmapContext(BitmapContext*, char hashString[33]);
+void computeSHA1HashStringForBitmapContext(BitmapContext*, char hashString[33]);
 RefPtr<BitmapContext> createPagedBitmapContext();
 RefPtr<BitmapContext> createBitmapContextFromWebView(bool onscreen, bool incrementalRepaint, bool sweepHorizontally, bool drawSelectionRect);
 void dumpBitmap(BitmapContext*, const char* checksum);
diff --git a/Tools/DumpRenderTree/PlatformWin.cmake b/Tools/DumpRenderTree/PlatformWin.cmake
index 0548b8c..fd0652b 100644
--- a/Tools/DumpRenderTree/PlatformWin.cmake
+++ b/Tools/DumpRenderTree/PlatformWin.cmake
@@ -11,7 +11,6 @@
     win/FrameLoadDelegate.cpp
     win/GCControllerWin.cpp
     win/HistoryDelegate.cpp
-    win/MD5.cpp
     win/PixelDumpSupportWin.cpp
     win/PolicyDelegate.cpp
     win/ResourceLoadDelegate.cpp
diff --git a/Tools/DumpRenderTree/cairo/PixelDumpSupportCairo.cpp b/Tools/DumpRenderTree/cairo/PixelDumpSupportCairo.cpp
index 9c89310..17fed05 100644
--- a/Tools/DumpRenderTree/cairo/PixelDumpSupportCairo.cpp
+++ b/Tools/DumpRenderTree/cairo/PixelDumpSupportCairo.cpp
@@ -36,8 +36,8 @@
 #include <algorithm>
 #include <ctype.h>
 #include <wtf/Assertions.h>
-#include <wtf/MD5.h>
 #include <wtf/RefPtr.h>
+#include <wtf/SHA1.h>
 #include <wtf/StringExtras.h>
 
 using namespace std;
@@ -61,7 +61,7 @@
     printPNG(data, dataLength, checksum);
 }
 
-void computeMD5HashStringForBitmapContext(BitmapContext* context, char hashString[33])
+void computeSHA1HashStringForBitmapContext(BitmapContext* context, char hashString[33])
 {
     cairo_t* bitmapContext = context->cairoContext();
     cairo_surface_t* surface = cairo_get_target(bitmapContext);
@@ -72,14 +72,14 @@
     size_t pixelsWide = cairo_image_surface_get_width(surface);
     size_t bytesPerRow = cairo_image_surface_get_stride(surface);
 
-    MD5 md5Context;
+    SHA1 sha1;
     unsigned char* bitmapData = static_cast<unsigned char*>(cairo_image_surface_get_data(surface));
     for (unsigned row = 0; row < pixelsHigh; row++) {
-        md5Context.addBytes(bitmapData, 4 * pixelsWide);
+        sha1.addBytes(bitmapData, 4 * pixelsWide);
         bitmapData += bytesPerRow;
     }
-    MD5::Digest hash;
-    md5Context.checksum(hash);
+    SHA1::Digest hash;
+    sha1.computeHash(hash);
 
     snprintf(hashString, 33, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
         hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7],
diff --git a/Tools/DumpRenderTree/cg/PixelDumpSupportCG.cpp b/Tools/DumpRenderTree/cg/PixelDumpSupportCG.cpp
index 7ec595c..5bc0403 100644
--- a/Tools/DumpRenderTree/cg/PixelDumpSupportCG.cpp
+++ b/Tools/DumpRenderTree/cg/PixelDumpSupportCG.cpp
@@ -39,10 +39,9 @@
 #include <wtf/Assertions.h>
 #include <wtf/RefPtr.h>
 #include <wtf/RetainPtr.h>
+#include <wtf/SHA1.h>
 
-#if PLATFORM(WIN)
-#include "MD5.h"
-#elif PLATFORM(IOS_FAMILY)
+#if PLATFORM(IOS_FAMILY)
 #include <MobileCoreServices/UTCoreTypes.h>
 #define COMMON_DIGEST_FOR_OPENSSL
 #include <CommonCrypto/CommonDigest.h>
@@ -71,7 +70,7 @@
     printPNG(static_cast<const unsigned char*>(data), static_cast<size_t>(dataLength), checksum);
 }
 
-void computeMD5HashStringForBitmapContext(BitmapContext* context, char hashString[33])
+void computeSHA1HashStringForBitmapContext(BitmapContext* context, char hashString[33])
 {
     CGContextRef bitmapContext = context->cgContext();
 
@@ -81,8 +80,7 @@
     size_t bytesPerRow = CGBitmapContextGetBytesPerRow(bitmapContext);
 
     // We need to swap the bytes to ensure consistent hashes independently of endianness
-    MD5_CTX md5Context;
-    MD5_Init(&md5Context);
+    SHA1 sha1;
     unsigned char* bitmapData = static_cast<unsigned char*>(CGBitmapContextGetData(bitmapContext));
 #if PLATFORM(COCOA)
     if ((CGBitmapContextGetBitmapInfo(bitmapContext) & kCGBitmapByteOrderMask) == kCGBitmapByteOrder32Big) {
@@ -90,19 +88,19 @@
             uint32_t buffer[pixelsWide];
             for (unsigned column = 0; column < pixelsWide; column++)
                 buffer[column] = OSReadLittleInt32(bitmapData, 4 * column);
-            MD5_Update(&md5Context, buffer, 4 * pixelsWide);
+            sha1.addBytes(reinterpret_cast<const uint8_t*>(buffer), 4 * pixelsWide);
             bitmapData += bytesPerRow;
         }
     } else
 #endif
     {
         for (unsigned row = 0; row < pixelsHigh; row++) {
-            MD5_Update(&md5Context, bitmapData, 4 * pixelsWide);
+            sha1.addBytes(bitmapData, 4 * pixelsWide);
             bitmapData += bytesPerRow;
         }
     }
-    unsigned char hash[16];
-    MD5_Final(hash, &md5Context);
+    SHA1::Digest hash;
+    sha1.computeHash(hash);
 
     hashString[0] = '\0';
     for (int i = 0; i < 16; i++)
diff --git a/Tools/DumpRenderTree/win/MD5.cpp b/Tools/DumpRenderTree/win/MD5.cpp
deleted file mode 100644
index 53b5607..0000000
--- a/Tools/DumpRenderTree/win/MD5.cpp
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2007 Apple, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "config.h"
-#include "MD5.h"
-
-#include <windows.h>
-
-typedef void (WINAPI*initPtr)(MD5_CTX*);
-typedef void (WINAPI*updatePtr)(MD5_CTX*, unsigned char*, unsigned);
-typedef void (WINAPI*finalPtr)(MD5_CTX*);
-
-static HMODULE cryptDLL()
-{
-    static HMODULE module = LoadLibraryW(L"Cryptdll.dll");
-    return module;
-}
-
-static initPtr init()
-{
-    static initPtr ptr = reinterpret_cast<initPtr>(GetProcAddress(cryptDLL(), "MD5Init"));
-    return ptr;
-}
-
-static updatePtr update()
-{
-    static updatePtr ptr = reinterpret_cast<updatePtr>(GetProcAddress(cryptDLL(), "MD5Update"));
-    return ptr;
-}
-
-static finalPtr final()
-{
-    static finalPtr ptr = reinterpret_cast<finalPtr>(GetProcAddress(cryptDLL(), "MD5Final"));
-    return ptr;
-}
-
-void MD5_Init(MD5_CTX* context)
-{
-    init()(context);
-}
-
-void MD5_Update(MD5_CTX* context, unsigned char* input, unsigned length)
-{
-    update()(context, input, length);
-}
-
-void MD5_Final(unsigned char hash[16], MD5_CTX* context)
-{
-    final()(context);
-
-    for (int i = 0; i < 16; ++i)
-        hash[i] = context->digest[i];
-}
diff --git a/Tools/DumpRenderTree/win/MD5.h b/Tools/DumpRenderTree/win/MD5.h
deleted file mode 100644
index 44f92ca..0000000
--- a/Tools/DumpRenderTree/win/MD5.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2007 Apple, Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- * 3.  Neither the name of Apple Inc. ("Apple") nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef MD5_h
-#define MD5_h
-
-typedef unsigned long ULONG;
-
-struct MD5_CTX {
-    WTF_MAKE_STRUCT_FAST_ALLOCATED;
-    ULONG i[2];
-    ULONG buf[4];
-    unsigned char in[64];
-    unsigned char digest[16];
-};
-
-void MD5_Init(MD5_CTX*);
-void MD5_Update(MD5_CTX*, unsigned char* input, unsigned length);
-void MD5_Final(unsigned char hash[16], MD5_CTX*);
-
-#endif // MD5_h
diff --git a/Tools/DumpRenderTree/win/PixelDumpSupportDirect2D.cpp b/Tools/DumpRenderTree/win/PixelDumpSupportDirect2D.cpp
index 2ab9ac3..cd9a75b 100644
--- a/Tools/DumpRenderTree/win/PixelDumpSupportDirect2D.cpp
+++ b/Tools/DumpRenderTree/win/PixelDumpSupportDirect2D.cpp
@@ -27,7 +27,6 @@
 #include "PixelDumpSupportDirect2D.h"
 
 #include "DumpRenderTree.h"
-#include "MD5.h"
 #include "PixelDumpSupport.h"
 #include <algorithm>
 #include <ctype.h>
@@ -64,7 +63,7 @@
     // Not implemented.
 }
 
-void computeMD5HashStringForBitmapContext(BitmapContext* context, char hashString[33])
+void computeSHA1HashStringForBitmapContext(BitmapContext* context, char hashString[33])
 {
     UNUSED_PARAM(context);
     UNUSED_PARAM(hashString);
diff --git a/Tools/TestWebKitAPI/CMakeLists.txt b/Tools/TestWebKitAPI/CMakeLists.txt
index 78faf9d..698b7b8 100644
--- a/Tools/TestWebKitAPI/CMakeLists.txt
+++ b/Tools/TestWebKitAPI/CMakeLists.txt
@@ -57,7 +57,6 @@
     Tests/WTF/ListHashSet.cpp
     Tests/WTF/Lock.cpp
     Tests/WTF/Logger.cpp
-    Tests/WTF/MD5.cpp
     Tests/WTF/Markable.cpp
     Tests/WTF/MathExtras.cpp
     Tests/WTF/MediaTime.cpp
diff --git a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
index d641130..f20eb32 100644
--- a/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
+++ b/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
@@ -546,7 +546,6 @@
 		7C83DEE01D0A590C00FEBCF3 /* IntegerToStringConversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 266FAFD215E5775200F61D5B /* IntegerToStringConversion.cpp */; };
 		7C83DEE81D0A590C00FEBCF3 /* ListHashSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 26300B1716755CD90066886D /* ListHashSet.cpp */; };
 		7C83DEED1D0A590C00FEBCF3 /* MathExtras.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B4039F9C15E6D8B3007255D6 /* MathExtras.cpp */; };
-		7C83DEEF1D0A590C00FEBCF3 /* MD5.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5393C71757BA9700C07123 /* MD5.cpp */; };
 		7C83DEF11D0A590C00FEBCF3 /* MediaTime.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CD5497B315857F0C00B5BC30 /* MediaTime.cpp */; };
 		7C83DEF61D0A590C00FEBCF3 /* MetaAllocator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FC6C4CE141034AD005B7F0C /* MetaAllocator.cpp */; };
 		7C83DEFE1D0A590C00FEBCF3 /* NakedPtr.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEB6F74E1B2BA44E009E4922 /* NakedPtr.cpp */; };
@@ -2614,7 +2613,6 @@
 		CD2D0D19213465560018C784 /* NowPlaying.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = NowPlaying.mm; sourceTree = "<group>"; };
 		CD3065DF2165682E00E895DF /* VideoQualityDisplayCompositing.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = VideoQualityDisplayCompositing.mm; sourceTree = "<group>"; };
 		CD321B031E3A84B700EB21C8 /* video-with-muted-audio-and-webaudio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "video-with-muted-audio-and-webaudio.html"; sourceTree = "<group>"; };
-		CD5393C71757BA9700C07123 /* MD5.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MD5.cpp; sourceTree = "<group>"; };
 		CD5393C91757BAC400C07123 /* SHA1.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SHA1.cpp; sourceTree = "<group>"; };
 		CD5451E919E41F9D0016936F /* CSSParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSParser.cpp; sourceTree = "<group>"; };
 		CD5497B315857F0C00B5BC30 /* MediaTime.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaTime.cpp; sourceTree = "<group>"; };
@@ -4058,7 +4056,6 @@
 				A57D54F51F3395D000A97AA7 /* Logger.h */,
 				EC79F168BE454E579E417B05 /* Markable.cpp */,
 				B4039F9C15E6D8B3007255D6 /* MathExtras.cpp */,
-				CD5393C71757BA9700C07123 /* MD5.cpp */,
 				CD5497B315857F0C00B5BC30 /* MediaTime.cpp */,
 				0FC6C4CE141034AD005B7F0C /* MetaAllocator.cpp */,
 				93A427AC180DA60F00CD24D7 /* MoveOnly.h */,
@@ -4771,7 +4768,6 @@
 				A57D54F61F3395D000A97AA7 /* Logger.cpp in Sources */,
 				4909EE3A2D09480C88982D56 /* Markable.cpp in Sources */,
 				7C83DEED1D0A590C00FEBCF3 /* MathExtras.cpp in Sources */,
-				7C83DEEF1D0A590C00FEBCF3 /* MD5.cpp in Sources */,
 				7C83DEF11D0A590C00FEBCF3 /* MediaTime.cpp in Sources */,
 				7C83DEF61D0A590C00FEBCF3 /* MetaAllocator.cpp in Sources */,
 				CE78705F2107AB980053AC67 /* MoveOnlyLifecycleLogger.cpp in Sources */,
@@ -4875,7 +4871,6 @@
 				0711DF52226A95FC003DD2F7 /* AVFoundationSoftLinkTest.mm in Sources */,
 				7CCE7EB51A411A7E00447C4C /* BackForwardList.mm in Sources */,
 				1C7FEB20207C0F2E00D23278 /* BackgroundColor.mm in Sources */,
-				CD0370E324A44D9600BA3CAE /* MediaLoading.mm in Sources */,
 				C15CBB3023F1FF1A00300CC7 /* BacklightLevelNotification.mm in Sources */,
 				C1692DCA23D10DAE006E88F7 /* Battery.mm in Sources */,
 				374B7A601DF36EEE00ACCB6C /* BundleEditingDelegate.mm in Sources */,
@@ -5097,6 +5092,7 @@
 				076E507F1F4513D6006E9F5A /* Logging.cpp in Sources */,
 				CE1866491F72E8F100A0CAB6 /* MarkedText.cpp in Sources */,
 				07CC7DFE2266330900E39181 /* MediaBufferingPolicy.mm in Sources */,
+				CD0370E324A44D9600BA3CAE /* MediaLoading.mm in Sources */,
 				CDA315981ED53651009F60D3 /* MediaPlaybackSleepAssertion.mm in Sources */,
 				CDC9442E1EF1FC080059C3C4 /* MediaStreamTrackDetached.mm in Sources */,
 				51BE9E662376089F00B4E117 /* MediaType.mm in Sources */,
diff --git a/Tools/TestWebKitAPI/Tests/WTF/MD5.cpp b/Tools/TestWebKitAPI/Tests/WTF/MD5.cpp
deleted file mode 100644
index 2c862a9..0000000
--- a/Tools/TestWebKitAPI/Tests/WTF/MD5.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * This code implements the MD5 message-digest algorithm.
- * The algorithm is due to Ron Rivest.  This code was
- * written by Colin Plumb in 1993, no copyright is claimed.
- * This code is in the public domain; do with it what you wish.
- *
- * Equivalent code is available from RSA Data Security, Inc.
- * This code has been tested against that, and is equivalent,
- * except that you don't need to include two pages of legalese
- * with every copy.
- */
-
-#include "config.h"
-#include <wtf/MD5.h>
-#include <wtf/StringExtras.h>
-#include <wtf/text/CString.h>
-
-namespace TestWebKitAPI {
-
-static void expectMD5(CString input, CString expected)
-{
-    MD5 md5;
-    md5.addBytes(reinterpret_cast<const uint8_t*>(input.data()), input.length());
-    MD5::Digest digest;
-    md5.checksum(digest);
-    char* buf = 0;
-    CString actual = CString::newUninitialized(32, buf);
-    for (size_t i = 0; i < MD5::hashSize; i++, buf += 2)
-        snprintf(buf, 3, "%02x", digest[i]);
-
-    ASSERT_EQ(expected.length(), actual.length());
-    ASSERT_STREQ(expected.data(), actual.data());
-}
-
-TEST(WTF_MD5, Computation)
-{
-    // MD5 Test suite from http://www.ietf.org/rfc/rfc1321.txt.
-    expectMD5("", "d41d8cd98f00b204e9800998ecf8427e");
-    expectMD5("a", "0cc175b9c0f1b6a831c399e269772661");
-    expectMD5("abc", "900150983cd24fb0d6963f7d28e17f72");
-    expectMD5("message digest", "f96b697d7cb7938d525a2f31aaf161d0");
-    expectMD5("abcdefghijklmnopqrstuvwxyz", "c3fcd3d76192e4007dfb496cca67e13b");
-    expectMD5("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "d174ab98d277d9f5a5611c2c9f419d9f");
-    expectMD5("12345678901234567890123456789012345678901234567890123456789012345678901234567890", "57edf4a22be3c955ac49da2e2107b67a");
-}
-
-} // namespace TestWebKitAPI
diff --git a/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp b/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp
index cf29922..25a15b8 100644
--- a/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp
+++ b/Tools/WebKitTestRunner/cairo/TestInvocationCairo.cpp
@@ -36,12 +36,12 @@
 #include <cairo/cairo.h>
 #include <cstdio>
 #include <wtf/Assertions.h>
-#include <wtf/MD5.h>
+#include <wtf/SHA1.h>
 #include <wtf/StringExtras.h>
 
 namespace WTR {
 
-static void computeMD5HashStringForCairoSurface(cairo_surface_t* surface, char hashString[33])
+static void computeSHA1HashStringForCairoSurface(cairo_surface_t* surface, char hashString[33])
 {
     ASSERT(cairo_image_surface_get_format(surface) == CAIRO_FORMAT_ARGB32 || cairo_image_surface_get_format(surface) == CAIRO_FORMAT_RGB24);
 
@@ -49,14 +49,14 @@
     size_t pixelsWide = cairo_image_surface_get_width(surface);
     size_t bytesPerRow = cairo_image_surface_get_stride(surface);
 
-    MD5 md5Context;
+    SHA1 sha1;
     unsigned char* bitmapData = static_cast<unsigned char*>(cairo_image_surface_get_data(surface));
     for (size_t row = 0; row < pixelsHigh; ++row) {
-        md5Context.addBytes(bitmapData, 4 * pixelsWide);
+        sha1.addBytes(bitmapData, 4 * pixelsWide);
         bitmapData += bytesPerRow;
     }
-    MD5::Digest hash;
-    md5Context.checksum(hash);
+    SHA1::Digest hash;
+    sha1.computeHash(hash);
 
     snprintf(hashString, 33, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
         hash[0], hash[1], hash[2], hash[3], hash[4], hash[5], hash[6], hash[7],
@@ -122,7 +122,7 @@
         paintRepaintRectOverlay(surface, repaintRects);
 
     char actualHash[33];
-    computeMD5HashStringForCairoSurface(surface, actualHash);
+    computeSHA1HashStringForCairoSurface(surface, actualHash);
     if (!compareActualHashToExpectedAndDumpResults(actualHash))
         dumpBitmap(surface, actualHash);
 
diff --git a/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp b/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp
index fc9cf7f..67338f4 100644
--- a/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp
+++ b/Tools/WebKitTestRunner/cg/TestInvocationCG.cpp
@@ -31,8 +31,8 @@
 #include "TestController.h"
 #include <ImageIO/CGImageDestination.h>
 #include <WebKit/WKImageCG.h>
-#include <wtf/MD5.h>
 #include <wtf/RetainPtr.h>
+#include <wtf/SHA1.h>
 
 #if PLATFORM(MAC) && !PLATFORM(IOS_FAMILY)
 #include <CoreServices/CoreServices.h>
@@ -67,10 +67,10 @@
     return createCGContextFromCGImage(image.get());
 }
 
-void computeMD5HashStringForContext(CGContextRef bitmapContext, char hashString[33])
+void computeSHA1HashStringForContext(CGContextRef bitmapContext, char hashString[33])
 {
     if (!bitmapContext) {
-        WTFLogAlways("computeMD5HashStringForContext: context is null\n");
+        WTFLogAlways("computeSHA1HashStringForContext: context is null\n");
         return;
     }
     ASSERT(CGBitmapContextGetBitsPerPixel(bitmapContext) == 32); // ImageDiff assumes 32 bit RGBA, we must as well.
@@ -79,7 +79,7 @@
     size_t bytesPerRow = CGBitmapContextGetBytesPerRow(bitmapContext);
     
     // We need to swap the bytes to ensure consistent hashes independently of endianness
-    MD5 md5;
+    SHA1 sha1;
     unsigned char* bitmapData = static_cast<unsigned char*>(CGBitmapContextGetData(bitmapContext));
 #if PLATFORM(COCOA)
     if ((CGBitmapContextGetBitmapInfo(bitmapContext) & kCGBitmapByteOrderMask) == kCGBitmapByteOrder32Big) {
@@ -87,23 +87,23 @@
             Vector<uint8_t> buffer(4 * pixelsWide);
             for (unsigned column = 0; column < pixelsWide; column++)
                 buffer[column] = OSReadLittleInt32(bitmapData, 4 * column);
-            md5.addBytes(buffer);
+            sha1.addBytes(buffer);
             bitmapData += bytesPerRow;
         }
     } else
 #endif
     {
         for (unsigned row = 0; row < pixelsHigh; row++) {
-            md5.addBytes(bitmapData, 4 * pixelsWide);
+            sha1.addBytes(bitmapData, 4 * pixelsWide);
             bitmapData += bytesPerRow;
         }
     }
 
-    MD5::Digest hash;
-    md5.checksum(hash);
+    SHA1::Digest hash;
+    sha1.computeHash(hash);
 
     hashString[0] = '\0';
-    for (size_t i = 0; i < MD5::hashSize; i++)
+    for (size_t i = 0; i < 16; i++)
         snprintf(hashString, 33, "%s%02x", hashString, hash[i]);
 }
 
@@ -182,7 +182,7 @@
         paintRepaintRectOverlay(context.get(), imageSize, repaintRects);
 
     char actualHash[33];
-    computeMD5HashStringForContext(context.get(), actualHash);
+    computeSHA1HashStringForContext(context.get(), actualHash);
     if (!compareActualHashToExpectedAndDumpResults(actualHash))
         dumpBitmap(context.get(), actualHash);
 }
diff --git a/Tools/WebKitTestRunner/win/TestInvocationDirect2D.cpp b/Tools/WebKitTestRunner/win/TestInvocationDirect2D.cpp
index 37a37a8..84996db 100644
--- a/Tools/WebKitTestRunner/win/TestInvocationDirect2D.cpp
+++ b/Tools/WebKitTestRunner/win/TestInvocationDirect2D.cpp
@@ -35,7 +35,6 @@
 #include <WebCore/NotImplemented.h>
 #include <cstdio>
 #include <wtf/Assertions.h>
-#include <wtf/MD5.h>
 #include <wtf/StringExtras.h>
 
 namespace WTR {