This is a discussion on Cannot convert 'des_ks_struct ( *)[16]' to 'des_ks_struct *' ?? - Openssl ; ------=_Part_3667_28920538.1174983478481 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline hi, i'm trying to develop a simple application which will encrypt text file using triple des. actually i got the code from my friend, and he's using openssl 0.9.8a while i'm ...
------=_Part_3667_28920538.1174983478481
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
hi,
i'm trying to develop a simple application which will encrypt text file
using triple des. actually i got the code from my friend, and he's using
openssl 0.9.8a while i'm using 0.9.9b. i faced a problem when compiling the
source code using borland... i'll always get the error msg
"[C++ Error] testDes.cpp(45): E2034 Cannot convert 'des_ks_struct ( *)[16]'
to 'des_ks_struct *'" and
"[C++ Error] testDes.cpp(45): E2342 Type mismatch in parameter 'ks1' (wanted
'des_ks_struct *', got 'des_ks_struct ( *)[16]')"
can someone please help me? thanks a lot.
the source code is below:
#pragma hdrstop
#include "testDes.h"
#include
#include
//---------------------------------------------------------------------------
#pragma package(smart_init)
void TRIPLEDESchipherFile()
{
TFileStream *j = new TFileStream("source.txt",fmOpenRead);
TFileStream *n = new TFileStream("destination.txt",fmCreate);
AnsiString myKey = "test1234";
int Mode = 1;
char ch[8], outch[8]; //Encrypt every 8 byte per block
des_cblock k1,k2,k3;
des_key_schedule ks1,ks2,ks3;
des_string_to_key(myKey.SubString(1,8).c_str(),&k1);
des_set_key_unchecked(&k1,ks1);
des_string_to_key(myKey.SubString(9,8).c_str(),&k2);
des_set_key_unchecked(&k2,ks2);
des_string_to_key(myKey.SubString(17,8).c_str(),&k3);
des_set_key_unchecked(&k3,ks3);
if(!Mode)
j->Seek(128, soFromBeginning);
else
j->Seek(0, soFromBeginning);
int la;
int sizefile = 0;
for(;
{
if(sizefile < j->Size && (j->Size - sizefile) >= 8)
{
j->Read(ch,8);
des_ecb3_encrypt((const_des_cblock *) ch, (des_cblock *)
outch,&ks1,&ks2,&ks3,Mode);
n->Write(outch,8);
sizefile += 8;
}
else
{
if(sizefile < j->Size)
{
j->Read(ch, j->Size -sizefile);
for(la = (j->Size - sizefile); la < 8; la++)
{
//Add some pad
ch[la] = ' ';
}
des_ecb3_encrypt((const_des_cblock *) ch, (des_cblock *)
outch,&ks1,&ks2,&ks3,Mode);
n->Write(outch,8);
sizefile += (j->Size -sizefile);
}
else
break;
}
}
FileClose(j->Handle);
FileClose(n->Handle);
}
------=_Part_3667_28920538.1174983478481
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
hi,
i'm trying to develop a simple application which will encrypt text file using triple des. actually i got the code from my friend, and he's using openssl 0.9.8a while i'm using 0.9.9b. i faced a problem when compiling the source code using borland... i'll always get the error msg
"[C++ Error] testDes.cpp(45): E2034 Cannot convert 'des_ks_struct ( *)[16]' to 'des_ks_struct *'" and
"[C++ Error] testDes.cpp(45): E2342 Type mismatch in parameter 'ks1' (wanted 'des_ks_struct *', got 'des_ks_struct ( *)[16]')"
can someone please help me? thanks a lot.
the source code is below:
#pragma hdrstop
#include "testDes.h"
#include <Classes.hpp>
#include <openssl/des.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
void TRIPLEDESchipherFile()
{
TFileStream *j = new TFileStream("source.txt",fmOpenRead);
TFileStream *n = new TFileStream("destination.txt",fmCreate);
AnsiString myKey = "test1234";
int Mode = 1;
char ch[8], outch[8]; //Encrypt every 8 byte per block
des_cblock k1,k2,k3;
des_key_schedule ks1,ks2,ks3;
des_string_to_key(myKey.SubString(1,8).c_str(),&k 1);
des_set_key_unchecked(&k1,ks1);
des_string_to_key(myKey.SubString(9,8).c_str(),&k 2);
des_set_key_unchecked(&k2,ks2);
des_string_to_key(myKey.SubString(17,8).c_str(),& k3);
des_set_key_unchecked(&k3,ks3);
if(!Mode)
j->Seek(128, soFromBeginning);
else
j->Seek(0, soFromBeginning);
int la;
int sizefile = 0;
for(;
{
if(sizefile < j->Size && (j->Size - sizefile) >= 8)
{
j->Read(ch,8);
des_ecb3_encrypt((const_des_cblock *) ch, (des_cblock *) outch,&ks1,&ks2,&ks3,Mode);
n->Write(outch,8);
sizefile += 8;
}
else
{
if(sizefile < j->Size)
{
j->Read(ch, j->Size -sizefile);
for(la = (j->Size - sizefile); la < 8; la++)
{
//Add some pad
ch[la] = ' ';
}
des_ecb3_encrypt((const_des_cblock *) ch, (des_cblock *) outch,&ks1,&ks2,&ks3,Mode);
n->Write(outch,8);
sizefile += (j->Size -sizefile);
}
else
break;
}
}
FileClose(j->Handle);
FileClose(n->Handle);
}
------=_Part_3667_28920538.1174983478481--
__________________________________________________ ____________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users@openssl.org
Automated List Manager majordomo@openssl.org