Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does ASN.1 encode an object identifier?

I am having trouble understanding the basic concepts of ASN.1.

If a type is an OID, does the corresponding number get actually encoded in the binary data?

For instance in this definition:

id-ad-ocsp         OBJECT IDENTIFIER ::= { id-ad 1 } 

Does the corresponding 1.3.6.1.5.5.7.48.1 get encoded in the binary exactly like this?

I am asking this because I am trying to understand a specific value I see in a DER file (a certificate), which is 04020500, and I am not sure how to interpret it.

like image 743
Cratylus Avatar asked May 08 '11 17:05

Cratylus


People also ask

What is the purpose of ASN 1 object identifier tree?

1 OBJECT IDENTIFIER tag: 06. The ASN. 1 OBJECT IDENTIFIER type is used when you need to provide a unique identifier (for example, for a module).

How OID are encoded?

Each integer of a dotted decimal object identifier (OID) is encoded according to the following rules: The first two nodes of the OID are encoded onto a single byte. The first node is multiplied by the decimal 40 and the result is added to the value of the second node.


1 Answers

Yes, the OID is encoded in the binary data. The OID 1.3.6.1.5.5.7.48.1 you mention becomes 2b 06 01 05 05 07 30 01 (the first two numbers are encoded in a single byte, all remaining numbers are encoded in a single bytes as well because they're all smaller than 128).

A nice description of OID encoding is found here.

But the best way to analyze your ASN.1 data is to paste in into an online decoder, e.g. http://lapo.it/asn1js/.

like image 146
Codo Avatar answered Sep 28 '22 16:09

Codo