use capsules_extra::test::aes::TestAes128Cbc;
use capsules_extra::test::aes::TestAes128Ctr;
use kernel::hil::symmetric_encryption::{AES128, AES128_BLOCK_SIZE, AES128_KEY_SIZE};
use kernel::static_init;
use sam4l::aes::Aes;
pub unsafe fn run_aes128_ctr(aes: &'static Aes) {
let t = static_init_test_ctr(aes);
aes.set_client(t);
t.run();
}
pub unsafe fn run_aes128_cbc(aes: &'static Aes) {
let t = static_init_test_cbc(aes);
aes.set_client(t);
t.run();
}
unsafe fn static_init_test_ctr(aes: &'static Aes) -> &'static TestAes128Ctr<'static, Aes<'static>> {
let source = static_init!([u8; 4 * AES128_BLOCK_SIZE], [0; 4 * AES128_BLOCK_SIZE]);
let data = static_init!([u8; 6 * AES128_BLOCK_SIZE], [0; 6 * AES128_BLOCK_SIZE]);
let key = static_init!([u8; AES128_KEY_SIZE], [0; AES128_KEY_SIZE]);
let iv = static_init!([u8; AES128_BLOCK_SIZE], [0; AES128_BLOCK_SIZE]);
static_init!(
TestAes128Ctr<'static, Aes>,
TestAes128Ctr::new(aes, key, iv, source, data, true)
)
}
unsafe fn static_init_test_cbc(aes: &'static Aes) -> &'static TestAes128Cbc<'static, Aes<'static>> {
let source = static_init!([u8; 4 * AES128_BLOCK_SIZE], [0; 4 * AES128_BLOCK_SIZE]);
let data = static_init!([u8; 6 * AES128_BLOCK_SIZE], [0; 6 * AES128_BLOCK_SIZE]);
let key = static_init!([u8; AES128_KEY_SIZE], [0; AES128_KEY_SIZE]);
let iv = static_init!([u8; AES128_BLOCK_SIZE], [0; AES128_BLOCK_SIZE]);
static_init!(
TestAes128Cbc<'static, Aes>,
TestAes128Cbc::new(aes, key, iv, source, data, true)
)
}