From f4b6098c2359a75cc16275aad7ba2bf001261dea Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Sun, 20 Nov 2016 21:15:13 -0500 Subject: Move UUID utilities to hal.h; change attribute values to (const void *). --- hal.h | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'hal.h') diff --git a/hal.h b/hal.h index df330ae..ee27649 100644 --- a/hal.h +++ b/hal.h @@ -39,6 +39,7 @@ #include #include #include +#include /* * A handy macro from cryptlib. @@ -566,6 +567,26 @@ extern hal_error_t hal_ecdsa_verify(const hal_core_t *core, const uint8_t * const hash, const size_t hash_len, const uint8_t * const signature, const size_t signature_len); +/* + * UUID stuff. All UUIDs we use (or are likely to use) are type 4 "random" UUIDs + */ + +typedef struct { uint8_t uuid[16]; } hal_uuid_t; + +#define HAL_UUID_TEXT_SIZE (sizeof("00112233-4455-6677-8899-aabbccddeeff")) + +static inline int hal_uuid_cmp(const hal_uuid_t * const a, const hal_uuid_t * const b) +{ + return memcmp(a, b, sizeof(hal_uuid_t)); +} + +extern hal_error_t hal_uuid_gen(hal_uuid_t *uuid); + +extern hal_error_t hal_uuid_parse(hal_uuid_t *uuid, const char * const string); + +extern hal_error_t hal_uuid_format(const hal_uuid_t * const uuid, + char *buffer, const size_t buffer_len); + /* * Higher level RPC-based mechanism for working with HSM at arm's * length, using handles instead of direct access to the cores. @@ -689,8 +710,6 @@ extern hal_error_t hal_rpc_hash_finalize(const hal_hash_handle_t hash, * a session handle and which ones don't...). */ -typedef struct { uint8_t uuid[16]; } hal_uuid_t; - typedef struct { uint32_t handle; } hal_pkey_handle_t; typedef uint32_t hal_key_flags_t; @@ -762,7 +781,7 @@ extern hal_error_t hal_rpc_pkey_verify(const hal_pkey_handle_t pkey, typedef struct { uint32_t type; size_t length; - const uint8_t *value; + const void *value; } hal_rpc_pkey_attribute_t; extern hal_error_t hal_rpc_pkey_match(const hal_client_handle_t client, -- cgit v1.2.3