aboutsummaryrefslogtreecommitdiff
path: root/rpc_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'rpc_api.c')
-rw-r--r--rpc_api.c47
1 files changed, 36 insertions, 11 deletions
diff --git a/rpc_api.c b/rpc_api.c
index 6ffd7a0..1a2d268 100644
--- a/rpc_api.c
+++ b/rpc_api.c
@@ -75,7 +75,9 @@ static inline int check_pkey_flags(const hal_key_flags_t flags)
return (flags &~ (HAL_KEY_FLAG_USAGE_DIGITALSIGNATURE |
HAL_KEY_FLAG_USAGE_KEYENCIPHERMENT |
HAL_KEY_FLAG_USAGE_DATAENCIPHERMENT |
- HAL_KEY_FLAG_TOKEN)) == 0;
+ HAL_KEY_FLAG_TOKEN |
+ HAL_KEY_FLAG_PUBLIC |
+ HAL_KEY_FLAG_EXPORTABLE)) == 0;
}
static inline int check_pkey_type_curve_flags(const hal_key_type_t type,
@@ -216,26 +218,23 @@ hal_error_t hal_rpc_hash_finalize(const hal_hash_handle_t hash,
hal_error_t hal_rpc_pkey_load(const hal_client_handle_t client,
const hal_session_handle_t session,
hal_pkey_handle_t *pkey,
- const hal_key_type_t type,
- const hal_curve_name_t curve,
hal_uuid_t *name,
const uint8_t * const der, const size_t der_len,
const hal_key_flags_t flags)
{
- if (pkey == NULL || name == NULL || der == NULL || der_len == 0 || !check_pkey_type_curve_flags(type, curve, flags))
+ if (pkey == NULL || name == NULL || der == NULL || der_len == 0 || !check_pkey_flags(flags))
return HAL_ERROR_BAD_ARGUMENTS;
- return hal_rpc_pkey_dispatch->load(client, session, pkey, type, curve, name, der, der_len, flags);
+ return hal_rpc_pkey_dispatch->load(client, session, pkey, name, der, der_len, flags);
}
hal_error_t hal_rpc_pkey_open(const hal_client_handle_t client,
const hal_session_handle_t session,
hal_pkey_handle_t *pkey,
- const hal_uuid_t * const name,
- const hal_key_flags_t flags)
+ const hal_uuid_t * const name)
{
if (pkey == NULL || name == NULL)
return HAL_ERROR_BAD_ARGUMENTS;
- return hal_rpc_pkey_dispatch->open(client, session, pkey, name, flags);
+ return hal_rpc_pkey_dispatch->open(client, session, pkey, name);
}
hal_error_t hal_rpc_pkey_generate_rsa(const hal_client_handle_t client,
@@ -338,16 +337,18 @@ hal_error_t hal_rpc_pkey_match(const hal_client_handle_t client,
const hal_session_handle_t session,
const hal_key_type_t type,
const hal_curve_name_t curve,
+ const hal_key_flags_t mask,
const hal_key_flags_t flags,
const hal_pkey_attribute_t *attributes,
const unsigned attributes_len,
+ unsigned *state,
hal_uuid_t *result,
unsigned *result_len,
const unsigned result_max,
const hal_uuid_t * const previous_uuid)
{
if ((attributes == NULL && attributes_len > 0) || previous_uuid == NULL ||
- result == NULL || result_len == NULL || result_max == 0)
+ state == NULL || result == NULL || result_len == NULL || result_max == 0)
return HAL_ERROR_BAD_ARGUMENTS;
if (attributes != NULL)
@@ -355,9 +356,9 @@ hal_error_t hal_rpc_pkey_match(const hal_client_handle_t client,
if (attributes[i].value == NULL)
return HAL_ERROR_BAD_ARGUMENTS;
- return hal_rpc_pkey_dispatch->match(client, session, type, curve, flags,
+ return hal_rpc_pkey_dispatch->match(client, session, type, curve, mask, flags,
attributes, attributes_len,
- result, result_len, result_max, previous_uuid);
+ state, result, result_len, result_max, previous_uuid);
}
hal_error_t hal_rpc_pkey_set_attributes(const hal_pkey_handle_t pkey,
@@ -381,6 +382,30 @@ hal_error_t hal_rpc_pkey_get_attributes(const hal_pkey_handle_t pkey,
attributes_buffer, attributes_buffer_len);
}
+hal_error_t hal_rpc_pkey_export(const hal_pkey_handle_t pkey,
+ const hal_pkey_handle_t kekek,
+ uint8_t *pkcs8, size_t *pkcs8_len, const size_t pkcs8_max,
+ uint8_t *kek, size_t *kek_len, const size_t kek_max)
+{
+ if (pkcs8 == NULL || pkcs8_len == NULL || kek == NULL || kek_len == NULL || kek_max <= KEK_LENGTH)
+ return HAL_ERROR_BAD_ARGUMENTS;
+ return hal_rpc_pkey_dispatch->export(pkey, kekek, pkcs8, pkcs8_len, pkcs8_max, kek, kek_len, kek_max);
+}
+
+hal_error_t hal_rpc_pkey_import(const hal_client_handle_t client,
+ const hal_session_handle_t session,
+ hal_pkey_handle_t *pkey,
+ hal_uuid_t *name,
+ const hal_pkey_handle_t kekek,
+ const uint8_t * const pkcs8, const size_t pkcs8_len,
+ const uint8_t * const kek, const size_t kek_len,
+ const hal_key_flags_t flags)
+{
+ if (pkey == NULL || name == NULL || pkcs8 == NULL || kek == NULL || kek_len <= 2)
+ return HAL_ERROR_BAD_ARGUMENTS;
+ return hal_rpc_pkey_dispatch->import(client, session, pkey, name, kekek, pkcs8, pkcs8_len, kek, kek_len, flags);
+}
+
/*
* Local variables:
* indent-tabs-mode: nil