aboutsummaryrefslogtreecommitdiff
path: root/tests/test-aes-key-wrap.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2015-11-13 17:53:30 -0500
committerPaul Selkirk <paul@psgd.org>2015-11-13 17:53:30 -0500
commita7037d918cbf60bd829e44ccc6d1522f55d5d8b1 (patch)
tree708a05da632c4ed5b8bd3601c39e3b0c0cf41ea7 /tests/test-aes-key-wrap.c
parent49ac8847de1120a4ae7b72747ee259bc0f5ffb3c (diff)
parent6ed2c92afd94c08a07f31a7bec345baef07bdf19 (diff)
Merge branch 'config_core_selector'
Diffstat (limited to 'tests/test-aes-key-wrap.c')
-rw-r--r--tests/test-aes-key-wrap.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/tests/test-aes-key-wrap.c b/tests/test-aes-key-wrap.c
index b784c54..caf3a2c 100644
--- a/tests/test-aes-key-wrap.c
+++ b/tests/test-aes-key-wrap.c
@@ -107,7 +107,8 @@ static const char *format_hex(const uint8_t *bin, const size_t len, char *hex, c
return hex;
}
-static int run_test(const uint8_t * const K, const size_t K_len,
+static int run_test(const hal_core_t *core,
+ const uint8_t * const K, const size_t K_len,
const uint8_t * const C, const size_t C_len)
{
const size_t Q_len = sizeof(Q);
@@ -122,7 +123,7 @@ static int run_test(const uint8_t * const K, const size_t K_len,
*/
printf("Wrapping with %lu-bit KEK...\n", (unsigned long) K_len * 8);
- if ((err = hal_aes_keywrap(K, K_len, Q, Q_len, c, &c_len)) != HAL_OK) {
+ if ((err = hal_aes_keywrap(core, K, K_len, Q, Q_len, c, &c_len)) != HAL_OK) {
printf("Couldn't wrap with %lu-bit KEK: %s\n",
(unsigned long) K_len * 8, hal_error_string(err));
ok1 = 0;
@@ -142,7 +143,7 @@ static int run_test(const uint8_t * const K, const size_t K_len,
*/
printf("Unwrapping with %lu-bit KEK...\n", (unsigned long) K_len * 8);
- if ((err = hal_aes_keyunwrap(K, K_len, C, C_len, q, &q_len)) != HAL_OK) {
+ if ((err = hal_aes_keyunwrap(core, K, K_len, C, C_len, q, &q_len)) != HAL_OK) {
printf("Couldn't unwrap with %lu-bit KEK: %s\n",
(unsigned long) K_len * 8, hal_error_string(err));
ok2 = 0;
@@ -165,15 +166,18 @@ int main (int argc, char *argv[])
int failures = 0;
printf("Testing whether AES core reports present...");
- if (hal_io_expected(AES_ADDR_NAME0, (const uint8_t *) (AES_CORE_NAME0 AES_CORE_NAME1), 8) != HAL_OK) {
+
+ const hal_core_t *core = hal_core_find(AES_CORE_NAME, NULL);
+
+ if (core == NULL) {
printf("no, skipping keywrap tests\n");
}
else {
printf("yes\n");
- if (!run_test(K_128, sizeof(K_128), C_128, sizeof(C_128)))
+ if (!run_test(core, K_128, sizeof(K_128), C_128, sizeof(C_128)))
failures++;
- if (!run_test(K_256, sizeof(K_256), C_256, sizeof(C_256)))
+ if (!run_test(core, K_256, sizeof(K_256), C_256, sizeof(C_256)))
failures++;
}