From a031d726ccdd358cec63a7892b3ce1e88b201313 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 7 Apr 2017 17:41:30 -0400 Subject: Pull key type information from uploaded key in hal_rpc_pkey_load(). Now that we use PKCS #8 format for private keys, all key formats we use include ASN.1 AlgorithmIdentifier field describing the key, so specifying key type and curve as arguments to hal_rpc_pkey_load() is neither necessary nor particularly useful. --- rpc_server.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'rpc_server.c') diff --git a/rpc_server.c b/rpc_server.c index 4aa5de4..55f15fe 100644 --- a/rpc_server.c +++ b/rpc_server.c @@ -322,30 +322,28 @@ static hal_error_t pkey_load(const uint8_t **iptr, const uint8_t * const ilimit, hal_client_handle_t client; hal_session_handle_t session; hal_pkey_handle_t pkey; - uint32_t type; - uint32_t curve; hal_uuid_t name; const uint8_t *der; uint32_t der_len; hal_key_flags_t flags; hal_error_t ret; + uint8_t *optr_orig = *optr; check(hal_xdr_decode_int(iptr, ilimit, &client.handle)); check(hal_xdr_decode_int(iptr, ilimit, &session.handle)); - check(hal_xdr_decode_int(iptr, ilimit, &type)); - check(hal_xdr_decode_int(iptr, ilimit, &curve)); check(hal_xdr_decode_buffer_in_place(iptr, ilimit, &der, &der_len)); check(hal_xdr_decode_int(iptr, ilimit, &flags)); - /* call the local function */ - ret = hal_rpc_pkey_load(client, session, &pkey, type, curve, &name, der, der_len, flags); + ret = hal_rpc_pkey_load(client, session, &pkey, &name, der, der_len, flags); - if (ret == HAL_OK) { - uint8_t *optr_orig = *optr; - if ((ret = hal_xdr_encode_int(optr, olimit, pkey.handle)) != HAL_OK || - (ret = hal_xdr_encode_buffer(optr, olimit, name.uuid, sizeof(name.uuid))) != HAL_OK) - *optr = optr_orig; - } + if (ret == HAL_OK) + ret = hal_xdr_encode_int(optr, olimit, pkey.handle); + + if (ret == HAL_OK) + ret = hal_xdr_encode_buffer(optr, olimit, name.uuid, sizeof(name.uuid)); + + if (ret != HAL_OK) + *optr = optr_orig; return ret; } -- cgit v1.2.3