And, simeple example for AES with Counter mode.
CTR_Mode<AES>::Encryption aes_ctr_enc(s_key, 16, s_iv);
aes_ctr_enc.ProcessString((unsigned char*)buf, buf_size);
CTR_Mode<AES>::Decryption aes_ctr_dec(s_key, 16, s_iv);
aes_ctr_dec.ProcessString((unsigned char*)buf, buf_size);
----- Original Message -----
From: Anthony Cosgrove
To: [EMAIL PROTECTED]
Sent: Sunday, December 08, 2002 3:49 PM
Subject: Errors while dealing with AES
I know I'm not doing something right but I can't seem to find any example code that
will show me how to properly initialize the AES class. Below is a snippet that I
ripped from test.cpp and attempted to mangle it to what I need to do. Can someone
please tell me what I'm missing / doing wrong?
void AES_test(byte *&text, int itsize)
{
const byte key[] = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45,
0x67, 0x89, 0xab, 0xcd, 0xef};
const byte iv[] =
{0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef,0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef};
byte *ciphertext = new byte[itsize];
CFB_Mode<AES>::Encryption encryption_AES_CBC;
encryption_AES_CBC.SetKeyWithIV(key, 16, iv);
encryption_AES_CBC.ProcessString(ciphertext, text, itsize);
byte *decrypted = new byte[itsize];
CFB_Mode<AES>::Decryption decryption_AES_CBC;
decryption_AES_CBC.ProcessString(decrypted, ciphertext, itsize);
}
I can get the encryption function to work (I think because during debug VC6 is
spitting out my encrypted result) - but if I call the decryption, I get an unhandled
exception 0xc0000005 - In the debugger it points to the
CFB_DecryptionTemplate<BASE>::CombineMessageAndShiftRegister(byte *output, byte *reg,
const byte *message, unsigned int length) function in strciphr.cpp.
Can someone give me a pointer please? Or at least point me to some example AES code
that someone wrote using crypto++?
Thanks in advance,
Anthony