aboutsummaryrefslogtreecommitdiff
path: root/ks_volatile.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2017-05-29 00:44:18 -0400
committerRob Austein <sra@hactrn.net>2017-05-29 00:44:18 -0400
commit5cee716555db92942c5b11c824839bb00aaf35b9 (patch)
tree6003da5d6b3a7f5994a6db24ba1a6d1594f62ae9 /ks_volatile.c
parent9e20f2fa42bcd493548bf7764958848ab72d1255 (diff)
Debug per-session keys.
Diffstat (limited to 'ks_volatile.c')
-rw-r--r--ks_volatile.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/ks_volatile.c b/ks_volatile.c
index c1ea72d..0b39133 100644
--- a/ks_volatile.c
+++ b/ks_volatile.c
@@ -169,8 +169,8 @@ static hal_error_t ks_volatile_set_owner(hal_ks_t *ks,
* Test key ownership.
*/
-static hal_error_t ks_volatile_test_owner(hal_ks_t *ks, const
- unsigned blockno,
+static hal_error_t ks_volatile_test_owner(hal_ks_t *ks,
+ const unsigned blockno,
const hal_client_handle_t client,
const hal_session_handle_t session)
{
@@ -185,6 +185,22 @@ static hal_error_t ks_volatile_test_owner(hal_ks_t *ks, const
}
/*
+ * Copy key ownership.
+ */
+
+static hal_error_t ks_volatile_copy_owner(hal_ks_t *ks,
+ const unsigned source,
+ const unsigned target)
+{
+ if (ks != hal_ks_volatile || db->keys == NULL || source >= ks->size || target >= ks->size)
+ return HAL_ERROR_IMPOSSIBLE;
+
+ db->keys[target].client = db->keys[source].client;
+ db->keys[target].session = db->keys[source].session;
+ return HAL_OK;
+}
+
+/*
* Initialize keystore.
*/
@@ -217,6 +233,8 @@ static hal_error_t ks_volatile_init(hal_ks_t *ks, const int alloc)
if ((err = hal_ks_init_common(ks)) != HAL_OK)
goto done;
+ ks->per_session = 1;
+
err = HAL_OK;
done:
@@ -238,7 +256,8 @@ static const hal_ks_driver_t ks_volatile_driver = {
.erase = ks_volatile_erase,
.erase_maybe = ks_volatile_erase, /* sic */
.set_owner = ks_volatile_set_owner,
- .test_owner = ks_volatile_test_owner
+ .test_owner = ks_volatile_test_owner,
+ .copy_owner = ks_volatile_copy_owner
};
static ks_volatile_db_t _db = { .ks.driver = &ks_volatile_driver };