DER encoded Public key [I hate ASN.1]
038181006BA216825F01E8A2E9015AAD9872B3BD68B453D29C7C4648C6653407111C1488D3E633EF07FEF90BA09BF90A94160091C24789FEDA738858C24B95949C844A4AB312B5F52250A9A234382F0B2E8402F260A54F065436632671B004737ED81B5EBE1003A71829C1D3ADEB5F17AB0BE58B6B8969FD6A115ADE4A615FA68B20E7E3]
Note the "extra length" byte 81 which is required if length >= 0x80 ???
if the actual length > 0xFF then more rules???
Note the 00 unused bits byte which follows the 03 bit string
03 81 bit string
8D 00 unused buts 0 L=8D
30 81 89 sequence L=89
02 81 81 Integer L= 81
(modulus)
00CE64E4BADC06A5D6D72FFB9A97E81EACC4C007864DE5FFCF5212FFC0433C7DDDD7042EDB2DBB97217170224A763D3FDDC92EF5447299243873070A84DCDA4392882D17BC61A0BC22D8DA46AD3C3F7A5EF430A34813F11B0C611D36DE4E54377716DE82B7E2AC21994244CDC406ADF83F32A685B5D925F2796FFF35F5B6DA19D1
02 03 integer (note NO "extra" length byte)
modulus
010001
Very few ASN.1 decoders will expand this
most of the online and Free decoders dont
bouncycastle DERObject to ASN1Object does NOT
java certificate object does return modulus and exponent
pumka mentions lipingshare ASN.1 Editor
which DOES expand... the msi installer is picky about its location..
oddly it shows modulus in Hex and Exponent in DEcimal
so to extract data (if length < 256 bytes)
must go something like this:
If ((raw[1] & 0x80) != 0)
lz = 2;
else
lz = 1;
length = raw[lz];
if (raw[0] == 0x03)
dz = lz+1;
else
dz = lz;
move(raw,dz,data,0,lz)
...now to spend a couple months writing ASN.1 de/encode??
No comments:
Post a Comment