intrbiz / arduino-crypto

A minimal crypto library for ESP8266 Arduino
Other
140 stars 54 forks source link

AES example #3

Closed anaisortn closed 7 years ago

anaisortn commented 7 years ago

Hi, using your example on ESP8266, the decrypted output isAdd NodeAdd NodeAdd NodeAdd NodeAdd Node��N���0��%���렝N���0��%� instead of Add NodeAdd NodeAdd NodeAdd NodeAdd Node

#include 
/* code was modified by george spanos 
* 16/12/14
*/
AES aes ;
byte *key = (unsigned char*)"0123456789010123";
byte plain[] = "Add NodeAdd NodeAdd NodeAdd NodeAdd Node";

//real iv = iv x2 ex: 01234567 = 0123456701234567
unsigned long long int my_iv = 36753562;
void setup ()
{
Serial.begin (115200) ;
delay(500);
printf("\n===testng mode\n") ;
//  otfly_test () ;
//  otfly_test256 () ;
}
void loop ()
{
prekey_test () ;
delay(2000);
}
void prekey (int bits)
{
aes.iv_inc();
byte iv [N_BLOCK] ;
byte plain_p[48];
byte cipher [48] ;
byte check [48] ;
unsigned long ms = micros ();
aes.set_IV(my_iv);
aes.get_IV(iv);
aes.do_aes_encrypt(plain,41,cipher,key,bits,iv);
aes.do_aes_decrypt(cipher,48,check,key,bits,iv);
printf("%s \n", check);
}
void prekey_test ()
{
prekey (128) ;
}

What am I missing?

anaisortn commented 7 years ago

Sorry, wrong repo.