pem檔案格式詳細解析 收藏
pem檔案格式存檔
author:roson sun [email protected]
time:2006-4-11
1. 描述:
openssl使用pem(rfc 1421-1424)文件格式,如果使用其他語言包,則需要將此格式進行解碼並將各個私公鑰加入。
2. 說明:
a) 首先使用base64解碼,如果是非ansi txt格式,需要做轉換。
b) 乙個rsa私鑰包含一下資訊(1024位):
>openssl rsa -in key.pem -noout -text
modulus:
00:d5:00:b2:18:c3:04:d1:ac:80:c6:22:a0:cc:5c:
f1:c0:4a:83:95:e5:c9:88:ae:31:64:ab:e1:15:42:
de:1a:da:bc:f5:d2:05:05:74:9d:d3:86:94:9b:9d:
74:bb:e5:72:a4:b8:40:27:61:88:d4:ac:20:b0:2b:
1c:1e:d7:9b:43:c5:06:b6:3a:b4:42:f0:5a:22:38:
23:74:99:4a:50:f1:f1:54:11:5a:44:0b:40:cf:83:
8a:73:6c:34:15:98:0a:7d:cf:0e:e5:00:8d:07:40:
f7:7d:fb:3f:64:35:1b:5d:a3:40:a9:51:fa:92:7d:
34:ef:03:fe:e0:59:56:31:25
數量:128
publicexponent:
01:00:01
數量:3
privateexponent:
11:e2:a8:11:ba:36:6a:60:c0:c3:62:5e:fc:2a:05:
c6:ae:bb:13:d8:22:af:0e:69:69:59:a1:61:c6:a6:
9d:bc:a6:47:41:e6:58:09:ed:c2:b8:37:3c:45:e1:
6a:71:9e:c9:c4:0a:e7:03:a2:98:b1:07:61:a3:8d:
0d:ed:ee:c4:7f:ca:fe:7d:c1:2e:2f:ca:3d:16:81:
4f:bf:ad:6a:03:ca:d7:80:dc:57:03:fe:cf:1f:37:
05:8d:58:79:14:01:1f:66:42:e4:f1:b6:9d:f1:01:
37:12:f4:d8:15:c0:cc:9b:fc:ea:55:cb:2f:ba:46:
fd:17:11:7e:43:b5:d1:15
數量:128
prime1:
00:ed:a0:e8:25:cc:1c:aa:f5:44:e2:78:9e:54:2c:
1d:60:cb:8f:32:b3:68:6d:b3:1d:cd:a9:8c:2a:ca:
02:bc:7b:a7:8b:06:1d:fa:af:4f:8c:26:81:54:12:
ec:7d:92:20:77:85:ef:6e:06:a6:8b:9c:eb:ab:6a:
e6:a1:83:6d:a3
數量:64(去掉開頭的0)
prime2:
00:e5:78:66:5a:84:22:51:78:2d:14:fc:5f:f8:4e:
45:5f:e3:b2:5e:5b:50:a4:f5:55:e0:f3:0e:98:2c:
52:61:c2:50:df:f4:b7:bc:6e:69:3e:99:ff:1c:50:
a8:89:05:7a:2b:25:91:56:a5:a6:8f:8a:ec:80:82:
fa:eb:09:c2:97
數量:64(去掉開頭的0)
exponent1:
00:89:e6:26:d2:48:71:1a:84:db:44:d1:da:8f:de:
49:ee:32:33:17:a9:25:a1:03:a0:f8:08:bc:5e:d8:
7c:5e:05:24:65:79:57:4c:73:10:26:b4:f1:b8:68:
82:f5:1c:27:db:34:ce:8d:7b:2e:8b:36:b5:4c:f4:
ec:82:2e:53:21
數量:64(去掉開頭的0)
exponent2:
6a:16:a6:e3:74:31:55:8f:04:f0:ad:d9:44:b8:13:
14:c8:f5:5e:f0:42:b1:71:07:5a:2f:a4:f0:af:95:
0a:c3:46:96:b3:d1:fa:58:e5:69:5e:d2:f5:e9:48:
71:c8:c9:79:87:2d:d1:6c:56:3c:08:d3:5c:7a:b1:
bc:d6:4f:53
數量:64
coefficient:
62:dd:3f:f4:c7:30:c7:77:5e:8c:ae:c8:11:c1:23:
b0:6d:7d:07:54:8f:e7:12:1d:e1:00:ad:70:55:12:
43:f6:6f:a9:d7:94:9d:33:15:66:16:2d:d1:76:13:
33:0d:ae:6f:e3:3f:46:4b:4a:78:14:02:2e:72:66:
59:0c:2d:6a
數量:64
c) 與c#中rsaparameter結構體對應表:
說明pem
rsaparameter
modulus
modulus
exponent
exponent
prime1
pexponent1
qprime2
dpexponent2
dqcoefficient
inverseq
privateexponent
dd) pem偏移(1024位,以0為開始字元,十進位制)
說明pem私鑰
pem公鑰
長度modulus
1129
128publicexponent
141159
3privateexponent
147×
128prime1
278×
64prime2
345×
64exponent1
412×
64exponent2
478×
64coefficient
545×
64e) 例子程式(c#):
///
/// 用得到的解碼值來得到相應的parameter(base64->rsaparameter)
///
/// 源
/// 0私鑰1公鑰
///
public rsaparameters getkeypara(string hashkey,int type)
rsap.modulus=arrpemmodulus;
//publicexponent
for(int i=0;irsap.exponent=arrpempublicexponent;
//privateexponent
for(int i=0;irsap.d=arrpemprivateexponent;
//prime1
for(int i=0;irsap.p=arrpemprime1;
//prime2
for(int i=0;irsap.q=arrpemprime2;
//exponent1
for(int i=0;irsap.dp=arrpemexponent1;
//exponent2
for(int i=0;irsap.dq=arrpemexponent2;
//coefficient
for(int i=0;irsap.inverseq=arrpemcoefficient;
}else//公鑰
rsap.modulus=arrpemmodulus;
for(int i=0;irsap.exponent=arrpempublicexponent;
}return rsap;
}
QuickTime檔案格式解析
peter lee 2008 06 14 一 簡介 quicktime 是公司開發的一套完整的多 平台架構,可以用來進行多種 的建立,生產,和分發,並為這一過程提供端到端的支援 包括 的實時捕捉,以程式設計的方式合成 匯入和匯出現有的 還有編輯和製作,壓縮,分發,以及使用者回放等多個環節。quick...
sol檔案格式解析
在網上搜了一遍只看到這個分析 sharedobject sol檔案頭總是00 bf,接著4個位元組是大小 這個大小是之後所有塊的大小哦 然後也是固定的54 43 53 4f 00 04 00 00 00 00。第17 18位元組是sharedobject變數名的長度,緊跟著就是sharedobjec...
FLV檔案格式解析
flv是流 封裝格式,我們可以將其資料看為二進位制位元組流。總體上看,flv包括檔案頭 file header 和檔案體 file body 兩部分,其中檔案體由一系列的tag及tag size對組成。因此乙個flv檔案看上去是下面的結構 其中,previous tag size 緊跟在每個 tag...