diff options
author | Rob Austein <sra@hactrn.net> | 2017-04-11 00:29:00 -0400 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2017-04-11 00:29:00 -0400 |
commit | 4837c5d366e965e196828a2898e2471c592b85e1 (patch) | |
tree | 9230d37874fdb683ef2020d8d3b805ee67e6f289 /projects | |
parent | 7a8a2564c64894026e6e79eb116f5b8b358d622c (diff) |
Track API changes on sw/libhal pkcs8 branch.
Diffstat (limited to 'projects')
-rw-r--r-- | projects/cli-test/mgmt-keystore.c | 19 | ||||
-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 |
5 files changed, 27 insertions, 25 deletions
diff --git a/projects/cli-test/mgmt-keystore.c b/projects/cli-test/mgmt-keystore.c index 09d512e..6e26d6d 100644 --- a/projects/cli-test/mgmt-keystore.c +++ b/projects/cli-test/mgmt-keystore.c @@ -198,7 +198,7 @@ static int cmd_keystore_delete_key(struct cli_def *cli, const char *command, cha return CLI_ERROR; } - if ((status = hal_rpc_pkey_open(client, session, &pkey, &name, HAL_KEY_FLAG_TOKEN)) != LIBHAL_OK || + if ((status = hal_rpc_pkey_open(client, session, &pkey, &name)) != LIBHAL_OK || (status = hal_rpc_pkey_delete(pkey)) != LIBHAL_OK) { cli_print(cli, "Failed deleting key: %s", hal_error_string(status)); return CLI_ERROR; @@ -231,7 +231,7 @@ static int cmd_keystore_show_data(struct cli_def *cli, const char *command, char 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 }; @@ -240,10 +240,10 @@ 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_key_type_t type; hal_error_t status; hal_uuid_t uuids[50]; - unsigned n; int done = 0; cli_print(cli, title); @@ -251,7 +251,8 @@ static int show_keys(struct cli_def *cli, const char *title, const hal_key_flags 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 0; @@ -270,7 +271,7 @@ static int show_keys(struct cli_def *cli, const char *title, const hal_key_flags return 0; } - 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 0; @@ -317,10 +318,10 @@ static int show_keys(struct cli_def *cli, const char *title, const hal_key_flags static int cmd_keystore_show_keys(struct cli_def *cli, const char *command, char *argv[], int argc) { - int ok = 1; - ok &= show_keys(cli, "Memory keystore:", 0); - ok &= show_keys(cli, "Token keystore:", HAL_KEY_FLAG_TOKEN); - return ok ? CLI_OK : CLI_ERROR; + if (show_keys(cli, "Keystore:")) + return CLI_OK; + else + return CLI_ERROR; } static int cmd_keystore_erase(struct cli_def *cli, const char *command, char *argv[], int argc) 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); |