aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2015-05-23 09:56:13 -0400
committerRob Austein <sra@hactrn.net>2015-05-23 09:56:13 -0400
commitb932b1976b8c288686accf14e13cd499877408f9 (patch)
tree58a8971dfc4979cbb1ef7bab7e46b0bd1e2cf5f2
parentc5f1ddb1b10e69e815a561132a38b4ff23a1310c (diff)
Guess it might help to write the config value to the AES core after
constructing it, doh.
-rw-r--r--aes_keywrap.c6
-rw-r--r--tests/test-aes-key-wrap.c12
2 files changed, 13 insertions, 5 deletions
diff --git a/aes_keywrap.c b/aes_keywrap.c
index cc62676..9ded0e1 100644
--- a/aes_keywrap.c
+++ b/aes_keywrap.c
@@ -18,7 +18,6 @@
#include "cryptech.h"
-
/*
* How long the ciphertext will be for a given plaintext length.
*/
@@ -74,8 +73,9 @@ static hal_error_t load_kek(const uint8_t *K, const size_t K_len, const kek_acti
* Load the KEK and tell the core to expand it.
*/
- if ((err = hal_io_write(AES_ADDR_KEY0, K, K_len)) != HAL_OK ||
- (err = hal_io_init(AES_ADDR_CTRL)) != HAL_OK)
+ if ((err = hal_io_write(AES_ADDR_KEY0, K, K_len)) != HAL_OK ||
+ (err = hal_io_write(AES_ADDR_CONFIG, config, sizeof(config))) != HAL_OK ||
+ (err = hal_io_init(AES_ADDR_CTRL)) != HAL_OK)
return err;
return HAL_OK;
diff --git a/tests/test-aes-key-wrap.c b/tests/test-aes-key-wrap.c
index 34838b8..1af9a2f 100644
--- a/tests/test-aes-key-wrap.c
+++ b/tests/test-aes-key-wrap.c
@@ -94,7 +94,7 @@ static int run_test(const uint8_t * const K, const size_t K_len,
if ((err = hal_aes_keywrap(K, K_len, Q, Q_len, c, &c_len)) != HAL_OK) {
printf("couldn't wrap with %lu-bit KEK: %s\n",
- K_len * 8, hal_error_string(err));
+ (unsigned long) K_len * 8, hal_error_string(err));
ok1 = 0;
}
else if (C_len != c_len || memcmp(C, c, C_len) != 0) {
@@ -110,7 +110,7 @@ static int run_test(const uint8_t * const K, const size_t K_len,
if ((err = hal_aes_keyunwrap(K, K_len, C, C_len, q, &q_len)) != HAL_OK) {
printf("couldn't unwrap with %lu-bit KEK: %s\n",
- K_len * 8, hal_error_string(err));
+ (unsigned long) K_len * 8, hal_error_string(err));
ok2 = 0;
}
else if (Q_len != q_len || memcmp(Q, q, Q_len) != 0) {
@@ -127,6 +127,14 @@ 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))
+ printf("yes\n");
+ else
+ printf("no\n");
+
+ hal_io_set_debug(1);
+
printf("Testing 128-bit KEK...");
if (run_test(K_128, sizeof(K_128), C_128, sizeof(C_128)))
printf("OK\n");