<!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 style="color: #777777;">
<a href="https://gitlab.com/asosedkin">Alexander Sosedkin</a>
commented on a
discussion on <a href="https://gitlab.com/gnutls/gnutls/-/merge_requests/2067#note_3135862814">lib/ext/key_share.c</a>:
</p>
<table class="code gl-mb-5" style="border-spacing: 0; margin-bottom: 1rem; border-collapse: collapse; width: auto; font-family: monospace; font-size: 90%;" bgcolor="#ffffff" width="100%" cellpadding="0" cellspacing="0">
<tr class="line_holder" style="line-height: 1.6;">
<td class="old_line diff-line-num" data-linenumber="100" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #ececef; border-right-style: solid; padding: inherit;" align="right" bgcolor="#fbfafd">
100
</td>
<td class="new_line diff-line-num" data-linenumber="100" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #ececef; border-right-style: solid; padding: inherit;" align="right" bgcolor="#fbfafd">
100
</td>
<td class="line_content" style="padding: inherit;"><pre style='display: block; font-size: 14px; color: #3a383f; position: relative; 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: break-all; word-wrap: break-word; background-color: inherit; border-radius: 2px; margin: 0; padding: 0; border: inherit solid #dcdcde;'> <span class="line" data-lang="c"></span>
</pre></td>
</tr>
<tr class="line_holder" style="line-height: 1.6;">
<td class="old_line diff-line-num" data-linenumber="101" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #ececef; border-right-style: solid; padding: inherit;" align="right" bgcolor="#fbfafd">
101
</td>
<td class="new_line diff-line-num" data-linenumber="101" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #ececef; border-right-style: solid; padding: inherit;" align="right" bgcolor="#fbfafd">
101
</td>
<td class="line_content" style="padding: inherit;"><pre style='display: block; font-size: 14px; color: #3a383f; position: relative; 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: break-all; word-wrap: break-word; background-color: inherit; border-radius: 2px; margin: 0; padding: 0; border: inherit solid #dcdcde;'> <span class="line" data-lang="c">      <span class="k" style="font-weight: 600;">case</span> <span class="n" style="color: #333333;">GNUTLS_PK_ECDH_X25519</span><span class="p">:</span></span>
</pre></td>
</tr>
<tr class="line_holder" style="line-height: 1.6;">
<td class="old_line diff-line-num" data-linenumber="102" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #ececef; border-right-style: solid; padding: inherit;" align="right" bgcolor="#fbfafd">
102
</td>
<td class="new_line diff-line-num" data-linenumber="102" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #ececef; border-right-style: solid; padding: inherit;" align="right" bgcolor="#fbfafd">
102
</td>
<td class="line_content" style="padding: inherit;"><pre style='display: block; font-size: 14px; color: #3a383f; position: relative; 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: break-all; word-wrap: break-word; background-color: inherit; border-radius: 2px; margin: 0; padding: 0; border: inherit solid #dcdcde;'> <span class="line" data-lang="c">      <span class="k" style="font-weight: 600;">case</span> <span class="n" style="color: #333333;">GNUTLS_PK_ECDH_X448</span><span class="p">:</span></span>
</pre></td>
</tr>
<tr class="line_holder old" style="line-height: 1.6;">
<td class="old_line diff-line-num old" data-linenumber="103" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: inherit;" align="right" bgcolor="#f9d7dc">
103
</td>
<td class="new_line diff-line-num old" data-linenumber="103" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: inherit;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content old" style="padding: inherit;" bgcolor="#fbe9eb"><pre style='display: block; font-size: 14px; color: #3a383f; position: relative; 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: break-all; word-wrap: break-word; background-color: inherit; border-radius: 2px; margin: 0; padding: 0; border: inherit solid #dcdcde;'>-<span class="line" data-lang="c">              <span class="n" style="color: #333333;">gnutls_pk_params_release</span><span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="n" style="color: #333333;">session</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333333;">key</span><span class="p">.</span><span class="n" style="color: #333333;">kshare</span><span class="p">.</span><span class="n" style="color: #333333;">ecdhx_params</span><span class="p">);</span></span>
</pre></td>
</tr>
<tr class="line_holder old" style="line-height: 1.6;">
<td class="old_line diff-line-num old" data-linenumber="104" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: inherit;" align="right" bgcolor="#f9d7dc">
104
</td>
<td class="new_line diff-line-num old" data-linenumber="103" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #fac5cd; border-right-style: solid; padding: inherit;" align="right" bgcolor="#f9d7dc">
 
