From here, there are $14$ bytes specifying the file format of the key. I am still quite confused about the format bytes. For example, the following public key

30 82 01 0a 02 82 01 01 00 8e a3 d1 c7 9c 86 05 52 3d 70 9a 5b 24 8a 6e ab 8f 5d 8d 9a 44 5f 25 78 c7 ba bd 3a a6 e1 36 b8 55 88 18 d7 ea e8 14 2c 68 8f e7 fe 94 4c f3 fd ad 0b e6 d2 eb 9e d2 66 b4 3a 3b d1 bb 5d d5 2a 53 7e 0f 1d ba ec 03 29 9d 47 50 3b 99 fb 4a 3a 80 a2 23 3e d7 11 e3 de a8 8d ab 7c 90 d0 92 af 36 b8 8b 28 fd 80 ec bc 37 6d 23 44 86 4e 28 19 1d 18 37 af 44 a9 40 b3 f6 e7 6c ad 56 5d 6f ff 3b e3 a5 cc 23 5c 54 2a 47 28 5b 29 f3 45 8e 69 98 ad 57 45 2e 60 bd ac 55 fc 35 e8 47 9f 98 0d f9 ea 9d 55 35 c9 db af 24 d2 bc 18 12 02 53 d6 aa ef 9c c9 11 c9 8e d7 7c 4f 2f 22 0f 66 b1 bf 06 a5 fa 87 22 9f ff f6 20 75 e7 51 87 26 30 c2 e1 a5 30 2c a1 fc 47 a5 f7 a5 38 d3 cc 8d 0e ee 5a 54 ee a2 f9 ff d0 0a 0f 18 7f 94 d2 04 5e 1f 25 ca be 4e 30 c3 40 00 ed a4 ce 58 ab 23 39 2d 02 03 01 00 01

is taken from google's certificate. The first byte $30$ means it is a sequence. Then I don't know what is the meaning from 2nd byte to 9th byte. Can anyone explain to me?

UPDATE: The 2nd byte (82) means that the following 2 bytes give the length of the sequence. The 5th byte tells us that it is an integer. The byte following it tells us the length and the value of the integer (I guess). Then the rest I have no idea.

Also what do the last 3 bytes stand for? I can't find format start with $01$.


1 Answer 1


You've mostly pieced it out. This is a DER encoding the the public key, and consists of a sequence of two integers (the first being the modulus, and the second being the exponent).

Here is the breakdown of the encoding:


The value 30 is used to signify 'sequence'; this is a container that carries a list of DER-encoded objects.

82 01 0a

Whenever we have an object (including a sequence), we always encode the length of the object (that is, how many bytes are in the DER-encoding of the object, not counting the object type and the length field); here, the 82 signifies that the length itself is 2 bytes long, and that the total length is 0x010a = 266 bytes.


Now, we get to the first object in the sequence; the value 02 is used to signify 'integer'.

82 01 01

And this is the length of the integer; again, the 82 signifies that the length itself is 2 bytes long, and that the total length is 0x0101 = 257 bytes.

00 8e a3 d1 c7 ... ab 23 39 2d

These 257 bytes are the actual integer, in bigendian format. Note that the first byte is a 00; that is required because of the rules of DER encoding. Specifically, the 02 format encodes an integer, and it is allowed to encode a negative integer (remember, DER is a general format, and is not targetted specifically to encoding public keys). The rule is that the integer is negative if the msbit of the encoded value is a 1. We need to encode a positive integer; the top byte of the value we encode is 8e, which has a msbit of 1. To prevent this from confusing the decoder, we prepend a 00 on top to make the msbit 0.

And, while you didn't ask about the end part, here are the last 5 bytes:


This signifies that the second element in the sequence encodes an integer


This signifies that this integer is encoded in 3 bytes

01 00 01

This signifies that the encoded integer is 0x10001 == 65537

  • $\begingroup$ In RSA, public keys are encryption key and modulus. So I assume that the two numbers in the sequence are the key and modulus respectively? $\endgroup$
    – Idonknow
    Nov 3, 2014 at 13:12
  • $\begingroup$ @Idonknow: no, the two integers are 'the modulus' and the 'public exponent', just as I said $\endgroup$
    – poncho
    Nov 3, 2014 at 13:15
  • $\begingroup$ Did I got this correct? The whole DER encoded data is actually "sequence of values, integer N1, integer N2" without any additional metadata (all the bytes are just encoding this exact sequence). And the actual meaning of that data (first integer is modulus, second is exponent for RSA algorithm) is not encoded in the encoding of public key but the software must have hardcoded interpretation to correctly use those two integers. $\endgroup$ Apr 22, 2022 at 11:58
  • 1
    $\begingroup$ @MikkoRantalainen: there is a standard object identifier that would identify this as an RSA public key; however if someone already knows this is an RSA public key, that is often omitted (as in this case) $\endgroup$
    – poncho
    Apr 22, 2022 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.