Analyzing a X.509 certificate with ECDSA signature I found a 0x00 byte I can't explain.
The signature of a X.509 certificate should be given in an ASN.1 BIT STRING structure.
For ECDSA the signature consists of two integers (r, s) coded as ASN.1 SEQUENCE of two ASN.1 INTEGERs.
In my example (generated with openssl) I got this:
ASN.1 tag for BIT STRING
| length
| |
| | ASN.1 tag for SEQEUNCE
| | | length
| | | |
| | | | ASN.1 tag for INTEGER ASN.1 tag for INTEGER
| | | | | length | length
| | | | | | | |
| | | | | | 0x21 bytes integer value | | 0x21 bytes integer value
| | | | | | ____________|____________ | | ____________|____________
v v v v v v / \ v v / \
... 03 49 00 30 46 02 21 00 D5 F4 76 43 ... A2 BD 95 02 21 00 DF 01 30 24 ... 50 12 32
^
|
why is there a 0x00 byte?
Why is there an extra 0x00 byte before the ASN.1 SEQUENCE tag?