From 5cee716555db92942c5b11c824839bb00aaf35b9 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Mon, 29 May 2017 00:44:18 -0400 Subject: Debug per-session keys. --- ks_volatile.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'ks_volatile.c') 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) { @@ -184,6 +184,22 @@ static hal_error_t ks_volatile_test_owner(hal_ks_t *ks, const return HAL_ERROR_KEY_NOT_FOUND; } +/* + * 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 }; -- cgit v1.2.3