aboutsummaryrefslogtreecommitdiff
path: root/rpc_client.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-11-01 19:47:50 -0400
committerRob Austein <sra@hactrn.net>2016-11-01 19:47:50 -0400
commitd844d764a4f0614bf378331b007467de288f74eb (patch)
tree57b8645d338f1549d2b06c4bc3b22c0a6ef950bc /rpc_client.c
parentd3301ac269431c5aa45061abdb2d4400793b1eee (diff)
Add hal_rpc_pkey_get_key_curve().
Incidental minor refactoring of hal_rpc_server_dispatch().
Diffstat (limited to 'rpc_client.c')
-rw-r--r--rpc_client.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/rpc_client.c b/rpc_client.c
index 959e26a..2df30b1 100644
--- a/rpc_client.c
+++ b/rpc_client.c
@@ -616,6 +616,31 @@ static hal_error_t pkey_remote_get_key_type(const hal_pkey_handle_t pkey,
return rpc_ret;
}
+static hal_error_t pkey_remote_get_key_curve(const hal_pkey_handle_t pkey,
+ hal_curve_name_t *curve)
+{
+ uint8_t outbuf[nargs(3)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf);
+ uint8_t inbuf[nargs(4)];
+ const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf);
+ uint32_t curve32;
+ hal_client_handle_t dummy_client = {0};
+ hal_error_t rpc_ret;
+
+ check(hal_xdr_encode_int(&optr, olimit, RPC_FUNC_PKEY_GET_KEY_CURVE));
+ check(hal_xdr_encode_int(&optr, olimit, dummy_client.handle));
+ check(hal_xdr_encode_int(&optr, olimit, pkey.handle));
+ check(hal_rpc_send(outbuf, optr - outbuf));
+
+ check(read_matching_packet(RPC_FUNC_PKEY_GET_KEY_CURVE, inbuf, sizeof(inbuf), &iptr, &ilimit));
+
+ check(hal_xdr_decode_int(&iptr, ilimit, &rpc_ret));
+ if (rpc_ret == HAL_OK) {
+ check(hal_xdr_decode_int(&iptr, ilimit, &type32));
+ *curve = (hal_curve_name_t)curve32;
+ }
+ return rpc_ret;
+}
+
static hal_error_t pkey_remote_get_key_flags(const hal_pkey_handle_t pkey,
hal_key_flags_t *flags)
{
@@ -1053,6 +1078,7 @@ const hal_rpc_pkey_dispatch_t hal_rpc_remote_pkey_dispatch = {
pkey_remote_close,
pkey_remote_delete,
pkey_remote_get_key_type,
+ pkey_remote_get_key_curve,
pkey_remote_get_key_flags,
pkey_remote_get_public_key_len,
pkey_remote_get_public_key,
@@ -1074,6 +1100,7 @@ const hal_rpc_pkey_dispatch_t hal_rpc_mixed_pkey_dispatch = {
pkey_remote_close,
pkey_remote_delete,
pkey_remote_get_key_type,
+ pkey_remote_get_key_curve,
pkey_remote_get_key_flags,
pkey_remote_get_public_key_len,
pkey_remote_get_public_key,