// This mail will go with a forcefully attached disclaimer. Please ignore the same. I know that this message will be archived.
Hi all, I am using triple-DES to encrypt and decrypt a string. The openssl function that I call is: des_ede3_cbc_encrypt. I set an IV, and 3 keys for this purpose. I have taken some help from "destest.c" supplied with the distribution. The amazing thing is: the encryption/decryption is not working for only 1 input string, for all other input string (as far as I could test), it is working. I am on "OpenSSL 0.9.8g 19 Oct 2007". Example1: [EMAIL PROTECTED] crypt]$ ./tdes 1196075759^10.77.199.189^R^user1k1 Encrypted/Decrypted string is: [1196075759^10.77.199.18] Result: Not working, it is not giving complete output. Example2: [EMAIL PROTECTED] crypt]$ ./tdes 1196075758^10.77.199.189^R^user1k1 Encrypted/Decrypted string is: [1196075758^10.77.199.189^R^user1k1] Result: Working, it is giving complete output. (The input sting is different from the first one: 119607575*8*) For all examples that I tried, the only failure is with the Example 1 above. *All* others passed. Is there some bug with the function, or am I missing something? A minimal program that demonstrates this strange behaviour is given below. // Command line usage: <program> InputString // Output: Same string, being encrypted and then decrypted. // It checks for argc (command line) - all those are not shown in this minimal example. #include <openssl/des.h> #define BUFSIZE 1024 int main(int argc, char *argv[]) { unsigned char out[BUFSIZE]={0}; cryptWrapper((unsigned char*)argv[1], out); printf("Encrypted/Decrypted string is: [%s]\n", out); return 0; } int cryptWrapper(unsigned char *in, unsigned char *out) { unsigned char EncrOut[BUFSIZE]={0}; unsigned char DecrOut[BUFSIZE]={0}; unsigned char tdesKey1[8] = {0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef}; unsigned char tdesKey2[8] = {0xf1,0xe0,0xd3,0xc2,0xb5,0xa4,0x97,0x86}; unsigned char tdesKey3[8] = {0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; unsigned char initVector[8] = {0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10}; // The initialization vector des_key_schedule kSched1, kSched2, kSched3; des_cblock iv; memcpy(iv,initVector,sizeof(initVector)); // set the initialization vector DES_set_key_checked(&tdesKey1, &kSched1); // set the key schedule DES_set_key_checked(&tdesKey2, &kSched2); // set the key schedule DES_set_key_checked(&tdesKey3, &kSched3); // set the key schedule memset(out, 0, BUFSIZE); des_ede3_cbc_encrypt(in, EncrOut, (long)strlen((char*)in), kSched1, kSched2, kSched3, &iv, DES_ENCRYPT); // Encrypt memcpy(iv,initVector,sizeof(initVector)); DES_set_key_checked(&tdesKey1, &kSched1); DES_set_key_checked(&tdesKey2, &kSched2); DES_set_key_checked(&tdesKey3, &kSched3); des_ede3_cbc_encrypt((unsigned char*)EncrOut, DecrOut, (long)strlen((char*)EncrOut)+1, kSched1, kSched2, kSched3, &iv, DES_DECRYPT); strcpy((char *) out, (char *) DecrOut); return 0; } 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]