Re: OpenSSL cryptography fails in release mode, but no in debug

2009-04-16 Thread Atti
I couldn't make the new version work, but I installed 0.9.8g, from
binaries, deleted everything related to OpenSSL, and recompiled the
example. It now generated the same output, but in my actual project it
still wasn't working. I found some errors in the key handling, and
after I fixed that, the blowfish started working, but not the 3DES. I
tried AES too, and they all worked, except the one I was using. It's
not a problem tho, I use the AES now, and everything is working fine
now, but with the older version of OpenSSL.

Thank you for your help.

On Wed, Apr 15, 2009 at 9:16 PM, Victor Duchovni
victor.ducho...@morganstanley.com wrote:
 On Wed, Apr 15, 2009 at 08:19:34PM +0300, Atti wrote:

 Okay, well as I said, I compiled and ran the example from the OpenSSL
 docs (http://openssl.org/docs/crypto/EVP_EncryptInit.html#EXAMPLES),
 which has an IV, and the application still behaves the same.

 What key and IV sizes does the following code variant report? On
 a Unix system both 0.9.8i and 1.0.0-beta1 produce consistent
 identical ciphertexts that decrypt via openssl bf -in cipher.bin -K
 000102030405060708090A0B0C0D0E0F -iv 0102030405060708 -d as advertised.

 #include openssl/evp.h
 #include stdio.h
 int do_crypt(char *outfile)
 {
    unsigned char outbuf[1024];
    int outlen, tmplen;
    unsigned char key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
    unsigned char iv[] = {1,2,3,4,5,6,7,8};
    char intext[] = Some Crypto Text;
    EVP_CIPHER_CTX ctx;
    FILE *out;

    EVP_CIPHER_CTX_init(ctx);
    EVP_EncryptInit_ex(ctx, EVP_bf_cbc(), NULL, key, iv);
    fprintf(stderr, key length=%d, IV length=%d\n,
            EVP_CIPHER_CTX_key_length(ctx),
            EVP_CIPHER_CTX_iv_length(ctx));
    if(!EVP_EncryptUpdate(ctx, outbuf, outlen, intext, strlen(intext)))
        return 0;
    if(!EVP_EncryptFinal_ex(ctx, outbuf + outlen, tmplen))
        return 0;
    outlen += tmplen;
    EVP_CIPHER_CTX_cleanup(ctx);

    out = fopen(outfile, wb);
    fwrite(outbuf, 1, outlen, out);
    fclose(out);
    return 1;
 }
 int main(int argc, char *argv[]) { return !do_crypt(argv[1]); }
 __
 OpenSSL Project                                 http://www.openssl.org
 User Support Mailing List                    openssl-us...@openssl.org
 Automated List Manager                           majord...@openssl.org

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: OpenSSL cryptography fails in release mode, but no in debug

2009-04-15 Thread Atti
I built the new OpenSSL (1.0.0) and tried to run the blowfish encryption
example from the OpenSSL docs (
http://openssl.org/docs/crypto/EVP_EncryptInit.html#EXAMPLES) but this time
I used the same library to compile the application, because this build only
made this one. I made one debug and one release build with VS2008, and they
both generated different cyphertexts with the same key and input data. I
also used the same .DLL, becase there is only one, and as I read from the
FAQ, that should be okay. What am I doing wrong?


Re: OpenSSL cryptography fails in release mode, but no in debug

2009-04-15 Thread Atti
I built the new OpenSSL (1.0.0) and tried to run the blowfish
encryption example from the OpenSSL docs
(http://openssl.org/docs/crypto/EVP_EncryptInit.html#EXAMPLES) but
this time I used the same library to compile the application, because
this build only made this one. I made one debug and one release build
with VS2008, and they both generated different cyphertexts with the
same key and input data. I also used the same .DLL, becase there is
only one, and as I read from the FAQ, that should be okay. What am I
doing wrong?

On Tue, Apr 14, 2009 at 2:49 PM, Atti att...@gmail.com wrote:

 Sorry, I made a mistake when I wrote the first text, I'm using 
 libeay32MDd.lib - /MDd for debug and libeay32MD.lib - /MD for release. I only 
 made the mistake writing this, I'm linking against the correct .libs in my 
 project.

 On Tue, Apr 14, 2009 at 2:03 PM, Atti att...@gmail.com wrote:

 Hy, I'm using an older version of OpenSSL (the new one has errors in 
 X509.h), on a Win32 machine, installed as binaries. I'm using the 
 EVP_Encrypt/Decrypt functions and a generated key to encrypt my data, and 
 everything works fine in debug mode. When I try to run the release mode, it 
 still runs fine, but the decryption returns scrambled data. I've read the 
 FAQ, and I am using the libraries as mentioned there (libeay32MTd.lib - /MDd 
 for debug and libeay32MT.lib - /MD for release). I didn't quite understood 
 the last part of the specific FAQ answer, about the .DLL usage. I use the 
 LIBEAY32.DLL, the only one I have.

 Thank You.

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Installing/using OpenSSL

2009-04-15 Thread Atti
Hello, I'm having some weird problems with all of my OpenSSL
applications (as a described in my previous mail), and they're most
probably caused by me using the wrong libs/DLL's. My OpenSSL version
is the newest (1.0.0beta), i built it just like the install
instructions say, on a WIN32 machine. The FAQ talks about different
static libraries for debug/release and MT/MD, but following the
instructions, the building only resulted in one library:
'libeay32.lib'.
I would like a clear answer on the following questions:
- which static library should i use for debug/release, did I not built
it correctly?
- which .DLL should i use at runtime? (Is the libeay32.dll usable for
both release and debug?)

Thank You.
__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: OpenSSL cryptography fails in release mode, but no in debug

2009-04-15 Thread Atti
I get always the same output for debug / and the different same each
time for the release, if I use the same key and the same input data.
I'm using the following EVP_* functions: EncryptInit(),
EncryptUpdate(), EncryptFinal(). Using the 3DES cbc algorithm, but I
tried the blowfish too, with the same results. I assume I use the
functions correctly, because they work in debug mode.
I don't know what an IV is.


On Wed, Apr 15, 2009 at 7:57 PM, Victor Duchovni
victor.ducho...@morganstanley.com wrote:
 On Wed, Apr 15, 2009 at 11:46:56AM +0300, Atti wrote:

 I built the new OpenSSL (1.0.0) and tried to run the blowfish
 encryption example from the OpenSSL docs
 (http://openssl.org/docs/crypto/EVP_EncryptInit.html#EXAMPLES) but
 this time I used the same library to compile the application, because
 this build only made this one. I made one debug and one release build
 with VS2008, and they both generated different cyphertexts with the
 same key and input data. I also used the same .DLL, becase there is
 only one, and as I read from the FAQ, that should be okay. What am I
 doing wrong?

 If you run a single build (either the debug or the release version)
 twice to encrypt the same data with the same key, do you get the same
 ciphertext each time? What encryption mode are you using and how do you
 generate the IV if an IV is required?

 --
        Viktor.
 __
 OpenSSL Project                                 http://www.openssl.org
 User Support Mailing List                    openssl-us...@openssl.org
 Automated List Manager                           majord...@openssl.org

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


Re: OpenSSL cryptography fails in release mode, but no in debug

2009-04-15 Thread Atti
Okay, well as I said, I compiled and ran the example from the OpenSSL
docs (http://openssl.org/docs/crypto/EVP_EncryptInit.html#EXAMPLES),
which has an IV, and the application still behaves the same.

On Wed, Apr 15, 2009 at 8:15 PM, Victor Duchovni
victor.ducho...@morganstanley.com wrote:
 On Wed, Apr 15, 2009 at 08:05:55PM +0300, Atti wrote:

 I get always the same output for debug / and the different same each
 time for the release, if I use the same key and the same input data.

 Clearly you have a constant IV with the debug library and a random
 IV otherwise.

 I'm using the following EVP_* functions: EncryptInit(),
 EncryptUpdate(), EncryptFinal(). Using the 3DES cbc algorithm, but I
 tried the blowfish too, with the same results.

 CBC requires an IV (initialization vector).


 I assume I use the
 functions correctly, because they work in debug mode.

 Likely an accident, because memory initialization is more deterministic
 debug more.

 I don't know what an IV is.

 Well that's likely to be the problem. And generally each time you
 encrypt a message you choose a random IV, so you should not expect
 the ciphertext to be constant, but the party receiving the message
 does need the IV, which can be sent as part of the ciphertext or
 computed by both sides in some deterministic manner from a shared
 seed.

 --
        Viktor.
 __
 OpenSSL Project                                 http://www.openssl.org
 User Support Mailing List                    openssl-us...@openssl.org
 Automated List Manager                           majord...@openssl.org

__
OpenSSL Project http://www.openssl.org
User Support Mailing Listopenssl-users@openssl.org
Automated List Manager   majord...@openssl.org


OpenSSL cryptography fails in release mode, but no in debug

2009-04-14 Thread Atti
Hy, I'm using an older version of OpenSSL (the new one has errors in
X509.h), on a Win32 machine, installed as binaries. I'm using the
EVP_Encrypt/Decrypt functions and a generated key to encrypt my data, and
everything works fine in debug mode. When I try to run the release mode, it
still runs fine, but the decryption returns scrambled data. I've read the
FAQ, and I am using the libraries as mentioned there (libeay32MTd.lib - /MDd
for debug and libeay32MT.lib - /MD for release). I didn't quite understood
the last part of the specific FAQ answer, about the .DLL usage. I use the
LIBEAY32.DLL, the only one I have.

Thank You.


Re: OpenSSL cryptography fails in release mode, but no in debug

2009-04-14 Thread Atti
Sorry, I made a mistake when I wrote the first text, I'm using
libeay32MDd.lib - /MDd for debug and libeay32MD.lib - /MD for release. I
only made the mistake writing this, I'm linking against the correct .libs in
my project.

On Tue, Apr 14, 2009 at 2:03 PM, Atti att...@gmail.com wrote:

 Hy, I'm using an older version of OpenSSL (the new one has errors in
 X509.h), on a Win32 machine, installed as binaries. I'm using the
 EVP_Encrypt/Decrypt functions and a generated key to encrypt my data, and
 everything works fine in debug mode. When I try to run the release mode, it
 still runs fine, but the decryption returns scrambled data. I've read the
 FAQ, and I am using the libraries as mentioned there (libeay32MTd.lib - /MDd
 for debug and libeay32MT.lib - /MD for release). I didn't quite understood
 the last part of the specific FAQ answer, about the .DLL usage. I use the
 LIBEAY32.DLL, the only one I have.

 Thank You.