[Cryptech-Commits] [sw/stm32] branch ksng updated: Reinitialize keystore data structures after wiping keystore flash.

git at cryptech.is git at cryptech.is
Tue Nov 15 07:05:21 UTC 2016


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

sra at hactrn.net pushed a commit to branch ksng
in repository sw/stm32.

The following commit(s) were added to refs/heads/ksng by this push:
     new 434088c  Reinitialize keystore data structures after wiping keystore flash.
434088c is described below

commit 434088cf8f53770bf016fe8503beaefcdd3c45b4
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Tue Nov 15 02:04:51 2016 -0500

    Reinitialize keystore data structures after wiping keystore flash.
---
 projects/cli-test/mgmt-keystore.c | 20 +++++++++++++++-----
 projects/hsm/mgmt-keystore.c      | 20 +++++++++++++++-----
 2 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/projects/cli-test/mgmt-keystore.c b/projects/cli-test/mgmt-keystore.c
index 3afd238..457abc2 100644
--- a/projects/cli-test/mgmt-keystore.c
+++ b/projects/cli-test/mgmt-keystore.c
@@ -325,6 +325,7 @@ static int cmd_keystore_show_keys(struct cli_def *cli, const char *command, char
 
 static int cmd_keystore_erase(struct cli_def *cli, const char *command, char *argv[], int argc)
 {
+    hal_error_t err;
     int status;
 
     if (argc != 1 || strcmp(argv[0], "YesIAmSure") != 0) {
@@ -333,13 +334,22 @@ static int cmd_keystore_erase(struct cli_def *cli, const char *command, char *ar
     }
 
     cli_print(cli, "OK, erasing keystore, this might take a while...");
-    if ((status = keystore_erase_sectors(0, KEYSTORE_NUM_SECTORS - 1)) != 1)
-        cli_print(cli, "Failed erasing keystore: %i", status);
-    else
-        cli_print(cli, "Keystore erased");
+    if ((status = keystore_erase_sectors(0, KEYSTORE_NUM_SECTORS - 1)) != 1) {
+        cli_print(cli, "Failed erasing token keystore: %i", status);
+	return CLI_ERROR;
+    }
 
-#warning Should notify libhal/ks_flash that we whacked the keystore
+    if ((err = hal_ks_init(hal_ks_token_driver, 0)) != LIBHAL_OK) {
+        cli_print(cli, "Failed to reinitialize token keystore: %s", hal_error_string(err));
+	return CLI_ERROR;
+    }
+
+    if ((err = hal_ks_init(hal_ks_volatile_driver, 0)) != LIBHAL_OK) {
+        cli_print(cli, "Failed to reinitialize memory keystore: %s", hal_error_string(err));
+	return CLI_ERROR;
+    }
 
+    cli_print(cli, "Keystore erased");
     return CLI_OK;
 }
 
diff --git a/projects/hsm/mgmt-keystore.c b/projects/hsm/mgmt-keystore.c
index a15243f..6ee6cf3 100644
--- a/projects/hsm/mgmt-keystore.c
+++ b/projects/hsm/mgmt-keystore.c
@@ -265,6 +265,7 @@ static int cmd_keystore_show_keys(struct cli_def *cli, const char *command, char
 
 static int cmd_keystore_erase(struct cli_def *cli, const char *command, char *argv[], int argc)
 {
+    hal_error_t err;
     int status;
 
     if (argc != 1 || strcmp(argv[0], "YesIAmSure") != 0) {
@@ -273,13 +274,22 @@ static int cmd_keystore_erase(struct cli_def *cli, const char *command, char *ar
     }
 
     cli_print(cli, "OK, erasing keystore, this might take a while...");
-    if ((status = keystore_erase_sectors(0, KEYSTORE_NUM_SECTORS - 1)) != 1)
-        cli_print(cli, "Failed erasing keystore: %i", status);
-    else
-        cli_print(cli, "Keystore erased");
+    if ((status = keystore_erase_sectors(0, KEYSTORE_NUM_SECTORS - 1)) != 1) {
+        cli_print(cli, "Failed erasing token keystore: %i", status);
+	return CLI_ERROR;
+    }
 
-#warning Should notify libhal/ks_flash that we whacked the keystore
+    if ((err = hal_ks_init(hal_ks_token_driver, 0)) != LIBHAL_OK) {
+        cli_print(cli, "Failed to reinitialize token keystore: %s", hal_error_string(err));
+	return CLI_ERROR;
+    }
+
+    if ((err = hal_ks_init(hal_ks_volatile_driver, 0)) != LIBHAL_OK) {
+        cli_print(cli, "Failed to reinitialize memory keystore: %s", hal_error_string(err));
+	return CLI_ERROR;
+    }
 
+    cli_print(cli, "Keystore erased");
     return CLI_OK;
 }
 

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list