一、簡介
asn1parse命令是一種用來診斷ASN.1結構的工具,也能用於從ASN1.1數據中提取數據
二、語法
openssl asn1parse [-inform PEM|DER] [-in filename] [-out filename] [-noout] [-offset number] [-length number] [-i] [- structure filename] [-strparse offset]
選項
-inform arg input format - one of DER PEM -in arg input file -out arg output file (output format is always DER -noout arg don't produce any output -offset arg offset into file -length arg length of section in file -i indent entries -dump dump unknown data in hex form -dlimit arg dump the first arg bytes of unknown data in hex form -oid file file of extra oid definitions -strparse offset a series of these can be used to 'dig' into multiple ASN1 blob wrappings -genstr str string to generate ASN1 structure from -genconf file file to generate ASN1 structure from
三、ASN.1結構
0:d=0 hl=4 l= 710 cons: SEQUENCE
0 表示節點在整個文件中的偏移長度 d=0 表示節點深度 hl=4 表示節點頭字節長度 l=710 表示節點數據字節長度 cons 表示該節點為結構節點,表示包含子節點或者子結構數據 prim 表示該節點為原始節點,包含數據 SEQUENCE、OCTETSTRING等都是ASN.1中定義的數據類型,具體可以參考ASN.1格式說明。 最后一個節點OCTET STRING [HEX DUMP],就是加密后的私鑰數據。
四、實例
1、分析一個文件
openssl asn1parse -in ec_pubkey.pem
2、分析一個DER文件
openssl asn1parse -inform DER -in file.der