3 #include<AES-128_V10.h>
4 //#include "./printf.h"
8 byte *key = (unsigned char*)"0123456789010123";
9 const int size_mesg=64;
16 //real iv = iv x2 ex: 01234567 = 0123456701234567
17 unsigned long long int my_iv = 36753562;
23 unsigned char NwkSkey[16] = {
24 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
25 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
28 unsigned char AppSkey[16] = {
29 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
30 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
37 Serial.begin (57600) ;
40 // printf("\n===testng mode\n") ;
58 void prekey (int bits)
64 byte plain[size_mesg];
65 byte cipher [size_mesg] ;
66 byte check [size_mesg] ;
69 for(int i=0;i<size_mesg;i++) {
77 unsigned long ms = micros ();
81 aes.do_aes_encrypt(plain,size_mesg,cipher,key,bits,iv);
82 Serial.print("Encryption took: ");
83 Serial.println(micros() - ms);
87 aes.do_aes_decrypt(cipher,size_mesg,check,key,bits,iv);
88 Serial.print("Decryption took: ");
89 Serial.println(micros() - ms);
90 /* printf("\n\nPLAIN :");
91 aes.printArray(plain,(bool)true);
93 aes.printArray(cipher,(bool)false);
95 aes.printArray(check,(bool)true);
97 aes.printArray(iv,16);
98 printf("\n============================================================\n");
102 for(int i=0;i<size_mesg-1;i++) {
104 if(check[i]!=plain[i]) {
105 printf("%d %d %d\n",plain[i],check[i],i);
109 Serial.print("CHECK ");
110 Serial.println(equal);
112 for(int i=0;i<16;i++) {
113 Serial.print(plain[i]);
119 AES_Encrypt(plain,AppSkey);
120 int time=micros() - ms;
121 Serial.print("new enc took: ");
122 Serial.println(time);
124 for(int i=0;i<16;i++) {
125 Serial.print(plain[i]);