aboutsummaryrefslogtreecommitdiff
path: root/ks_volatile.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-11-14 18:02:07 -0500
committerRob Austein <sra@hactrn.net>2016-11-14 18:02:07 -0500
commitb448b28f538517556f3d35dee81dbf07d433df60 (patch)
tree42e9868767e80b2707d559fbcab442030a096e19 /ks_volatile.c
parentd6e9917d07ddb0a5f8218fecdcd8bda3a1104912 (diff)
More API cleanup: remove hal_rpc_pkey_list().
hal_rpc_pkey_list() was a simplistic solution that worked when the keystore only supported a handful of keys and we needed a quick temporary solution in time for a workshop. It doesn't handle large numbers of keys well, and while we could fix that, all of its functionality is now available via more robust API functions, so simplifying the API by deleting it seems best. Since this change required mucking with dispatch vectors yet again, it converts them to use C99 "designated initializer" syntax.
Diffstat (limited to 'ks_volatile.c')
-rw-r--r--ks_volatile.c62
1 files changed, 11 insertions, 51 deletions
diff --git a/ks_volatile.c b/ks_volatile.c
index 8767458..0ee19c8 100644
--- a/ks_volatile.c
+++ b/ks_volatile.c
@@ -345,45 +345,6 @@ static hal_error_t ks_delete(hal_ks_t *ks,
return HAL_OK;
}
-static hal_error_t ks_list(hal_ks_t *ks,
- hal_client_handle_t client,
- hal_session_handle_t session,
- hal_pkey_info_t *result,
- unsigned *result_len,
- const unsigned result_max)
-{
- if (ks == NULL || result == NULL || result_len == NULL)
- return HAL_ERROR_BAD_ARGUMENTS;
-
- ks_t *ksv = ks_to_ksv(ks);
-
- if (ksv->db == NULL)
- return HAL_ERROR_KEYSTORE_ACCESS;
-
- *result_len = 0;
-
- for (int i = 0; i < ksv->db->ksi.used; i++) {
- unsigned b = ksv->db->ksi.index[i];
-
- if (ksv->db->ksi.names[b].chunk > 0)
- continue;
-
- if (!key_visible_to_session(ksv, client, session, &ksv->db->keys[b]))
- continue;
-
- if (*result_len >= result_max)
- return HAL_ERROR_RESULT_TOO_LONG;
-
- result[i].name = ksv->db->ksi.names[b].name;
- result[i].type = ksv->db->keys[b].type;
- result[i].curve = ksv->db->keys[b].curve;
- result[i].flags = ksv->db->keys[b].flags;
- ++ *result_len;
- }
-
- return HAL_OK;
-}
-
static hal_error_t ks_match(hal_ks_t *ks,
hal_client_handle_t client,
hal_session_handle_t session,
@@ -397,7 +358,7 @@ static hal_error_t ks_match(hal_ks_t *ks,
const unsigned result_max,
const hal_uuid_t * const previous_uuid)
{
- if (ks == NULL || attributes == NULL ||
+ if (ks == NULL || (attributes == NULL && attributes_len > 0) ||
result == NULL || result_len == NULL || previous_uuid == NULL)
return HAL_ERROR_BAD_ARGUMENTS;
@@ -572,17 +533,16 @@ static hal_error_t ks_get_attributes(hal_ks_t *ks,
}
const hal_ks_driver_t hal_ks_volatile_driver[1] = {{
- ks_volatile_init,
- ks_volatile_shutdown,
- ks_volatile_open,
- ks_volatile_close,
- ks_store,
- ks_fetch,
- ks_delete,
- ks_list,
- ks_match,
- ks_set_attributes,
- ks_get_attributes
+ .init = ks_volatile_init,
+ .shutdown = ks_volatile_shutdown,
+ .open = ks_volatile_open,
+ .close = ks_volatile_close,
+ .store = ks_store,
+ .fetch = ks_fetch,
+ .delete = ks_delete,
+ .match = ks_match,
+ .set_attributes = ks_set_attributes,
+ .get_attributes = ks_get_attributes
}};
#endif /* STATIC_KS_VOLATILE_SLOTS > 0 */