This program keeps looping Setup part. But if i remove the line
char *rcv=encandenc(bu);
then program works perfectly. I need this line for encryption purposes.
Everything works fine but i need encryption so i added function and just this *rcv=encandenc(bu); line and code starts looping in setup. But if i comment this line everything works fine.
void setup()
{
Serial.begin(9600);
if (gsm.begin(9600))
{
Serial.println(F("\nstatus=READY"));
started = true;
}
else
{
Serial.println(F("\nstatus=IDLE"));
}
delay(300);
};
void loop()
{
char *rcv = encandenc(bu); // if i comment this line then program works totally okay but i want this line for later use
delay(1000);
};
char *encandenc(char * bu)
{
CBC<AES128> cbc;
uint8_t key[16] = {97, 115, 100, 102, 103, 104, 106, 107, 108, 112, 111, 105, 117, 121, 116, 114}; //asdfghjklpoiuytr
uint8_t iv[16] = {113, 119, 101, 114, 116, 121, 117, 105, 111, 112, 108, 107, 106, 104, 103, 102}; //qwertyuioplkjhgf
uint8_t input[96];
size_t len = 16;
memcpy(input, bu, 96);
delay(1000);
cbc.setKey(key, 16);
delay(1000);
cbc.setIV(iv, 16);
delay(1000);
cbc.encrypt(input, input, 96);
delay(1000);
cbc.clear();
int inputLen = sizeof(input);
int encodedLen = base64_enc_len(inputLen);
char encoded[encodedLen];
base64_encode(encoded, input, inputLen);
delay(1000);
return encoded;
}