<!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 class="details" style="font-style: italic; color: #777;">
<a href="https://gitlab.com/petrpavlu">Petr Pavlu</a> created a merge request:
</p>
<p>
</p>
<div class="branch">
Project:Branches: petrpavlu/gnutls:sign-spurious-message to gnutls/gnutls:master
</div>
<div class="author">
Author: Petr Pavlu
</div>
<div class="assignee">
Assignees:
</div>
<div class="approvers">
</div>
<div>
<p dir="auto">When checking in <code>_gnutls_pubkey_compatible_with_sig()</code> whether a public key is compatible with a signature algorithm, run first <code>pubkey_supports_sig()</code> before performing weaker checks that can accept the given algorithm but with an audit-log warning. This avoids an issue when a weaker check would log an audit message for some signature algorithm that would then be determined as incompatible by the <code>pubkey_supports_sig()</code> check anyway.</p>
<p dir="auto">For instance, a GnuTLS server might have a certificate with a SECP384R1 public key and a client can report that it supports
ECDSA-SECP256R1-SHA256 and ECDSA-SECP384R1-SHA384. In such a case, the GnuTLS server will eventually find that it must use ECDSA-SECP384R1-SHA384 with this public key. However, the code would first run <code>_gnutls_pubkey_compatible_with_sig()</code> to check if SECP384R1 is compatible with ECDSA-SECP256R1-SHA256. The function would report the audit warning "The hash size used in signature (32) is less than the expected (48)" but then reject the signature algorithm in <code>pubkey_supports_sig()</code> as incompatible because it has a different curve. Since the algorithm gets rejected it is not necessary to inform about its hash size difference in the audit log.</p>
<p dir="auto">The problem can be reproduced as follows:</p>
<ol dir="auto">
<li>
<p>Run a server:</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">$ certtool --generate-privkey --key-type=ecdsa --curve=secp384r1 --outfile=server_privkey.pem</span>
<span id="LC2" class="line" lang="plaintext">$ certtool --generate-self-signed --load-privkey=server_privkey.pem --outfile=server_cert.pem</span>
<span id="LC3" class="line" lang="plaintext">[use defaults, set a sensible expiration date]</span>
<span id="LC4" class="line" lang="plaintext">$ gnutls-serv --x509keyfile=server_privkey.pem --x509certfile=server_cert.pem --port=4567</span>
<span id="LC5" class="line" lang="plaintext">HTTP Server listening on IPv4 0.0.0.0 port 4567...done</span>
<span id="LC6" class="line" lang="plaintext">HTTP Server listening on IPv6 :: port 4567...done</span></code></pre>
</li>
<li>
<p>Connect a client:</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">$ gnutls-cli --port=4567 --insecure localhost</span>
<span id="LC2" class="line" lang="plaintext">Processed 0 CA certificate(s).</span>
<span id="LC3" class="line" lang="plaintext">Resolving 'localhost:4567'...</span>
<span id="LC4" class="line" lang="plaintext">Connecting to '::1:4567'...</span>
<span id="LC5" class="line" lang="plaintext">[...]</span></code></pre>
</li>
<li>
<p>Output on the server:</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">* Accepted connection from IPv6 ::1 port 44786 on Wed Jul 22 14:22:26 202</span>
<span id="LC2" class="line" lang="plaintext">|<0x5608c399e3c0>| The hash size used in signature (32) is less than the expected (48)</span>
<span id="LC3" class="line" lang="plaintext">|<0x5608c399e3c0>| The hash size used in signature (32) is less than the expected (48)</span>
<span id="LC4" class="line" lang="plaintext">[...]</span></code></pre>
</li>
</ol>
<h2 dir="auto">
<a id="user-content-checklist" class="anchor" href="#checklist" aria-hidden="true"></a>Checklist</h2>
<ul class="task-list" dir="auto">
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" checked disabled> Commits have <code>Signed-off-by:</code> with name/author being identical to the commit author</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Code modified for feature</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Test suite updated with functionality tests</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Test suite updated with negative tests</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Documentation updated / NEWS entry present (for non-trivial changes)</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> CI timeout is 2h or higher (see Settings/CICD/General pipelines/Timeout)</li>
</ul>
<h2 dir="auto">
<a id="user-content-reviewers-checklist" class="anchor" href="#reviewers-checklist" aria-hidden="true"></a>Reviewer's checklist:</h2>
<ul class="task-list" dir="auto">
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Any issues marked for closing are addressed</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> There is a test suite reasonably covering new functionality or modifications</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> Function naming, parameters, return values, types, etc., are consistent and according to <code>CONTRIBUTION.md</code>
</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> This feature/change has adequate documentation added</li>
<li class="task-list-item">
<input type="checkbox" class="task-list-item-checkbox" disabled> No obvious mistakes in the code</li>
</ul>
</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/1301">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/a48e035f6a637a2e5f7d84d33f08b70a/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/1301"}}</script>
</p>
</div>
</body>
</html>