aboutsummaryrefslogtreecommitdiff
path: root/rpc_client.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-05-15 20:49:18 -0400
committerRob Austein <sra@hactrn.net>2016-05-15 20:49:18 -0400
commit0690aa3d48966a4b151a468fd3a0a65bb99de439 (patch)
treee88db7d7d677ea48d9bb3dbd57acc514785a44f7 /rpc_client.c
parent53b0dd22287e07ca32184c27b7ec0d75d358bde4 (diff)
Add hal_rpc_pkey_rename(); allow null string as (temporary) key name.
Temporary nature of null string as key name is not enforced by the keystore code, it's just a convention to allow callers to generate a keypair, obtain the public key, hash that to a Subject Key Identifier (SKI), and rename the key using the SKI as the new name. This is a compromise to let us use SKI-based key names in PKCS #11 while keeping the keystore code simple.
Diffstat (limited to 'rpc_client.c')
-rw-r--r--rpc_client.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/rpc_client.c b/rpc_client.c
index 71dcc7c..3a84305 100644
--- a/rpc_client.c
+++ b/rpc_client.c
@@ -513,6 +513,27 @@ static hal_error_t pkey_remote_delete(const hal_pkey_handle_t pkey)
return rpc_ret;
}
+static hal_error_t pkey_remote_rename(const hal_pkey_handle_t pkey,
+ const uint8_t * const name, const size_t name_len)
+{
+ uint8_t outbuf[nargs(3) + pad(name_len)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf);
+ uint8_t inbuf[nargs(1)];
+ const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf);
+ size_t ilen = sizeof(inbuf);
+ hal_error_t rpc_ret;
+
+ check(hal_xdr_encode_int(&optr, olimit, RPC_FUNC_PKEY_DELETE));
+ check(hal_xdr_encode_int(&optr, olimit, pkey.handle));
+ check(hal_xdr_encode_buffer(&optr, olimit, name, name_len));
+ check(hal_rpc_send(outbuf, optr - outbuf));
+
+ check(hal_rpc_recv(inbuf, &ilen));
+ assert(ilen <= sizeof(inbuf));
+ check(hal_xdr_decode_int(&iptr, ilimit, &rpc_ret));
+ return rpc_ret;
+}
+
+
static hal_error_t pkey_remote_get_key_type(const hal_pkey_handle_t pkey,
hal_key_type_t *type)
{
@@ -851,6 +872,12 @@ static hal_error_t pkey_mixed_delete(const hal_pkey_handle_t pkey)
return mixed_handle_dispatch(pkey)->delete(pkey);
}
+static hal_error_t pkey_mixed_rename(const hal_pkey_handle_t pkey,
+ const uint8_t * const name, const size_t name_len)
+{
+ return mixed_handle_dispatch(pkey)->rename(pkey, name, name_len);
+}
+
static hal_error_t pkey_mixed_get_key_type(const hal_pkey_handle_t pkey,
hal_key_type_t *key_type)
{
@@ -912,6 +939,7 @@ const hal_rpc_pkey_dispatch_t hal_rpc_remote_pkey_dispatch = {
pkey_remote_generate_ec,
pkey_remote_close,
pkey_remote_delete,
+ pkey_remote_rename,
pkey_remote_get_key_type,
pkey_remote_get_key_flags,
pkey_remote_get_public_key_len,
@@ -928,6 +956,7 @@ const hal_rpc_pkey_dispatch_t hal_rpc_mixed_pkey_dispatch = {
pkey_mixed_generate_ec,
pkey_mixed_close,
pkey_mixed_delete,
+ pkey_mixed_rename,
pkey_mixed_get_key_type,
pkey_mixed_get_key_flags,
pkey_mixed_get_public_key_len,