<!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 on a
<a href="https://gitlab.com/gnutls/gnutls/-/merge_requests/1299#note_381661234">discussion</a>:
</p>
<div style="">
<p dir="auto">In summary:</p>
<blockquote dir="auto">
<ul>
<li>Shared secret generation: section 5.7.1.1 (FFC) and 5.7.1.2 (ECC) - this patch covers this check</li>
</ul>
</blockquote>
<p dir="auto">Done in <a href="https://gitlab.com/gnutls/gnutls/-/commit/bea53f1b46a64d6dcf5bbe4794740c4d4459f9bf" data-original="bea53f1b46a64d6dcf5bbe4794740c4d4459f9bf" data-link="false" data-link-reference="false" data-project="179611" data-commit="bea53f1b46a64d6dcf5bbe4794740c4d4459f9bf" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="dh: check validity of Z before export" class="gfm gfm-commit has-tooltip">bea53f1b</a> (FFC) and <a href="https://gitlab.com/gnutls/gnutls/-/commit/13202600d3e42258d8758b05ff45a3e3d0f07e4e" data-original="13202600d3e42258d8758b05ff45a3e3d0f07e4e" data-link="false" data-link-reference="false" data-project="179611" data-commit="13202600d3e42258d8758b05ff45a3e3d0f07e4e" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="ecdh: check validity of P before export" class="gfm gfm-commit has-tooltip">13202600</a> (ECC).</p>
<blockquote dir="auto">
<ul>
<li>
<p>receipt of remote public key following section 5.6.2.2.2:</p>
<ul>
<li>
<p>FFC:</p>
<p>. if PQG are RFC3526 / RFC7919 primes, then apply (at least) the partial validation from section 5.6.2.3.2</p>
<p>. otherwise perform the full validation compliant to section 5.6.2.3.1</p>
</li>
</ul>
</li>
</ul>
</blockquote>
<p dir="auto">I believe this is already done in <code>lib/nettle/pk.c:_wrap_nettle_pk_derive</code>.  The relevant code is around:</p>
<ul dir="auto">
<li><a href="https://gitlab.com/gnutls/gnutls/-/blob/master/lib/nettle/pk.c#L312">https://gitlab.com/gnutls/gnutls/-/blob/master/lib/nettle/pk.c#L312</a></li>
<li><a href="https://gitlab.com/gnutls/gnutls/-/blob/master/lib/nettle/pk.c#L322">https://gitlab.com/gnutls/gnutls/-/blob/master/lib/nettle/pk.c#L322</a></li>
</ul>
<blockquote dir="auto">
<ul>
<li>ECC: perform partial validation compliant to 5.6.2.3.4</li>
</ul>
</blockquote>
<p dir="auto">This is also done through <code>_wrap_nettle_pk_derive</code> already:</p>
<ul dir="auto">
<li>
<code>_wrap_nettle_pk_derive</code> calls <code>_ecc_params_to_pubkey</code>: <a href="https://gitlab.com/gnutls/gnutls/-/blob/master/lib/nettle/pk.c#L397">https://gitlab.com/gnutls/gnutls/-/blob/master/lib/nettle/pk.c#L397</a>
</li>
<li>
<code>_ecc_params_to_pubkey</code> uses nettle's <code>ecc_point_set</code>: <a href="https://gitlab.com/gnutls/gnutls/-/blob/master/lib/nettle/pk.c#L397">https://gitlab.com/gnutls/gnutls/-/blob/master/lib/nettle/pk.c#L397</a>
</li>
<li>
<code>ecc_point_set</code> has all the necessary checks: <a href="https://gitlab.com/gnutls/nettle/-/blob/master/ecc-point.c#L64">https://gitlab.com/gnutls/nettle/-/blob/master/ecc-point.c#L64</a> (step 1 and 2) and <a href="https://gitlab.com/gnutls/nettle/-/blob/master/ecc-point.c#L64">https://gitlab.com/gnutls/nettle/-/blob/master/ecc-point.c#L64</a> (step 3)</li>
</ul>
<blockquote dir="auto">
<ul>
<li>
<p>generation of local key pair following section 5.6.2.1.3:</p>
<ul>
<li>
<p>FFC:</p>
<p>. perform the full validation compliant to section 5.6.2.3.1</p>
</li>
</ul>
</li>
</ul>
</blockquote>
<p dir="auto">Done in <a href="https://gitlab.com/gnutls/gnutls/-/commit/8b575625614fbe5a22b68dc8d1877efb1d44dd37" data-original="8b575625614fbe5a22b68dc8d1877efb1d44dd37" data-link="false" data-link-reference="false" data-project="179611" data-commit="8b575625614fbe5a22b68dc8d1877efb1d44dd37" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="dh: perform SP800-56A rev3 full pubkey validation on keygen" class="gfm gfm-commit has-tooltip">8b575625</a>.</p>
<blockquote dir="auto">
<ul>
<li>
<p>ECC:</p>
<p>. perform a full validation compliant to section 5.6.2.3.3</p>
</li>
</ul>
</blockquote>
<p dir="auto">Done in <a href="https://gitlab.com/gnutls/gnutls/-/commit/db001209da553a7eeaa68fd06d2d64a22ef42bde" data-original="db001209da553a7eeaa68fd06d2d64a22ef42bde" data-link="false" data-link-reference="false" data-project="179611" data-commit="db001209da553a7eeaa68fd06d2d64a22ef42bde" data-reference-type="commit" data-container="body" data-placement="top" data-html="true" title="ecdh: perform SP800-56A rev3 full pubkey validation on keygen" class="gfm gfm-commit has-tooltip">db001209</a>.</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/1299#note_381661234">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/e91dbee892654c5a0256d4c1ed1ac059/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/1299#note_381661234"}}</script>


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