EcodroneSRL
Member
Hello everyone!
I'm currently developing a code, running on Teensy4.1, that stores some variables in the SD card. Before the storing, we want to encrypt the plaintext and we tried to use the CryptoAccel library. We tried to run this test code to see if the library works well:
Now, the result of the operations are shown in the image.
The strange thing is that the Serial.write(iv) instruction prints the AES key instead of the decrypted plaintext. Can someone tell us why this happens? We are newbies of this type of features of Teensy boards, and we read also posts on this forum about the compatibility of the CryptoAccel library with Teensy 4.1 and we have a lot of doubts, so thank in advance to everyone for the support!
I'm currently developing a code, running on Teensy4.1, that stores some variables in the SD card. Before the storing, we want to encrypt the plaintext and we tried to use the CryptoAccel library. We tried to run this test code to see if the library works well:
Code:
#include "CryptoAccel.h"
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
delay(1000);
Serial.println("Starting :)");
unsigned int i;
unsigned char aeskey[16] = "Password";
unsigned char keysched[4*44];
mmcau_aes_set_key(aeskey, 128, keysched);
unsigned char in[16];
for(i = 0; i < sizeof(in); i++)
{
in[i] = 49+i;
}
for(i = 0; i < sizeof(in); i++)
{
Serial.write(in[i]);
}
Serial.println();
unsigned char out[16];
mmcau_aes_encrypt(in, keysched, 10, out);
for(i = 0; i < sizeof(out); i++)
{
Serial.write(out[i]);
}
Serial.println();
unsigned char iv[16];
mmcau_aes_decrypt(out, keysched, 10, iv);
for(i = 0; i < sizeof(iv); i++)
{
Serial.write(iv[i]);
}
Serial.println();
}
void loop() {
// put your main code here, to run repeatedly:
}
Now, the result of the operations are shown in the image.
The strange thing is that the Serial.write(iv) instruction prints the AES key instead of the decrypted plaintext. Can someone tell us why this happens? We are newbies of this type of features of Teensy boards, and we read also posts on this forum about the compatibility of the CryptoAccel library with Teensy 4.1 and we have a lot of doubts, so thank in advance to everyone for the support!