<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK] Use libgcrypt instead of GnuTLS for CryptoDigest and SubtleCrypto HMAC implementation"
   href="https://bugs.webkit.org/show_bug.cgi?id=163125#c8">Comment # 8</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GTK] Use libgcrypt instead of GnuTLS for CryptoDigest and SubtleCrypto HMAC implementation"
   href="https://bugs.webkit.org/show_bug.cgi?id=163125">bug 163125</a>
              from <span class="vcard"><a class="email" href="mailto:olivier.blin&#64;softathome.com" title="Olivier Blin &lt;olivier.blin&#64;softathome.com&gt;"> <span class="fn">Olivier Blin</span></a>
</span></b>
        <pre>(In reply to <a href="show_bug.cgi?id=163125#c7">comment #7</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=290961&amp;action=diff" name="attach_290961" title="Patch">attachment 290961</a> <a href="attachment.cgi?id=290961&amp;action=edit" title="Patch">[details]</a></span>
&gt; Patch
&gt; 
&gt; View in context:
&gt; <a href="https://bugs.webkit.org/attachment.cgi?id=290961&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=290961&amp;action=review</a>
&gt; 
&gt; Thanks for working on this! I'm giving r+ but with several things that need
&gt; fixed before committing:
&gt; 
&gt; &gt; Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:3
&gt; &gt; + * Copyright (C) 2014 Igalia S.L. All rights reserved.
&gt; &gt; + * Copyright (C) 2016 SoftAtHome. All rights reserved.
&gt; 
&gt; Please remove the &quot;All rights reserved&quot; since that contradicts the license
&gt; right below.</span >

This is actually copied from CryptoAlgorithmHMACGnuTLS.cpp, from Igalia.

Is the following fine?

+ * Copyright (C) 2014 Igalia S.L.
+ * Copyright (C) 2016 SoftAtHome

<span class="quote">&gt; &gt; Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:81
&gt; &gt; +    UNUSED_PARAM(failureCallback);
&gt; &gt; +    int algorithm = getGCryptDigestAlgorithm(parameters.hash);
&gt; &gt; +    if (algorithm == GCRY_MAC_NONE) {
&gt; &gt; +        ec = NOT_SUPPORTED_ERR;
&gt; &gt; +        return;
&gt; 
&gt; You don't need to call failureCallback when the function fails...?</span >

I wondered about this too, but this is also copied from the gnutls flavor.
The Mac flavor is also ignoring the failure callback.

I can use failureCallback, not sure about unwanted side-effects.

<span class="quote">&gt; &gt; Source/WebCore/platform/crypto/gcrypt/CryptoDigestGCrypt.cpp:73
&gt; &gt; +    switch (algorithm) {
&gt; &gt; +    case CryptoDigest::Algorithm::SHA_1: {
&gt; &gt; +        gcryptAlgorithm = GCRY_MD_SHA1;
&gt; &gt; +        break;
&gt; &gt; +    }
&gt; &gt; +    case CryptoDigest::Algorithm::SHA_224: {
&gt; &gt; +        gcryptAlgorithm = GCRY_MD_SHA224;
&gt; &gt; +        break;
&gt; &gt; +    }
&gt; &gt; +    case CryptoDigest::Algorithm::SHA_256: {
&gt; &gt; +        gcryptAlgorithm = GCRY_MD_SHA256;
&gt; &gt; +        break;
&gt; &gt; +    }
&gt; &gt; +    case CryptoDigest::Algorithm::SHA_384: {
&gt; &gt; +        gcryptAlgorithm = GCRY_MD_SHA384;
&gt; &gt; +        break;
&gt; &gt; +    }
&gt; &gt; +    case CryptoDigest::Algorithm::SHA_512: {
&gt; &gt; +        gcryptAlgorithm = GCRY_MD_SHA512;
&gt; &gt; +        break;
&gt; &gt; +    }
&gt; &gt; +    }
&gt; 
&gt; You don't need the extra braces around the cases here, since you're not
&gt; declaring any variables in the cases.</span >

Sure, I kept the existing style from the gnutls file, but I will fix.

<span class="quote">&gt; &gt; Source/cmake/FindGCrypt.cmake:23
&gt; &gt; +    # set(GCRYPT_FOUND TRUE)
&gt; 
&gt; Well that's not right, did you comment it out for testing? Or was it broken
&gt; already when you copied it from wherever its upstream is?</span >

I copied it from <a href="https://github.com/substack/libssh/blob/master/cmake/Modules/FindGCrypt.cmake">https://github.com/substack/libssh/blob/master/cmake/Modules/FindGCrypt.cmake</a> , but it seems to be an old copy.
The real upstream of libssh is this one, with an additional &quot;cmake: Update GCrypt module&quot; commit:
<a href="https://git.libssh.org/projects/libssh.git/tree/cmake/Modules/FindGCrypt.cmake">https://git.libssh.org/projects/libssh.git/tree/cmake/Modules/FindGCrypt.cmake</a>

Does it look better?

It still has a &quot;GCRYPT_FOUND&quot; comment on top, while the file never defines it.

Another alternative is this one:
<a href="https://quickgit.kde.org/?p=kwallet.git&amp;a=blob&amp;h=20053f1a790c99d5d75c495ed7c3255867d4efb7&amp;hb=23344979ed047053256e21638338ef67a1a937ff&amp;f=cmake%2FFindLibGcrypt.cmake">https://quickgit.kde.org/?p=kwallet.git&amp;a=blob&amp;h=20053f1a790c99d5d75c495ed7c3255867d4efb7&amp;hb=23344979ed047053256e21638338ef67a1a937ff&amp;f=cmake%2FFindLibGcrypt.cmake</a>

<span class="quote">&gt; &gt; Source/cmake/FindGCrypt.cmake:70
&gt; &gt; +endif (GCRYPT_LIBRARIES AND GCRYPT_INCLUDE_DIRS)
&gt; 
&gt; WebKit CMake style is endif ()</span >

Ok

<span class="quote">&gt; &gt; Source/cmake/OptionsGTK.cmake:35
&gt; &gt; +find_package(GCrypt REQUIRED)
&gt; 
&gt; All the functions you used were available in the first release of GCrypt?
&gt; 
&gt; &gt; Tools/ChangeLog:8
&gt; &gt; +        * gtk/install-dep endencies: List libgcrypt for WebKitGTK+ build, and gnutls for jhbuild only.
&gt; 
&gt; Er, why keep GnuTLS? You've completely removed the dependency, so you can
&gt; get rid of it, right?</span >

For glib-networking in jhbuild</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>