<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>


<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">

<p style="color: #777777;">
<a href="https://gitlab.com/dueno">Daiki Ueno</a>
commented:
</p>
<div style="">
<p dir="auto">After digging it further, I'm in doubt with the <code>padlock_sha1_blocks</code> call itself. In the actual use of it in <code>sha-padlock.c</code> is the following:</p>
<pre class="code highlight js-syntax-highlight c" lang="c" v-pre="true"><code><span id="LC1" class="line" lang="c"><span class="cp">#define SHA1_COMPRESS(ctx, data) (padlock_sha1_blocks((void*)(ctx)->state, data, 1))</span></span>
<span id="LC2" class="line" lang="c"></span>
<span id="LC3" class="line" lang="c"><span class="kt">void</span></span>
<span id="LC4" class="line" lang="c"><span class="nf">padlock_sha1_update</span><span class="p">(</span><span class="k">struct</span> <span class="n">sha1_ctx</span> <span class="o">*</span><span class="n">ctx</span><span class="p">,</span></span>
<span id="LC5" class="line" lang="c">                   <span class="kt">size_t</span> <span class="n">length</span><span class="p">,</span> <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">data</span><span class="p">)</span></span>
<span id="LC6" class="line" lang="c"><span class="p">{</span></span>
<span id="LC7" class="line" lang="c">       <span class="n">MD_UPDATE</span><span class="p">(</span><span class="n">ctx</span><span class="p">,</span> <span class="n">length</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">SHA1_COMPRESS</span><span class="p">,</span> <span class="n">MD1_INCR</span><span class="p">(</span><span class="n">ctx</span><span class="p">));</span></span>
<span id="LC8" class="line" lang="c"><span class="p">}</span></span></code></pre>
<p dir="auto">where <code>MD_UPDATE</code> (defined in <code><nettle/macros.h></code>) takes a "compress" function as the 4th argument, which should have the following singature:</p>
<pre class="code highlight js-syntax-highlight c" lang="c" v-pre="true"><code><span id="LC1" class="line" lang="c"><span class="kt">void</span> <span class="nf">nettle_sha1_compress</span><span class="p">(</span><span class="kt">uint32_t</span> <span class="o">*</span><span class="n">state</span><span class="p">,</span> <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span><span class="n">input</span><span class="p">);</span></span></code></pre>
<p dir="auto">which assumes that <code>input</code> contains a complete SHA-1 block (64 bytes).
Back to the <code>SHA1_COMPRESS</code> definition above, it calls <code>padlock_sha1_blocks</code> with the last argument 1. That indicates that, <code>padlock_sha1_blocks</code> takes the number of blocks rather than the number of characters.</p>
<p dir="auto">Therefore, I conclude that the logic in <code>check_phe_partial</code> is completely wrong.</p>
</div>


</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #666;">

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/issues/1076#note_404150382">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/-/sent_notifications/79d427070957f4ea186488ab17f13dab/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.com/gnutls/gnutls/-/issues/1076#note_404150382"}}</script>


</p>
</div>
</body>
</html>