Add create_nonce_gen function to keymat interface
authorAdrian-Ken Rueegsegger <ken@codelabs.ch>
Wed, 2 May 2012 15:49:35 +0000 (17:49 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 18 May 2012 06:15:41 +0000 (08:15 +0200)
This function returns a nonce generator object.

src/libcharon/sa/ikev1/keymat_v1.c
src/libcharon/sa/ikev2/keymat_v2.c
src/libcharon/sa/keymat.h

index 00de6f0..000c73a 100644 (file)
@@ -985,6 +985,12 @@ METHOD(keymat_t, create_dh, diffie_hellman_t*,
        return lib->crypto->create_dh(lib->crypto, group);
 }
 
+METHOD(keymat_t, create_nonce_gen, nonce_gen_t*,
+       private_keymat_v1_t *this)
+{
+       return lib->crypto->create_nonce_gen(lib->crypto);
+}
+
 METHOD(keymat_t, get_aead, aead_t*,
        private_keymat_v1_t *this, bool in)
 {
@@ -1019,6 +1025,7 @@ keymat_v1_t *keymat_v1_create(bool initiator)
                        .keymat = {
                                .get_version = _get_version,
                                .create_dh = _create_dh,
+                               .create_nonce_gen = _create_nonce_gen,
                                .get_aead = _get_aead,
                                .destroy = _destroy,
                        },
index 3adceee..1f25257 100644 (file)
@@ -83,6 +83,12 @@ METHOD(keymat_t, create_dh, diffie_hellman_t*,
        return lib->crypto->create_dh(lib->crypto, group);
 }
 
+METHOD(keymat_t, create_nonce_gen, nonce_gen_t*,
+       private_keymat_v2_t *this)
+{
+       return lib->crypto->create_nonce_gen(lib->crypto);
+}
+
 /**
  * Derive IKE keys for a combined AEAD algorithm
  */
@@ -571,6 +577,7 @@ keymat_v2_t *keymat_v2_create(bool initiator)
                        .keymat = {
                                .get_version = _get_version,
                                .create_dh = _create_dh,
+                               .create_nonce_gen = _create_nonce_gen,
                                .get_aead = _get_aead,
                                .destroy = _destroy,
                        },
index 8bfe796..a64be23 100644 (file)
@@ -61,6 +61,16 @@ struct keymat_t {
        diffie_hellman_t* (*create_dh)(keymat_t *this,
                                                                   diffie_hellman_group_t group);
 
+       /**
+        * Create a nonce generator object.
+        *
+        * The nonce generator can be used to create nonces needed during IKE/CHILD
+        * SA establishment or rekeying.
+        *
+        * @return                              nonce generator object
+        */
+       nonce_gen_t* (*create_nonce_gen)(keymat_t *this);
+
        /*
         * Get a AEAD transform to en-/decrypt and sign/verify IKE messages.
         *