diff options
-rw-r--r-- | rpc_client.c | 80 | ||||
-rw-r--r-- | rpc_server.c | 83 | ||||
-rw-r--r-- | xdr.c | 12 | ||||
-rw-r--r-- | xdr_internal.h | 8 |
4 files changed, 105 insertions, 78 deletions
diff --git a/rpc_client.c b/rpc_client.c index 21c4327..02e3320 100644 --- a/rpc_client.c +++ b/rpc_client.c @@ -54,7 +54,8 @@ static hal_error_t get_version(uint32_t *version) { uint8_t outbuf[nargs(1)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -73,7 +74,8 @@ static hal_error_t get_version(uint32_t *version) static hal_error_t get_random(void *buffer, const size_t length) { uint8_t outbuf[nargs(2)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2) + pad(length)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2) + pad(length)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); uint32_t rcvlen = length; hal_error_t rpc_ret; @@ -97,7 +99,8 @@ static hal_error_t set_pin(const hal_client_handle_t client, const char * const pin, const size_t pin_len) { uint8_t outbuf[nargs(4) + pad(pin_len)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(1)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(1)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -132,7 +135,8 @@ static hal_error_t login(const hal_client_handle_t client, const char * const pin, const size_t pin_len) { uint8_t outbuf[nargs(4) + pad(pin_len)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(1)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(1)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -151,7 +155,8 @@ static hal_error_t login(const hal_client_handle_t client, static hal_error_t logout(const hal_client_handle_t client) { uint8_t outbuf[nargs(2)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(1)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(1)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -168,7 +173,8 @@ static hal_error_t logout(const hal_client_handle_t client) static hal_error_t logout_all(void) { uint8_t outbuf[nargs(1)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(1)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(1)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -185,7 +191,8 @@ static hal_error_t is_logged_in(const hal_client_handle_t client, const hal_user_t user) { uint8_t outbuf[nargs(3)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(1)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(1)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -203,7 +210,8 @@ static hal_error_t is_logged_in(const hal_client_handle_t client, static hal_error_t hash_get_digest_len(const hal_digest_algorithm_t alg, size_t *length) { uint8_t outbuf[nargs(2)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); uint32_t len32; hal_error_t rpc_ret; @@ -226,7 +234,8 @@ static hal_error_t hash_get_digest_algorithm_id(const hal_digest_algorithm_t alg uint8_t *id, size_t *len, const size_t len_max) { uint8_t outbuf[nargs(3)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2) + pad(len_max)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2) + pad(len_max)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); uint32_t len32 = len_max; hal_error_t rpc_ret; @@ -249,7 +258,8 @@ static hal_error_t hash_get_digest_algorithm_id(const hal_digest_algorithm_t alg static hal_error_t hash_get_algorithm(const hal_hash_handle_t hash, hal_digest_algorithm_t *alg) { uint8_t outbuf[nargs(2)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); uint32_t alg32; hal_error_t rpc_ret; @@ -275,7 +285,8 @@ static hal_error_t hash_initialize(const hal_client_handle_t client, const uint8_t * const key, const size_t key_len) { uint8_t outbuf[nargs(5) + pad(key_len)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -299,7 +310,8 @@ static hal_error_t hash_update(const hal_hash_handle_t hash, const uint8_t * data, const size_t length) { uint8_t outbuf[nargs(3) + pad(length)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(1)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(1)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -318,7 +330,8 @@ static hal_error_t hash_finalize(const hal_hash_handle_t hash, uint8_t *digest, const size_t length) { uint8_t outbuf[nargs(3)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2) + pad(length)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2) + pad(length)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); uint32_t digest_len = length; hal_error_t rpc_ret; @@ -348,7 +361,8 @@ static hal_error_t pkey_remote_load(const hal_client_handle_t client, const hal_key_flags_t flags) { uint8_t outbuf[nargs(8) + pad(name_len) + pad(der_len)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -379,7 +393,8 @@ static hal_error_t pkey_remote_find(const hal_client_handle_t client, const hal_key_flags_t flags) { uint8_t outbuf[nargs(6) + pad(name_len)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -409,7 +424,8 @@ static hal_error_t pkey_remote_generate_rsa(const hal_client_handle_t client, const hal_key_flags_t flags) { uint8_t outbuf[nargs(7) + pad(name_len) + pad(exp_len)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -439,7 +455,8 @@ static hal_error_t pkey_remote_generate_ec(const hal_client_handle_t client, const hal_key_flags_t flags) { uint8_t outbuf[nargs(6) + pad(name_len)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -463,7 +480,8 @@ static hal_error_t pkey_remote_generate_ec(const hal_client_handle_t client, static hal_error_t pkey_remote_close(const hal_pkey_handle_t pkey) { uint8_t outbuf[nargs(2)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(1)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(1)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -480,7 +498,8 @@ static hal_error_t pkey_remote_close(const hal_pkey_handle_t pkey) static hal_error_t pkey_remote_delete(const hal_pkey_handle_t pkey) { uint8_t outbuf[nargs(2)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(1)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(1)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -498,7 +517,8 @@ static hal_error_t pkey_remote_get_key_type(const hal_pkey_handle_t pkey, hal_key_type_t *type) { uint8_t outbuf[nargs(2)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); uint32_t type32; hal_error_t rpc_ret; @@ -521,7 +541,8 @@ static hal_error_t pkey_remote_get_key_flags(const hal_pkey_handle_t pkey, hal_key_flags_t *flags) { uint8_t outbuf[nargs(2)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); uint32_t flags32; hal_error_t rpc_ret; @@ -543,7 +564,8 @@ static hal_error_t pkey_remote_get_key_flags(const hal_pkey_handle_t pkey, static size_t pkey_remote_get_public_key_len(const hal_pkey_handle_t pkey) { uint8_t outbuf[nargs(2)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); uint32_t len32; hal_error_t rpc_ret; @@ -567,7 +589,8 @@ static hal_error_t pkey_remote_get_public_key(const hal_pkey_handle_t pkey, uint8_t *der, size_t *der_len, const size_t der_max) { uint8_t outbuf[nargs(3)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2) + pad(der_max)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2) + pad(der_max)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); uint32_t dlen32 = der_max; hal_error_t rpc_ret; @@ -594,7 +617,8 @@ static hal_error_t pkey_remote_sign(const hal_session_handle_t session, uint8_t * signature, size_t *signature_len, const size_t signature_max) { uint8_t outbuf[nargs(6) + pad(input_len)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2) + pad(signature_max)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2) + pad(signature_max)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); uint32_t slen32 = signature_max; hal_error_t rpc_ret; @@ -624,7 +648,8 @@ static hal_error_t pkey_remote_verify(const hal_session_handle_t session, const uint8_t * const signature, const size_t signature_len) { uint8_t outbuf[nargs(6) + pad(input_len) + pad(signature_len)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(1)], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(1)]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); hal_error_t rpc_ret; @@ -642,7 +667,7 @@ static hal_error_t pkey_remote_verify(const hal_session_handle_t session, return rpc_ret; } -static hal_error_t hal_xdr_decode_pkey_info(uint8_t **iptr, const uint8_t * const ilimit, hal_pkey_info_t *info) +static hal_error_t hal_xdr_decode_pkey_info(const uint8_t **iptr, const uint8_t * const ilimit, hal_pkey_info_t *info) { uint32_t i32; @@ -659,7 +684,8 @@ static hal_error_t pkey_remote_list(hal_pkey_info_t *result, hal_key_flags_t flags) { uint8_t outbuf[nargs(3)], *optr = outbuf, *olimit = outbuf + sizeof(outbuf); - uint8_t inbuf[nargs(2) + pad(result_max * sizeof(hal_pkey_info_t))], *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); + uint8_t inbuf[nargs(2) + pad(result_max * sizeof(hal_pkey_info_t))]; + const uint8_t *iptr = inbuf, *ilimit = inbuf + sizeof(inbuf); size_t ilen = sizeof(inbuf); uint32_t len; hal_error_t ret, rpc_ret; diff --git a/rpc_server.c b/rpc_server.c index d64603c..7e7a6c2 100644 --- a/rpc_server.c +++ b/rpc_server.c @@ -44,7 +44,7 @@ #define pad(n) (((n) + 3) & ~3) -static hal_error_t get_version(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t get_version(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { uint32_t version; @@ -58,7 +58,7 @@ static hal_error_t get_version(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t get_random(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t get_random(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { uint32_t length; @@ -82,12 +82,12 @@ static hal_error_t get_random(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t set_pin(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t set_pin(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_client_handle_t client; uint32_t user; - uint8_t *pin; + const uint8_t *pin; uint32_t pin_len; hal_error_t ret; @@ -100,12 +100,12 @@ static hal_error_t set_pin(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t login(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t login(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_client_handle_t client; uint32_t user; - uint8_t *pin; + const uint8_t *pin; uint32_t pin_len; hal_error_t ret; @@ -118,7 +118,7 @@ static hal_error_t login(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t logout(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t logout(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_client_handle_t client; @@ -131,7 +131,7 @@ static hal_error_t logout(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t logout_all(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t logout_all(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_error_t ret; @@ -141,7 +141,7 @@ static hal_error_t logout_all(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t is_logged_in(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t is_logged_in(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_client_handle_t client; @@ -156,7 +156,7 @@ static hal_error_t is_logged_in(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t hash_get_digest_len(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t hash_get_digest_len(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { uint32_t alg; @@ -172,7 +172,7 @@ static hal_error_t hash_get_digest_len(uint8_t **iptr, const uint8_t * const ili return ret; } -static hal_error_t hash_get_digest_algorithm_id(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t hash_get_digest_algorithm_id(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { uint32_t alg; @@ -203,7 +203,7 @@ static hal_error_t hash_get_digest_algorithm_id(uint8_t **iptr, const uint8_t * return ret; } -static hal_error_t hash_get_algorithm(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t hash_get_algorithm(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_hash_handle_t hash; @@ -219,14 +219,14 @@ static hal_error_t hash_get_algorithm(uint8_t **iptr, const uint8_t * const ilim return ret; } -static hal_error_t hash_initialize(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t hash_initialize(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_client_handle_t client; hal_session_handle_t session; hal_hash_handle_t hash; uint32_t alg; - uint8_t *key; + const uint8_t *key; uint32_t key_len; hal_error_t ret; @@ -242,11 +242,11 @@ static hal_error_t hash_initialize(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t hash_update(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t hash_update(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_hash_handle_t hash; - uint8_t *data; + const uint8_t *data; uint32_t length; hal_error_t ret; @@ -258,7 +258,7 @@ static hal_error_t hash_update(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t hash_finalize(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t hash_finalize(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_hash_handle_t hash; @@ -283,7 +283,7 @@ static hal_error_t hash_finalize(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t pkey_load(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_load(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_client_handle_t client; @@ -291,7 +291,7 @@ static hal_error_t pkey_load(uint8_t **iptr, const uint8_t * const ilimit, hal_pkey_handle_t pkey; uint32_t type; uint32_t curve; - uint8_t *name, *der; + const uint8_t *name, *der; uint32_t name_len, der_len; hal_key_flags_t flags; hal_error_t ret; @@ -311,14 +311,14 @@ static hal_error_t pkey_load(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t pkey_find(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_find(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_client_handle_t client; hal_session_handle_t session; hal_pkey_handle_t pkey; uint32_t type; - uint8_t *name; + const uint8_t *name; uint32_t name_len; hal_key_flags_t flags; hal_error_t ret; @@ -336,16 +336,16 @@ static hal_error_t pkey_find(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t pkey_generate_rsa(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_generate_rsa(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_client_handle_t client; hal_session_handle_t session; hal_pkey_handle_t pkey; - uint8_t *name; + const uint8_t *name; uint32_t name_len; uint32_t key_len; - uint8_t *exp; + const uint8_t *exp; uint32_t exp_len; hal_key_flags_t flags; hal_error_t ret; @@ -364,13 +364,13 @@ static hal_error_t pkey_generate_rsa(uint8_t **iptr, const uint8_t * const ilimi return ret; } -static hal_error_t pkey_generate_ec(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_generate_ec(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_client_handle_t client; hal_session_handle_t session; hal_pkey_handle_t pkey; - uint8_t *name; + const uint8_t *name; uint32_t name_len; uint32_t curve; hal_key_flags_t flags; @@ -389,7 +389,7 @@ static hal_error_t pkey_generate_ec(uint8_t **iptr, const uint8_t * const ilimit return ret; } -static hal_error_t pkey_close(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_close(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_pkey_handle_t pkey; @@ -402,7 +402,7 @@ static hal_error_t pkey_close(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t pkey_delete(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_delete(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_pkey_handle_t pkey; @@ -415,7 +415,7 @@ static hal_error_t pkey_delete(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -static hal_error_t pkey_get_key_type(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_get_key_type(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_pkey_handle_t pkey; @@ -431,7 +431,7 @@ static hal_error_t pkey_get_key_type(uint8_t **iptr, const uint8_t * const ilimi return ret; } -static hal_error_t pkey_get_key_flags(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_get_key_flags(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_pkey_handle_t pkey; @@ -447,7 +447,7 @@ static hal_error_t pkey_get_key_flags(uint8_t **iptr, const uint8_t * const ilim return ret; } -static hal_error_t pkey_get_public_key_len(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_get_public_key_len(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_pkey_handle_t pkey; @@ -462,7 +462,7 @@ static hal_error_t pkey_get_public_key_len(uint8_t **iptr, const uint8_t * const return HAL_OK; } -static hal_error_t pkey_get_public_key(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_get_public_key(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_pkey_handle_t pkey; @@ -493,13 +493,13 @@ static hal_error_t pkey_get_public_key(uint8_t **iptr, const uint8_t * const ili return ret; } -static hal_error_t pkey_remote_sign(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_remote_sign(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_session_handle_t session; hal_pkey_handle_t pkey; hal_hash_handle_t hash; - uint8_t *input; + const uint8_t *input; uint32_t input_len; uint32_t sig_max; size_t sig_len; @@ -527,15 +527,15 @@ static hal_error_t pkey_remote_sign(uint8_t **iptr, const uint8_t * const ilimit return ret; } -static hal_error_t pkey_remote_verify(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_remote_verify(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { hal_session_handle_t session; hal_pkey_handle_t pkey; hal_hash_handle_t hash; - uint8_t *input; + const uint8_t *input; uint32_t input_len; - uint8_t *sig; + const uint8_t *sig; uint32_t sig_len; hal_error_t ret; @@ -564,7 +564,7 @@ static hal_error_t hal_xdr_encode_pkey_info(uint8_t **optr, const uint8_t * cons } -static hal_error_t pkey_list(uint8_t **iptr, const uint8_t * const ilimit, +static hal_error_t pkey_list(const uint8_t **iptr, const uint8_t * const ilimit, uint8_t **optr, const uint8_t * const olimit) { uint8_t *optr_orig = *optr; @@ -593,10 +593,11 @@ static hal_error_t pkey_list(uint8_t **iptr, const uint8_t * const ilimit, return ret; } -void hal_rpc_server_dispatch(const uint8_t * const ibuf, const size_t ilen, uint8_t * const obuf, size_t * const olen) +void hal_rpc_server_dispatch(const uint8_t * const ibuf, const size_t ilen, + uint8_t * const obuf, size_t * const olen) { - uint8_t * iptr = ibuf; - uint8_t * ilimit = ibuf + ilen; + const uint8_t * iptr = ibuf; + const uint8_t * ilimit = ibuf + ilen; uint8_t * optr = obuf + 4; /* reserve 4 bytes for return code */ uint8_t * olimit = obuf + *olen; uint32_t rpc_func_num; @@ -78,7 +78,7 @@ hal_error_t hal_xdr_encode_int(uint8_t ** const outbuf, const uint8_t * const li return HAL_OK; } -hal_error_t hal_xdr_decode_int(uint8_t **inbuf, const uint8_t * const limit, uint32_t *value) +hal_error_t hal_xdr_decode_int(const uint8_t ** const inbuf, const uint8_t * const limit, uint32_t *value) { /* arg checks */ if (inbuf == NULL || *inbuf == NULL || limit == NULL || value == NULL) @@ -132,11 +132,11 @@ hal_error_t hal_xdr_encode_buffer(uint8_t **outbuf, const uint8_t * const limit, /* This version returns a pointer to the data in the input buffer. * It is used in the rpc server. */ -hal_error_t hal_xdr_decode_buffer_in_place(uint8_t **inbuf, const uint8_t * const limit, uint8_t ** const value, uint32_t * const len) +hal_error_t hal_xdr_decode_buffer_in_place(const uint8_t **inbuf, const uint8_t * const limit, const uint8_t ** const value, uint32_t * const len) { hal_error_t ret; uint32_t xdr_len; - uint8_t *orig_inbuf = *inbuf; + const uint8_t *orig_inbuf = *inbuf; /* arg checks */ if (inbuf == NULL || *inbuf == NULL || limit == NULL || value == NULL || len == NULL) @@ -170,11 +170,11 @@ hal_error_t hal_xdr_decode_buffer_in_place(uint8_t **inbuf, const uint8_t * cons /* This version copies the data to the user-supplied buffer. * It is used in the rpc client. */ -hal_error_t hal_xdr_decode_buffer(uint8_t **inbuf, const uint8_t * const limit, uint8_t * const value, uint32_t * const len) +hal_error_t hal_xdr_decode_buffer(const uint8_t **inbuf, const uint8_t * const limit, uint8_t * const value, uint32_t * const len) { hal_error_t ret; - uint8_t *vptr; - uint8_t *orig_inbuf = *inbuf; + const uint8_t *vptr; + const uint8_t *orig_inbuf = *inbuf; uint32_t xdr_len; if ((ret = hal_xdr_decode_buffer_in_place(inbuf, limit, &vptr, &xdr_len)) == HAL_OK) { diff --git a/xdr_internal.h b/xdr_internal.h index 00793b0..921b991 100644 --- a/xdr_internal.h +++ b/xdr_internal.h @@ -43,7 +43,7 @@ hal_error_t hal_xdr_encode_int(uint8_t ** const outbuf, const uint8_t * const limit, const uint32_t value); -hal_error_t hal_xdr_decode_int(uint8_t ** const inbuf, +hal_error_t hal_xdr_decode_int(const uint8_t ** const inbuf, const uint8_t * const limit, uint32_t * const value); @@ -52,12 +52,12 @@ hal_error_t hal_xdr_encode_buffer(uint8_t ** const outbuf, const uint8_t * const value, const uint32_t len); -hal_error_t hal_xdr_decode_buffer_in_place(uint8_t ** const inbuf, +hal_error_t hal_xdr_decode_buffer_in_place(const uint8_t ** const inbuf, const uint8_t * const limit, - uint8_t ** const vptr, + const uint8_t ** const vptr, uint32_t * const len); -hal_error_t hal_xdr_decode_buffer(uint8_t ** const inbuf, +hal_error_t hal_xdr_decode_buffer(const uint8_t ** const inbuf, const uint8_t * const limit, uint8_t * const value, uint32_t * const len); |