diff options
author | Rob Austein <sra@hactrn.net> | 2016-11-15 02:04:51 -0500 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2016-11-15 02:04:51 -0500 |
commit | 434088cf8f53770bf016fe8503beaefcdd3c45b4 (patch) | |
tree | eb93d99322b7703fc00047422ac069a5589d7cc5 /projects/cli-test | |
parent | 08c377d92306656f32d36e4efad06d65c4f0b6ba (diff) |
Reinitialize keystore data structures after wiping keystore flash.
Diffstat (limited to 'projects/cli-test')
-rw-r--r-- | projects/cli-test/mgmt-keystore.c | 20 |
1 files changed, 15 insertions, 5 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; } |