<!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">
<div style="">
<p dir="auto">Hi Daiki,</p>
<blockquote dir="auto">
<p>Is this internal IV subject to validation?</p>
</blockquote>
<p dir="auto">Yes, I need the IV after an encrypt or decrypt operation.</p>
<blockquote dir="auto">
<p>Wouldn't it be feasible to do
something like (not tested at all though):</p>
</blockquote>
<blockquote dir="auto">
<pre class="code highlight js-syntax-highlight c" lang="c" v-pre="true"><code><span id="LC1" class="line" lang="c"><span class="n">gnutls_cipher_init</span><span class="p">(</span><span class="o">&</span><span class="n">ch</span><span class="p">,</span> <span class="n">GNUTLS_CIPHER_AES_128_CFB8</span><span class="p">,</span> <span class="o">&</span><span class="n">key</span><span class="p">,</span> <span class="o">&</span><span class="n">iv</span><span class="p">);</span></span>
<span id="LC2" class="line" lang="c"><span class="n">gnutls_cipher_encrypt</span><span class="p">(</span><span class="n">ch</span><span class="p">,</span> <span class="n">data</span><span class="p">.</span><span class="n">data</span><span class="p">,</span> <span class="n">data</span><span class="p">.</span><span class="n">size</span><span class="p">);</span></span>
<span id="LC3" class="line" lang="c"><span class="n">block_size</span> <span class="o">=</span> <span class="n">gnutls_cipher_get_block_size</span><span class="p">(</span><span class="n">GNUTLS_CIPHER_AES_128_CFB8</span><span class="p">);</span></span>
<span id="LC4" class="line" lang="c"><span class="k">if</span> <span class="p">(</span><span class="n">data</span><span class="p">.</span><span class="n">size</span> <span class="o"><</span> <span class="n">block_size</span><span class="p">)</span> <span class="p">{</span></span>
<span id="LC5" class="line" lang="c"> <span class="cm">/* concatenate the initial IV and ciphertext */</span></span>
<span id="LC6" class="line" lang="c"> <span class="n">memcpy</span><span class="p">(</span><span class="n">next_iv</span><span class="p">,</span> <span class="n">iv</span><span class="p">.</span><span class="n">data</span> <span class="o">+</span> <span class="n">block_size</span> <span class="o">-</span> <span class="p">(</span><span class="n">block_size</span> <span class="o">-</span> <span class="n">data</span><span class="p">.</span><span class="n">size</span><span class="p">),</span></span>
<span id="LC7" class="line" lang="c"><span class="n">block_size</span> <span class="o">-</span> <span class="n">data</span><span class="p">.</span><span class="n">size</span><span class="p">);</span> <span class="n">memcpy</span><span class="p">(</span><span class="n">next_iv</span> <span class="o">+</span> <span class="n">block_size</span> <span class="o">-</span> <span class="n">data</span><span class="p">.</span><span class="n">size</span><span class="p">,</span></span>
<span id="LC8" class="line" lang="c"><span class="n">data</span><span class="p">.</span><span class="n">data</span><span class="p">,</span> <span class="n">block_size</span> <span class="o">-</span> <span class="p">(</span><span class="n">block_size</span> <span class="o">-</span> <span class="n">data</span><span class="p">.</span><span class="n">size</span><span class="p">));</span> <span class="p">}</span> <span class="k">else</span> <span class="p">{</span></span>
<span id="LC9" class="line" lang="c"> <span class="cm">/* use the last block of the ciphertext */</span></span>
<span id="LC10" class="line" lang="c"> <span class="n">memcpy</span><span class="p">(</span><span class="n">next_iv</span><span class="p">,</span> <span class="n">data</span><span class="p">.</span><span class="n">data</span> <span class="o">+</span> <span class="p">(</span><span class="n">data</span><span class="p">.</span><span class="n">size</span> <span class="o">-</span> <span class="n">block_size</span><span class="p">),</span> <span class="n">block_size</span><span class="p">);</span></span>
<span id="LC11" class="line" lang="c"><span class="p">}</span></span></code></pre>
</blockquote>
<p dir="auto">It seems that you are proposing to re-create the IV operation GnuTLS applies
in the calling code. This is not permissible. We need the IV that was left by
GnuTLS' operation.</p>
<p dir="auto">Ciao
Stephan</p>
</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/988#note_166225271">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/33fa2f121f5bacb4fe86e9d5a46989b4/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/988#note_166225271"}}</script>
</p>
</div>
</body>
</html>