Add context id getter to TKM DH implementation
This commit is contained in:
committed by
Tobias Brunner
parent
ba0d7d9a76
commit
528fc21ffe
@@ -103,6 +103,12 @@ METHOD(diffie_hellman_t, destroy, void,
|
|||||||
free(this);
|
free(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
METHOD(tkm_diffie_hellman_t, get_id, dh_id_type,
|
||||||
|
private_tkm_diffie_hellman_t *this)
|
||||||
|
{
|
||||||
|
return this->context_id;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Described in header.
|
* Described in header.
|
||||||
*/
|
*/
|
||||||
@@ -119,6 +125,7 @@ tkm_diffie_hellman_t *tkm_diffie_hellman_create(diffie_hellman_group_t group)
|
|||||||
.get_dh_group = _get_dh_group,
|
.get_dh_group = _get_dh_group,
|
||||||
.destroy = _destroy,
|
.destroy = _destroy,
|
||||||
},
|
},
|
||||||
|
.get_id = _get_id,
|
||||||
},
|
},
|
||||||
.group = group,
|
.group = group,
|
||||||
.context_id = tkm->idmgr->acquire_id(tkm->idmgr, TKM_CTX_DH),
|
.context_id = tkm->idmgr->acquire_id(tkm->idmgr, TKM_CTX_DH),
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
typedef struct tkm_diffie_hellman_t tkm_diffie_hellman_t;
|
typedef struct tkm_diffie_hellman_t tkm_diffie_hellman_t;
|
||||||
|
|
||||||
#include <library.h>
|
#include <library.h>
|
||||||
|
#include <tkm/types.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* diffie_hellman_t implementation using the trusted key manager.
|
* diffie_hellman_t implementation using the trusted key manager.
|
||||||
@@ -30,6 +31,14 @@ struct tkm_diffie_hellman_t {
|
|||||||
* Implements diffie_hellman_t interface.
|
* Implements diffie_hellman_t interface.
|
||||||
*/
|
*/
|
||||||
diffie_hellman_t dh;
|
diffie_hellman_t dh;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Diffie-Hellman context id.
|
||||||
|
*
|
||||||
|
* @return id of this DH context.
|
||||||
|
*/
|
||||||
|
dh_id_type (*get_id)(tkm_diffie_hellman_t * const this);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ START_TEST(test_dh_creation)
|
|||||||
|
|
||||||
dh = tkm_diffie_hellman_create(MODP_4096_BIT);
|
dh = tkm_diffie_hellman_create(MODP_4096_BIT);
|
||||||
fail_if(!dh, "MODP_4096 not created");
|
fail_if(!dh, "MODP_4096 not created");
|
||||||
|
fail_if(!dh->get_id(dh), "Invalid context id (0)");
|
||||||
|
|
||||||
dh->dh.destroy(&dh->dh);
|
dh->dh.destroy(&dh->dh);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user