// from https://raw.githubusercontent.com/Ko-/aes-armcortexm/public/aes256ctr/aes_256_ctr.c // taken Feb 25/2021 // REFERENCE ONLY -- not used. #include "../common/stm32wrapper.h" #include #include #include typedef struct param { uint32_t ctr; uint8_t nonce[12]; uint8_t rk[15*16]; } param; extern void AES_256_keyschedule(const uint8_t *, uint8_t *); extern void AES_256_encrypt_ctr(param const *, const uint8_t *, uint8_t *, uint32_t); #define AES_256_decrypt_ctr AES_256_encrypt_ctr int main(void) { clock_setup(); gpio_setup(); usart_setup(115200); // plainly reading from CYCCNT is more efficient than using the // dwt_read_cycle_counter() interface offered by libopencm3, // as this adds extra overhead because of the function call SCS_DEMCR |= SCS_DEMCR_TRCENA; DWT_CYCCNT = 0; DWT_CTRL |= DWT_CTRL_CYCCNTENA; const uint32_t LEN = 256*16; const uint32_t LEN_ROUNDED = ((LEN+15)/16)*16; const uint8_t nonce[12] = {1,2,3,1,2,4,1,2,5,1,2,6}; const uint8_t key[32] = {4,5,6,7,4,5,6,8,4,5,6,9,4,5,6,10,4,5,6,11,4,5,6,12,4,5,6,13,4,5,6,14}; uint8_t in[LEN]; uint8_t out[LEN_ROUNDED]; unsigned int i; for(i=0;i 0) send_USART_str(buffer); */ /* // Perform decryption p.ctr = 0; AES_256_decrypt_ctr(&p, out, in, LEN); // Print plaintext sprintf(buffer, "in: "); send_USART_str(buffer); for(i=0;i 0) send_USART_str(buffer); */ while (1); return 0; }