Dr S N Henson wrote:

> "Jason A. Aras" wrote:
> 
>> I am working on a quick C hack to test out the use of the RSA encryption
>> functions.  When i make a call to RSA_public_encrypt() it sometimes
>> fails (but does not return a -1) and sometimes works.
>> 
> 
> What makes you think it fails?


It fails because when this data is being sent to the 
RSA_private_decrypt() function it fails with a padding error.


> 
>> When it fails it returns the length of a string, but a strlen() on the
>> 'to' variable is not equal to what RSA_public_encrypt() returns.  I do
>> not know what the problem is, other than a memory problem.  I first
>> thought the problem was in calling RSA_private_decrypt(); because it was
>> returning a packing error, but it turned out that the crypted data was
>> corrupt some how.
>> 
> 
> strlen() wont work on encrypted data since it can contain embedded
> nulls. In the case of RSA_public_encrypt() the size of the encrypted
> data is always RSA_size(key) as indicated in the manual.
> 
> Steve.

The error only occurs when the strlen() and the return value of 
RSA_pulic_encrypt() are not the same.

I am also curious as to functions to convert the encrypted data to/from 
a text representation for storage.

Jason

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

Reply via email to