#include "mbed.h"
#include "main.h"
#include "aes.h"


// Create a DigitalOutput object to toggle an LED whenever data is received.
static DigitalOut led(LED1);

Serial pc(USBTX, USBRX);

int main(void)
{

    uint8_t key[] = { 0xfc, 0x7e, 0x15, 0x16, 0x2d, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c };
	char plaintext[16];
	uint8_t ciphertext[16];

    pc.baud(115200);

	while (1) {

        //pc.gets(plaintext,16);

                // Print on serial
        for (int i = 0; i < 16; i++){

           plaintext[i] = pc.getc();

        }

        
        // Encrypt the received data 
        AES_ECB_encrypt((uint8_t*)plaintext, key, ciphertext, 16);



        // Print on serial
        for (int i = 0; i < 16; i++){

            pc.putc(ciphertext[i]);

        }
        //printf("/n");


    }
}