<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en" style='--code-editor-font: var(--default-mono-font, "GitLab Mono"), JetBrains Mono, Menlo, DejaVu Sans Mono, Liberation Mono, Consolas, Ubuntu Mono, Courier New, andale mono, lucida console, monospace;'>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>
GitLab
</title>

<style data-premailer="ignore" type="text/css">
a { color: #1068bf; }
</style>

<style>img {
max-width: 100%; height: auto;
}
body {
font-size: .875rem;
}
body {
-webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px;
}
body {
font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji"; font-size: inherit;
}
</style>
</head>
<body style='font-size: inherit; -webkit-text-shadow: rgba(255,255,255,.01) 0 0 1px; font-family: "GitLab Sans",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Noto Sans",Ubuntu,Cantarell,"Helvetica Neue",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";'>
<div class="content">

<p class="details" style="font-style: italic; color: #626168;">
<a href="https://gitlab.com/asosedkin">Alexander Sosedkin</a> created an issue: <a href="https://gitlab.com/gnutls/gnutls/-/issues/1763">#1763</a>
</p>
<div class="md" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word;">
<h2 dir="auto" style="margin-top: 0; margin-bottom: 10px;" align="initial">
<a href="#description-of-problem" aria-hidden="true" class="anchor" id="user-content-description-of-problem" style="margin-top: 0; margin-left: -16px; text-decoration: none; outline: none; position: absolute; width: 16px;"></a>Description of problem:</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">If I enable both mlkem768x25519 and x25519 with <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>@SYSTEM:-GROUP-ALL:+GROUP-X25519-MLKEM768:+GROUP-X25519</code>, they're both present in Supported Groups, but only one share, the X25519-MLKEM768 one, gets sent, despite that sending two shares is supposed to be the default behaviour: <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>GNUTLS_KEY_SHARE_TOP2 : Generate key shares for the top-2 different groups which are enabled. For example (ECDH + x25519). This is the default.</code></p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">The code that skips sending the x25519 one is likely the <code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-weight: inherit; overflow-wrap: break-word; white-space: break-spaces; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; word-break: keep-all; padding: 0.125rem 0.25rem;'>if (pk_types_overlap(group, selected_groups[j])) break;</code> from <a href="https://gitlab.com/gnutls/gnutls/-/merge_requests/1892/diffs?commit_id=1065654c828eaad638fab3c4af7096ab0c8ee615" title="key_share: detect overlap of PK types in hybrid groups" class="gfm gfm-merge_request" data-original="https://gitlab.com/gnutls/gnutls/-/merge_requests/1892/diffs?commit_id=1065654c828eaad638fab3c4af7096ab0c8ee615" data-link="false" data-link-reference="true" data-merge-request="339026387" data-project="179611" data-project-path="gnutls/gnutls" data-iid="1892" data-container="body" data-placement="top" data-reference-type="merge_request">!1892 (<span class="gfm gfm-commit" style='font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; font-size: 95%; margin-top: 0;'>1065654c</span>)</a></p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">This ticket is related to <a href="https://gitlab.com/gnutls/gnutls/-/issues/1710" title="Support specifying groups to send in key_share extension" class="gfm gfm-issue" data-original="https://gitlab.com/gnutls/gnutls/-/issues/1710" data-link="false" data-link-reference="true" data-issue="167295338" data-project="179611" data-iid="1710" data-namespace-path="gnutls/gnutls" data-project-path="gnutls/gnutls" data-issue-type="issue" data-container="body" data-placement="top" data-reference-type="issue" style="margin-top: 0;">#1710</a> and <a href="https://gitlab.com/gnutls/gnutls/-/issues/1551" title="gnutls_handshake() failed: An unexpected TLS packet was received." class="gfm gfm-issue" data-original="https://gitlab.com/gnutls/gnutls/-/issues/1551" data-link="false" data-link-reference="true" data-issue="146985636" data-project="179611" data-iid="1551" data-namespace-path="gnutls/gnutls" data-project-path="gnutls/gnutls" data-issue-type="issue" data-container="body" data-placement="top" data-reference-type="issue">#1551</a>, but I'm filing it separately because fixing this particular quirk in isolation might be simpler than any of these two.</p>
<h2 dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">
<a href="#version-of-gnutls-used" aria-hidden="true" class="anchor" id="user-content-version-of-gnutls-used" style="margin-top: 0; margin-left: -16px; text-decoration: none; outline: none; position: absolute; width: 16px;"></a>Version of gnutls used:</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">3.8.10</p>
<h2 dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">
<a href="#distributor-of-gnutls-eg-ubuntu-fedora-rhel" aria-hidden="true" class="anchor" id="user-content-distributor-of-gnutls-eg-ubuntu-fedora-rhel" style="margin-top: 0; margin-left: -16px; text-decoration: none; outline: none; position: absolute; width: 16px;"></a>Distributor of gnutls (e.g., Ubuntu, Fedora, RHEL)</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">RHEL</p>
<h2 dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">
<a href="#how-reproducible" aria-hidden="true" class="anchor" id="user-content-how-reproducible" style="margin-top: 0; margin-left: -16px; text-decoration: none; outline: none; position: absolute; width: 16px;"></a>How reproducible:</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">reliably</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Steps to Reproduce:</p>
<ul dir="auto" style="text-align: initial; list-style-type: disc; margin: 0 0 1rem; padding: 0;">
<li style="margin-top: 0; line-height: 1.6em; margin-left: 25px; padding-left: 3px;"><code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 0.125rem 0.25rem;'>tcpdump ...</code></li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;"><code style='font-size: 90%; color: #18171d; word-wrap: break-word; background-color: #ececef; border-radius: .25rem; margin-top: 0; font-family: "GitLab Mono", "JetBrains Mono", "Menlo", "DejaVu Sans Mono", "Liberation Mono", "Consolas", "Ubuntu Mono", "Courier New", "andale mono", "lucida console", monospace; font-variant-ligatures: none; white-space: pre-wrap; overflow-wrap: break-word; word-break: keep-all; padding: 0.125rem 0.25rem;'>gnutls-cli --priority @SYSTEM:-GROUP-ALL:+GROUP-X25519-MLKEM768:+GROUP-X25519 ...</code></li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">inspect the ClientHellos</li>
</ul>
<h2 dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">
<a href="#actual-results" aria-hidden="true" class="anchor" id="user-content-actual-results" style="margin-top: 0; margin-left: -16px; text-decoration: none; outline: none; position: absolute; width: 16px;"></a>Actual results:</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Both key shares are correctly advertised as supported, but only one is being offered. A server offering just X25519 will HelloRetryRequest back, gnutls will send a second ClientHello with a X25519 key share, the connection will be established, but with an extra roundtrip.</p>
<h2 dir="auto" style="margin-top: 20px; margin-bottom: 10px;" align="initial">
<a href="#expected-results" aria-hidden="true" class="anchor" id="user-content-expected-results" style="margin-top: 0; margin-left: -16px; text-decoration: none; outline: none; position: absolute; width: 16px;"></a>Expected results:</h2>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial">Both key shares are sent. A server offering just X25519 will use the X25519 key share, the connection will be established with no extra roundtrip.</p>
<p dir="auto" style="color: #3a383f; margin: 0 0 1rem;" align="initial"><a href="https://datatracker.ietf.org/doc/draft-ietf-tls-hybrid-design/16" rel="nofollow noreferrer noopener" target="_blank" style="margin-top: 0;">https://datatracker.ietf.org/doc/draft-ietf-tls-hybrid-design/16</a> 3.2 suggests it's legal to reuse the single X25519 value across both key shares instead of generating a second one, which would make it a preferred outcome due to the performance considerations.</p>
<p dir="auto" style="color: #3a383f; margin: 0;" align="initial">Would also be fun if servers were smart enough to pick apart the hybrid key share and use the X25519 part of it with no HRR; fun, but, I presume, not spec-compliant.</p>
</div>

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

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/issues/1763">view it on GitLab</a>.
<br>
You're receiving this email because of your account on <a target="_blank" rel="noopener noreferrer" href="https://gitlab.com">gitlab.com</a>. <a href="https://gitlab.com/-/sent_notifications/1-64xmdgpj17y3fsgd26gy1qs9r/unsubscribe" target="_blank" rel="noopener noreferrer">Unsubscribe</a> from this thread · <a href="https://gitlab.com/-/profile/notifications" target="_blank" rel="noopener noreferrer" class="mng-notif-link">Manage all notifications</a> · <a href="https://gitlab.com/help" target="_blank" rel="noopener noreferrer" class="help-link">Help</a>
<span style="color: transparent; font-size: 0; display: none; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0;">
Notification message regarding https://gitlab.com/gnutls/gnutls/-/issues/1763 at 1763656243
</span>
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.com/gnutls/gnutls/-/issues/1763"}}</script>


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