<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Hi folks,</p>
<p>I have implementation-specific question.</p>
<p>Here is a quote from Noise spec:</p>
<p>
<blockquote type="cite">
<ul>
<li>
<p><strong><code>EncryptWithAd(ad, plaintext)</code></strong>:
If <code>k</code> is non-empty returns <code>ENCRYPT(k,
n++, ad, plaintext)</code>. Otherwise returns <code>plaintext</code>.</p>
</li>
</ul>
</blockquote>
Since there might be an error during decryption (MAC is incorrect
as an example), when should `n` be incremented?</p>
<p>`noise-c` library does this immediately after decryption
independently from decryption result:</p>
<p>
<blockquote type="cite">/* Encrypt the plaintext and authenticate
it */<br>
err = (*(state->encrypt))(state, ad, ad_len, buffer->data,
buffer->size);<br>
++(state->n);<br>
if (err != NOISE_ERROR_NONE)<br>
return err;</blockquote>
However, in my use case I need to avoid nonce increment if
decryption fails, as this is a valid and acceptable behavior in my
case.</p>
<p>So should nonce be incremented immediately like it is done in
`noise-c` already or should it only be incremented on successful
decryption?<br>
</p>
<p>I'm aware that latest versions of the spec give optional control
over nonce and my use case can be implemented using it.</p>
<pre class="moz-signature" cols="0">--
Sincerely, Nazar Mokrynskyi
github.com/nazar-pc</pre>
</body>
</html>