<!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/gnutls/-/issues/1236">#1236</a>
</p>
<div></div>
<p dir="auto">over on the IETF's <a href="https://www.ietf.org/mailman/listinfo/spasm" rel="nofollow noreferrer noopener" target="_blank">LAMPS WG's mailing list</a>, <a href="https://mailarchive.ietf.org/arch/msg/spasm/fy6ilJRnqBaXiZctVyHJELQMmK8/" rel="nofollow noreferrer noopener" target="_blank">David A. Cooper writes</a>:</p>
<pre class="code highlight js-syntax-highlight language-plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">the keyUsage extensions in the certificates are </span>
<span id="LC2" class="line" lang="plaintext">not DER encoded. The keyUsage extensions in the certificates are all </span>
<span id="LC3" class="line" lang="plaintext">encoded in the form "03 03 07 XX 00."</span>
<span id="LC4" class="line" lang="plaintext"></span>
<span id="LC5" class="line" lang="plaintext">It seems that the developer of the encoder mistakenly believed that the </span>
<span id="LC6" class="line" lang="plaintext">bit string should always be 9 bits long in order to correspond to the </span>
<span id="LC7" class="line" lang="plaintext">definition of keyUsage:</span>
<span id="LC8" class="line" lang="plaintext"></span>
<span id="LC9" class="line" lang="plaintext">    KeyUsage ::= BIT STRING {</span>
<span id="LC10" class="line" lang="plaintext">                digitalSignature        (0),</span>
<span id="LC11" class="line" lang="plaintext">                nonRepudiation          (1), -- recent editions of X.509</span>
<span id="LC12" class="line" lang="plaintext">    have</span>
<span id="LC13" class="line" lang="plaintext">                                     -- renamed this bit to</span>
<span id="LC14" class="line" lang="plaintext">    contentCommitment</span>
<span id="LC15" class="line" lang="plaintext">                keyEncipherment         (2),</span>
<span id="LC16" class="line" lang="plaintext">                dataEncipherment        (3),</span>
<span id="LC17" class="line" lang="plaintext">                keyAgreement            (4),</span>
<span id="LC18" class="line" lang="plaintext">                keyCertSign             (5),</span>
<span id="LC19" class="line" lang="plaintext">                cRLSign                 (6),</span>
<span id="LC20" class="line" lang="plaintext">                encipherOnly            (7),</span>
<span id="LC21" class="line" lang="plaintext">                decipherOnly            (8) }</span>
<span id="LC22" class="line" lang="plaintext"></span>
<span id="LC23" class="line" lang="plaintext">However, X.680 and X.690 specify that when encoding a named bit list, </span>
<span id="LC24" class="line" lang="plaintext">such as above, any trailing zeros must be removed. So, a keyUsage </span>
<span id="LC25" class="line" lang="plaintext">extension with just digitalSignature and nonRepudiation set would be </span>
<span id="LC26" class="line" lang="plaintext">encoded as a bit string that is only two bits long ('11') and a keyUsage </span>
<span id="LC27" class="line" lang="plaintext">extension with just keyAgreement set would be encoded as a bit string </span>
<span id="LC28" class="line" lang="plaintext">that is five bits long ('00001').</span>
<span id="LC29" class="line" lang="plaintext"></span>
<span id="LC30" class="line" lang="plaintext">So, the correct encoding for the keyUsage extension would be:</span>
<span id="LC31" class="line" lang="plaintext"></span>
<span id="LC32" class="line" lang="plaintext">  * "03 02 01 06" for the CA certificate</span>
<span id="LC33" class="line" lang="plaintext">  * "03 02 06 C0" for the digital signature certificates</span>
<span id="LC34" class="line" lang="plaintext">  * "03 02 05 20" for the encryption certificates</span>
<span id="LC35" class="line" lang="plaintext">  * "03 02 03 08" for the key agreement certificates</span></code></pre>
<p dir="auto">This concerns <a href="https://datatracker.ietf.org/doc/draft-ietf-lamps-samples/" rel="nofollow noreferrer noopener" target="_blank">draft-ietf-lamps-samples</a>, which contains certificates being generated by <code>certtool</code>.</p>

</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/-/issues/1236">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/63127dfeab66807de7d97c61ad892c72/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/gnutls/-/issues/1236"}}</script>


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