#include "Rij_Consts.h"
#include "Rijndael.h"
//https://www.hanewin.net/encrypt/aes/aes-test.htm สำหรับเทสเทียบ
void setup() {
Serial.begin(115200);
//mbedtls_aes_context aes;
unsigned char iv[16] = {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
//char * key = "abcdefghijklmnop";
//const unsigned char key[16];
unsigned char key[16] = {0xE8,0xE9,0xEA,0xEB,0xED,0xEE,0xEF,0xF0,0xF2,0xF3,0xF4,0xF5,0xF7,0xF8,0xF9,0xFA};
//unsigned char key[16] = {0xFA,0xF9,0xF8,0xF7,0xF5,0xF4,0xF3,0xF2,0xF0,0xEF,0xEE,0xED,0xEB,0xEA,0xE9,0xE8};//กลับ
//char *input = "Tech tutorials x";
unsigned char input[16] ={0x01,0x4B,0xAF,0x22,0x78,0xA6,0x9D,0x33,0x1D,0x51,0x80,0x10,0x36,0x43,0xE9,0x9A};
//unsigned char input[16] ={0x9A,0xE9,0x43,0x36,0x10,0x80,0x51,0x1D,0x33,0x9D,0xA6,0x78,0x22,0xAF,0x4B,0x01};//กลับ
unsigned char output[16]; //6743C3D1519AB4F2CD9A78AB09A511BD ต้องได้ตามนี้
printf("Testing ECB mode:\n");
printf("Original Plaintext:\n");
for(int i = 0; i < 16; ++i){
printf("%2.2X ", input[i]);
}
unsigned char keys[176];//for 128
Schedule_Keys(AES_128, key, 16, keys);
printf("\n\nKEYs:\n");
for(int i = 0; i < 16; ++i){
printf("%2.2X ", keys[i]);
}
Encrypt(AES_128, input, 16, keys, output);
printf("\n\nCiphertext:\n");
for(int i = 0; i < 16; ++i){
char str[16];
sprintf(str, "%2.2X ", output[i]);
Serial.print(str);
}
}
void loop() {}
Hi developers, I've been figuring it out. What is wrong with my Encryption. It is sure not what I was looking for . My encryption is not correct.
My keys(128): "E8E9EAEBEDEEEFF0F2F3F4F5F7F8F9FA".
Plaintext: "014BAF2278A69D331D5180103643E99A".
Ciphertext(must be) : "6743C3D1519AB4F2CD9A78AB09A511BD".
But my ciphertext, in the picture, is not correct. Thank you for helping.