format services/aes-test

This commit is contained in:
bunnie 2024-01-14 22:04:34 +08:00
parent dbf8525572
commit 81c5a1da57
3 changed files with 519 additions and 623 deletions

View file

@ -77,13 +77,7 @@ fn encrypt_test(id: AesId) {
dut = aes_enc_round(dut, tmp as u32, id);
reference ^= byte;
if dut != reference {
log::error!(
"Encrypt BUG at index {}, {:?}: dut {:08x} != {:08x} ref\n",
idx,
id,
dut,
reference
);
log::error!("Encrypt BUG at index {}, {:?}: dut {:08x} != {:08x} ref\n", idx, id, dut, reference);
return;
}
}
@ -121,13 +115,7 @@ fn decrypt_test(id: AesId) {
dut = aes_dec_round(dut, tmp as u32, id);
reference ^= byte;
if dut != reference {
log::error!(
"Decrypt BUG at index {}, {:?}: dut {:08x} != {:08x} ref\n",
idx,
id,
dut,
reference
);
log::error!("Decrypt BUG at index {}, {:?}: dut {:08x} != {:08x} ref\n", idx, id, dut, reference);
return;
}
}

File diff suppressed because it is too large Load diff

View file

@ -4,10 +4,9 @@
#[cfg(feature = "low_level_tests")]
mod low_level_tests;
use hex_literal::hex;
use aes::{Aes128, Block};
use aes::cipher::{BlockDecrypt, BlockEncrypt, KeyInit};
use aes::{Aes128, Block};
use hex_literal::hex;
struct AesEcbTest<'a> {
key: &'a [u8],
@ -17,11 +16,7 @@ struct AesEcbTest<'a> {
impl<'a> AesEcbTest<'a> {
pub fn new(key: &'a [u8], plaintext: &'a [u8], ciphertext: &'a [u8]) -> Self {
Self {
key,
plaintext,
ciphertext,
}
Self { key, plaintext, ciphertext }
}
pub fn test(&self) -> Result<(), &'static str> {
@ -59,10 +54,7 @@ impl<'a> AesEcbTest<'a> {
fn main() -> ! {
log_server::init_wait().unwrap();
log::info!(
"Hello, world! This is the AES client, PID {}",
xous::current_pid().unwrap().get()
);
log::info!("Hello, world! This is the AES client, PID {}", xous::current_pid().unwrap().get());
// let key: [u8; 32] = [
// 0x70, 0x69, 0x19, 0xa0, 0x40, 0x61, 0x05, 0x17, 0xf7, 0xff, 0xf5, 0x27, 0x2b, 0x64, 0x04,
@ -158,11 +150,7 @@ fn main() -> ! {
}
}
log::error!(
"{} tests were run and {} errors were encountered",
tests.len(),
failures
);
log::error!("{} tests were run and {} errors were encountered", tests.len(), failures);
#[cfg(feature = "low_level_tests")]
{