46 lines
1.2 KiB
Rust
Executable file
46 lines
1.2 KiB
Rust
Executable file
#![no_main]
|
|
#![no_std]
|
|
|
|
use defmt::{debug, info};
|
|
use hal::pwr::PWR;
|
|
use hal::rtc::{Datelike, NaiveDateTime, Rtc, Timelike};
|
|
use panic_probe as _;
|
|
|
|
use defmt_rtt as _; // global logger
|
|
|
|
use cortex_m_rt::entry;
|
|
use hal::{pac, prelude::*, rcc::Config};
|
|
|
|
const AES_PT: [u8; 16] = [
|
|
0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA,
|
|
];
|
|
const AES_KEY: [u32; 4] = [0x1991, 0x1991, 0xAAAAAAAA, 0xBBBBBBBB];
|
|
|
|
#[entry]
|
|
fn main() -> ! {
|
|
let dp = pac::Peripherals::take().unwrap();
|
|
let cp = cortex_m::Peripherals::take().unwrap();
|
|
|
|
let mut rcc = dp.RCC.freeze(Config::hsi16());
|
|
let mut delay = cp.SYST.delay(rcc.clocks);
|
|
|
|
compile_error!("The chip does not have an AES unit >:{");
|
|
let aes = hal::aes::AES::new(dp.AES, &mut rcc);
|
|
let mut ecb_stream = aes.enable(<dyn hal::aes::Mode>::ecb_encrypt(), AES_KEY);
|
|
let mut encbuf: [[u8; 16]; 4] = [[0; 16]; 4];
|
|
|
|
let mut i = 0;
|
|
debug!("Entering Loop");
|
|
#[allow(clippy::never_loop)]
|
|
loop {
|
|
debug!("reading from aes stream");
|
|
encbuf[i % 4] = ecb_stream.process(&AES_PT).unwrap();
|
|
|
|
info!("encbuf[{:02}]: {:02x}", i, encbuf);
|
|
|
|
if i > 100 {
|
|
delay.delay_ms(200_u16);
|
|
}
|
|
i += 1;
|
|
}
|
|
}
|