<!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
discussion on <a href="https://gitlab.com/gnutls/gnutls/-/merge_requests/1367#note_534253834">lib/x509/x509_ext.c</a>:
</p>
<table>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3602" 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">
3602
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3602" class="line" lang="c">           <span class="k" style="font-weight: 600;">return</span> <span class="n" style="color: #333;">get_sigalg_for_sha1</span><span class="p">(</span><span class="n" style="color: #333;">sig_algo</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3603" 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">
3603
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3603" class="line" lang="c">   <span class="k" style="font-weight: 600;">case</span> <span class="mi" style="color: #099;">3</span><span class="p">:</span> <span class="cm" style="color: #998; font-style: italic;">/* sha224 */</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3604" 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">
3604
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3604" class="line" lang="c">           <span class="k" style="font-weight: 600;">return</span> <span class="n" style="color: #333;">get_sigalg_for_sha224</span><span class="p">(</span><span class="n" style="color: #333;">sig_algo</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3605" 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">
3605
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3605" class="line" lang="c">   <span class="k" style="font-weight: 600;">case</span> <span class="mi" style="color: #099;">4</span><span class="p">:</span> <span class="cm" style="color: #998; font-style: italic;">/* sha256 */</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3606" 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">
3606
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3606" class="line" lang="c">           <span class="k" style="font-weight: 600;">return</span> <span class="n" style="color: #333;">get_sigalg_for_sha256</span><span class="p">(</span><span class="n" style="color: #333;">sig_algo</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3607" 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">
3607
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3607" class="line" lang="c">   <span class="k" style="font-weight: 600;">case</span> <span class="mi" style="color: #099;">5</span><span class="p">:</span> <span class="cm" style="color: #998; font-style: italic;">/* sha384 */</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3608" 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">
3608
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3608" class="line" lang="c">           <span class="k" style="font-weight: 600;">return</span> <span class="n" style="color: #333;">get_sigalg_for_sha384</span><span class="p">(</span><span class="n" style="color: #333;">sig_algo</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3609" 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">
3609
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3609" class="line" lang="c">   <span class="k" style="font-weight: 600;">case</span> <span class="mi" style="color: #099;">6</span><span class="p">:</span> <span class="cm" style="color: #998; font-style: italic;">/* sha512 */</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3610" 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">
3610
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3610" class="line" lang="c">           <span class="k" style="font-weight: 600;">return</span> <span class="n" style="color: #333;">get_sigalg_for_sha512</span><span class="p">(</span><span class="n" style="color: #333;">sig_algo</span><span class="p">);</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3611" 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">
3611
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3611" class="line" lang="c">   <span class="p">}</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3612" 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">
3612
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3612" class="line" lang="c"><span class="p">}</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3613" 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">
3613
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3613" class="line" lang="c"></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3614" 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">
3614
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3614" class="line" lang="c"><span class="k" style="font-weight: 600;">static</span> <span class="kt" style="color: #458; font-weight: 600;">int</span> <span class="nf" style="color: #900; font-weight: 600;">write_sigalg</span><span class="p">(</span><span class="n" style="color: #333;">gnutls_sign_algorithm_t</span> <span class="n" style="color: #333;">sigalg</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="n" style="color: #333;">out</span><span class="p">)</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3615" 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">
3615
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3615" class="line" lang="c"><span class="p">{</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3616" 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">
3616
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3616" class="line" lang="c">   <span class="k" style="font-weight: 600;">switch</span> <span class="p">(</span><span class="n" style="color: #333;">sigalg</span><span class="p">)</span> <span class="p">{</span></span>
</pre>
</td>
</tr>
<tr class="line_holder new" id="">
<td class="old_line diff-line-num new" data-linenumber="3467" 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="3617" 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">
3617
</td>
<td class="line_content new" style="padding-left: 0.5em; padding-right: 0.5em;" bgcolor="#ecfdf0">
<pre style="margin: 0;">+<span id="LC3617" class="line" lang="c">   <span class="k" style="font-weight: 600;">case</span> <span class="n" style="color: #333;">GNUTLS_SIGN_RSA_MD5</span><span class="p">:</span></span>
</pre>
</td>
</tr>

</table>
<div style="">
<p dir="auto">I was thinking something like below, similar to the arrays defined in <code>lib/algorithms/*</code>:</p>
<pre class="code highlight js-syntax-highlight c" lang="c" v-pre="true" style="background-color: #fff; font-family: monospace; font-size: 90%; -premailer-cellpadding: 0; -premailer-cellspacing: 0; -premailer-width: 100%; color: #998; font-style: italic; margin: 0;"><code><span id="LC1" class="line" lang="c"><span class="k" style="font-weight: 600;">struct</span> <span class="n" style="color: #333;">sct_sign_algorithm_st</span> <span class="p">{</span></span>
<span id="LC2" class="line" lang="c">  <span class="kt" style="color: #458; font-weight: 600;">uint8_t</span> <span class="n" style="color: #333;">codepoint</span><span class="p">[</span><span class="mi" style="color: #099;">2</span><span class="p">];</span></span>
<span id="LC3" class="line" lang="c">  <span class="n" style="color: #333;">gnutls_sign_algorithm_t</span> <span class="n" style="color: #333;">sign_algo</span><span class="p">;</span></span>
<span id="LC4" class="line" lang="c">  <span class="n" style="color: #333;">gnutls_hash_algorithm_t</span> <span class="n" style="color: #333;">hash_algo</span><span class="p">;</span></span>
<span id="LC5" class="line" lang="c"><span class="p">};</span></span>
<span id="LC6" class="line" lang="c"></span>
<span id="LC7" class="line" lang="c"><span class="k" style="font-weight: 600;">const</span> <span class="k" style="font-weight: 600;">struct</span> <span class="n" style="color: #333;">sct_sign_algorithm_st</span><span class="p">[]</span> <span class="o" style="font-weight: 600;">=</span> <span class="p">{</span></span>
<span id="LC8" class="line" lang="c">  <span class="p">...</span></span>
<span id="LC9" class="line" lang="c">  <span class="p">{</span></span>
<span id="LC10" class="line" lang="c">    <span class="p">.</span><span class="n" style="color: #333;">codepoint</span> <span class="o" style="font-weight: 600;">=</span> <span class="p">{</span> <span class="mh" style="color: #099;">0x05</span><span class="p">,</span> <span class="mh" style="color: #099;">0x01</span> <span class="p">},</span></span>
<span id="LC11" class="line" lang="c">    <span class="p">.</span><span class="n" style="color: #333;">sign_algo</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">GNUTLS_SIGN_RSA_SHA384</span><span class="p">,</span></span>
<span id="LC12" class="line" lang="c">    <span class="p">.</span><span class="n" style="color: #333;">hash_algo</span> <span class="o" style="font-weight: 600;">=</span> <span class="n" style="color: #333;">GNUTLS_DIG_SHA384</span><span class="p">,</span></span>
<span id="LC13" class="line" lang="c">  <span class="p">},</span></span>
<span id="LC14" class="line" lang="c">  <span class="p">...</span></span>
<span id="LC15" class="line" lang="c"><span class="p">};</span></span></code></pre>
<p dir="auto">It would be slower than the accessing 2-dimensional matrix, as it requires searching on the array, but given the fact that there is only 18 (= 6 * 3) elements, that wouldn't affect performance much.</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/1367#note_534253834">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/ca5b32009c6b41d3dc03721e6ba0cc23/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/1367#note_534253834"}}</script>


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