8 byte *key = (unsigned char*)"0123456789010123";
9 byte *iv = (unsigned char*)"0123456789010123";
12 void printArray(byte *mes, int n) {
13 for (byte i = 0; i < n; i++) {
23 // put your setup code here to run once:
24 Serial.begin (57600) ;
30 // put your main code here, to run repeatedly:
32 AES aes(key, iv, AES::AES_MODE_128, AES::CIPHER_ENCRYPT);
34 uint8_t plain[size_mesg];
35 uint8_t cipher [size_mesg] ;
36 uint8_t check [size_mesg] ;
40 for(int i=0;i<size_mesg;i++) {
45 unsigned long ms1 = micros ();
46 aes.encryptCBC(plain, cipher, size_mesg);
47 Serial.print("Encryption took: ");
48 Serial.println(micros() - ms1);
49 AES aes2(key, iv, AES::AES_MODE_128, AES::CIPHER_DECRYPT);
53 aes2.decryptCBC(cipher, check, size_mesg);
54 Serial.print("Decryption took: ");
55 Serial.println(micros() - ms1);
59 /*printArray(plain,size_mesg);
60 printArray(cipher,size_mesg);
61 printArray(check,size_mesg);
64 for(int i=0;i<size_mesg-1;i++) {
66 if(check[i]!=plain[i]) {
67 // printf("%d %d %d\n",plain[i],check[i],i);
71 printf("CHECK %d\n",equal);