RSA学习1
对PEM文件(以前是一个邮件编码)进行编码,得到RSA公钥.国密的RSA标准,一般是tlv(tag-version)格式的.
明文hash后的数据进行BER编码再进行加密.-签名
对于RSA的结构,全部数据可以叫私钥,其中取N值和E值可以叫公钥.以下为RSA的结构,
algId 算法Id ,代表目前算法为RSA算法,如可取10000,即为65536
keyBitLen 密钥位长,1024或者2048
N值,合数模长modulus,一般为128,不过考虑兼容2048字节内容,会申请256个空间,当使用128字节的时候,填充到后面的位置.
E值,公开幂,可以定义4个字节,一般只有3个字节内容,从1到3,0字节置空
D值,私钥D值,模长,其余为一半模长
P值
Q值
DP值
DQ值
QP值
raw:
30820258020101028180bdbd35558e8594c9a52ad3a5adb1fb823ca2b5533d6f426a633c0c79dfb02a3d29f14837dcae1540bb3338306903477659daa46a6cb6b00f03ed4353c682f2e8f7baea6e95820daed6b913b1634c424af5e167d9cf13ea22fb1c5431bc3699ed2661f061cacf128b8a402692c236da6e5cfe82c40ef7e708686edf174475310f0203010001028180583650467fa561204296dfa14658da0a99b037c70467e6a3d9910067e4f45d1ee49215b64af5f05190f6e627b39adfad8966da4bd4513717340729e71802a775951b9d88266d1e8cd394234656a3f22790a4d0f679a1191e3c3ca737df82bb55ef7b8e50c9be07f7eb359f5366268cc67a733966d7fc40e897543f270ecd48590240e68e3a07ba47f5d3c80346bf43e383b84aee3a19a67f808bd4b6089be7a0b9b30331e5da9ffd4ab9b90155472ae9c9ce8cf46768e344c81afa64f4a6bbf3fe8b0240d2add052a88916bd1a72b1f688d16b04f1e051cf3a08c3e6898f8b8fdbdf900423b23084d4be1f5179c04106500b5415635a9b84f7a1bced943e70e08c804c0d0240cedda07ddc8bc2ab9254363f5937a3b151322d596486149de26eae8ccca8eed60b30d34f75abfc47661327242301fffbdf874fddd1c59e526e86f4e941cd6c7f0240949750fa2bb25cde4d5c1dd6a313092738ad9d25ca69ca39bc46090a12eaf0396b2fcf76b051d3e6f4373be586e92689db4459b203b2087d8c7429cac66deab502407700787c04703e8e1d72adfbea7203e81b949b849001908f3078adfd7c9f4cb775821671b4858701d2429d5c64b2a7d855d620cb43065351ac55cd6ef039f2be
30820258(30-tag,82-代表长度由2bytes表示,0258-lengh-2bytes) 020101
028180
(N值开始,公钥模)bdbd35558e8594c9a52ad3a5adb1fb823ca2b5533d6f426a633c0c79dfb02a3d29f14837dcae1540bb3338306903477659daa46a6cb6b00f03ed4353c682f2e8
f7baea6e95820daed6b913b1634c424af5e167d9cf13ea22fb1c5431bc3699ed2661f061cacf128b8a402692c236da6e5cfe82c40ef7e708686edf174475310f
(N值结束)
0203 (E值开始)010001(E值结束,公钥指数)
028180(tlv,v>=0x80,L为0x81,1个字节用来表示v的长度)
(D值开始)583650467fa561204296dfa14658da0a99b037c70467e6a3d9910067e4f45d1ee49215b64af5f05190f6e627b39adfad8966da4bd4513717340729e71802a775951b9d88266d1e8cd394234656a3f22790a4d0f679a1191e3c3ca737df82bb55ef7b8e50c9be07f7eb359f5366268cc67a733966d7fc40e897543f270ecd4859
(D值结束)
0240
(P值开始)e68e3a07ba47f5d3c80346bf43e383b84aee3a19a67f808bd4b6089be7a0b9b30331e5da9ffd4ab9b90155472ae9c9ce8cf46768e344c81afa64f4a6bbf3fe8b
(P值结束)
0240
(Q值开始)d2add052a88916bd1a72b1f688d16b04f1e051cf3a08c3e6898f8b8fdbdf900423b23084d4be1f5179c04106500b5415635a9b84f7a1bced943e70e08c804c0d
(Q值结束)
0240
(DP值开始)cedda07ddc8bc2ab9254363f5937a3b151322d596486149de26eae8ccca8eed60b30d34f75abfc47661327242301fffbdf874fddd1c59e526e86f4e941cd6c7f
(DP值结束)
0240
(DP值开始)949750fa2bb25cde4d5c1dd6a313092738ad9d25ca69ca39bc46090a12eaf0396b2fcf76b051d3e6f4373be586e92689db4459b203b2087d8c7429cac66deab5(DP值结束)
0240
(QP值开始)7700787c04703e8e1d72adfbea7203e81b949b849001908f3078adfd7c9f4cb775821671b4858701d2429d5c64b2a7d855d620cb43065351ac55cd6ef039f2be(QP值结束)