Hello list,
I have a programm, that works under different platforms (hp-ux, aix, linux,
windows nt/2000). This program sends some information (beside, xdr coded
with the help of rpc) from one platform to another platform. I want to
encrypt this communication with aes. For this purpose I'm using the aes
encryption from the crypto library. This works for nearly every platform,
but if I send the encrypted information from aix 4.3.2 to windows 2000 the
communication fails. This is very strange, as it works great for the other
platforms, e.g. linux -> windows, hp-ux -> windows, windows -> windows.
In order to find the error I wrote a small test program. It opens a file and
reads 16 byte of data. This data is encrypted and saved. Than the data is
decrypted and saved again. I run the test program under windows and under
aix. In order to compare the results, I transfer both files from aix to
windows with ftp (binary mode) and open the windows and aix files with
ultraedit. Here I can see, that the encrypted file under windows and aix
look different, although the decrypted file looks fine at the end. What am I
missing? Any help would really be appreciated.
Bye the way, I'm not very fimilar to unix/aix. So I don't know how to debug
an application under aix to find the positon where the difference occurs.
I'm developing with MS VS 6.0 SP 5 under Windows 2000 Server. Under aix
4.3.2 I'm using gcc 3.0.1 (Reading specs from
/usr/local/lib/gcc-lib/powerpc-ibm-aix4.3.2.0/3.0.1/specs, Configured with:
./configure --enable-threads=aix --disable-nls, Thread model: single, gcc
version 3.0.1).
I'm using the old version 4.1 of the crypto lib, but I think the classes I'm
using are not different to the actual version (please correct me if I'm
wrong :-).
My test program looks like the following. I don't know exactly if I'm using
the aes encryption generally in the right way. If I'm making a big mistake,
just give me the correct code and I'm willing to use this.
#include <stdio.h>
#include "rijndael.h"
int main(int argc, char** argv)
{
FILE* fp_orig = NULL;
FILE* fp_enc = NULL;
FILE* fp_dec = NULL;
char buffer[16];
char encrypted[16];
char decrypted[16];
CryptoPP::RijndaelEncryption* rEnc = NULL;
CryptoPP::RijndaelDecryption* rDec = NULL;
fp_orig = fopen("c:\\orig.txt","rb");
fp_enc = fopen("c:\\enc.txt","wb");
fp_dec = fopen("c:\\dec.txt","wb");
fread(buffer,sizeof(char),16,fp_orig);
rEnc = new CryptoPP::RijndaelEncryption( (const unsigned char*)
"keykeykeykeykeyk", 16);
rDec = new CryptoPP::RijndaelDecryption( (const unsigned char*)
"keykeykeykeykeyk", 16);
rEnc->ProcessBlock( (const unsigned char*)buffer, (unsigned
char*)encrypted);
fwrite(encrypted,sizeof(char),16,fp_enc);
rDec->ProcessBlock( (const unsigned char*)encrypted, (unsigned
char*)decrypted);
fwrite(decrypted,sizeof(char),16,fp_dec);
fclose(fp_orig);
fclose(fp_enc);
fclose(fp_dec);
delete rEnc;
delete rDec;
return 0;
}
I've added the original file, the encrypted file and the decrypted file from
both aix and windows as an attachment.
Greetings
Mario
<<windows_dec.txt>> <<windows_enc.txt>> <<windows_orig.txt>>
<<aix_orig.txt>> <<aix_enc.txt>> <<aix_dec.txt>>
1234567890123456
�ьlch</8�<}��
1234567890123456
1234567890123456
��74�R\�0�8�2
1234567890123456