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_server.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'rpc_server.c') diff --git a/rpc_server.c b/rpc_server.c index ed9a8d5..ae891a4 100644 --- a/rpc_server.c +++ b/rpc_server.c @@ -759,7 +759,10 @@ static hal_error_t pkey_get_attributes(const uint8_t **iptr, const uint8_t * con ret = hal_xdr_encode_int(optr, olimit, attributes[i].type); if (ret != HAL_OK) break; - ret = hal_xdr_encode_buffer(optr, olimit, attributes[i].value, attributes[i].length); + if (attributes_buffer_len == 0) + ret = hal_xdr_encode_int(optr, olimit, attributes[i].length); + else + ret = hal_xdr_encode_buffer(optr, olimit, attributes[i].value, attributes[i].length); } } -- cgit v1.2.3