Hi all,

I am using the EVP API for encryption and decryption (Code snippet below).
The encrypion works fine, but the decryption fails in EVP_CipherInit_ex.
Both the codes are identical except that the said function uses 1 as the
last argument for encryption and 0 for decryption.

I am on Redhat Linux, OpenSSL 0.9.8h 28 May 2008, and g++ 3.3.2 compiler.
(C++ compiler)


The EVP_CipherInit_ex function returned 0 - indicating failure. Upon
investigation, I found out that the context cipher function pointer
"do_cipher" is NULL. I have no clue why this will be NULL. In encryption,
do_cipher is not NULL; only in decryption, this pointer is NULL.

Is there any way to resolve/fix this issue? Do I need to do anything else?

I could not find the definition of EVP_des_ede3_cbc() in the openssl
codebase.



        unsigned char initVector[8] =
{0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};    //The init vector will be
derived from this
        unsigned char iv[EVP_MAX_IV_LENGTH], key[EVP_MAX_KEY_LENGTH];

        EVP_CIPHER_CTX ctx;

        unsigned char keyInput[24] =
{0x3F,0x6F,0x6B,0x69,0x20,0x5E,0x5F,0x45,0x65,0x54,0x5D,0x56,0x63,0x68,0x6E,
0x6F,0x14,0x32,0x2C,0x41,0x3F,0xD3,0x9B,0xA3};

        memcpy(iv,initVector,sizeof(iv));


        EVP_CIPHER_CTX_init(&ctx);


        int r2 = EVP_CipherInit_ex(&ctx, EVP_des_ede3_cbc(), NULL, keyInput,
iv, 0);
        fprintf(stderr, "cipher initEX ret =%d\n",r2);

          if (ctx.cipher->do_cipher == NULL)
                fprintf(stderr, "do_cipher is NULL!!\n");  // This prints,
meaning do_cipher is NULL!!

//
//.. CipherUpdate/Final follow. Not shown here.
//


DISCLAIMER
==========
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
User Support Mailing List                    openssl-users@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to