如何從 rsaEncryption OID 中辨識 RSASSA-PSS?
在RFC 8446之後,它指出:
RSASSA-PSS RSAE 算法:表示使用 RSASSA-PSS 的簽名算法
$$ RFC8017 $$使用遮罩生成函式 1. 遮罩生成函式中使用的摘要和被簽名的摘要都是相應的雜湊算法,如$$ SHS $$. Salt的長度必須等於摘要算法輸出的長度。如果公鑰包含在 X.509 證書中,它必須使用 rsaEncryption OID$$ RFC5280 $$.
從RFC 4055中可以看出:
當 RSA 私鑰所有者不希望將公鑰的使用僅限於 RSASSA-PSS 或 RSAES-OAEP 時,rsaEncryption 對象標識符繼續辨識主題公鑰。在這種情況下,rsaEncryption 對象標識符必須用於主體公鑰資訊中的算法欄位,並且參數欄位必須包含 NULL。
嘗試驗證證書籤名時讓我感到困惑,如果 OID 是 rsaEncryption 以及使用什麼雜湊,我怎麼知道使用了哪種算法?(PSS 與否)
因為params欄位為NULL,並且只有OID資訊,那麼我從哪裡可以得到簽名和雜湊算法等相關資訊呢?
證書中有兩種不同的標識符,證書的公鑰算法和頒發者的簽名算法。兩者甚至不必是同一個算法系列(例如,RSA CA 證書可以簽署 ECDSA 證書,反之亦然)。
在以下證書解析結構中,從偏移量 24 和 529 (
certificate.tbsCertificate.signature
和certificate.signatureAlgorithm
) 開始的算法標識符標識頒發機構使用 RSA PKCS#1 和 SHA-1 (id-sha1WithRSAEncryption
) 簽署了證書。偏移量 371 (
certificate.tbsCertificate.subjectPublicKeyInfo.algorithm
) 處的算法標識符標識此證書中包含的公鑰是 RSA 密鑰 (id-rsaEncryption
)。如果頒發機構使用 RSASSA-PSS 簽署了證書,則
certificate.signatureAlgorithm
和certificate.tbcCertificate.signature
值將具有 RSA-PSS 對象標識符 (1.2.840.113549.1.1.10
),並且它們的參數將傳達 PSS 數據。$ openssl asn1parse -in rsa384.cer -i 0:d=0 hl=4 l= 591 cons: SEQUENCE 4:d=1 hl=4 l= 521 cons: SEQUENCE 8:d=2 hl=2 l= 3 cons: cont [ 0 ] 10:d=3 hl=2 l= 1 prim: INTEGER :02 13:d=2 hl=2 l= 9 prim: INTEGER :C42D621149D3EE63 24:d=2 hl=2 l= 13 cons: SEQUENCE 26:d=3 hl=2 l= 9 prim: OBJECT :sha1WithRSAEncryption 37:d=3 hl=2 l= 0 prim: NULL 39:d=2 hl=3 l= 146 cons: SEQUENCE 42:d=3 hl=2 l= 11 cons: SET 44:d=4 hl=2 l= 9 cons: SEQUENCE 46:d=5 hl=2 l= 3 prim: OBJECT :countryName 51:d=5 hl=2 l= 2 prim: PRINTABLESTRING :US 55:d=3 hl=2 l= 19 cons: SET 57:d=4 hl=2 l= 17 cons: SEQUENCE 59:d=5 hl=2 l= 3 prim: OBJECT :stateOrProvinceName 64:d=5 hl=2 l= 10 prim: UTF8STRING :Washington 76:d=3 hl=2 l= 16 cons: SET 78:d=4 hl=2 l= 14 cons: SEQUENCE 80:d=5 hl=2 l= 3 prim: OBJECT :localityName 85:d=5 hl=2 l= 7 prim: UTF8STRING :Redmond 94:d=3 hl=2 l= 24 cons: SET 96:d=4 hl=2 l= 22 cons: SEQUENCE 98:d=5 hl=2 l= 3 prim: OBJECT :organizationName 103:d=5 hl=2 l= 15 prim: UTF8STRING :Microsoft Corp. 120:d=3 hl=2 l= 32 cons: SET 122:d=4 hl=2 l= 30 cons: SEQUENCE 124:d=5 hl=2 l= 3 prim: OBJECT :organizationalUnitName 129:d=5 hl=2 l= 23 prim: UTF8STRING :.NET Framework (CoreFx) 154:d=3 hl=2 l= 32 cons: SET 156:d=4 hl=2 l= 30 cons: SEQUENCE 158:d=5 hl=2 l= 3 prim: OBJECT :commonName 163:d=5 hl=2 l= 23 prim: UTF8STRING :RSA 384-bit Certificate 188:d=2 hl=2 l= 30 cons: SEQUENCE 190:d=3 hl=2 l= 13 prim: UTCTIME :160302165904Z 205:d=3 hl=2 l= 13 prim: UTCTIME :160401165904Z 220:d=2 hl=3 l= 146 cons: SEQUENCE 223:d=3 hl=2 l= 11 cons: SET 225:d=4 hl=2 l= 9 cons: SEQUENCE 227:d=5 hl=2 l= 3 prim: OBJECT :countryName 232:d=5 hl=2 l= 2 prim: PRINTABLESTRING :US 236:d=3 hl=2 l= 19 cons: SET 238:d=4 hl=2 l= 17 cons: SEQUENCE 240:d=5 hl=2 l= 3 prim: OBJECT :stateOrProvinceName 245:d=5 hl=2 l= 10 prim: UTF8STRING :Washington 257:d=3 hl=2 l= 16 cons: SET 259:d=4 hl=2 l= 14 cons: SEQUENCE 261:d=5 hl=2 l= 3 prim: OBJECT :localityName 266:d=5 hl=2 l= 7 prim: UTF8STRING :Redmond 275:d=3 hl=2 l= 24 cons: SET 277:d=4 hl=2 l= 22 cons: SEQUENCE 279:d=5 hl=2 l= 3 prim: OBJECT :organizationName 284:d=5 hl=2 l= 15 prim: UTF8STRING :Microsoft Corp. 301:d=3 hl=2 l= 32 cons: SET 303:d=4 hl=2 l= 30 cons: SEQUENCE 305:d=5 hl=2 l= 3 prim: OBJECT :organizationalUnitName 310:d=5 hl=2 l= 23 prim: UTF8STRING :.NET Framework (CoreFx) 335:d=3 hl=2 l= 32 cons: SET 337:d=4 hl=2 l= 30 cons: SEQUENCE 339:d=5 hl=2 l= 3 prim: OBJECT :commonName 344:d=5 hl=2 l= 23 prim: UTF8STRING :RSA 384-bit Certificate 369:d=2 hl=2 l= 76 cons: SEQUENCE 371:d=3 hl=2 l= 13 cons: SEQUENCE 373:d=4 hl=2 l= 9 prim: OBJECT :rsaEncryption 384:d=4 hl=2 l= 0 prim: NULL 386:d=3 hl=2 l= 59 prim: BIT STRING 447:d=2 hl=2 l= 80 cons: cont [ 3 ] 449:d=3 hl=2 l= 78 cons: SEQUENCE 451:d=4 hl=2 l= 29 cons: SEQUENCE 453:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Subject Key Identifier 458:d=5 hl=2 l= 22 prim: OCTET STRING [HEX DUMP]:0414E451B61668BCEA124E09FE0A9E36B13865957515 482:d=4 hl=2 l= 31 cons: SEQUENCE 484:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Authority Key Identifier 489:d=5 hl=2 l= 24 prim: OCTET STRING [HEX DUMP]:30168014E451B61668BCEA124E09FE0A9E36B13865957515 515:d=4 hl=2 l= 12 cons: SEQUENCE 517:d=5 hl=2 l= 3 prim: OBJECT :X509v3 Basic Constraints 522:d=5 hl=2 l= 5 prim: OCTET STRING [HEX DUMP]:30030101FF 529:d=1 hl=2 l= 13 cons: SEQUENCE 531:d=2 hl=2 l= 9 prim: OBJECT :sha1WithRSAEncryption 542:d=2 hl=2 l= 0 prim: NULL 544:d=1 hl=2 l= 49 prim: BIT STRING