For Rasberry pi
Updated: spaniakos 2015
This is an example of how to use AES in CBC mode easily. The text and keys can be either in HEX or String format.
#include <AES.h>
#include "printf.h"
void prekey_test ();
void prekey (int bits, int blocks);
byte key[] = "01234567899876543210012345678998";
byte plain[] = "TESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTESTTEST";
unsigned long long int my_iv = 01234567;
int main(int argc, char** argv)
{
printf("\n===testng mode\n") ;
for (int i=0;i<1;i++){
prekey_test () ;
}
}
void prekey (int bits)
{
byte iv [N_BLOCK] ;
byte plain_p[sizeof(plain) + (N_BLOCK - (sizeof(plain) % 16)) - 1];
byte cipher[sizeof(plain_p)];
aes.do_aes_dencrypt(cipher,aes.
get_size(),plain_p,key,bits,iv);
printf("\n\nPLAIN :");
printf("\nCIPHER:");
printf("\nPlain2:");
printf("\n============================================================\n");
}
void prekey_test ()
{
prekey (128) ;
}