<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[208297] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/208297">208297</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-11-02 13:05:41 -0700 (Wed, 02 Nov 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>[GTK] Use libgcrypt instead of GnuTLS for CryptoDigest and SubtleCrypto HMAC implementation
https://bugs.webkit.org/show_bug.cgi?id=163125
Patch by Olivier Blin <olivier.blin@softathome.com> on 2016-11-02
Reviewed by Michael Catanzaro.
.:
* Source/cmake/OptionsGTK.cmake: Updated to use libgcrypt files instead of gnutls.
At least version 1.6.0 is needed for the HMAC APIs.
libgcrypt is now needed unconditionally for CryptoDigest, used by CSP.
Source/WebCore:
No new tests, already covered by existing SubtleCrypto tests.
* PlatformGTK.cmake: Use libgcrypt instead of gnutls.
* crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp: Added. Adapted from the GnuTLS backend.
(WebCore::getGCryptDigestAlgorithm):
(WebCore::calculateSignature):
(WebCore::CryptoAlgorithmHMAC::platformSign):
(WebCore::CryptoAlgorithmHMAC::platformVerify):
* platform/crypto/gcrypt/CryptoDigestGCrypt.cpp: Added. Adapted from the GnuTLS backend.
(WebCore::CryptoDigest::CryptoDigest):
(WebCore::CryptoDigest::~CryptoDigest):
(WebCore::CryptoDigest::create):
(WebCore::CryptoDigest::addBytes):
(WebCore::CryptoDigest::computeHash):
Tools:
* gtk/install-dependencies: List libgcrypt for WebKitGTK+ build, and gnutls for jhbuild only.
gnutls is useful for glib-networking in jhbuild.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkChangeLog">trunk/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorePlatformGTKcmake">trunk/Source/WebCore/PlatformGTK.cmake</a></li>
<li><a href="#trunkSourcecmakeOptionsGTKcmake">trunk/Source/cmake/OptionsGTK.cmake</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsgtkinstalldependencies">trunk/Tools/gtk/install-dependencies</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li>trunk/Source/WebCore/crypto/gcrypt/</li>
<li><a href="#trunkSourceWebCorecryptogcryptCryptoAlgorithmHMACGCryptcpp">trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp</a></li>
<li>trunk/Source/WebCore/platform/crypto/gcrypt/</li>
<li><a href="#trunkSourceWebCoreplatformcryptogcryptCryptoDigestGCryptcpp">trunk/Source/WebCore/platform/crypto/gcrypt/CryptoDigestGCrypt.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/ChangeLog (208296 => 208297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/ChangeLog        2016-11-02 19:47:16 UTC (rev 208296)
+++ trunk/ChangeLog        2016-11-02 20:05:41 UTC (rev 208297)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2016-11-02 Olivier Blin <olivier.blin@softathome.com>
+
+ [GTK] Use libgcrypt instead of GnuTLS for CryptoDigest and SubtleCrypto HMAC implementation
+ https://bugs.webkit.org/show_bug.cgi?id=163125
+
+ Reviewed by Michael Catanzaro.
+
+ * Source/cmake/OptionsGTK.cmake: Updated to use libgcrypt files instead of gnutls.
+ At least version 1.6.0 is needed for the HMAC APIs.
+ libgcrypt is now needed unconditionally for CryptoDigest, used by CSP.
+
</ins><span class="cx"> 2016-11-02 Romain Bellessort <romain.bellessort@crf.canon.fr>
</span><span class="cx">
</span><span class="cx"> [Readable Streams API] Enable creation of ReadableByteStreamController
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (208296 => 208297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-11-02 19:47:16 UTC (rev 208296)
+++ trunk/Source/WebCore/ChangeLog        2016-11-02 20:05:41 UTC (rev 208297)
</span><span class="lines">@@ -1,3 +1,25 @@
</span><ins>+2016-11-02 Olivier Blin <olivier.blin@softathome.com>
+
+ [GTK] Use libgcrypt instead of GnuTLS for CryptoDigest and SubtleCrypto HMAC implementation
+ https://bugs.webkit.org/show_bug.cgi?id=163125
+
+ Reviewed by Michael Catanzaro.
+
+ No new tests, already covered by existing SubtleCrypto tests.
+
+ * PlatformGTK.cmake: Use libgcrypt instead of gnutls.
+ * crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp: Added. Adapted from the GnuTLS backend.
+ (WebCore::getGCryptDigestAlgorithm):
+ (WebCore::calculateSignature):
+ (WebCore::CryptoAlgorithmHMAC::platformSign):
+ (WebCore::CryptoAlgorithmHMAC::platformVerify):
+ * platform/crypto/gcrypt/CryptoDigestGCrypt.cpp: Added. Adapted from the GnuTLS backend.
+ (WebCore::CryptoDigest::CryptoDigest):
+ (WebCore::CryptoDigest::~CryptoDigest):
+ (WebCore::CryptoDigest::create):
+ (WebCore::CryptoDigest::addBytes):
+ (WebCore::CryptoDigest::computeHash):
+
</ins><span class="cx"> 2016-11-02 Brent Fulgham <bfulgham@apple.com>
</span><span class="cx">
</span><span class="cx"> REGRESSION(r203289):Assertion in MathOperator::stretchTo() on Wikipedia Page
</span></span></pre></div>
<a id="trunkSourceWebCorePlatformGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/PlatformGTK.cmake (208296 => 208297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/PlatformGTK.cmake        2016-11-02 19:47:16 UTC (rev 208296)
+++ trunk/Source/WebCore/PlatformGTK.cmake        2016-11-02 20:05:41 UTC (rev 208297)
</span><span class="lines">@@ -89,7 +89,7 @@
</span><span class="cx">
</span><span class="cx"> platform/audio/glib/AudioBusGLib.cpp
</span><span class="cx">
</span><del>- platform/crypto/gnutls/CryptoDigestGnuTLS.cpp
</del><ins>+ platform/crypto/gcrypt/CryptoDigestGCrypt.cpp
</ins><span class="cx">
</span><span class="cx"> platform/gamepad/glib/GamepadsGlib.cpp
</span><span class="cx">
</span><span class="lines">@@ -274,9 +274,9 @@
</span><span class="cx"> ${GLIB_GMODULE_LIBRARIES}
</span><span class="cx"> ${GLIB_GOBJECT_LIBRARIES}
</span><span class="cx"> ${GLIB_LIBRARIES}
</span><del>- ${GNUTLS_LIBRARIES}
</del><span class="cx"> ${GUDEV_LIBRARIES}
</span><span class="cx"> ${HARFBUZZ_LIBRARIES}
</span><ins>+ ${LIBGCRYPT_LIBRARIES}
</ins><span class="cx"> ${LIBSECRET_LIBRARIES}
</span><span class="cx"> ${LIBSOUP_LIBRARIES}
</span><span class="cx"> ${LIBXML2_LIBRARIES}
</span><span class="lines">@@ -302,9 +302,9 @@
</span><span class="cx"> ${GEOCLUE_INCLUDE_DIRS}
</span><span class="cx"> ${GIO_UNIX_INCLUDE_DIRS}
</span><span class="cx"> ${GLIB_INCLUDE_DIRS}
</span><del>- ${GNUTLS_INCLUDE_DIRS}
</del><span class="cx"> ${GUDEV_INCLUDE_DIRS}
</span><span class="cx"> ${HARFBUZZ_INCLUDE_DIRS}
</span><ins>+ ${LIBGCRYPT_INCLUDE_DIRS}
</ins><span class="cx"> ${LIBSECRET_INCLUDE_DIRS}
</span><span class="cx"> ${LIBSOUP_INCLUDE_DIRS}
</span><span class="cx"> ${LIBXML2_INCLUDE_DIR}
</span><span class="lines">@@ -420,9 +420,10 @@
</span><span class="cx"> crypto/algorithms/CryptoAlgorithmSHA384.cpp
</span><span class="cx"> crypto/algorithms/CryptoAlgorithmSHA512.cpp
</span><span class="cx">
</span><ins>+ crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp
+
</ins><span class="cx"> crypto/gnutls/CryptoAlgorithmAES_CBCGnuTLS.cpp
</span><span class="cx"> crypto/gnutls/CryptoAlgorithmAES_KWGnuTLS.cpp
</span><del>- crypto/gnutls/CryptoAlgorithmHMACGnuTLS.cpp
</del><span class="cx"> crypto/gnutls/CryptoAlgorithmRSAES_PKCS1_v1_5GnuTLS.cpp
</span><span class="cx"> crypto/gnutls/CryptoAlgorithmRSASSA_PKCS1_v1_5GnuTLS.cpp
</span><span class="cx"> crypto/gnutls/CryptoAlgorithmRSA_OAEPGnuTLS.cpp
</span></span></pre></div>
<a id="trunkSourceWebCorecryptogcryptCryptoAlgorithmHMACGCryptcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp (0 => 208297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp         (rev 0)
+++ trunk/Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp        2016-11-02 20:05:41 UTC (rev 208297)
</span><span class="lines">@@ -0,0 +1,133 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L.
+ * Copyright (C) 2016 SoftAtHome
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "CryptoAlgorithmHMAC.h"
+
+#if ENABLE(SUBTLE_CRYPTO)
+
+#include "CryptoAlgorithmHmacParamsDeprecated.h"
+#include "CryptoKeyHMAC.h"
+#include "ExceptionCode.h"
+#include <gcrypt.h>
+#include <wtf/CryptographicUtilities.h>
+
+namespace WebCore {
+
+static int getGCryptDigestAlgorithm(CryptoAlgorithmIdentifier hashFunction)
+{
+ switch (hashFunction) {
+ case CryptoAlgorithmIdentifier::SHA_1:
+ return GCRY_MAC_HMAC_SHA1;
+ case CryptoAlgorithmIdentifier::SHA_224:
+ return GCRY_MAC_HMAC_SHA224;
+ case CryptoAlgorithmIdentifier::SHA_256:
+ return GCRY_MAC_HMAC_SHA256;
+ case CryptoAlgorithmIdentifier::SHA_384:
+ return GCRY_MAC_HMAC_SHA384;
+ case CryptoAlgorithmIdentifier::SHA_512:
+ return GCRY_MAC_HMAC_SHA512;
+ default:
+ return GCRY_MAC_NONE;
+ }
+}
+
+static bool calculateSignature(int algorithm, const Vector<uint8_t>& key, const CryptoOperationData& data, Vector<uint8_t>& signature)
+{
+ size_t digestLength = gcry_mac_get_algo_maclen(algorithm);
+ const void* keyData = key.data() ? key.data() : reinterpret_cast<const uint8_t*>("");
+
+ bool result = false;
+ gcry_mac_hd_t hd;
+ gcry_error_t err;
+
+ err = gcry_mac_open(&hd, algorithm, 0, nullptr);
+ if (err)
+ goto cleanup;
+
+ err = gcry_mac_setkey(hd, keyData, key.size());
+ if (err)
+ goto cleanup;
+
+ err = gcry_mac_write(hd, data.first, data.second);
+ if (err)
+ goto cleanup;
+
+ signature.resize(digestLength);
+ err = gcry_mac_read(hd, signature.data(), &digestLength);
+ if (err)
+ goto cleanup;
+
+ signature.resize(digestLength);
+ result = true;
+
+cleanup:
+ if (hd)
+ gcry_mac_close(hd);
+
+ return result;
+}
+
+void CryptoAlgorithmHMAC::platformSign(const CryptoAlgorithmHmacParamsDeprecated& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& data, VectorCallback&& callback, VoidCallback&& failureCallback, ExceptionCode& ec)
+{
+ UNUSED_PARAM(failureCallback);
+ int algorithm = getGCryptDigestAlgorithm(parameters.hash);
+ if (algorithm == GCRY_MAC_NONE) {
+ ec = NOT_SUPPORTED_ERR;
+ return;
+ }
+
+ Vector<uint8_t> signature;
+ if (calculateSignature(algorithm, key.key(), data, signature))
+ callback(signature);
+ else
+ failureCallback();
+}
+
+void CryptoAlgorithmHMAC::platformVerify(const CryptoAlgorithmHmacParamsDeprecated& parameters, const CryptoKeyHMAC& key, const CryptoOperationData& expectedSignature, const CryptoOperationData& data, BoolCallback&& callback, VoidCallback&& failureCallback, ExceptionCode& ec)
+{
+ UNUSED_PARAM(failureCallback);
+ int algorithm = getGCryptDigestAlgorithm(parameters.hash);
+ if (algorithm == GCRY_MAC_NONE) {
+ ec = NOT_SUPPORTED_ERR;
+ return;
+ }
+
+ Vector<uint8_t> signature;
+ if (!calculateSignature(algorithm, key.key(), data, signature)) {
+ failureCallback();
+ return;
+ }
+
+ // Using a constant time comparison to prevent timing attacks.
+ bool result = signature.size() == expectedSignature.second && !constantTimeMemcmp(signature.data(), expectedSignature.first, signature.size());
+
+ callback(result);
+}
+
+}
+
+#endif // ENABLE(SUBTLE_CRYPTO)
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformcryptogcryptCryptoDigestGCryptcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/crypto/gcrypt/CryptoDigestGCrypt.cpp (0 => 208297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/crypto/gcrypt/CryptoDigestGCrypt.cpp         (rev 0)
+++ trunk/Source/WebCore/platform/crypto/gcrypt/CryptoDigestGCrypt.cpp        2016-11-02 20:05:41 UTC (rev 208297)
</span><span class="lines">@@ -0,0 +1,97 @@
</span><ins>+/*
+ * Copyright (C) 2014 Igalia S.L.
+ * Copyright (C) 2016 SoftAtHome
+ *
+ * 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. 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 INC. 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 "CryptoDigest.h"
+
+#include <gcrypt.h>
+
+namespace WebCore {
+
+struct CryptoDigestContext {
+ int algorithm;
+ gcry_md_hd_t md;
+};
+
+CryptoDigest::CryptoDigest()
+ : m_context(new CryptoDigestContext)
+{
+}
+
+CryptoDigest::~CryptoDigest()
+{
+}
+
+std::unique_ptr<CryptoDigest> CryptoDigest::create(CryptoDigest::Algorithm algorithm)
+{
+ int gcryptAlgorithm;
+
+ switch (algorithm) {
+ case CryptoDigest::Algorithm::SHA_1:
+ gcryptAlgorithm = GCRY_MD_SHA1;
+ break;
+ case CryptoDigest::Algorithm::SHA_224:
+ gcryptAlgorithm = GCRY_MD_SHA224;
+ break;
+ case CryptoDigest::Algorithm::SHA_256:
+ gcryptAlgorithm = GCRY_MD_SHA256;
+ break;
+ case CryptoDigest::Algorithm::SHA_384:
+ gcryptAlgorithm = GCRY_MD_SHA384;
+ break;
+ case CryptoDigest::Algorithm::SHA_512:
+ gcryptAlgorithm = GCRY_MD_SHA512;
+ break;
+ }
+
+ std::unique_ptr<CryptoDigest> digest(new CryptoDigest);
+ digest->m_context->algorithm = gcryptAlgorithm;
+
+ gcry_md_open(&digest->m_context->md, gcryptAlgorithm, 0);
+ if (!digest->m_context->md)
+ return nullptr;
+
+ return digest;
+}
+
+void CryptoDigest::addBytes(const void* input, size_t length)
+{
+ gcry_md_write(m_context->md, input, length);
+}
+
+Vector<uint8_t> CryptoDigest::computeHash()
+{
+ int digestLen = gcry_md_get_algo_dlen(m_context->algorithm);
+ Vector<uint8_t> result(digestLen);
+
+ gcry_md_final(m_context->md);
+ memcpy(result.data(), gcry_md_read(m_context->md, 0), digestLen);
+ gcry_md_close(m_context->md);
+
+ return result;
+}
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourcecmakeOptionsGTKcmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/cmake/OptionsGTK.cmake (208296 => 208297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/cmake/OptionsGTK.cmake        2016-11-02 19:47:16 UTC (rev 208296)
+++ trunk/Source/cmake/OptionsGTK.cmake        2016-11-02 20:05:41 UTC (rev 208297)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> find_package(Cairo 1.10.2 REQUIRED)
</span><span class="cx"> find_package(Fontconfig 2.8.0 REQUIRED)
</span><span class="cx"> find_package(Freetype2 2.4.2 REQUIRED)
</span><del>-find_package(GnuTLS 3.0.0 REQUIRED)
</del><ins>+find_package(LibGcrypt 1.6.0 REQUIRED)
</ins><span class="cx"> find_package(GTK3 3.6.0 REQUIRED)
</span><span class="cx"> find_package(GDK3 3.6.0 REQUIRED)
</span><span class="cx"> find_package(HarfBuzz 0.9.2 REQUIRED)
</span><span class="lines">@@ -276,10 +276,6 @@
</span><span class="cx"> SET_AND_EXPOSE_TO_BUILD(USE_OPENWEBRTC TRUE)
</span><span class="cx"> endif ()
</span><span class="cx">
</span><del>-if (ENABLE_LEGACY_ENCRYPTED_MEDIA)
- find_package(LibGcrypt REQUIRED)
-endif ()
-
</del><span class="cx"> SET_AND_EXPOSE_TO_BUILD(USE_TEXTURE_MAPPER TRUE)
</span><span class="cx">
</span><span class="cx"> if (ENABLE_OPENGL)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (208296 => 208297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-11-02 19:47:16 UTC (rev 208296)
+++ trunk/Tools/ChangeLog        2016-11-02 20:05:41 UTC (rev 208297)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-11-02 Olivier Blin <olivier.blin@softathome.com>
+
+ [GTK] Use libgcrypt instead of GnuTLS for CryptoDigest and SubtleCrypto HMAC implementation
+ https://bugs.webkit.org/show_bug.cgi?id=163125
+
+ Reviewed by Michael Catanzaro.
+
+ * gtk/install-dependencies: List libgcrypt for WebKitGTK+ build, and gnutls for jhbuild only.
+ gnutls is useful for glib-networking in jhbuild.
+
</ins><span class="cx"> 2016-11-02 Carlos Garcia Campos <cgarcia@igalia.com>
</span><span class="cx">
</span><span class="cx"> NetworkSession: Network process crash when converting main resource to download
</span></span></pre></div>
<a id="trunkToolsgtkinstalldependencies"></a>
<div class="modfile"><h4>Modified: trunk/Tools/gtk/install-dependencies (208296 => 208297)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/gtk/install-dependencies        2016-11-02 19:47:16 UTC (rev 208296)
+++ trunk/Tools/gtk/install-dependencies        2016-11-02 20:05:41 UTC (rev 208297)
</span><span class="lines">@@ -106,11 +106,11 @@
</span><span class="cx"> libedit-dev \
</span><span class="cx"> libenchant-dev \
</span><span class="cx"> libfaad-dev \
</span><ins>+ $(aptIfElse libgcrypt20-dev libgcrypt11-dev) \
</ins><span class="cx"> $(aptIfElse libgeoclue-2-dev libgeoclue-dev) \
</span><span class="cx"> libgirepository1.0-dev \
</span><span class="cx"> libgl1-mesa-dev \
</span><span class="cx"> libgl1-mesa-glx \
</span><del>- libgnutls28-dev \
</del><span class="cx"> libgtk2.0-dev \
</span><span class="cx"> libgtk-3-dev \
</span><span class="cx"> libgstreamer1.0-dev \
</span><span class="lines">@@ -173,8 +173,8 @@
</span><span class="cx"> libevdev-dev \
</span><span class="cx"> libexpat1-dev \
</span><span class="cx"> libgbm-dev \
</span><del>- libgcrypt11-dev \
</del><span class="cx"> libgles2-mesa-dev \
</span><ins>+ libgnutls28-dev \
</ins><span class="cx"> libgpg-error-dev \
</span><span class="cx"> libjson-glib-dev \
</span><span class="cx"> libinput-dev \
</span><span class="lines">@@ -256,7 +256,6 @@
</span><span class="cx"> gobject-introspection \
</span><span class="cx"> mesa \
</span><span class="cx"> mesa-libgl \
</span><del>- gnutls \
</del><span class="cx"> gtk2 \
</span><span class="cx"> gtk3 \
</span><span class="cx"> libsystemd \
</span><span class="lines">@@ -264,6 +263,7 @@
</span><span class="cx"> mpg123 \
</span><span class="cx"> opus \
</span><span class="cx"> pango \
</span><ins>+ libgcrypt \
</ins><span class="cx"> libnotify \
</span><span class="cx"> libpng \
</span><span class="cx"> libpulse \
</span><span class="lines">@@ -308,6 +308,7 @@
</span><span class="cx"> packages="$packages \
</span><span class="cx"> expat \
</span><span class="cx"> git \
</span><ins>+ gnutls \
</ins><span class="cx"> gobject-introspection \
</span><span class="cx"> gsettings-desktop-schemas \
</span><span class="cx"> icon-naming-utils \
</span><span class="lines">@@ -315,7 +316,6 @@
</span><span class="cx"> libdrm \
</span><span class="cx"> libepoxy \
</span><span class="cx"> libevdev \
</span><del>- libgcrypt \
</del><span class="cx"> libgpg-error \
</span><span class="cx"> libinput \
</span><span class="cx"> p11-kit \
</span><span class="lines">@@ -369,7 +369,6 @@
</span><span class="cx"> gcc-c++ \
</span><span class="cx"> geoclue2-devel \
</span><span class="cx"> gettext-devel \
</span><del>- gnutls-devel \
</del><span class="cx"> gobject-introspection-devel \
</span><span class="cx"> gperf \
</span><span class="cx"> gstreamer1-devel \
</span><span class="lines">@@ -384,6 +383,7 @@
</span><span class="cx"> libXtst-devel \
</span><span class="cx"> libxslt-devel \
</span><span class="cx"> libedit-devel \
</span><ins>+ libgcrypt-devel \
</ins><span class="cx"> libgudev1-devel \
</span><span class="cx"> libjpeg-turbo-devel \
</span><span class="cx"> libnotify-devel \
</span><span class="lines">@@ -435,6 +435,7 @@
</span><span class="cx"> docbook-utils-pdf \
</span><span class="cx"> git \
</span><span class="cx"> gobject-introspection \
</span><ins>+ gnutls-devel \
</ins><span class="cx"> gsettings-desktop-schemas-devel \
</span><span class="cx"> icon-naming-utils \
</span><span class="cx"> itstool \
</span><span class="lines">@@ -443,7 +444,6 @@
</span><span class="cx"> libdrm-devel \
</span><span class="cx"> libepoxy-devel \
</span><span class="cx"> libevdev-devel
</span><del>- libgcrypt-devel \
</del><span class="cx"> libgpg-error-devel \
</span><span class="cx"> libinput-devel \
</span><span class="cx"> libp11-devel \
</span></span></pre>
</div>
</div>
</body>
</html>