[Cryptech-Commits] [sw/libhal] 07/58: Guess it might help to write the config value to the AES core after constructing it, doh.

git at cryptech.is git at cryptech.is
Tue Jul 7 18:24:51 UTC 2015


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch master
in repository sw/libhal.

commit b932b1976b8c288686accf14e13cd499877408f9
Author: Rob Austein <sra at hactrn.net>
Date:   Sat May 23 09:56:13 2015 -0400

    Guess it might help to write the config value to the AES core after
    constructing it, doh.
---
 aes_keywrap.c             |  6 +++---
 tests/test-aes-key-wrap.c | 12 ++++++++++--
 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");



More information about the Commits mailing list