I am writing to/reading from a file.  Opening the file in binary mode seems
to have done the trick.  Thanks!


On Wed, Oct 30, 2013 at 9:30 PM, Dave Thompson <dthomp...@prinpay.com>wrote:

> First, what do you mean by string? I assume you realize that raw
> RSA-encrypted values ****
>
> (and other modern algorithms like AES and RC4 also) are binary data which
> can contain ****
>
> zero bytes and thus are not C strings; strlen() etc. won’t work right.
> This would cause ****
>
> trouble on all platforms, but only at random. (C++ std::string does not
> rely on null ****
>
> termination and can work with a little care.)****
>
> ** **
>
> Do you write the value out to a file using stdio (or C++ i/ostream) and
> read it back?****
>
> If so, how do you open the file? C and C++ standard I/O allows the
> platform to ****
>
> alter the representation of newline in text files, i.e. the char
> corresponding to \n ****
>
> in the program can be something else in the file and in particular for
> Windows ****
>
> it is the pair CR LF whereas in Unix including AFAIK MacOSX it is just NL.
> If you ****
>
> want to portably write binary data to a file in C use a binary file.****
>
> ** **
>
> If it’s not that, I don’t know what it is. Try looking at the data with a
> debugger ****
>
> after encrypting and before decrypting, especially the length and first
> and last ****
>
> few bytes (I like 4). If you don’t have a debugger write a few lines of
> code ****
>
> to print them out.****
>
> ** **
>
> ** **
>
> *From:* owner-openssl-us...@openssl.org [
> mailto:owner-openssl-us...@openssl.org <owner-openssl-us...@openssl.org>]
> *On Behalf Of *Shelli Skinner
> *Sent:* Tuesday, October 29, 2013 22:46
> *To:* openssl-users@openssl.org
> *Subject:* *** Spam *** RSA_public_encrypt/RSA_private decrypt giving
> inconsistent results in Windows****
>
> ** **
>
> Hello,****
>
> ** **
>
> Just to get the feel for how to use these functions, I am writing a test
> program that encrypts a string using RSA_public_encrypt, and then decrypts
> the encrypted string using RSA_private_decrypt.  I am observing random
> failures, on Windows only.  On OSX, it works consistently.  I have done
> some research and am suspicious that the Windows encrypted strings may be
> getting corrupted....but I am not sure and very new to OpenSSL.  Does
> anyone have any input as to what would cause this kind of inconsistent
> behavior?****
>
> ** **
>
> Thanks so much,****
>
> Shelli****
>

Reply via email to