<!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/lumag">Dmitry Eremin-Solenikov</a>
commented on a discussion
on <a href="https://gitlab.com/gnutls/gnutls/merge_requests/992#note_167534005">lib/nettle/gost/streebog.c</a>:
</p>
<table>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="1219" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
1219
</td>
<td class="diff-line-num new_line" data-linenumber="1219" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
1219
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC1219" class="line" lang="c">        <span class="p">}</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="1220" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
1220
</td>
<td class="diff-line-num new_line" data-linenumber="1220" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
1220
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC1220" class="line" lang="c">    <span class="p">}</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="1221" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
1221
</td>
<td class="diff-line-num new_line" data-linenumber="1221" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
1221
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC1221" class="line" lang="c"></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="diff-line-num new old_line" data-linenumber="1222" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="diff-line-num new new_line" data-linenumber="1222" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
1222
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC1222" class="line" lang="c">  <span class="n" style="color: #333;">cf</span> <span class="o" style="font-weight: 600;">=</span> <span class="mi" style="color: #099;">0</span><span class="p">;</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="1222" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
1222
</td>
<td class="diff-line-num new_line" data-linenumber="1223" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
1223
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC1223" class="line" lang="c">  <span class="n" style="color: #333;">ctx</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">sigma</span><span class="p">[</span><span class="mi" style="color: #099;">0</span><span class="p">]</span> <span class="o" style="font-weight: 600;">+=</span> <span class="n" style="color: #333;">M</span><span class="p">[</span><span class="mi" style="color: #099;">0</span><span class="p">];</span></span>
</pre>
</td>
</tr>
<tr class="line_holder" id="">
<td class="diff-line-num old_line" data-linenumber="1223" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
1223
</td>
<td class="diff-line-num new_line" data-linenumber="1224" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #f0f0f0; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#fafafa">
1224
</td>
<td class="line_content" style="padding-left: 0.5em; padding-right: 0.5em;">
<pre style="margin: 0;"> <span id="LC1224" class="line" lang="c">  <span class="k" style="font-weight: 600;">for</span> <span class="p">(</span><span class="n" style="color: #333;">i</span> <span class="o" style="font-weight: 600;">=</span> <span class="mi" style="color: #099;">1</span><span class="p">;</span> <span class="n" style="color: #333;">i</span> <span class="o" style="font-weight: 600;"><</span> <span class="mi" style="color: #099;">8</span><span class="p">;</span> <span class="n" style="color: #333;">i</span><span class="o" style="font-weight: 600;">++</span><span class="p">)</span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="">
<td class="diff-line-num old old_line" data-linenumber="1224" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
1224
</td>
<td class="diff-line-num new_line old" data-linenumber="1225" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC1224" class="line" lang="c">    <span class="k" style="font-weight: 600;"><span class="idiff left">if</span></span><span class="idiff"> </span><span class="p"><span class="idiff">(</span></span><span class="n" style="color: #333;"><span class="idiff">ctx</span></span><span class="o" style="font-weight: 600;"><span class="idiff">-></span></span><span class="n" style="color: #333;"><span class="idiff">sigma</span></span><span class="p"><span class="idiff">[</span></span><span class="n" style="color: #333;"><span class="idiff">i</span></span><span class="o" style="font-weight: 600;"><span class="idiff">-</span></span><span class="mi" style="color: #099;"><span class="idiff">1</span></span><span class="p"><span class="idiff">]</span></span><span class="idiff"> </span><span class="o" style="font-weight: 600;"><span class="idiff"><</span></span><span class="idiff"> </span><span class="n" style="color: #333;"><span class="idiff">M</span></span><span class="p"><span class="idiff">[</span></span><span class="n" style="color: #333;"><span class="idiff">i</span></span><span class="o" style="font-weight: 600;"><span class="idiff">-</span></span><span class="mi" style="color: #099;"><span class="idiff">1</span></span><span class="p"><span class="idiff right">])</span></span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="">
<td class="diff-line-num old old_line" data-linenumber="1225" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
1225
</td>
<td class="diff-line-num new_line old" data-linenumber="1225" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC1225" class="line" lang="c">      <span class="n" style="color: #333;"><span class="idiff left">ctx</span></span><span class="o" style="font-weight: 600;"><span class="idiff">-></span></span><span class="n" style="color: #333;"><span class="idiff">sigma</span></span><span class="p"><span class="idiff">[</span></span><span class="n" style="color: #333;"><span class="idiff">i</span></span><span class="p"><span class="idiff">]</span></span><span class="idiff"> </span><span class="o" style="font-weight: 600;"><span class="idiff">+=</span></span><span class="idiff"> </span><span class="n" style="color: #333;"><span class="idiff">M</span></span><span class="p"><span class="idiff">[</span></span><span class="n" style="color: #333;"><span class="idiff">i</span></span><span class="p"><span class="idiff">]</span></span><span class="idiff"> </span><span class="o" style="font-weight: 600;"><span class="idiff">+</span></span><span class="idiff"> </span><span class="mi" style="color: #099;"><span class="idiff">1</span></span><span class="p"><span class="idiff right">;</span></span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="">
<td class="diff-line-num old old_line" data-linenumber="1226" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
1226
</td>
<td class="diff-line-num new_line old" data-linenumber="1225" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC1226" class="line" lang="c"><span class="idiff left">    </span><span class="k" style="font-weight: 600;"><span class="idiff right">else</span></span></span>
</pre>
</td>
</tr>
<tr class="line_holder old" id="">
<td class="diff-line-num old old_line" data-linenumber="1227" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
1227
</td>
<td class="diff-line-num new_line old" data-linenumber="1225" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content old" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#fbe9eb">
<pre style="margin: 0;">-<span id="LC1227" class="line" lang="c">      <span class="n" style="color: #333;">ctx</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">sigma</span><span class="p">[</span><span class="n" style="color: #333;">i</span><span class="p">]</span> <span class="o" style="font-weight: 600;">+=</span> <span class="n" style="color: #333;">M</span><span class="p">[</span><span class="n" style="color: #333;">i</span><span class="p">];</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="diff-line-num new old_line" data-linenumber="1228" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="diff-line-num new new_line" data-linenumber="1225" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
1225
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC1225" class="line" lang="c">    <span class="p"><span class="idiff left right">{</span></span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="diff-line-num new old_line" data-linenumber="1228" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="diff-line-num new new_line" data-linenumber="1226" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
1226
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC1226" class="line" lang="c">      <span class="k" style="font-weight: 600;"><span class="idiff left">if</span></span><span class="idiff"> </span><span class="p"><span class="idiff">(</span></span><span class="n" style="color: #333;"><span class="idiff">ctx</span></span><span class="o" style="font-weight: 600;"><span class="idiff">-></span></span><span class="n" style="color: #333;"><span class="idiff">sigma</span></span><span class="p"><span class="idiff">[</span></span><span class="n" style="color: #333;"><span class="idiff">i</span></span><span class="o" style="font-weight: 600;"><span class="idiff">-</span></span><span class="mi" style="color: #099;"><span class="idiff">1</span></span><span class="p"><span class="idiff">]</span></span><span class="idiff"> </span><span class="o" style="font-weight: 600;"><span class="idiff">!=</span></span><span class="idiff"> </span><span class="n" style="color: #333;"><span class="idiff">M</span></span><span class="p"><span class="idiff">[</span></span><span class="n" style="color: #333;"><span class="idiff">i</span></span><span class="o" style="font-weight: 600;"><span class="idiff">-</span></span><span class="mi" style="color: #099;"><span class="idiff">1</span></span><span class="p"><span class="idiff right">])</span></span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="diff-line-num new old_line" data-linenumber="1228" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="diff-line-num new new_line" data-linenumber="1227" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
1227
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC1227" class="line" lang="c"><span class="idiff left">  </span><span class="n" style="color: #333;"><span class="idiff">cf</span></span><span class="idiff"> </span><span class="o" style="font-weight: 600;"><span class="idiff">=</span></span><span class="idiff"> </span><span class="p"><span class="idiff">(</span></span><span class="n" style="color: #333;"><span class="idiff">ctx</span></span><span class="o" style="font-weight: 600;"><span class="idiff">-></span></span><span class="n" style="color: #333;"><span class="idiff">sigma</span></span><span class="p"><span class="idiff">[</span></span><span class="n" style="color: #333;"><span class="idiff">i</span></span><span class="o" style="font-weight: 600;"><span class="idiff">-</span></span><span class="mi" style="color: #099;"><span class="idiff">1</span></span><span class="p"><span class="idiff">]</span></span><span class="idiff"> </span><span class="o" style="font-weight: 600;"><span class="idiff"><</span></span><span class="idiff"> </span><span class="n" style="color: #333;"><span class="idiff">M</span></span><span class="p"><span class="idiff">[</span></span><span class="n" style="color: #333;"><span class="idiff">i</span></span><span class="o" style="font-weight: 600;"><span class="idiff">-</span></span><span class="mi" style="color: #099;"><span class="idiff">1</span></span><span class="p"><span class="idiff right">]);</span></span></span>
</pre>
</td>
</tr>

