5 #include "sw/device/lib/crypto/drivers/aes.h"
8 #include "sw/device/lib/crypto/drivers/entropy.h"
9 #include "sw/device/lib/crypto/impl/status.h"
11 #include "sw/device/lib/testing/test_framework/check.h"
15 static const uint32_t kSecretKey[] = {
48 {.data = 0xe2bec16b, 0x969f402e, 0x117e3de9, 0x2a179373},
50 {.data = 0x578a2dae, 0x9cac031e, 0xac6fb79e, 0x518eaf45},
52 {.data = 0x461cc830, 0x11e45ca3, 0x19c1fbe5, 0xef520a1a},
54 {.data = 0x45249ff6, 0x179b4fdf, 0x7b412bad, 0x10376ce6},
59 {.data = 0x91614d87, 0x26e320b6, 0x6468ef1b, 0xceb60d99},
61 {.data = 0x6bf60698, 0xfffd7079, 0x7b181786, 0xfffdffb9},
63 {.data = 0x3edfe45a, 0x5ed3d5db, 0x02094f5b, 0xab3eb00d},
65 {.data = 0xda1d031e, 0xd103be2f, 0xa0702179, 0xee9c00f3},
73 const uint32_t share0[8] = {~kSecretKey[0],
81 const uint32_t share1[8] = {UINT32_MAX, UINT32_MAX, UINT32_MAX, UINT32_MAX,
84 LOG_INFO(
"Configuring the AES hardware.");
86 .
mode = kAesCipherModeCtr,
89 .key_shares = {share0, share1},
91 TRY(aes_encrypt_begin(key, &kIv));
95 for (
size_t i = 0; i <
ARRAYSIZE(kPlaintext); ++i) {
97 TRY(aes_update(out, &kPlaintext[i]));
100 TRY(aes_update(out, NULL));
102 CHECK_ARRAYS_EQ((uint32_t *)ciphertext, (uint32_t *)kCiphertext,
103 sizeof(ciphertext) / (
sizeof(uint32_t)));
107 TRY(aes_end(&final_iv));
109 CHECK_ARRAYS_EQ(final_iv.data, kFinalIv.data, kAesBlockNumWords);
114 OTTF_DEFINE_TEST_CONFIG();
117 CHECK_STATUS_OK(entropy_complex_init());
118 CHECK_STATUS_OK(run_aes_test());