diff options
Diffstat (limited to 'projects/hsm')
-rwxr-xr-x | projects/hsm/cryptech_miniterm | 2 | ||||
-rwxr-xr-x | projects/hsm/cryptech_upload | 2 | ||||
-rw-r--r-- | projects/hsm/mgmt-keystore.c | 27 | ||||
-rw-r--r-- | projects/hsm/mgmt-thread.c | 2 |
4 files changed, 17 insertions, 16 deletions
diff --git a/projects/hsm/cryptech_miniterm b/projects/hsm/cryptech_miniterm index b8ea3b1..af52b0e 100755 --- a/projects/hsm/cryptech_miniterm +++ b/projects/hsm/cryptech_miniterm @@ -40,6 +40,6 @@ import os default_port = os.getenv("CRYPTECH_CTY_CLIENT_SERIAL_DEVICE") default_baud = os.getenv("CRYPTECH_CTY_CLIENT_SERIAL_SPEED", 921600) -sys.exit(serial.tools.miniterm.main(default_port = default_port, +sys.exit(serial.tools.miniterm.main(default_port = default_port, default_baudrate = int(default_baud))) diff --git a/projects/hsm/cryptech_upload b/projects/hsm/cryptech_upload index 26afa67..559195d 100755 --- a/projects/hsm/cryptech_upload +++ b/projects/hsm/cryptech_upload @@ -258,7 +258,7 @@ If you got here by accident, ^C now, without answering the PIN prompt. def main(): global args args = parse_args() - + if args.bootloader: if not args.simon_says_whack_my_bootloader: diff --git a/projects/hsm/mgmt-keystore.c b/projects/hsm/mgmt-keystore.c index 4855998..230bded 100644 --- a/projects/hsm/mgmt-keystore.c +++ b/projects/hsm/mgmt-keystore.c @@ -156,13 +156,14 @@ static int cmd_keystore_delete_key(struct cli_def *cli, const char *command, cha return CLI_ERROR; } - status = hal_rpc_pkey_open(client, session, &pkey, &name, HAL_KEY_FLAG_TOKEN); - - if (status == HAL_ERROR_KEY_NOT_FOUND) - status = hal_rpc_pkey_open(client, session, &pkey, &name, 0); + if ((status = hal_rpc_pkey_open(client, session, &pkey, &name)) != LIBHAL_OK) { + cli_print(cli, "Couldn't find key: %s", hal_error_string(status)); + return CLI_ERROR; + } - if (status != LIBHAL_OK || (status = hal_rpc_pkey_delete(pkey)) != LIBHAL_OK) { + if ((status = hal_rpc_pkey_delete(pkey)) != LIBHAL_OK) { cli_print(cli, "Failed deleting key: %s", hal_error_string(status)); + (void) hal_rpc_pkey_close(pkey); return CLI_ERROR; } @@ -171,7 +172,7 @@ static int cmd_keystore_delete_key(struct cli_def *cli, const char *command, cha return CLI_OK; } -static int show_keys(struct cli_def *cli, const char *title, const hal_key_flags_t qflags) +static int show_keys(struct cli_def *cli, const char *title) { const hal_client_handle_t client = { -1 }; const hal_session_handle_t session = { HAL_HANDLE_NONE }; @@ -180,19 +181,20 @@ static int show_keys(struct cli_def *cli, const char *title, const hal_key_flags hal_pkey_handle_t pkey; hal_curve_name_t curve; hal_key_flags_t flags; + unsigned n, state = 0; + hal_uuid_t uuids[50]; hal_key_type_t type; hal_error_t status; - hal_uuid_t uuids[50]; int count = 0; int done = 0; - unsigned n; cli_print(cli, title); while (!done) { if ((status = hal_rpc_pkey_match(client, session, HAL_KEY_TYPE_NONE, HAL_CURVE_NONE, - qflags, NULL, 0, uuids, &n, sizeof(uuids)/sizeof(*uuids), + 0, 0, NULL, 0, &state, uuids, &n, + sizeof(uuids)/sizeof(*uuids), &previous_uuid)) != LIBHAL_OK) { cli_print(cli, "Could not fetch UUID list: %s", hal_error_string(status)); return CLI_ERROR; @@ -211,7 +213,7 @@ static int show_keys(struct cli_def *cli, const char *title, const hal_key_flags return CLI_ERROR; } - if ((status = hal_rpc_pkey_open(client, session, &pkey, &uuids[i], qflags)) != LIBHAL_OK) { + if ((status = hal_rpc_pkey_open(client, session, &pkey, &uuids[i])) != LIBHAL_OK) { cli_print(cli, "Could not open key %s: %s", key_name, hal_error_string(status)); return CLI_ERROR; @@ -267,7 +269,7 @@ static int show_pin(struct cli_def *cli, char *label, hal_user_t user) * I'm not sure iterations is the most interesting thing to show, but * it's what we had before. */ - + cli_print(cli, "%s iterations: 0x%lx", label, p->iterations); return CLI_OK; } @@ -276,8 +278,7 @@ static int cmd_keystore_show_keys(struct cli_def *cli, const char *command, char { int err = 0; - err |= show_keys(cli, "Memory keystore:", 0); - err |= show_keys(cli, "Token keystore:", HAL_KEY_FLAG_TOKEN); + err |= show_keys(cli, "Keystore:"); cli_print(cli, "\nPins:"); err |= show_pin(cli, "Wheel", HAL_USER_WHEEL); diff --git a/projects/hsm/mgmt-thread.c b/projects/hsm/mgmt-thread.c index 82b8e72..7cc13c9 100644 --- a/projects/hsm/mgmt-thread.c +++ b/projects/hsm/mgmt-thread.c @@ -78,7 +78,7 @@ static int cmd_thread_show(struct cli_def *cli, const char *command, char *argv[ name = "osTimerThread"; else name = "unknown"; - + cli_print(cli, "%d:\tptask\t%p\t%s", task_id, task->ptask, name); cli_print(cli, "\tstate\t%d\t\t%s", (int)task->state, task_state[task->state]); cli_print(cli, "\tprio\t%d", (int)task->prio); |