mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-08 04:56:43 +00:00
add aes test option into the mbox1 test
This commit is contained in:
parent
57ce335bd7
commit
bd45919944
3 changed files with 46 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
|
@ -1018,6 +1018,7 @@ dependencies = [
|
|||
name = "cram-mbox1"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"aes 0.8.3",
|
||||
"log",
|
||||
"num-derive 0.4.2",
|
||||
"num-traits",
|
||||
|
|
|
|||
|
|
@ -14,9 +14,12 @@ log-server = { package = "xous-api-log", version = "0.1.65" }
|
|||
log = "0.4.14"
|
||||
num-derive = { version = "0.4.2", default-features = false }
|
||||
num-traits = { version = "0.2.14", default-features = false }
|
||||
aes = { path = "../aes" }
|
||||
|
||||
[features]
|
||||
"cramium" = ["utralib/cramium-fpga"]
|
||||
"vexii-test" = ["aes/vexii-test"]
|
||||
"aestests" = []
|
||||
"hwsim" = []
|
||||
"message-test" = []
|
||||
# ext specifies to use the APB client, instead of the loopback local
|
||||
|
|
|
|||
|
|
@ -181,6 +181,48 @@ fn main() {
|
|||
#[cfg(feature = "hwsim")]
|
||||
let mut core_csr = CSR::new(c_csr.as_mut_ptr() as *mut u32);
|
||||
|
||||
#[cfg(feature = "aestests")]
|
||||
{
|
||||
use aes::cipher::generic_array::GenericArray;
|
||||
use aes::cipher::{BlockDecrypt, BlockEncrypt, KeyInit};
|
||||
log::info!("AES");
|
||||
const TEST_MAX_LEN: usize = 4096;
|
||||
let mut dataset_op = [0u8; TEST_MAX_LEN];
|
||||
for (i, d) in dataset_op.iter_mut().enumerate() {
|
||||
*d = i as u8;
|
||||
}
|
||||
log::info!("key");
|
||||
let key_array: [u8; 32] = [0; 32];
|
||||
let key = GenericArray::from_slice(&key_array);
|
||||
let cipher_hw = aes::Aes256::new(&key);
|
||||
log::info!("round");
|
||||
for iter in 0..2 {
|
||||
core_csr.wfo(utra::main::REPORT_REPORT, 0xae50_0000 + iter);
|
||||
for (i, mut chunk) in dataset_op.chunks_exact_mut(aes::BLOCK_SIZE).enumerate() {
|
||||
let mut block = GenericArray::clone_from_slice(&mut chunk);
|
||||
core_csr.wfo(utra::main::REPORT_REPORT, 0xae5e_0000 + iter + ((i as u32) << 16));
|
||||
cipher_hw.encrypt_block(&mut block);
|
||||
core_csr.wfo(utra::main::REPORT_REPORT, 0xae5e_1000 + iter + ((i as u32) << 16));
|
||||
for (&src, dst) in block.iter().zip(chunk.iter_mut()) {
|
||||
*dst = src;
|
||||
}
|
||||
}
|
||||
for (i, mut chunk) in dataset_op.chunks_exact_mut(aes::BLOCK_SIZE).enumerate() {
|
||||
let mut block = GenericArray::clone_from_slice(&mut chunk);
|
||||
core_csr.wfo(utra::main::REPORT_REPORT, 0xae5d_0000 + iter + ((i as u32) << 16));
|
||||
cipher_hw.decrypt_block(&mut block);
|
||||
core_csr.wfo(utra::main::REPORT_REPORT, 0xae5d_1000 + iter + ((i as u32) << 16));
|
||||
for (&src, dst) in block.iter().zip(chunk.iter_mut()) {
|
||||
*dst = src;
|
||||
}
|
||||
}
|
||||
if iter == 0 {
|
||||
log::info!("0 done");
|
||||
}
|
||||
}
|
||||
log::info!("done");
|
||||
}
|
||||
|
||||
let tt = xous_api_ticktimer::Ticktimer::new().unwrap();
|
||||
let mut total = 0;
|
||||
let mut iter = 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue