Reference-Request

DER 格式的公鑰容器的技術名稱是什麼?

  • September 17, 2014

我有以下格式的公鑰(格式中性;類型由 DER 字節指定)格式:

$ 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:
   81:b2:18:cb:a1:82:7f:ef:ad:ef:1a:61:52:46:54:
   d0:50:1f:73:14:ad:2c:8e:4c:d8:90:74:9a:f5:37:
   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:
   c5:26:42:ad:3e:f4:bb:8e:e8:70:1d:7f:cc:3b:a6:
   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-----

這種格式的技術名稱是什麼?我一直想稱它為PKCS#8,但我認為這是不正確的,因為 PKCS#8 是一種私鑰格式。我們將公鑰的 PKCS#8 等效 DER 格式命名為什麼?

從RFC 5280 (X.509)可以看出,這種結構是SubjectPublicKeyInfo. 該欄位的格式如下:

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

AlgorithmIdentifier定義如下:

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

上述兩種類型定義了ASN.1中外層容器的格式(與欄位NULL對應的值parameters)。是由PKCS #1 v2.1 的附錄 A.1.1定義的BIT STRING內部對象,如下所示:

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

引用自:https://crypto.stackexchange.com/questions/19149