[Cryptech-Commits] [sw/libhal] 02/02: Drag C pkey test code up to current RPC API.
git at cryptech.is
git at cryptech.is
Sat Nov 12 04:36:45 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/libhal.
commit 584fdaaaa051a7d6ff906f9244f6ee31678da272
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Fri Nov 11 23:35:59 2016 -0500
Drag C pkey test code up to current RPC API.
---
tests/test-rpc_pkey.c | 16 +++++++++++++---
1 file 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;
}
More information about the Commits
mailing list