Hi,
I am enciphering a series of files and am trying to decipher them with this
routine, it is basically the same as the one I have used for enciphering.
It has however been a while since I have done this and I am now having
trouble trying to remember how it is done. Can anyone help with this.
thanx
lee
--- code follows ------------------------------------------>
filesLeft=0;
while(filesLeft<(mObjects->numFiles)){
sourceFile=mObjects->files[filesLeft];
destFile=sourceFile;
destFile.Replace(".enc",".zip");
fileIn.Open(sourceFile, CFile::typeBinary | CFile::modeRead, NULL);
fileOut.Open(destFile, CFile::typeBinary | CFile::modeCreate |
CFile::modeWrite, NULL);
RAND_pseudo_bytes(salt,PKCS5_SALT_LEN);
fileIn.Read("Salted__",strlen("Salted__"));
fileIn.Read(&salt,PKCS5_SALT_LEN);
// seems to fail after here - am i using the salt correctly??
ciph = EVP_des_ede3_cbc();
EVP_BytesToKey(ciph,EVP_md5(),salt,(unsigned char
*)passwd,strlen(passwd),1,(unsigned char *)key,(unsigned char *)iv);
EVP_CipherInit(&ctx, ciph, (unsigned char *)key, (unsigned char
*)iv,0);
i=1;
while (i!=0){
i=fileIn.Read(buff,512);
EVP_CipherUpdate(&ctx, out, &outl, (unsigned char *)buff, i);
fileOut.Write(&out, outl);
}
EVP_CipherFinal(&ctx, out, &outl);
fileOut.Write(&out, outl);
fileIn.Close();
fileOut.Close();
filesLeft++;
}
----- end of code ----------------------------------------------------->
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]