#include <Crypto.h>
#include <AES.h>
#include <string.h>
AESSmall256 aes256;
uint16_t plaintext[128] = {0xc126,
0x29f7,
0x5999,
0x825e,
0xcc56,
0x9ca1,
0xf0e9,
0x1a12,
0xf1e7,
0x52b6,
0xa8e6,
0x7233,
0x7235,
0x0f94,
0x690f,
0x507a,
0x7cb3,
0xe651,
0xd0a7,
0x6130,
0x6e8a,
0xd554,
0x7ce2,
0x8ece,
0x62de,
0x5e91,
0xb845,
0xfcc5,
0x62d6,
0xa366,
0xcb00,
0x0ea6,
0x1600,
0x52b4,
0x72f9,
0xece0,
0xf444,
0x5c18,
0x0df5,
0x0261,
0xe604,
0x69dc,
0x7b9f,
0xdcf3,
0x292a,
0x6305,
0x21e0,
0x7c1b,
0x0dc6,
0x0fd4,
0x75f9,
0xe663,
0xa6d4,
0x2957,
0x07f7,
0xf706,
0x9e2a,
0x8c1b,
0x190e,
0x0e23,
0x3391,
0xcc30,
0xc724,
0xd415,
0x3d28,
0x9997,
0xf8c0,
0xe66d,
0x6326,
0x57cb,
0x7e2b,
0x29d4,
0x2681,
0xb9d6,
0xda2f,
0x4829,
0x8442,
0xd043,
0xeb78,
0xf121,
0x0d99,
0x1a59,
0x0bc9,
0xafa7,
0x5e73,
0xe362,
0x5dfc,
0x0aaa,
0x4320,
0x8928,
0x3a85,
0xa25a,
0x5d07,
0x73f4,
0xcee6,
0x8f86,
0xcf45,
0x5635,
0x87dd,
0xfe41,
0x52cb,
0x5418,
0xf7e7,
0x8ff6,
0xd67e,
0x7692,
0xfe41,
0xccd8,
0x0c29,
0xbc57,
0x0910,
0x00d2,
0x0c39,
0xfc2e,
0xd0ef,
0x0a52,
0x09a4,
0xd577,
0x05a6,
0x0199,
0xd918,
0x0a79,
0x0bf9,
0x04a1,
0x06fe,
0x007e,
0x0516,
0x01e8};
uint16_t plaintext2[128];
uint16_t ciphertext2[128];
uint8_t buffer[16];
uint8_t buffer1[16];
uint8_t ciphertext[256];
uint8_t plaintext1[256];
int count =0 ;
uint8_t key[32] ={0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F};
uint8_t * bptr = (uint8_t*) (plaintext);
uint8_t * bptr1 = (uint8_t*) (ciphertext2);
void setup()
{
Serial.begin(9600);
delay(1000);
Serial.print("plaintext:");
[B]Serial.println(plaintext[10], HEX);[/B]
for (int i = 0 ; i < 16 ; i++)
{
uint8_t aes_block [16] ;
for (int j = 0 ; j < 16 ; j++)
aes_block [j] = *bptr++ ;
aes256.setKey(key, aes256.keySize());
aes256.encryptBlock(buffer, aes_block);
memcpy(ciphertext + (i*16), buffer,16);
}
memcpy(ciphertext2, ciphertext,256);
Serial.print("ciphertext:");
[B]Serial.println(ciphertext2[10], HEX);[/B]
for (int i = 0 ; i < 16 ; i++)
{
uint8_t clear_block [16] ;
for (int j = 0 ; j < 16 ; j++)
clear_block [j] = *bptr1++ ;
aes256.setKey(key, aes256.keySize());
aes256.decryptBlock(buffer1, clear_block);
memcpy(plaintext1 + (i*16), buffer1,16);
}
memcpy(plaintext2, plaintext1,256);
Serial.print("plaintext:");
[B]Serial.println(plaintext2[10], HEX);[/B]
}
void loop()
{
}