Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASN.1 SEQUENCE tag number encoding

Tags:

asn.1

der

according to for example http://luca.ntop.org/Teaching/Appunti/asn1.html a sequence has the tag number 10 in hexadecimal. But why it is then DER encoded as 30 and not 10? An INTEGER with the tag number 02 in hexadecimal is also encoded as 02. Thanks.

e.g.

Sample ::= SEQUENCE {
    number 5
}

encoded as 30 03 02 01 05

like image 812
Pete Avatar asked Jan 24 '18 08:01

Pete


People also ask

What is meant by ASN1 encoding?

ASN. 1 is the acronym for Abstract Syntax Notation One, a language for describing structured information; typically, information intended to be conveyed across some interface or communication medium. ASN. 1 has been standardised internationally. It is widely used in the specification of communication protocols.

What is ASN tag?

Specifying Tags Note that ASN. 1 tags can be used to identify a type as well as a field (for example, if some components of a SEQUENCE type are optional, tags can be used to detect whether the optional components are absent or present).

What is ASN format?

ASN. 1, or Abstract Syntax Notation One, is an International Standards Organization (ISO) data representation format used to achieve interoperability between platforms.

Is ASN1 still used?

It is broadly used in telecommunications and computer networking, and especially in cryptography. Protocol developers define data structures in ASN.


1 Answers

This is because in X.509 formats, SET and SEQUENCE types are used in constructed form. As the result, 6th bit is set to 1. By setting 1 in 6th bit for SEQUENCE universal tag (0x10) you will get 0x30 and 0x31 for SET (0x11 and 6th bit to 1 = 0x31). The rest universal types are encoded in primitive forms (6th bit is set to 0).

like image 197
Crypt32 Avatar answered Sep 28 '22 09:09

Crypt32