make use of the crypto_tester in the crypto_factory
[strongswan.git] / src / libstrongswan / crypto / crypto_factory.h
index c8c2bcc..f1ebcf9 100644 (file)
@@ -28,7 +28,9 @@ typedef struct crypto_factory_t crypto_factory_t;
 #include <crypto/signers/signer.h>
 #include <crypto/hashers/hasher.h>
 #include <crypto/prfs/prf.h>
+#include <crypto/rngs/rng.h>
 #include <crypto/diffie_hellman.h>
+#include <crypto/transform.h>
 
 /**
  * Constructor function for crypters
@@ -46,11 +48,16 @@ typedef signer_t* (*signer_constructor_t)(integrity_algorithm_t algo);
 typedef hasher_t* (*hasher_constructor_t)(hash_algorithm_t algo);
 
 /**
- * Constructor function for pseudo random fucntions
+ * Constructor function for pseudo random functions
  */
 typedef prf_t* (*prf_constructor_t)(pseudo_random_function_t algo);
 
 /**
+ * Constructor function for source of randomness
+ */
+typedef rng_t* (*rng_constructor_t)(rng_quality_t quality);
+
+/**
  * Constructor function for diffie hellman
  */
 typedef diffie_hellman_t* (*dh_constructor_t)(diffie_hellman_group_t group);
@@ -96,6 +103,14 @@ struct crypto_factory_t {
        prf_t* (*create_prf)(crypto_factory_t *this, pseudo_random_function_t algo);
        
        /**
+        * Create a source of randomness.
+        *
+        * @param quality               required randomness quality
+        * @return                              rng_t instance, NULL if no RNG with such a quality
+        */
+       rng_t* (*create_rng)(crypto_factory_t *this, rng_quality_t quality);
+       
+       /**
         * Create a diffie hellman instance.
         *
         * @param group                 diffie hellman group
@@ -176,6 +191,21 @@ struct crypto_factory_t {
        void (*remove_prf)(crypto_factory_t *this, prf_constructor_t create);
        
        /**
+        * Register a source of randomness.
+        *
+        * @param quality               quality of randomness this RNG serves
+        * @param create                constructor function for such a quality
+        */
+       void (*add_rng)(crypto_factory_t *this, rng_quality_t quality, rng_constructor_t create);
+       
+       /**
+        * Unregister a source of randomness.
+        *
+        * @param create                constructor function to unregister
+        */
+       void (*remove_rng)(crypto_factory_t *this, rng_constructor_t create);
+       
+       /**
         * Register a diffie hellman constructor.
         *
         * @param group                 dh group to constructor
@@ -193,9 +223,52 @@ struct crypto_factory_t {
        void (*remove_dh)(crypto_factory_t *this, dh_constructor_t create);
        
        /**
-     * Destroy a crypto_factory instance.
-     */
-    void (*destroy)(crypto_factory_t *this);
+        * Create an enumerator over all registered crypter algorithms.
+        *
+        * @return                              enumerator over encryption_algorithm_t
+        */
+       enumerator_t* (*create_crypter_enumerator)(crypto_factory_t *this);
+       
+       /**
+        * Create an enumerator over all registered signer algorithms.
+        *
+        * @return                              enumerator over integrity_algorithm_t
+        */
+       enumerator_t* (*create_signer_enumerator)(crypto_factory_t *this);
+       
+       /**
+        * Create an enumerator over all registered hasher algorithms.
+        *
+        * @return                              enumerator over hash_algorithm_t
+        */
+       enumerator_t* (*create_hasher_enumerator)(crypto_factory_t *this);
+       
+       /**
+        * Create an enumerator over all registered PRFs.
+        *
+        * @return                              enumerator over pseudo_random_function_t
+        */
+       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
+        */
+       enumerator_t* (*create_dh_enumerator)(crypto_factory_t *this);
+       
+       /**
+        * Add a test vector to the crypto factory.
+        *
+        * @param type                  type of the test vector
+        * @param ...                   pointer to a test vector, defined in crypto_tester.h
+        */
+       void (*add_test_vector)(crypto_factory_t *this, transform_type_t type, ...);
+       
+       /**
+        * Destroy a crypto_factory instance.
+        */
+       void (*destroy)(crypto_factory_t *this);
 };
 
 /**
@@ -203,4 +276,4 @@ struct crypto_factory_t {
  */
 crypto_factory_t *crypto_factory_create();
 
-#endif /* CRYPTO_FACTORY_H_ @}*/
+#endif /** CRYPTO_FACTORY_H_ @}*/