Hi,
On a PHP server using SSL my colleague does:

openssl genrsa -des3 -out private_key_file 256

openssl rsa -pubout -in private_key_file -out pub_key_file

then to sign some message data he uses the PHP call:

$digest = mhash(MHASH_MD5, $msg);

and then sign the obtained digest with:

openssl_private_encrypt($digest, $sign, $pkeyid);

I already know that 256 bit rsa key has securiry issue but it's
not my choice so, I'm trying to do the same with Java and JCE.
I create the keypair. I try to sign message data with "MD5withRSA"
but I get an exception:

SignatureException: key too small for signature type !

With Java If I specify a 512 bit RSA keys everithing works fine but
then the PHP server refuses my public key because is too long.
Speaking with a guy more expert than me about cryptography
( it's not so difficult ;-) ) he told me that:
a 256 bit rsa key can't be used for for MD5 signatures.
There is a minimum key size that can be used to compute a PKCS#1
signature with a given hash that has to do with the size of the
hash plus some padding that is used. He doesn't recall what the
absolute minimum is for MD5withRSA, but 256 bits is too small 
and 512 bits is enough.

If this is true, why on OpenSSL side everithing works fine?
the private encrypt function does something different ?

Thank you in advance
--
Davide





______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to