]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Use id manager to acquire nonce context id
authorReto Buerki <reet@codelabs.ch>
Tue, 7 Aug 2012 15:46:45 +0000 (17:46 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 19 Mar 2013 14:23:45 +0000 (15:23 +0100)
src/charon-tkm/src/tkm/tkm_nonceg.c

index 9ac32a7c7f61bbbe09d71d879b53486cc93af4b3..90b033f9f6aad063ba3452cfd433465e775b561c 100644 (file)
  * 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;
 }