</td>
<td class="line_content old" style="padding: inherit;" bgcolor="#fbe9eb"><pre style='display: block; font-size: 14px; color: #3a383f; position: relative; 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: break-all; word-wrap: break-word; background-color: inherit; border-radius: 2px; margin: 0; padding: 0; border: inherit solid #dcdcde;'>-<span class="line" data-lang="c">              <span class="n" style="color: #333333;">gnutls_pk_params_init</span><span class="p">(</span><span class="o" style="font-weight: 600;">&</span><span class="n" style="color: #333333;">session</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333333;">key</span><span class="p">.</span><span class="n" style="color: #333333;">kshare</span><span class="p">.</span><span class="n" style="color: #333333;">ecdhx_params</span><span class="p">);</span></span>
</pre></td>
</tr>
<tr class="line_holder new" style="line-height: 1.6;">
<td class="old_line diff-line-num new" data-linenumber="105" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: inherit;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="103" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: inherit;" align="right" bgcolor="#ddfbe6">
103
</td>
<td class="line_content new" style="padding: inherit;" bgcolor="#ecfdf0"><pre style='display: block; font-size: 14px; color: #3a383f; position: relative; 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: break-all; word-wrap: break-word; background-color: inherit; border-radius: 2px; margin: 0; padding: 0; border: inherit solid #dcdcde;'>+<span class="line" data-lang="c">              <span class="cm" style="color: #999988; font-style: italic;">/* try reusing existing values */</span></span>
</pre></td>
</tr>
<tr class="line_holder new" style="line-height: 1.6;">
<td class="old_line diff-line-num new" data-linenumber="105" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: inherit;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="104" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: inherit;" align="right" bgcolor="#ddfbe6">
104
</td>
<td class="line_content new" style="padding: inherit;" bgcolor="#ecfdf0"><pre style='display: block; font-size: 14px; color: #3a383f; position: relative; 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: break-all; word-wrap: break-word; background-color: inherit; border-radius: 2px; margin: 0; padding: 0; border: inherit solid #dcdcde;'>+<span class="line" data-lang="c">              <span class="k" style="font-weight: 600;">if</span> <span class="p">(</span><span class="n" style="color: #333333;">session</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333333;">key</span><span class="p">.</span><span class="n" style="color: #333333;">kshare</span><span class="p">.</span><span class="n" style="color: #333333;">ecdhx_params</span><span class="p">.</span><span class="n" style="color: #333333;">curve</span> <span class="o" style="font-weight: 600;">==</span> <span class="n" style="color: #333333;">group</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333333;">curve</span> <span class="o" style="font-weight: 600;">&&</span></span>
</pre></td>
</tr>
<tr class="line_holder new" style="line-height: 1.6;">
<td class="old_line diff-line-num new" data-linenumber="105" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: inherit;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="105" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: inherit;" align="right" bgcolor="#ddfbe6">
105
</td>
<td class="line_content new" style="padding: inherit;" bgcolor="#ecfdf0"><pre style='display: block; font-size: 14px; color: #3a383f; position: relative; 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: break-all; word-wrap: break-word; background-color: inherit; border-radius: 2px; margin: 0; padding: 0; border: inherit solid #dcdcde;'>+<span class="line" data-lang="c">                  <span class="n" style="color: #333333;">session</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333333;">key</span><span class="p">.</span><span class="n" style="color: #333333;">kshare</span><span class="p">.</span><span class="n" style="color: #333333;">ecdhx_params</span><span class="p">.</span><span class="n" style="color: #333333;">algo</span> <span class="o" style="font-weight: 600;">==</span> <span class="n" style="color: #333333;">group</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333333;">pk</span> <span class="o" style="font-weight: 600;">&&</span></span>
</pre></td>
</tr>
<tr class="line_holder new" style="line-height: 1.6;">
<td class="old_line diff-line-num new" data-linenumber="105" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: inherit;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="106" style="width: 35px; color: rgba(5,5,6,.24); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: inherit;" align="right" bgcolor="#ddfbe6">
106
</td>
<td class="line_content new" style="padding: inherit;" bgcolor="#ecfdf0"><pre style='display: block; font-size: 14px; color: #3a383f; position: relative; 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: break-all; word-wrap: break-word; background-color: inherit; border-radius: 2px; margin: 0; padding: 0; border: inherit solid #dcdcde;'>+<span class="line" data-lang="c">                  <span class="n" style="color: #333333;">session</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333333;">key</span><span class="p">.</span><span class="n" style="color: #333333;">kshare</span><span class="p">.</span><span class="n" style="color: #333333;">ecdhx_params</span><span class="p">.</span><span class="n" style="color: #333333;">raw_pub</span><span class="p">.</span><span class="n" style="color: #333333;">data</span> <span class="o" style="font-weight: 600;">!=</span> <span class="nb" style="color: #0086b3;">NULL</span><span class="p">)</span> <span class="p">{</span></span>
</pre></td>
</tr>

</table>
<div class="md" style="position: relative; z-index: 1; color: #3a383f; word-wrap: break-word;">
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">okay, so... here's an entire menu of versions to pick from:</p>
<ul dir="auto" style="text-align: initial; list-style-type: disc; margin: 0px 0px 1rem; padding: 0;">
<li style="margin-top: 0px; line-height: 1.6em; margin-left: 25px; padding-left: 3px;">...</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<a href="https://gitlab.com/gnutls/gnutls/-/commit/bdda1c936e49c026f20c8b156b5bd721629b98fd" title="key_share: reuse existing key shares (guards edition)" class="gfm gfm-commit has-tooltip" data-original="bdda1c936e" data-link="false" data-link-reference="false" data-commit="bdda1c936e49c026f20c8b156b5bd721629b98fd" data-project="179611" data-container="body" data-placement="top" data-reference-type="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: 0px;'>bdda1c93</a> key_share: reuse existing key shares (guards edition) - that's the continuation of what I was doing</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<a href="https://gitlab.com/gnutls/gnutls/-/commit/f7af8dbbeaa948c684ea0fd593e602cc6b7f3914" title="key_share: reuse key shares (4-loop edition)" class="gfm gfm-commit has-tooltip" data-original="f7af8dbbea" data-link="false" data-link-reference="false" data-commit="f7af8dbbeaa948c684ea0fd593e602cc6b7f3914" data-project="179611" data-container="body" data-placement="top" data-reference-type="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: 0px;'>f7af8dbb</a> key_share: reuse key shares (4-loop edition) - this is the version with a lot of passes, mind the limitations like slot reuse guards</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<a href="https://gitlab.com/gnutls/gnutls/-/commit/6636e9b641a1bb90a39de8c0c5ca1b598c7276c3" title="key_share: reuse key shares (3-loop edition)" class="gfm gfm-commit has-tooltip" data-original="6636e9b641" data-link="false" data-link-reference="false" data-commit="6636e9b641a1bb90a39de8c0c5ca1b598c7276c3" data-project="179611" data-container="body" data-placement="top" data-reference-type="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: 0px;'>6636e9b6</a> key_share: reuse key shares (3-loop edition) - what I see as a natural simplification</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<a href="https://gitlab.com/gnutls/gnutls/-/commit/b4c1bfc502ee1248a328f162b865e56d92a90648" title="key_share: reuse key shares (2-loop edition)" class="gfm gfm-commit has-tooltip" data-original="b4c1bfc502" data-link="false" data-link-reference="false" data-commit="b4c1bfc502ee1248a328f162b865e56d92a90648" data-project="179611" data-container="body" data-placement="top" data-reference-type="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: 0px;'>b4c1bfc5</a> key_share: reuse key shares (2-loop edition) - what I see as a natural simplification</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<a href="https://gitlab.com/gnutls/gnutls/-/commit/ec5163e8072cac8644533ff7bcbf9657b95caadd" title="key_share: reuse key shares (1-loop edition)" class="gfm gfm-commit has-tooltip" data-original="ec5163e807" data-link="false" data-link-reference="false" data-commit="ec5163e8072cac8644533ff7bcbf9657b95caadd" data-project="179611" data-container="body" data-placement="top" data-reference-type="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: 0px;'>ec5163e8</a> key_share: reuse key shares (1-loop edition) - what I see as a natural simplification</li>
<li style="line-height: 1.6em; margin-left: 25px; padding-left: 3px;">
<a href="https://gitlab.com/gnutls/gnutls/-/commit/48cced8375e38071b99c203625d4fac68e29045b" title="key_share: guards enable slot reuse" class="gfm gfm-commit has-tooltip" data-original="48cced8375" data-link="false" data-link-reference="false" data-commit="48cced8375e38071b99c203625d4fac68e29045b" data-project="179611" data-container="body" data-placement="top" data-reference-type="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: 0px;'>48cced83</a> key_share: guards enable slot reuse - and now we've come full circle</li>
</ul>
<p dir="auto" style="color: #3a383f; margin: 0px 0px 1rem;" align="initial">You've probably meant neither of these, but at least now you have an assortment of starting points at your disposal to continue explaining how multiple passes are better =)</p>
<p dir="auto" style="color: #3a383f; margin: 0px;" align="initial">what's the closest to what you wanted and what is it lacking?</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/-/merge_requests/2067#note_3135862814">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/3-a6rrps16ei4sw3kcvcmrfmz9d/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/-/merge_requests/2067#note_3135862814 at 1772738284
</span>
<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/2067#note_3135862814"}}</script>


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