Since awaiting for a reply, I realised this was the case. So the question is now, for different ciphers is the key length also different? is it eight characters for des3?
Also, how will i eventually add salt to this (specified in the command line as -salt but with no number present) Dr. Stephen Henson wrote: > > On Mon, Aug 10, 2009, MusicAndy wrote: > >> >> OK, so after the last post I made; I was trying to use the DES library, >> and >> was advised to use the higher level EVP library, I have now used this and >> getting the same type of error! %-| >> >> So where do I go from here. The command line that i wish to use for >> decrypting the file that i am encrypting is >> openssl des3 -d -nosalt -k "1" -in <source filename> -out <destination >> filename> >> >> The code that i am using to test these has two file streams, one for the >> input and one for the output and is shown below. This is test code only. >> What am i doing wrong here? Is it the key that is at fault. Please >> help... >> I also wish to use salt in the final implementation on this. Please >> advise... >> >> >> if(infile == NULL) >> AfxMessageBox("File load error"); >> >> fseek(infile, 0L, SEEK_END); >> numbytes = ftell(infile); >> >> fseek(infile, 0L, SEEK_SET); >> >> buffer = (char*)calloc(numbytes, sizeof(char)); >> >> fread(buffer, sizeof(char), numbytes, infile); >> >> >> unsigned char* input = new unsigned char[numbytes]; >> input = (unsigned char*)buffer; >> >> >> if(buffer == NULL) >> AfxMessageBox("Error with buffer"); >> >> unsigned char password[] = {'1'}; >> EVP_CIPHER_CTX ctx; >> EVP_CIPHER_CTX_init(&ctx); >> >> unsigned char* desBuf = new unsigned char[numbytes]; >> >> EVP_EncryptInit_ex(&ctx, EVP_des_ede3_cbc(), NULL,password,NULL); >> > > Well that's the problem right there. You have to pass a key and IV of the > correct length to EVP_EncryptInit_ex(). You are passing 1 byte and > whatever > garbage follows it in memory. > > You need to derive the correct key using EVP_BytestToKey() and pass the > derived key to EVP_EncryptInit_ex(). > > 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-tp24898590p24900014.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