<!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>
started a new
discussion on <a href="https://gitlab.com/gnutls/gnutls/-/merge_requests/1512#note_851179706">lib/ext/compress_certificate.c</a>:
</p>
<table>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="127" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
127
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC127" class="line" lang="c">        <span class="k" style="font-weight: 600;">return</span> <span class="n" style="color: #333;">gnutls_assert_val</span><span class="p">(</span><span class="n" style="color: #333;">GNUTLS_E_INVALID_REQUEST</span><span class="p">);</span></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="128" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
128
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC128" class="line" lang="c"></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="129" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
129
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC129" class="line" lang="c">    <span class="k" style="font-weight: 600;">for</span> <span class="p">(</span><span class="kt" style="color: #458; font-weight: 600;">unsigned</span> <span class="n" style="color: #333;">i</span> <span class="o" style="font-weight: 600;">=</span> <span class="mi" style="color: #099;">0</span><span class="p">;</span> <span class="n" style="color: #333;">i</span> <span class="o" style="font-weight: 600;"><</span> <span class="n" style="color: #333;">methods_len</span><span class="p">;</span> <span class="o" style="font-weight: 600;">++</span><span class="n" style="color: #333;">i</span><span class="p">)</span> <span class="p">{</span></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="130" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
130
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC130" class="line" lang="c">        <span class="n" style="color: #333;">tmp</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">_gnutls_compress_certificate_method2num</span><span class="p">(</span><span class="n" style="color: #333;">methods</span><span class="p">[</span><span class="n" style="color: #333;">i</span><span class="p">]);</span></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="131" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
131
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC131" class="line" lang="c">        <span class="k" style="font-weight: 600;">if</span> <span class="p">(</span><span class="n" style="color: #333;">tmp</span> <span class="o" style="font-weight: 600;">==</span> <span class="n" style="color: #333;">GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER</span> <span class="o" style="font-weight: 600;">||</span></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="132" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
132
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC132" class="line" lang="c">            <span class="n" style="color: #333;">gnutls_compression_get_name</span><span class="p">(</span><span class="n" style="color: #333;">tmp</span><span class="p">)</span> <span class="o" style="font-weight: 600;">==</span> <span class="nb" style="color: #0086b3;">NULL</span><span class="p">)</span></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="133" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
133
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC133" class="line" lang="c">            <span class="k" style="font-weight: 600;">return</span> <span class="n" style="color: #333;">gnutls_assert_val</span><span class="p">(</span><span class="n" style="color: #333;">GNUTLS_E_INVALID_REQUEST</span><span class="p">);</span></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="134" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
134
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC134" class="line" lang="c">        <span class="n" style="color: #333;">_gnutls_write_uint16</span><span class="p">(</span><span class="n" style="color: #333;">tmp</span><span class="p">,</span> <span class="p">(</span><span class="kt" style="color: #458; font-weight: 600;">uint8_t</span> <span class="o" style="font-weight: 600;">*</span><span class="p">)(</span><span class="n" style="color: #333;">algs</span> <span class="o" style="font-weight: 600;">+</span> <span class="n" style="color: #333;">i</span><span class="p">));</span></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="135" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
135
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC135" class="line" lang="c">    <span class="p">}</span></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="136" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
136
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC136" class="line" lang="c"></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="137" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
137
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC137" class="line" lang="c">    <span class="n" style="color: #333;">_gnutls_hello_ext_unset_priv</span><span class="p">(</span><span class="n" style="color: #333;">session</span><span class="p">,</span> <span class="n" style="color: #333;">GNUTLS_EXTENSION_COMPRESS_CERTIFICATE</span><span class="p">);</span></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="138" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
138
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC138" class="line" lang="c"></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="139" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
139
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC139" class="line" lang="c">    <span class="n" style="color: #333;">priv</span><span class="p">.</span><span class="n" style="color: #333;">data</span> <span class="o" style="font-weight: 600;">=</span> <span class="p">(</span><span class="kt" style="color: #458; font-weight: 600;">unsigned</span> <span class="kt" style="color: #458; font-weight: 600;">char</span> <span class="o" style="font-weight: 600;">*</span><span class="p">)</span><span class="n" style="color: #333;">algs</span><span class="p">;</span></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="140" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
140
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC140" class="line" lang="c">    <span class="n" style="color: #333;">priv</span><span class="p">.</span><span class="n" style="color: #333;">size</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">methods_len</span> <span class="o" style="font-weight: 600;">*</span> <span class="k" style="font-weight: 600;">sizeof</span><span class="p">(</span><span class="kt" style="color: #458; font-weight: 600;">uint16_t</span><span class="p">);</span></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="141" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
141
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC141" class="line" lang="c"></span>
</pre></td>
</tr>
<tr class="line_holder new">
<td class="old_line diff-line-num new" data-linenumber="1" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
 
