The Key looks completely different in command line to my program. Why would this be the case when i am calling the bytes to key function???? I am using a password of "1" therefore in the C++ do I need to do the same.. do I need to pad out the password in the C++?
Help :( MusicAndy wrote: > > Thanks again Steve, > > However the EVP_MAX_KEY_LENGTH appears to be a length of 32, not 24 that > DES3 requires. Therefore when i call EVP_EncryptInit_ex I am only going > to send 24 characters of this key, and see what happens then. > > It should only be sending 24 characters shouldnt it? > > > Dr. Stephen Henson wrote: >> >> On Mon, Aug 10, 2009, MusicAndy wrote: >> >>> >>> Thanks for your help so far, but still cannot get this working... >>> >>> Here is my latest code. >>> >>> I am trying to emulate something that should be simple, which can be >>> decrypted using >>> openssl des3 -d -nosalt -k "1" -in <source filename> -out <destination >>> > filename> >>> >>> >>> >>> EVP_CIPHER_CTX ctx; >>> EVP_CIPHER_CTX_init(&ctx); >>> const EVP_CIPHER* cipher=EVP_des_ede3_cbc(); >>> const EVP_MD *dgst=EVP_sha1(); >>> >>> u_char pass[8]; >>> // char salt[8]; >>> >>> unsigned char key[EVP_MAX_KEY_LENGTH]; >>> unsigned char iv[EVP_MAX_IV_LENGTH]; >>> >>> >>> >>> // printf("key_len: %d\n", cipher->key_len); >>> // printf(" iv_len: %d\n", cipher->iv_len); >>> >>> strcpy((char*)pass, "1"); >>> // strcpy((char*)salt, "ATHENA.MIT.EDUraeburn"); >>> >>> >>> EVP_BytesToKey(cipher,dgst,NULL,pass, 1, 3, key, iv); >>> >>> unsigned char* desBuf = new unsigned char[numbytes]; >>> >>> EVP_EncryptInit_ex(&ctx, cipher, NULL,key,iv); >>> >> >> The count parameter must be 1, not 3 for compatibility with the enc >> program. >> >> Also make sure the file is opened in binary mode ("rb"). >> >> You can use the -P option to "enc" and print out the key, IV in your >> programe >> to ensure they are identical. >> >> Steve. >> -- >> Dr Stephen N. Henson. OpenSSL project core developer. >> Commercial tech support now available see: http://www.openssl.org >> ______________________________________________________________________ >> OpenSSL Project http://www.openssl.org >> User Support Mailing List openssl-users@openssl.org >> Automated List Manager majord...@openssl.org >> >> > > -- View this message in context: http://www.nabble.com/EVP-errors%21-tp24898590p24903151.html Sent from the OpenSSL - User mailing list archive at Nabble.com. ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List openssl-users@openssl.org Automated List Manager majord...@openssl.org