<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#c13">Comment # 13</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#c11">comment #11</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; &gt; Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:40
&gt; &gt; +static int getGCryptDigestAlgorithm(CryptoAlgorithmIdentifier hashFunction)
&gt; 
&gt; Don't use &quot;get&quot; here. You could use
&gt; cryptoAlgorithmIdentifierToGCryptDigestAlgorithm or something similar, or
&gt; gcryptDigestAlgorithmForCryptoAlgorithmIdentifier</span >

The same naming is using for the Mac and gnutls backends.

<span class="quote">&gt; &gt; Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:66
&gt; &gt; +    gcry_mac_open(&amp;hd, algorithm, 0, 0);
&gt; 
&gt; 0, nullptr</span >

Ok

<span class="quote">&gt; &gt; Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:69
&gt; &gt; +    gcry_mac_read(hd, result.data(), &amp;digestLength);
&gt; 
&gt; Don't you need to handle the return value of digestLength? Can it really be
&gt; different to result.size()? I guess it can't be bigger than value returned
&gt; by gcry_mac_get_algo_maclen, but can it be smaller? If it should be the same
&gt; size I would add an assert, otherwise you would need to resize the vector
&gt; here.</span >

It can be smaller according to the API:
<a href="https://gnupg.org/documentation/manuals/gcrypt/Working-with-MAC-algorithms.html#Working-with-MAC-algorithms">https://gnupg.org/documentation/manuals/gcrypt/Working-with-MAC-algorithms.html#Working-with-MAC-algorithms</a>

I will resize it.

<span class="quote">&gt; &gt; Source/WebCore/crypto/gcrypt/CryptoAlgorithmHMACGCrypt.cpp:72
&gt; &gt; +    return result;
&gt; 
&gt; Most of the gcry functions used above return a gcry_error_t that is not
&gt; handled at all. We should call the failureCallback in platformSign if any of
&gt; those fail.</span >

I did not find code that made use of the failureCallback, besides CryptoAlgorithmHMAC::generateKey
I'll upload a version which handles gcry failures, but it makes the layout tests hang on failure.

(In reply to <a href="show_bug.cgi?id=163125#c12">comment #12</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; &gt; Tools/gtk/install-dependencies:109
&gt; &gt;          libfaad-dev \
&gt; &gt; +        libgcrypt11-dev \
&gt; &gt;          $(aptIfElse libgeoclue-2-dev libgeoclue-dev) \
&gt; 
&gt; On Debian/Ubuntu libgcrypt11-dev is a transitional dummy package to ease the
&gt; migration from the old libgcrypt11-dev to libgcrypt20-dev. So I would use
&gt; here:
&gt; $(aptIfElse libgcrypt20-dev libgcrypt11-dev) \</span >

Ok</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>