Skip to content

Commit

Permalink
Adding key to qkd_get_key_id
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrotega committed Nov 12, 2024
1 parent ecdf025 commit 18b8234
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/libstrongswan/plugins/qkd/qkd_etsi_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ bool qkd_set_key_id(qkd_handle_t handle, chunk_t key_id)
return TRUE;
}

bool qkd_get_key_id(qkd_handle_t handle, chunk_t *key_id)
bool qkd_get_key_id(qkd_handle_t handle, chunk_t *key_id, chunk_t *key)
{
DBG1(DBG_LIB, "QKD_plugin: qkd_get_key_id()");
if (!handle || !handle->is_open || !key_id)
Expand Down Expand Up @@ -238,10 +238,10 @@ bool qkd_get_key_id(qkd_handle_t handle, chunk_t *key_id)
// DBG1(DBG_LIB, "\tKey ID chunk: %s", handle->key_id);
// DBG1(DBG_LIB, "\tKey ID chunk: %s", *key_id);

// Replace handle's key_id with new one
*key = chunk_clone(chunk_create(b_key, QKD_KEY_SIZE));
chunk_free(&handle->key);
handle->key = chunk_clone(chunk_create(b_key, QKD_KEY_SIZE));
DBG1(DBG_LIB, "\tKey chunk: %s", handle->key);
handle->key = chunk_clone(*key);
DBG1(DBG_LIB, "\tKey chunk: %s", handle->key.ptr);

//qkd_print_key_id("QKD_plugin: Alice sending", *key_id);
return TRUE;
Expand Down
2 changes: 1 addition & 1 deletion src/libstrongswan/plugins/qkd/qkd_etsi_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ typedef struct qkd_handle_t {
bool qkd_open(qkd_handle_t *handle);
bool qkd_close(qkd_handle_t handle);
bool qkd_get_key(qkd_handle_t handle, chunk_t *key);
bool qkd_get_key_id(qkd_handle_t handle, chunk_t *key_id);
bool qkd_get_key_id(qkd_handle_t handle, chunk_t *key_id, chunk_t *key);
bool qkd_set_key_id(qkd_handle_t handle, chunk_t key_id);
bool qkd_generate_random_key_id(chunk_t *key_id);
void qkd_print_key(const char *prefix, chunk_t key);
Expand Down
4 changes: 3 additions & 1 deletion src/libstrongswan/plugins/qkd/qkd_kex.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ METHOD(key_exchange_t, get_public_key, bool,
{
DBG1(DBG_LIB, "QKD_plugin: Alice generating key ID");
chunk_t key_id;
if (!qkd_get_key_id(this->handle, &key_id))
chunk_t key;
if (!qkd_get_key_id(this->handle, &key_id, &key))
{
DBG1(DBG_LIB, "QKD_plugin: failed to get key ID");
return FALSE;
}
*value = chunk_clone(key_id);
chunk_clear(&key_id);
chunk_clear(&key);

DBG1(DBG_LIB, "\t[get_public_key] ID: %s", this->handle->key_id.ptr);
DBG1(DBG_LIB, "\t[get_public_key] Key: %s", this->handle->key.ptr);
Expand Down

0 comments on commit 18b8234

Please sign in to comment.