<!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: #666;">
<a href="https://gitlab.com/dkg">Daniel Kahn Gillmor</a> created an issue: <a href="https://gitlab.com/gnutls/libtasn1/-/issues/36">#36</a>
</p>
<div></div>
<h2 dir="auto">
<a id="user-content-description-of-problem" class="anchor" href="#description-of-problem" aria-hidden="true"></a>Description of problem:</h2>
<p dir="auto">Over in <a href="https://gitlab.com/gnutls/gnutls/-/issues/1238" data-original="https://gitlab.com/gnutls/gnutls/-/issues/1238" data-link="false" data-link-reference="true" data-project="179611" data-issue="87111762" data-reference-type="issue" data-container="body" data-placement="top" title="certtool: adding a policy without qualifiers results in empty sequence" class="gfm gfm-issue has-tooltip">gnutls#1238</a>, I noted that <code>certtool</code> was emitting an empty sequence of policyQualifiers even though the ASN.1 specification for <code>policyQualifiers</code> clearly says <code>(1..MAX) OPTIONAL</code>.</p>
<p dir="auto">If libtasn1 knows that a given <code>SEQUENCE</code> is <code>OPTIONAL</code> and it has a minimum length (e.g. <code>(1..MAX)</code>, or, regardless of the upper limit, even <code>(1..2)</code> really), and the data structure to be written is an <em>empty</em> sequence, then libtasn1 should be clever enough to omit the member entirely.</p>
<h2 dir="auto">
<a id="user-content-version-of-libtasn1-used" class="anchor" href="#version-of-libtasn1-used" aria-hidden="true"></a>Version of libtasn1 used:</h2>
<p dir="auto">4.16.0-2</p>
<h2 dir="auto">
<a id="user-content-distributor-of-libtasn1-eg-ubuntu-fedora-rhel" class="anchor" href="#distributor-of-libtasn1-eg-ubuntu-fedora-rhel" aria-hidden="true"></a>Distributor of libtasn1 (e.g., Ubuntu, Fedora, RHEL)</h2>
<p dir="auto">Debian</p>
<h2 dir="auto">
<a id="user-content-how-reproducible" class="anchor" href="#how-reproducible" aria-hidden="true"></a>How reproducible:</h2>
<p dir="auto">Steps to Reproduce:</p>
<pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">printf 'policy1=1.2.3.4\ncn="test"' > foo.template</span>
<span id="LC2" class="line" lang="plaintext">certtool --generate-privkey > foo.key</span>
<span id="LC3" class="line" lang="plaintext">certtool --generate-self-signed --template foo.template --load-privkey foo.key --outder | dumpasn1 </span></code></pre>
<h2 dir="auto">
<a id="user-content-actual-results" class="anchor" href="#actual-results" aria-hidden="true"></a>Actual results:</h2>
<pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">556   18:         SEQUENCE {</span>
<span id="LC2" class="line" lang="plaintext"> 558    3:           OBJECT IDENTIFIER certificatePolicies (2 5 29 32)</span>
<span id="LC3" class="line" lang="plaintext"> 563   11:           OCTET STRING 30 09 30 07 06 03 2A 03 04 30 00</span>
<span id="LC4" class="line" lang="plaintext">         :           }</span></code></pre>
<p dir="auto">The payload of the extension converts to:</p>
<pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">$ xxd -r -c 256 <<<"0000 30 09 30 07 06 03 2A 03 04 30 00" | dumpasn1 -</span>
<span id="LC2" class="line" lang="plaintext">  0   9: SEQUENCE {</span>
<span id="LC3" class="line" lang="plaintext">  2   7:   SEQUENCE {</span>
<span id="LC4" class="line" lang="plaintext">  4   3:     OBJECT IDENTIFIER '1 2 3 4'</span>
<span id="LC5" class="line" lang="plaintext">  9   0:     SEQUENCE {}</span>
<span id="LC6" class="line" lang="plaintext">       :     }</span>
<span id="LC7" class="line" lang="plaintext">       :   }</span>
<span id="LC8" class="line" lang="plaintext">$</span></code></pre>
<h2 dir="auto">
<a id="user-content-expected-results" class="anchor" href="#expected-results" aria-hidden="true"></a>Expected results:</h2>
<p dir="auto">The payload of the extension should be <code>30 07 30 05 06 03 2A 03 04</code>, which is:</p>
<pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">  0   7: SEQUENCE {</span>
<span id="LC2" class="line" lang="plaintext">  2   5:   SEQUENCE {</span>
<span id="LC3" class="line" lang="plaintext">  4   3:     OBJECT IDENTIFIER '1 2 3 4'</span>
<span id="LC4" class="line" lang="plaintext">       :     }</span>
<span id="LC5" class="line" lang="plaintext">       :   }</span></code></pre>

</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/libtasn1/-/issues/36">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/d643112a84005e4d105ac48b6f63f5f9/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 Issue","url":"https://gitlab.com/gnutls/libtasn1/-/issues/36"}}</script>


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