intrbiz / arduino-crypto

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

esp8266 restarts while doing encryption/decryption #8

Closed ahmadsajjad656 closed 6 years ago

ahmadsajjad656 commented 7 years ago

I am using encrypt/decryptCBC( ), the library works fine up to 32 bit data, but greater than 32 i.e. 48 bit restarts my esp8266 after 20 seconds. what is the problem. please help me.
My code.(I have changed encryptCBC()/decryptCBC() from private to public in library.)

//performing multiple of 16 bit encryption/decryption

include

void setup() { // put your setup code here, to run once: Serial.begin(9600);

Serial.println(); char encrypted[]=""; char Decrypted[]=""; int Datalength=0; const uint8_t keyEnc[]={1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8}; const uint8_t iv[]={1,1,1,1,1,1,2,2,2,2,3,3,4,4,7,7}; char data[]="Encrpt me otherwise y'll lose me got it $$$4$$"; Datalength=sizeof(data); AES AesEncrypt( keyEnc,iv,AES::AES_MODE_128, AES::CIPHER_ENCRYPT);//passing four values to the constructor of class AES,here we select AES mode //128bit/256bit, and select encryption or decryption AES AesDecrypt( keyEnc,iv,AES::AES_MODE_128, AES::CIPHER_DECRYPT);

AesEncrypt.encryptCBC((uint8_t) data,(uint8_t)encrypted,Datalength); delay(200); Serial.println(); Serial.println(); for(int i=0; i<Datalength;i++) Serial.print(encrypted[i]); Serial.println(); AesDecrypt.decryptCBC((uint8_t)encrypted,(uint8_t)Decrypted,Datalength); delay(200); //Decrypted =(String)&data[0]; for(int i=0; i<Datalength;i++) Serial.print(Decrypted[i]); Serial.println(); Serial.println(Datalength);

}

void loop() { // put your main code here, to run repeatedly:

}

ahmadsajjad656 commented 7 years ago

I have fixed my issue, soon I will upload my AES examples here.

intrbiz commented 6 years ago

For ESP8266 WDT feeds have been added to the CPU intensive functions, this should prevent a WDT reset when encrypting large blocks of data.