</td>
<td class="new_line diff-line-num new" data-linenumber="142" style="width: 35px; color: rgba(0,0,0,0.3); border-right-width: 1px; border-right-color: #c7f0d2; border-right-style: solid; padding: 0 5px;" align="right" bgcolor="#ddfbe6">
142
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0"><pre style="margin: 0;">+<span id="LC142" class="line" lang="c">    <span class="n" style="color: #333;">ret</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">_gnutls_hello_ext_set_datum</span><span class="p">(</span><span class="n" style="color: #333;">session</span><span class="p">,</span> <span class="n" style="color: #333;">GNUTLS_EXTENSION_COMPRESS_CERTIFICATE</span><span class="p">,</span> <span class="o" style="font-weight: 600;">&</span><span class="n" style="color: #333;">priv</span><span class="p">);</span></span>
</pre></td>
</tr>

</table>
<div style="">
<p dir="auto">I would suggest using <code>_gnutls_hello_ext_set_priv</code> instead of <code>_gnutls_hello_ext_set_datum</code>, in a similar manner to <code>gnutls_alpn_set_protocols</code>:</p>
<div class="gl-relative markdown-code-block js-markdown-code">
<pre class="code highlight js-syntax-highlight language-c" lang="c" v-pre="true" style="border-radius: 2px; background-color: #fff; font-family: monospace; font-size: 90%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; -premailer-width: 100%; margin: 0 0 8px; padding: 8px 12px; border: 1px solid #dbdbdb;"><code><span id="LC1" class="line" lang="c"><span class="k" style="font-weight: 600;">typedef</span> <span class="k" style="font-weight: 600;">struct</span> <span class="p">{</span></span>
<span id="LC2" class="line" lang="c">  <span class="n" style="color: #333;">gnutls_compression_method_t</span> <span class="n" style="color: #333;">methods</span><span class="p">[</span><span class="n" style="color: #333;">MAX_COMPRESS_CERTIFICATE_METHODS</span><span class="p">];</span></span>
<span id="LC3" class="line" lang="c">  <span class="kt" style="color: #458; font-weight: 600;">size_t</span> <span class="n" style="color: #333;">methods_len</span><span class="p">;</span></span>
<span id="LC4" class="line" lang="c"><span class="p">}</span> <span class="n" style="color: #333;">compress_certificate_ext_st</span><span class="p">;</span></span>
<span id="LC5" class="line" lang="c"></span>
<span id="LC6" class="line" lang="c"><span class="p">...</span></span>
<span id="LC7" class="line" lang="c"></span>
<span id="LC8" class="line" lang="c"><span class="n" style="color: #333;">compress_certificate_ext_st</span> <span class="o" style="font-weight: 600;">*</span><span class="n" style="color: #333;">priv</span><span class="p">;</span></span>
<span id="LC9" class="line" lang="c"><span class="n" style="color: #333;">priv</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">gnutls_malloc</span><span class="p">(</span><span class="k" style="font-weight: 600;">sizeof</span><span class="p">(</span><span class="o" style="font-weight: 600;">*</span><span class="n" style="color: #333;">priv</span><span class="p">));</span></span>
<span id="LC10" class="line" lang="c"><span class="p">...</span></span>
<span id="LC11" class="line" lang="c"><span class="n" style="color: #333;">memcpy</span><span class="p">(</span><span class="n" style="color: #333;">priv</span><span class="o" style="font-weight: 600;">-></span><span class="n" style="color: #333;">methods</span><span class="p">,</span> <span class="p">...);</span></span>
<span id="LC12" class="line" lang="c"><span class="n" style="color: #333;">_gnutls_hello_ext_set_priv</span><span class="p">(...,</span> <span class="n" style="color: #333;">priv</span><span class="p">);</span></span></code></pre>
<copy-code></copy-code>
</div>
<p dir="auto">That way, the conversiosn between <code>uint8_t *</code> and <code>gnutls_compression_method_t *</code> will be unnecessary.</p>
</div>


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

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/-/merge_requests/1512#note_851179706">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/c9e4a38061a549839105e3c6296dccb2/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/1512#note_851179706"}}</script>


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