imix/test/
aes_test.rs
1use capsules_extra::test::aes::TestAes128Cbc;
29use capsules_extra::test::aes::TestAes128Ctr;
30use kernel::hil::symmetric_encryption::{AES128, AES128_BLOCK_SIZE, AES128_KEY_SIZE};
31use kernel::static_init;
32use sam4l::aes::Aes;
33
34pub unsafe fn run_aes128_ctr(aes: &'static Aes) {
35 let t = static_init_test_ctr(aes);
36 aes.set_client(t);
37
38 t.run();
39}
40
41pub unsafe fn run_aes128_cbc(aes: &'static Aes) {
42 let t = static_init_test_cbc(aes);
43 aes.set_client(t);
44
45 t.run();
46}
47
48unsafe fn static_init_test_ctr(aes: &'static Aes) -> &'static TestAes128Ctr<'static, Aes<'static>> {
49 let source = static_init!([u8; 4 * AES128_BLOCK_SIZE], [0; 4 * AES128_BLOCK_SIZE]);
50 let data = static_init!([u8; 6 * AES128_BLOCK_SIZE], [0; 6 * AES128_BLOCK_SIZE]);
51 let key = static_init!([u8; AES128_KEY_SIZE], [0; AES128_KEY_SIZE]);
52 let iv = static_init!([u8; AES128_BLOCK_SIZE], [0; AES128_BLOCK_SIZE]);
53
54 static_init!(
55 TestAes128Ctr<'static, Aes>,
56 TestAes128Ctr::new(aes, key, iv, source, data, true)
57 )
58}
59
60unsafe fn static_init_test_cbc(aes: &'static Aes) -> &'static TestAes128Cbc<'static, Aes<'static>> {
61 let source = static_init!([u8; 4 * AES128_BLOCK_SIZE], [0; 4 * AES128_BLOCK_SIZE]);
62 let data = static_init!([u8; 6 * AES128_BLOCK_SIZE], [0; 6 * AES128_BLOCK_SIZE]);
63 let key = static_init!([u8; AES128_KEY_SIZE], [0; AES128_KEY_SIZE]);
64 let iv = static_init!([u8; AES128_BLOCK_SIZE], [0; AES128_BLOCK_SIZE]);
65
66 static_init!(
67 TestAes128Cbc<'static, Aes>,
68 TestAes128Cbc::new(aes, key, iv, source, data, true)
69 )
70}