Bonjour Giordano

Hodie Non. Aug. MMXI, Giordano Bruno scripsit:
> I tried your command, but I got an error:
> 
> C:\OpenSSL-Win32\bin>openssl rsautl -in example.der.sig -inkey
> example.key -pubin -verify -hexdump –raw
> Loading 'screen' into random state - done
> unable to load Public Key

You first have to create the necessary files, extracted from the
request (since it is self-signed).

> I read the PKCS#1, PKCS#8, PKCS#7 and PKCS#10 and now I have an better
> idea from PKI, but I'm still a begginer in these contents.
> 
> Could you tell-me how to make the example.key and example.der.sig? Is
> it in Base64 encoding?

Let's start with your example file: example.der.

Extract the contained public key:
  openssl req -pubkey -inform D -in example.der -noout > example.key

Now we'll extract the signature block.

Start by ASN1-parse your file:
  openssl asn1parse -inform D -i -dump -in example.der

You'll see the subject name, public key, extension requests, and the
signature at the end:
  318:d=1  hl=3 l= 129 prim:  BIT STRING        
      0000 - 00 8f 2c 23 95 d5 70 b6-19 df 20 fb 59 a6 e8 9f   ..,#..p... .Y...
      0010 - 5d 59 0b b5 33 69 6b ee-8b 4f 4e f8 1a 4d be 12   ]Y..3ik..ON..M..
      0020 - 30 5b 8b 1c bf 3b 09 9b-62 9c 00 a9 47 91 0d 06   0[...;..b...G...
      0030 - a4 3f 6e e7 a4 77 32 f4-ca 09 c7 1a b2 2f e8 62   .?n..w2....../.b
      0040 - c7 43 b1 0e a4 fe d6 61-fa 6c 43 81 3e af de a9   .C.....a.lC.>...
      0050 - 79 2d 72 b5 3a bc 00 01-59 d3 86 59 45 7a 28 54   y-r.:...Y..YEz(T
      0060 - 55 c6 b7 45 c0 22 96 6c-7a b1 a3 b7 f5 3f e2 5f   U..E.".lz....?._
      0070 - c9 96 b0 b8 2c 3c dc b8-9b 0b c0 e5 77 41 5a ae   ....,<......wAZ.
      0080 - 61                                                a

You know that the signature starts at offset 318. We need only the raw
signature, so we'll skip the first 318 bytes, the header (hl=3, so
skip 3 more bytes), and since it's a bit string, it starts with the
number of unused bits (expressed in one octet, 00 in this case), you
must also skip this octet. Finally, you need to skip 318+3+1=322
bytes:
  dd if=example.der of=example.der.sig bs=1 skip=322

The command should tell you that it has extracted 128 bytes, which is
the size of your 1024bits RSA signature. Since you're working under
Windows, you'll need to find a dd binary, or do the operation on a
Unix-like machine.

Now, you can perform the raw RSA verification:
  openssl rsautl -in example.der.sig -inkey example.key -pubin -verify -raw 
-hexdump

And you'll get the data that was passed to your signature function:
0000 - 32 dc d5 61 c5 88 4a 00-b3 a9 9b c2 61 ce d6 01   2..a..J.....a...
0010 - f6 b4 83 9b 60 0f 7d 99-15 34 e6 47 98 2b 06 5a   ....`.}..4.G.+.Z
0020 - cc 07 39 c6 f7 87 f4 75-6e 1a 16 5b 32 70 5a a3   ..9....un..[2pZ.
0030 - 5e 42 c0 71 02 4c a3 1d-48 31 7c 7c 12 bb 3f e6   ^B.q.L..H1||..?.
0040 - c4 4d e7 dc 43 80 0e b8-fe cb ba 15 b6 1e 8c 3d   .M..C..........=
0050 - 1b 98 31 04 23 51 9d 26-d7 ac fc a5 6d 47 6a 4f   ..1.#Q.&....mGjO
0060 - 9d bb 12 e3 e0 44 c7 4d-23 4c c0 49 a6 40 fe 38   .....D.M#L.I.@.8
0070 - e7 ab 48 f6 a3 f3 a5 a6-1a 11 bb 1b 94 d9 e0 bc   ..H.............

You then can manually verify the padding, hash algo, hash value, etc.

-- 
Erwann ABALEA <erwann.aba...@keynectis.com>
Département R&D
KEYNECTIS
11-13 rue René Jacques - 92131 Issy les Moulineaux Cedex - France
Tél.: +33 1 55 64 22 07
http://www.keynectis.com
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to