Hi,
When calling RSA_private_encrypt with RSA_NO_PADDING, the input must
have the same size as the RSA key modulus.
In your case, you are supplying 20 bytes whereas it certainly needs more
(for example, for a 1024 bit key, input must be 128 bytes long). So, you
have to add some sort of padding to your data before feeding it to
RSA_private_encrypt.
The other option is to use a standard padding by calling
RSA_private_encrypt with RSA_PKCS1_PADDING.
I hope this clarifies things to you.
Cheers,
--
Mounir IDRASSI
IDRIX
http://www.idrix.fr
On 7/19/2010 2:51 PM, anhpham wrote:
Hi all :x
I encountered an error when using function RSA_private_encrypt with
RSA_NO_PADDING option.
I had an unsigned char array a with length = 20, RSA* r,
unsigned char* sig = (unsigned char*) malloc(RSA_size(r)) and then I invoked
function int i = RSA_private_encrypt(20,a ,sign,r,RSA_NO_PADDING ); The
returned value i = -1 means that this function failed. However, when I
invoked int i = RSA_private_encrypt(20,a,sig,r,RSA_PKCS1_PADDING ), it did
run smoothly. I'm confused whether it is an error of the library or not but
I don't know how to solve this problem.
Please help me :-<
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majord...@openssl.org