Hi,
Thanks Jeffrey. A few more newbie questions :)
For ECB mode the initialization vector is not used or it`s fixed somewhere?
(http://www.tropsoft.com/strongenc/des.htm;)
The simplest programm I wrote is encrypting and decrypting the message, but the
encrypted does not
match with the expected (from the vendor test case application). The first 2
bytes matches, but
after that they are different. Any idea?
My App output:
Plain text is:
0x6 0x12 0x34 0x56 0xff 0xff 0xff 0xff
Cipher text is:
0x21 0x79 0xad 0xb9 0x24 0x59 0xee 0xe3
Decrypted text is:
0x6 0x12 0x34 0x56 0xff 0xff 0xff 0xff
The expected encrypted text is: 0x21 0x79 0x53 0xE1 0xC7 0xB1 0x72 0xAD
My source code:
#include "modes.h"
#include "des.h"
#include "hex.h"
#include <iostream>
#include <time.h>
#include <windows.h>
USING_NAMESPACE(CryptoPP)
USING_NAMESPACE(std)
int main()
{
//declare help variables
register int i;
const unsigned int blocksize = 8;
//declare key and plain text vector
const byte key[] =
{ 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61, 0x61 };
byte plaintext[] =
{ 0x06, 0x12, 0x34, 0x56, 0xFF, 0xFF, 0xFF, 0xFF };
//declare vectors to hole encrypted and decrypted messages
byte *ciphertext;
ciphertext = new byte[blocksize];
byte *decryptedtext;
decryptedtext = new byte[blocksize];
//declare encryption and decryption objects
ECB_Mode<DES>::Encryption ecbEncryption(key, DES::DEFAULT_KEYLENGTH,
NULL);
ECB_Mode<DES>::Decryption ecbDecryption(key, DES::DEFAULT_KEYLENGTH,
NULL);
//show plain text contents
printf("Plain text is:\n");
for(i=0; i<blocksize; i++) {
printf("%#x ", plaintext[i]);
}
//encrypt
ecbEncryption.ProcessData(ciphertext, plaintext, blocksize);
//show encrypted message
printf("\nCipher text is:\n");
for(i=0; i<blocksize; i++) {
printf("%#x ", ciphertext[i]);
}
//decrypt
ecbDecryption.ProcessData(decryptedtext, ciphertext, blocksize);
printf("\nDecrypted text is:\n");
for(i=0; i<blocksize; i++) {
printf("%#x ", decryptedtext[i]);
}
free(ciphertext);
free(decryptedtext);
return 0;
}
+ Samuel G. Mota
+ [EMAIL PROTECTED]
+ 55 (11) 4417 7093
+ Business Application Dpt.
+ Netset Servi�os em Tecnologia
+ a Hypercom Company
+ http://www.hypercom.com