Subject: Key usage ecnoding

From: "Muhammed Serdar Soran" <[email-masked]>
Date: Thu, 21 Dec 2006 14:09:19 +0200

Hello,

I have a problem about encoding of key usage extension. Key usage value is a
BIT STRING ASN1 type. There are 9 defined bits. Let's say we only want to set
the first bit (namely digitalSignature). Then what must be the other bits?
Here are two possibilities:
1) set all other bits to zero
2) other bits are not important and may be zero or may not exist.
3) something different!

Some of the applications can not read the key usage extension if you use the
first option. But I think the first option is legal and all applications must
be able to parse such key usage extensions. 

I looked at the standarts RFC 3280, RFC 3279, X.509 and X.690; but I could not
found any information about this. 

What is your opinion?

M. Serdar SORAN

---

From: "Kemp, David P." <[email-masked]>
Date: Thu, 21 Dec 2006 09:13:26 -0500

X.690 is the right place to look.  BIT STRING encoding consists of an
initial octet specifying the number of unused bits at the end, followed
by the contents octets of the bitstring.  With BER, the encoder may
append zero bits to Named Bit Strings (which is how key usage
is defined), but with DER trailing 0 bits must be removed and unused
bits in the final octet must be 0.

So if only the first bit (digitalSignature) is set, the initial octet
must specify 7 unused bits and the contents octet must have only
bit 8 set: 0x03 0x02 0x07 0x80.  That is the only legal DER option.
Applications that cannot read this value are broken.

Dave

-----Original Message-----
From: [email-masked] [mailto:[email-masked]]
On Behalf Of Muhammed Serdar Soran
Sent: Thursday, December 21, 2006 7:09 AM
To: [email-masked]
Subject: Key usage ecnoding

Hello,

I have a problem about encoding of key usage extension. Key usage value
is a
BIT STRING ASN1 type. There are 9 defined bits. Let's say we only want
to set
the first bit (namely digitalSignature). Then what must be the other
bits?
Here are two possibilities:
1) set all other bits to zero
2) other bits are not important and may be zero or may not exist.
3) something different!

Some of the applications can not read the key usage extension if you use
the
first option. But I think the first option is legal and all applications
must
be able to parse such key usage extensions. 

I looked at the standarts RFC 3280, RFC 3279, X.509 and X.690; but I
could not
found any information about this. 

What is your opinion?

M. Serdar SORAN

---

From: "Peter Hesse" <[email-masked]>
Date: Thu, 21 Dec 2006 09:28:00 -0500

See this message from 1998 on the topic (!)

http://www.imc.org/ietf-pkix/old-archive-98/msg01151.html

Basically, key usage is not a BITSTRING per se, it is a NamedBitList.  As a
result, trailing 0 bits get removed before encoding.

--Peter

-----Original Message-----
From: [email-masked] [mailto:[email-masked]] On
Behalf Of Muhammed Serdar Soran
Sent: Thursday, December 21, 2006 7:09 AM
To: [email-masked]
Subject: Key usage ecnoding

Hello,

I have a problem about encoding of key usage extension. Key usage value is a
BIT STRING ASN1 type. There are 9 defined bits. Let's say we only want to
set the first bit (namely digitalSignature). Then what must be the other
bits?
Here are two possibilities:
1) set all other bits to zero
2) other bits are not important and may be zero or may not exist.
3) something different!

Some of the applications can not read the key usage extension if you use the
first option. But I think the first option is legal and all applications
must be able to parse such key usage extensions. 

I looked at the standarts RFC 3280, RFC 3279, X.509 and X.690; but I could
not found any information about this. 

What is your opinion?

M. Serdar SORAN

---

From: Russ Housley <[email-masked]>
Date: Thu, 21 Dec 2006 10:28:51 -0500

You only include the number of bits that are necessary to send all of 
the set bits.

See the examples in RFC 3280 ...

495 30   14:         SEQUENCE {
497 06    3:           OBJECT IDENTIFIER keyUsage (2 5 29 15)
502 01    1:           BOOLEAN TRUE
505 04    4:           OCTET STRING, encapsulates {
507 03    2:               BIT STRING 7 unused bits
            :                 '1'B (bit 0)
            :               }
            :           }

Russ