Hi Steve,

I've just solved the problem, as you correctly guessed, I was using 
strlen(buffer) as the length of the string to decrypt.  The fact that 
it was sometimes working would be the case where the random element 
would not result in an embedded null being produced.  I suppose this 
problem is why people use the bp bio structure. i.e. this contains 
both data and datalen parameters.

Thanks

Chris R

----- Original Message ----- 
From: "Dr. Stephen Henson" <[EMAIL PROTECTED]>
To: <openssl-users@openssl.org>
Sent: Tuesday, September 20, 2005 3:19 AM
Subject: Re: rsa_publiic_encrypt problem


On Mon, Sep 19, 2005, Chris Rutherford wrote:

> Hi All,
>
> I have a strange problem with RSA_Public_Encrypt.  Basically it only
> produces decipherable information about 50% of the time, but with 
> the
> same clear text string.  i.e. I have an RSA encrypt decrypt 
> benchmark
> program using a static clear text char string.  sometimes it works,
> but other times it produces a padding error when I decrypt, but 
> using
> the same clear text.  Is this some kind of seeding problem?  How 
> else
> could it work about 50% of the time with the same clear text?
>

I did answer this before but it doesn't seem to have made it to the 
list. Are
you assuming the result is a text string and using/copying it with 
something
like strlen()? If so that will fail if the result contains an embedded 
null.

RSA_public_encrypt() with PKCS#1 padding contains a random element so 
you will
get different results for the same plaintext.

Steve.
--
Dr Stephen N. Henson. Email, S/MIME and PGP keys: see homepage
OpenSSL project core developer and freelance consultant.
Funding needed! Details on homepage.
Homepage: http://www.drh-consultancy.demon.co.uk
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]



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

Reply via email to