# What is the technical name for a public key container in DER format?

I have a public key in the following (format-neutral; the type is specified by the DER bytes) format:

$cat pubkey.der | openssl asn1parse -inform der -i 0:d=0 hl=4 l= 290 cons: SEQUENCE 4:d=1 hl=2 l= 13 cons: SEQUENCE 6:d=2 hl=2 l= 9 prim: OBJECT :rsaEncryption 17:d=2 hl=2 l= 0 prim: NULL 19:d=1 hl=4 l= 271 prim: BIT STRING$ cat pubkey.der | openssl rsa -inform der -pubin -text
Public-Key: (2048 bit)
Modulus:
00:ac:f3:c2:c6:60:c2:9b:1e:db:fb:b6:32:67:45:
09:25:be:b0:d9:66:21:a0:80:ac:52:be:d4:59:1c:
7f:85:c0:45:ed:4e:85:69:55:80:a9:1e:36:94:93:
19:ce:30:8b:89:5d:1a:8e:9a:d6:7a:88:6a:1a:68:
6d:72:57:5e:11:a2:ec:9e:44:b7:64:06:6a:1c:d0:
e7:54:91:3b:79:0a:2e:af:7e:f3:de:98:1c:3c:fd:
d6:67:73:63:7b:10:7d:b7:77:04:ab:42:17:33:4d:
28:79:ed:4c:a1:96:71:94:32:bf:2d:49:d6:bd:b2:
04:6c:be:6f:1a:a2:40:c4:a5:ee:d5:83:87:44:a5:
90:22:c5:96:14:69:3c:ae:65:76:9c:45:41:4b:5f:
04:03:27:b6:74:a5:3b:c4:27:d4:83:7c:0a:18:b4:
5d:36:95:6f:9b:08:f4:14:37:8d:33:be:bd:e0:46:
11:89:9e:f9:5b:49:f7:9e:c6:2f:86:5e:96:83:5e:
47:9c:c0:3a:60:91:ea:41:98:7f:3e:85:a5:ab:73:
b0:59
Exponent: 65537 (0x10001)
writing RSA key
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArPPCxmDCmx7b+7YyZ0UJ
Jb6w2WYhoICsUr7UWRx/hcBF7U6FaVWAqR42lJMZzjCLiV0ajprWeohqGmhtclde
EaLsnkS3ZAZqHNCBshjLoYJ/763vGmFSRlTQUB9zFK0sjkzYkHSa9TfnVJE7eQou
r37z3pgcPP3WZ3NjexB9t3cEq0IXM00oee1MoZZxlDK/LUnWvbLFJkKtPvS7juhw
HX/MO6YEbL5vGqJAxKXu1YOHRKWQIsWWFGk8rmV2nEVBS18EAye2dKU7xCfUg3wK
GLRdNpVvmwj0FDeNM7694EYRiZ75W0n3nsYvhl6Wg15HnMA6YJHqQZh/PoWlq3Ow
WQIDAQAB
-----END PUBLIC KEY-----


What is the technical name for this format? I keep wanting to call it PKCS#8, but I think that would be incorrect, since PKCS#8 is a private key format. What do we name the PKCS#8 equivalent DER format for public keys?

• The format is PKCS#1 with PEM encoding. Your question is however off topic here. – Henrick Hellström Sep 15 '14 at 23:03
• @HenrickHellström, the question of off/on topic aside, I don't necessarily agree. First, it's DER, not PEM. (the contents of the PEM header in my example are not relevant to the discussion.) Second, I checked RFC 3447 (PKCS#1 v2.1) and didn't see any mention of this particular format. To be specific, section A.1.1 mentions the public key syntax, but not the PKCS#8-like wrapping my example exhibits. (see the rsaEncryption OID in the asn1parse output.) – mpontillo Sep 15 '14 at 23:09
• If it's not a plain PKCS#1 RSAPublicKey, it is probably a SubjectPublicKeyInfo from PKIX/X.509 – Henrick Hellström Sep 15 '14 at 23:33
• @HenrickHellström, bingo, that is exactly what this is. Thank you. If you make that an answer, I will accept it. (for what it's worth) – mpontillo Sep 15 '14 at 23:35
• I do not agree with the close votes. This is not about decoding or decrypting a piece of ciphertext, it is about identifying a cryptography related data structure. That is both a concise question and of use to others. – Maarten Bodewes Sep 17 '14 at 8:50

As can be seen by RFC 5280 (X.509), this structure is the SubjectPublicKeyInfo. This field is formatted as follows:

SubjectPublicKeyInfo  ::=  SEQUENCE  {
algorithm            AlgorithmIdentifier,
subjectPublicKey     BIT STRING  }


The AlgorithmIdentifier is defined as follows:

AlgorithmIdentifier  ::=  SEQUENCE  {
algorithm               OBJECT IDENTIFIER,
parameters              ANY DEFINED BY algorithm OPTIONAL  }


The above two types define the format of the outer container in the ASN.1 in question (with the NULL value corresponding to the parameters field). The BIT STRING is an inner object defined by Appendix A.1.1 of PKCS #1 v2.1 as follows:

RSAPublicKey ::= SEQUENCE {
modulus           INTEGER,  -- n
publicExponent    INTEGER   -- e
}