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
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).