</table>
<div style="">
<p dir="auto">No, it will be reset once there is no carried overflow.
In your example (if we use bytes instead of u64, lsb arrays):
sigma = 01 00 00 00
M = ff 00 00 00
0. sigma = <strong>00</strong> 00 00 00</p>
<ol dir="auto">
<li>i = 1, cf = 1, sigma = 00 <strong>01</strong> 00 00</li>
<li>i = 2, cf = 0, sigma = 00 01 <strong>00</strong> 00</li>
<li>i = 3, cf = 0, sigma = 00 01 00 <strong>00</strong>
</li>
</ol>
<p dir="auto">A failing example:
sigma = ff ff ff 00 00
M = ff ff ff 00 00
then:
0. sigma = <strong>fe</strong> ff ff 00 00</p>
<ol dir="auto">
<li>i = 1, cf = 1 (overflow), sigma = fe <strong>ff</strong> ff 00 00</li>
<li>i = 2, cf = 1 (carried), sigma = fe ff <strong>ff</strong> 00 00 (with current code this would be fe ff <strong>fe</strong> 00 00)</li>
<li>i = 3, cf = 1 (carried), sigma = fe ff ff <strong>01</strong> 00</li>
<li>i = 4, cf = 0 (reset, no overflow), sigma = fe ff ff 01 <strong>00</strong>
</li>
</ol>
</div>


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

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/merge_requests/992#note_167534005">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/d44b8f7726cf71dcf451befdab4f4ae1/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 Merge request","url":"https://gitlab.com/gnutls/gnutls/merge_requests/992#note_167534005"}}</script>

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