Add enumerator for registered nonce generators.
authorTobias Brunner <tobias@strongswan.org>
Wed, 16 May 2012 16:25:25 +0000 (18:25 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 18 May 2012 06:15:41 +0000 (08:15 +0200)
src/libstrongswan/crypto/crypto_factory.c
src/libstrongswan/crypto/crypto_factory.h

index a734171..bd4e05c 100644 (file)
@@ -808,7 +808,7 @@ METHOD(crypto_factory_t, create_prf_enumerator, enumerator_t*,
 }
 
 /**
- * Filter function to enumerate algorithm, not entry
+ * Filter function to enumerate group, not entry
  */
 static bool dh_filter(void *n, entry_t **entry, diffie_hellman_group_t *group,
                                          void *i2, const char **plugin_name)
@@ -825,7 +825,7 @@ METHOD(crypto_factory_t, create_dh_enumerator, enumerator_t*,
 }
 
 /**
- * Filter function to enumerate algorithm, not entry
+ * Filter function to enumerate strength, not entry
  */
 static bool rng_filter(void *n, entry_t **entry, rng_quality_t *quality,
                                           void *i2, const char **plugin_name)
@@ -840,6 +840,22 @@ METHOD(crypto_factory_t, create_rng_enumerator, enumerator_t*,
 {
        return create_enumerator(this, this->rngs, rng_filter);
 }
+
+/**
+ * Filter function to enumerate plugin name, not entry
+ */
+static bool nonce_gen_filter(void *n, entry_t **entry, const char **plugin_name)
+{
+       *plugin_name = (*entry)->plugin_name;
+       return TRUE;
+}
+
+METHOD(crypto_factory_t, create_nonce_gen_enumerator, enumerator_t*,
+       private_crypto_factory_t *this)
+{
+       return create_enumerator(this, this->nonce_gens, nonce_gen_filter);
+}
+
 METHOD(crypto_factory_t, add_test_vector, void,
        private_crypto_factory_t *this, transform_type_t type, void *vector)
 {
@@ -919,6 +935,7 @@ crypto_factory_t *crypto_factory_create()
                        .create_prf_enumerator = _create_prf_enumerator,
                        .create_dh_enumerator = _create_dh_enumerator,
                        .create_rng_enumerator = _create_rng_enumerator,
+                       .create_nonce_gen_enumerator = _create_nonce_gen_enumerator,
                        .add_test_vector = _add_test_vector,
                        .destroy = _destroy,
                },
index c944348..611ca0b 100644 (file)
@@ -303,53 +303,60 @@ struct crypto_factory_t {
        /**
         * Create an enumerator over all registered crypter algorithms.
         *
-        * @return                              enumerator over encryption_algorithm_t
+        * @return                              enumerator over encryption_algorithm_t, plugin
         */
        enumerator_t* (*create_crypter_enumerator)(crypto_factory_t *this);
 
        /**
         * Create an enumerator over all registered aead algorithms.
         *
-        * @return                              enumerator over encryption_algorithm_t
+        * @return                              enumerator over encryption_algorithm_t, plugin
         */
        enumerator_t* (*create_aead_enumerator)(crypto_factory_t *this);
 
        /**
         * Create an enumerator over all registered signer algorithms.
         *
-        * @return                              enumerator over integrity_algorithm_t
+        * @return                              enumerator over integrity_algorithm_t, plugin
         */
        enumerator_t* (*create_signer_enumerator)(crypto_factory_t *this);
 
        /**
         * Create an enumerator over all registered hasher algorithms.
         *
-        * @return                              enumerator over hash_algorithm_t
+        * @return                              enumerator over hash_algorithm_t, plugin
         */
        enumerator_t* (*create_hasher_enumerator)(crypto_factory_t *this);
 
        /**
         * Create an enumerator over all registered PRFs.
         *
-        * @return                              enumerator over pseudo_random_function_t
+        * @return                              enumerator over pseudo_random_function_t, plugin
         */
        enumerator_t* (*create_prf_enumerator)(crypto_factory_t *this);
 
        /**
         * Create an enumerator over all registered diffie hellman groups.
         *
-        * @return                              enumerator over diffie_hellman_group_t
+        * @return                              enumerator over diffie_hellman_group_t, plugin
         */
        enumerator_t* (*create_dh_enumerator)(crypto_factory_t *this);
 
        /**
         * Create an enumerator over all registered random generators.
         *
-        * @return                              enumerator over rng_quality_t
+        * @return                              enumerator over rng_quality_t, plugin
         */
        enumerator_t* (*create_rng_enumerator)(crypto_factory_t *this);
 
        /**
+        * Create an enumerator over all registered nonce generators.
+        *
+        * @return                              enumerator over plugin
+        */
+       enumerator_t* (*create_nonce_gen_enumerator)(crypto_factory_t *this);
+
+       /**
         * Add a test vector to the crypto factory.
         *
         * @param type                  type of the test vector