'aes128_cbc_dec' was not declared in this scope

#include <AES.h>
#include <AESLib.h>
#include <AES_config.h>
#include <xbase64.h>

aes128_cbc_enc(key, IV, data, in);
void setup() {
Serial.begin(57600);
Serial.println("AES 128");
uint8_t key[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};//168 = 128 bytes
uint16_t in[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
uint8_t IV[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
char data[] = "The wifi Password is Bobby8990!."; //chars == bytes
unsigned long start1 = micros();//When the timer starts running before encryption
aes128_cbc_enc(key, IV, data, in);//multiple cbc (single calls)
Serial.println("encrypted:");
for (int i=0; i<sizeof(data);i++)
{
Serial.print(data&0xFF, HEX);

}

Serial.println(" ");

unsigned long diff1 = micros() - start1;// End time - start time

Serial.println(diff1);// Overall time used for encryption

unsigned long start2 = micros(); // timer starts running for decryption

aes128_cbc_dec(key, IV, data, in);

Serial.println("decrypted:");
Serial.println(data);

Serial.println("Decryption time");
unsigned long diff2 = micros()- start2;

Serial.println(diff2);
Serial.println("Time difference");
Serial.println(diff2-diff1); // time for encryption and decryption to occur.
Serial.println("Total Time");
Serial.println(diff2+diff1);
}
void loop(){

}

How to rectify this error?

how do you know this function, as well and the _enc() one are defined somewhere?

Start by properly posting your code with Code Tags as described here:

This compiles for me without error or warning, but it seems to be crashing! It reports "encrypted:" and the hex data TWENTY-FIVE TIMES. It never gets to reporting "decrypted:"

#include <AESLib.h>

void setup()
{
  Serial.begin(115200);
  delay(200);
  
  Serial.println("AES 128");
  
  const uint8_t key[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}; // 168 = 128 bytes
  const uint16_t in = 0;
  const uint8_t IV[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
  uint8_t data[] = "The wifi Password is Bobby8990!."; //chars == bytes
  
  unsigned long start1 = micros();//When the timer starts running before encryption
  
  aes128_cbc_enc(key, IV, data, in); // multiple cbc (single calls)
  
  Serial.println("encrypted:");
  for (unsigned i = 0; i < sizeof(data); i++)
  {
    Serial.print(data[i] & 0xFF, HEX);
  }

  Serial.println(" ");

  unsigned long diff1 = micros() - start1;// End time - start time

  Serial.println(diff1);// Overall time used for encryption

  unsigned long start2 = micros(); // timer starts running for decryption

  aes128_cbc_dec(key, IV, data, in);

  Serial.println("decrypted:");
  Serial.println((const char *)data);

  Serial.println("Decryption time");
  unsigned long diff2 = micros() - start2;

  Serial.println(diff2);
  Serial.println("Time difference");
  Serial.println(diff2 - diff1); // time for encryption and decryption to occur.
  Serial.println("Total Time");
  Serial.println(diff2 + diff1);
}

void loop()
{
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.