From 306c1dec5eb20da03bc9569aab83ae97a2ca9e7a Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sat, 19 Nov 2016 21:16:52 -0500 Subject: Support queries for attribute length and presence. Calling hal_rpc_pkey_get_attributes() with attribute_buffer_len = 0 now changes the return behavior so that it reports the lengths of attributes listed in the query, with a length of zero for attributes not present at all. This is mostly to support C_GetAttributeValue() in PKCS #11, but we also use it to make the Python interface a bit kinder to the user. --- rpc_client.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'rpc_client.c') diff --git a/rpc_client.c b/rpc_client.c index 0c57d51..4da0cb9 100644 --- a/rpc_client.c +++ b/rpc_client.c @@ -895,11 +895,18 @@ static hal_error_t pkey_remote_get_attributes(const hal_pkey_handle_t pkey, check(hal_xdr_decode_int(&iptr, ilimit, &u32)); if (u32 != attributes[i].type) return HAL_ERROR_RPC_PROTOCOL_ERROR; - u32 = attributes_buffer + attributes_buffer_len - abuf; - check(hal_xdr_decode_buffer(&iptr, ilimit, abuf, &u32)); - attributes[i].value = abuf; - attributes[i].length = u32; - abuf += u32; + if (attributes_buffer_len == 0) { + check(hal_xdr_decode_int(&iptr, ilimit, &u32)); + attributes[i].value = NULL; + attributes[i].length = u32; + } + else { + u32 = attributes_buffer + attributes_buffer_len - abuf; + check(hal_xdr_decode_buffer(&iptr, ilimit, abuf, &u32)); + attributes[i].value = abuf; + attributes[i].length = u32; + abuf += u32; + } } } return rpc_ret; -- cgit v1.2.3