diff options
author | Rob Austein <sra@hactrn.net> | 2016-11-11 23:35:59 -0500 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2016-11-11 23:35:59 -0500 |
commit | 584fdaaaa051a7d6ff906f9244f6ee31678da272 (patch) | |
tree | 113a4bf4aaeda803897b6432b76d688ba0349954 | |
parent | 2ff032823f6acf0cc409c0e541041ebe1f0dbc75 (diff) |
Drag C pkey test code up to current RPC API.
-rw-r--r-- | tests/test-rpc_pkey.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/tests/test-rpc_pkey.c b/tests/test-rpc_pkey.c index 6f2485b..f021827 100644 --- a/tests/test-rpc_pkey.c +++ b/tests/test-rpc_pkey.c @@ -60,7 +60,7 @@ static int test_attributes(const hal_pkey_handle_t pkey, const hal_uuid_t * const name, const hal_key_flags_t flags) { - static const size_t sizes[] = { 32, 100, 260, 1000, 2000, 2048, 0 }; + static const size_t sizes[] = { 32, 100, 260, 1000, 2000, 0 }; static const char format[] = "Test attribute %lu"; hal_error_t err; @@ -471,9 +471,16 @@ static int test_ecdsa_generate(const ecdsa_tc_t * const tc, hal_key_flags_t flag int main (int argc, char *argv[]) { + const hal_client_handle_t client = {HAL_HANDLE_NONE}; + const char *pin = argc > 1 ? argv[1] : "fnord"; + hal_error_t err; int ok = 1; - hal_rpc_client_init(); + if ((err = hal_rpc_client_init()) != HAL_OK) + printf("Warning: Trouble initializing RPC client: %s\n", hal_error_string(err)); + + if ((err = hal_rpc_login(client, HAL_USER_NORMAL, pin, strlen(pin))) != HAL_OK) + printf("Warning: Trouble logging into HSM: %s\n", hal_error_string(err)); for (int i = 0; i < (sizeof(rsa_tc)/sizeof(*rsa_tc)); i++) for (int j = 0; j < 2; j++) @@ -491,8 +498,11 @@ int main (int argc, char *argv[]) for (int j = 0; j < 2; j++) ok &= test_ecdsa_generate(&ecdsa_tc[i], j * HAL_KEY_FLAG_TOKEN); + if ((err = hal_rpc_logout(client)) != HAL_OK) + printf("Warning: Trouble logging out of HSM: %s\n", hal_error_string(err)); - ok &= hal_rpc_client_close(); + if ((err = hal_rpc_client_close()) != HAL_OK) + printf("Warning: Trouble shutting down RPC client: %s\n", hal_error_string(err)); return !ok; } |