i'm testing the AES algorithm
i have problems with the decryption function, it doesn't return the correct plaintext
Following is the source code of my test :
If anybody can help me,
Thank you
#include <stdio.h>
#include <openssl/aes.h>
int main(void) {
unsigned char key[] = {
0x06, 0xa9, 0x21, 0x40, 0x36, 0xb8, 0xa1, 0x5b,
0x51, 0x2e, 0x03, 0xd5, 0x34, 0x12, 0x00, 0x06
};
unsigned char iv[] = {
0x3d, 0xaf, 0xba, 0x42, 0x9d, 0x9e, 0xb4, 0x30,
0xb4, 0x22, 0xda, 0x80, 0x2c, 0x9f, 0xac, 0x41
};
unsigned char plaintext[] ={
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};
unsigned char ciphertext[] ={
0xe3, 0x53, 0x77, 0x9c, 0x10, 0x79, 0xae, 0xb8,
0x27, 0x08, 0x94, 0x2d, 0xbe, 0x77, 0x18, 0x1a
};
AES_KEY cypher_key;int i;
unsigned char temp[16];
unsigned char temp2[16];
AES_set_encrypt_key(key, 128, &cypher_key);
AES_cbc_encrypt(plaintext, temp, 16, &cypher_key, iv,
AES_ENCRYPT);
memset(&cypher_key, 0, sizeof(cypher_key));
memset(temp2,0,sizeof(temp2));
AES_set_decrypt_key(key, 128, &cypher_key);
AES_cbc_encrypt(temp, temp2, 16, &cypher_key, iv,
AES_DECRYPT);
if(memcmp(temp2,plaintext, sizeof(plaintext)))
printf("BAD DECRYPTION \n");
else
printf("DECRYPTION OK\n");
return 0;
}
Yahoo! Mail : votre e-mail personnel et gratuit qui vous suit partout !
Cr�ez votre Yahoo! Mail
Dialoguez en direct avec vos amis gr�ce � Yahoo! Messenger !
