diff options
author | Reto Buerki <reet@codelabs.ch> | 2012-08-07 17:46:45 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2013-03-19 15:23:45 +0100 |
commit | c38459d77d4400f4106781fdbf071c7d16793288 (patch) | |
tree | 6a1b4134232e0235398cba8ab58804728b769a55 /src | |
parent | f3cd7f50dea0bfc9806322eeacfae6b19a350272 (diff) | |
download | strongswan-c38459d77d4400f4106781fdbf071c7d16793288.tar.bz2 strongswan-c38459d77d4400f4106781fdbf071c7d16793288.tar.xz |
Use id manager to acquire nonce context id
Diffstat (limited to 'src')
-rw-r--r-- | src/charon-tkm/src/tkm/tkm_nonceg.c | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/charon-tkm/src/tkm/tkm_nonceg.c b/src/charon-tkm/src/tkm/tkm_nonceg.c index 9ac32a7c7..90b033f9f 100644 --- a/src/charon-tkm/src/tkm/tkm_nonceg.c +++ b/src/charon-tkm/src/tkm/tkm_nonceg.c @@ -14,11 +14,12 @@ * for more details. */ -#include "tkm_nonceg.h" - #include <tkm/client.h> #include <tkm/constants.h> +#include "tkm.h" +#include "tkm_nonceg.h" + typedef struct private_tkm_nonceg_t private_tkm_nonceg_t; /** @@ -31,16 +32,18 @@ struct private_tkm_nonceg_t { */ tkm_nonceg_t public; + /** + * Context id. + */ + nc_id_type context_id; + }; METHOD(nonce_gen_t, get_nonce, bool, private_tkm_nonceg_t *this, size_t size, u_int8_t *buffer) { nonce_type nonce; - - /* request nonce from TKM, the context is not yet used */ - const result_type result = ike_nc_create(1, size, &nonce); - if (result != TKM_OK) + if (ike_nc_create(this->context_id, size, &nonce) != TKM_OK) { return FALSE; } @@ -77,7 +80,14 @@ tkm_nonceg_t *tkm_nonceg_create() .destroy = _destroy, }, }, + .context_id = tkm->idmgr->acquire_id(tkm->idmgr, TKM_CTX_NONCE), ); + if (!this->context_id) + { + free(this); + return NULL; + } + return &this->public; } |