summaryrefslogtreecommitdiff
path: root/src/libstrongswan/crypto
diff options
context:
space:
mode:
authorRené Mayrhofer <rene@mayrhofer.eu.org>2011-03-05 09:20:09 +0100
committerRené Mayrhofer <rene@mayrhofer.eu.org>2011-03-05 09:20:09 +0100
commit568905f488e63e28778f87ac0e38d845f45bae79 (patch)
treed9969a147e36413583ff4bc75542d34c955f8823 /src/libstrongswan/crypto
parentf73fba54dc8b30c6482e1e8abf15bbf455592fcd (diff)
downloadvyos-strongswan-568905f488e63e28778f87ac0e38d845f45bae79.tar.gz
vyos-strongswan-568905f488e63e28778f87ac0e38d845f45bae79.zip
Imported Upstream version 4.5.1
Diffstat (limited to 'src/libstrongswan/crypto')
-rw-r--r--src/libstrongswan/crypto/crypto_factory.c133
-rw-r--r--src/libstrongswan/crypto/crypto_factory.h31
-rw-r--r--src/libstrongswan/crypto/crypto_tester.c166
-rw-r--r--src/libstrongswan/crypto/crypto_tester.h16
4 files changed, 222 insertions, 124 deletions
diff --git a/src/libstrongswan/crypto/crypto_factory.c b/src/libstrongswan/crypto/crypto_factory.c
index f2f01987d..2d13896d6 100644
--- a/src/libstrongswan/crypto/crypto_factory.c
+++ b/src/libstrongswan/crypto/crypto_factory.c
@@ -20,13 +20,29 @@
#include <utils/linked_list.h>
#include <crypto/crypto_tester.h>
+const char *default_plugin_name = "default";
+
typedef struct entry_t entry_t;
+
struct entry_t {
- /* algorithm */
+ /**
+ * algorithm
+ */
u_int algo;
- /* benchmarked speed */
+
+ /**
+ * plugin that registered this algorithm
+ */
+ const char *plugin_name;
+
+ /**
+ * benchmarked speed
+ */
u_int speed;
- /* constructor */
+
+ /**
+ * constructor
+ */
union {
crypter_constructor_t create_crypter;
aead_constructor_t create_aead;
@@ -128,7 +144,8 @@ METHOD(crypto_factory_t, create_crypter, crypter_t*,
{
if (this->test_on_create &&
!this->tester->test_crypter(this->tester, algo, key_size,
- entry->create_crypter, NULL))
+ entry->create_crypter, NULL,
+ default_plugin_name))
{
continue;
}
@@ -160,7 +177,8 @@ METHOD(crypto_factory_t, create_aead, aead_t*,
{
if (this->test_on_create &&
!this->tester->test_aead(this->tester, algo, key_size,
- entry->create_aead, NULL))
+ entry->create_aead, NULL,
+ default_plugin_name))
{
continue;
}
@@ -191,7 +209,8 @@ METHOD(crypto_factory_t, create_signer, signer_t*,
{
if (this->test_on_create &&
!this->tester->test_signer(this->tester, algo,
- entry->create_signer, NULL))
+ entry->create_signer, NULL,
+ default_plugin_name))
{
continue;
}
@@ -223,7 +242,8 @@ METHOD(crypto_factory_t, create_hasher, hasher_t*,
{
if (this->test_on_create && algo != HASH_PREFERRED &&
!this->tester->test_hasher(this->tester, algo,
- entry->create_hasher, NULL))
+ entry->create_hasher, NULL,
+ default_plugin_name))
{
continue;
}
@@ -254,7 +274,8 @@ METHOD(crypto_factory_t, create_prf, prf_t*,
{
if (this->test_on_create &&
!this->tester->test_prf(this->tester, algo,
- entry->create_prf, NULL))
+ entry->create_prf, NULL,
+ default_plugin_name))
{
continue;
}
@@ -286,7 +307,8 @@ METHOD(crypto_factory_t, create_rng, rng_t*,
{
if (this->test_on_create &&
!this->tester->test_rng(this->tester, quality,
- entry->create_rng, NULL))
+ entry->create_rng, NULL,
+ default_plugin_name))
{
continue;
}
@@ -350,7 +372,8 @@ METHOD(crypto_factory_t, create_dh, diffie_hellman_t*,
* Insert an algorithm entry to a list
*/
static void add_entry(private_crypto_factory_t *this, linked_list_t *list,
- int algo, u_int speed, void *create)
+ int algo, const char *plugin_name,
+ u_int speed, void *create)
{
entry_t *entry, *current;
linked_list_t *tmp;
@@ -358,6 +381,7 @@ static void add_entry(private_crypto_factory_t *this, linked_list_t *list,
INIT(entry,
.algo = algo,
+ .plugin_name = plugin_name,
.speed = speed,
);
entry->create = create;
@@ -391,16 +415,16 @@ static void add_entry(private_crypto_factory_t *this, linked_list_t *list,
}
METHOD(crypto_factory_t, add_crypter, void,
- private_crypto_factory_t *this, encryption_algorithm_t algo,
- crypter_constructor_t create)
+ private_crypto_factory_t *this, encryption_algorithm_t algo,
+ const char *plugin_name, crypter_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_crypter(this->tester, algo, 0, create,
- this->bench ? &speed : NULL))
+ this->bench ? &speed : NULL, plugin_name))
{
- add_entry(this, this->crypters, algo, speed, create);
+ add_entry(this, this->crypters, algo, plugin_name, speed, create);
}
}
@@ -425,16 +449,16 @@ METHOD(crypto_factory_t, remove_crypter, void,
}
METHOD(crypto_factory_t, add_aead, void,
- private_crypto_factory_t *this, encryption_algorithm_t algo,
- aead_constructor_t create)
+ private_crypto_factory_t *this, encryption_algorithm_t algo,
+ const char *plugin_name, aead_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_aead(this->tester, algo, 0, create,
- this->bench ? &speed : NULL))
+ this->bench ? &speed : NULL, plugin_name))
{
- add_entry(this, this->aeads, algo, speed, create);
+ add_entry(this, this->aeads, algo, plugin_name, speed, create);
}
}
@@ -459,16 +483,16 @@ METHOD(crypto_factory_t, remove_aead, void,
}
METHOD(crypto_factory_t, add_signer, void,
- private_crypto_factory_t *this, integrity_algorithm_t algo,
- signer_constructor_t create)
+ private_crypto_factory_t *this, integrity_algorithm_t algo,
+ const char *plugin_name, signer_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_signer(this->tester, algo, create,
- this->bench ? &speed : NULL))
+ this->bench ? &speed : NULL, plugin_name))
{
- add_entry(this, this->signers, algo, speed, create);
+ add_entry(this, this->signers, algo, plugin_name, speed, create);
}
}
@@ -493,16 +517,16 @@ METHOD(crypto_factory_t, remove_signer, void,
}
METHOD(crypto_factory_t, add_hasher, void,
- private_crypto_factory_t *this, hash_algorithm_t algo,
- hasher_constructor_t create)
+ private_crypto_factory_t *this, hash_algorithm_t algo,
+ const char *plugin_name, hasher_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_hasher(this->tester, algo, create,
- this->bench ? &speed : NULL))
+ this->bench ? &speed : NULL, plugin_name))
{
- add_entry(this, this->hashers, algo, speed, create);
+ add_entry(this, this->hashers, algo, plugin_name, speed, create);
}
}
@@ -527,16 +551,16 @@ METHOD(crypto_factory_t, remove_hasher, void,
}
METHOD(crypto_factory_t, add_prf, void,
- private_crypto_factory_t *this, pseudo_random_function_t algo,
- prf_constructor_t create)
+ private_crypto_factory_t *this, pseudo_random_function_t algo,
+ const char *plugin_name, prf_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_prf(this->tester, algo, create,
- this->bench ? &speed : NULL))
+ this->bench ? &speed : NULL, plugin_name))
{
- add_entry(this, this->prfs, algo, speed, create);
+ add_entry(this, this->prfs, algo, plugin_name, speed, create);
}
}
@@ -562,15 +586,15 @@ METHOD(crypto_factory_t, remove_prf, void,
METHOD(crypto_factory_t, add_rng, void,
private_crypto_factory_t *this, rng_quality_t quality,
- rng_constructor_t create)
+ const char *plugin_name, rng_constructor_t create)
{
u_int speed = 0;
if (!this->test_on_add ||
this->tester->test_rng(this->tester, quality, create,
- this->bench ? &speed : NULL))
+ this->bench ? &speed : NULL, plugin_name))
{
- add_entry(this, this->rngs, quality, speed, create);
+ add_entry(this, this->rngs, quality, plugin_name, speed, create);
}
}
@@ -595,10 +619,10 @@ METHOD(crypto_factory_t, remove_rng, void,
}
METHOD(crypto_factory_t, add_dh, void,
- private_crypto_factory_t *this, diffie_hellman_group_t group,
- dh_constructor_t create)
+ private_crypto_factory_t *this, diffie_hellman_group_t group,
+ const char *plugin_name, dh_constructor_t create)
{
- add_entry(this, this->dhs, group, 0, create);
+ add_entry(this, this->dhs, group, plugin_name, 0, create);
}
METHOD(crypto_factory_t, remove_dh, void,
@@ -660,9 +684,11 @@ static enumerator_t *create_enumerator(private_crypto_factory_t *this,
/**
* Filter function to enumerate algorithm, not entry
*/
-static bool crypter_filter(void *n, entry_t **entry, encryption_algorithm_t *algo)
+static bool crypter_filter(void *n, entry_t **entry, encryption_algorithm_t *algo,
+ void *i2, const char **plugin_name)
{
*algo = (*entry)->algo;
+ *plugin_name = (*entry)->plugin_name;
return TRUE;
}
@@ -681,9 +707,11 @@ METHOD(crypto_factory_t, create_aead_enumerator, enumerator_t*,
/**
* Filter function to enumerate algorithm, not entry
*/
-static bool signer_filter(void *n, entry_t **entry, integrity_algorithm_t *algo)
+static bool signer_filter(void *n, entry_t **entry, integrity_algorithm_t *algo,
+ void *i2, const char **plugin_name)
{
*algo = (*entry)->algo;
+ *plugin_name = (*entry)->plugin_name;
return TRUE;
}
@@ -696,9 +724,11 @@ METHOD(crypto_factory_t, create_signer_enumerator, enumerator_t*,
/**
* Filter function to enumerate algorithm, not entry
*/
-static bool hasher_filter(void *n, entry_t **entry, hash_algorithm_t *algo)
+static bool hasher_filter(void *n, entry_t **entry, hash_algorithm_t *algo,
+ void *i2, const char **plugin_name)
{
*algo = (*entry)->algo;
+ *plugin_name = (*entry)->plugin_name;
return TRUE;
}
@@ -711,9 +741,11 @@ METHOD(crypto_factory_t, create_hasher_enumerator, enumerator_t*,
/**
* Filter function to enumerate algorithm, not entry
*/
-static bool prf_filter(void *n, entry_t **entry, pseudo_random_function_t *algo)
+static bool prf_filter(void *n, entry_t **entry, pseudo_random_function_t *algo,
+ void *i2, const char **plugin_name)
{
*algo = (*entry)->algo;
+ *plugin_name = (*entry)->plugin_name;
return TRUE;
}
@@ -726,9 +758,11 @@ METHOD(crypto_factory_t, create_prf_enumerator, enumerator_t*,
/**
* Filter function to enumerate algorithm, not entry
*/
-static bool dh_filter(void *n, entry_t **entry, diffie_hellman_group_t *group)
+static bool dh_filter(void *n, entry_t **entry, diffie_hellman_group_t *group,
+ void *i2, const char **plugin_name)
{
*group = (*entry)->algo;
+ *plugin_name = (*entry)->plugin_name;
return TRUE;
}
@@ -738,6 +772,22 @@ METHOD(crypto_factory_t, create_dh_enumerator, enumerator_t*,
return create_enumerator(this, this->dhs, dh_filter);
}
+/**
+ * Filter function to enumerate algorithm, not entry
+ */
+static bool rng_filter(void *n, entry_t **entry, rng_quality_t *quality,
+ void *i2, const char **plugin_name)
+{
+ *quality = (*entry)->algo;
+ *plugin_name = (*entry)->plugin_name;
+ return TRUE;
+}
+
+METHOD(crypto_factory_t, create_rng_enumerator, enumerator_t*,
+ private_crypto_factory_t *this)
+{
+ return create_enumerator(this, this->rngs, rng_filter);
+}
METHOD(crypto_factory_t, add_test_vector, void,
private_crypto_factory_t *this, transform_type_t type, void *vector)
{
@@ -812,6 +862,7 @@ crypto_factory_t *crypto_factory_create()
.create_hasher_enumerator = _create_hasher_enumerator,
.create_prf_enumerator = _create_prf_enumerator,
.create_dh_enumerator = _create_dh_enumerator,
+ .create_rng_enumerator = _create_rng_enumerator,
.add_test_vector = _add_test_vector,
.destroy = _destroy,
},
diff --git a/src/libstrongswan/crypto/crypto_factory.h b/src/libstrongswan/crypto/crypto_factory.h
index ff06eda7b..8e5db6355 100644
--- a/src/libstrongswan/crypto/crypto_factory.h
+++ b/src/libstrongswan/crypto/crypto_factory.h
@@ -33,6 +33,8 @@ typedef struct crypto_factory_t crypto_factory_t;
#include <crypto/diffie_hellman.h>
#include <crypto/transform.h>
+#define CRYPTO_MAX_ALG_LINE 120 /* characters */
+
/**
* Constructor function for crypters
*/
@@ -144,11 +146,12 @@ struct crypto_factory_t {
* Register a crypter constructor.
*
* @param algo algorithm to constructor
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return
*/
void (*add_crypter)(crypto_factory_t *this, encryption_algorithm_t algo,
- crypter_constructor_t create);
+ const char *plugin_name, crypter_constructor_t create);
/**
* Unregister a crypter constructor.
@@ -168,21 +171,23 @@ struct crypto_factory_t {
* Register a aead constructor.
*
* @param algo algorithm to constructor
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return
*/
void (*add_aead)(crypto_factory_t *this, encryption_algorithm_t algo,
- aead_constructor_t create);
+ const char *plugin_name, aead_constructor_t create);
/**
* Register a signer constructor.
*
* @param algo algorithm to constructor
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return
*/
void (*add_signer)(crypto_factory_t *this, integrity_algorithm_t algo,
- signer_constructor_t create);
+ const char *plugin_name, signer_constructor_t create);
/**
* Unregister a signer constructor.
@@ -198,11 +203,12 @@ struct crypto_factory_t {
* create_hasher(HASH_PREFERRED).
*
* @param algo algorithm to constructor
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return
*/
void (*add_hasher)(crypto_factory_t *this, hash_algorithm_t algo,
- hasher_constructor_t create);
+ const char *plugin_name, hasher_constructor_t create);
/**
* Unregister a hasher constructor.
@@ -215,11 +221,12 @@ struct crypto_factory_t {
* Register a prf constructor.
*
* @param algo algorithm to constructor
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return
*/
void (*add_prf)(crypto_factory_t *this, pseudo_random_function_t algo,
- prf_constructor_t create);
+ const char *plugin_name, prf_constructor_t create);
/**
* Unregister a prf constructor.
@@ -232,9 +239,11 @@ struct crypto_factory_t {
* Register a source of randomness.
*
* @param quality quality of randomness this RNG serves
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for such a quality
*/
- void (*add_rng)(crypto_factory_t *this, rng_quality_t quality, rng_constructor_t create);
+ void (*add_rng)(crypto_factory_t *this, rng_quality_t quality,
+ const char *plugin_name, rng_constructor_t create);
/**
* Unregister a source of randomness.
@@ -247,11 +256,12 @@ struct crypto_factory_t {
* Register a diffie hellman constructor.
*
* @param group dh group to constructor
+ * @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
* @return
*/
void (*add_dh)(crypto_factory_t *this, diffie_hellman_group_t group,
- dh_constructor_t create);
+ const char *plugin_name, dh_constructor_t create);
/**
* Unregister a diffie hellman constructor.
@@ -303,6 +313,13 @@ struct crypto_factory_t {
enumerator_t* (*create_dh_enumerator)(crypto_factory_t *this);
/**
+ * Create an enumerator over all registered random generators.
+ *
+ * @return enumerator over rng_quality_t
+ */
+ enumerator_t* (*create_rng_enumerator)(crypto_factory_t *this);
+
+ /**
* Add a test vector to the crypto factory.
*
* @param type type of the test vector
diff --git a/src/libstrongswan/crypto/crypto_tester.c b/src/libstrongswan/crypto/crypto_tester.c
index d17485ff2..276f4329a 100644
--- a/src/libstrongswan/crypto/crypto_tester.c
+++ b/src/libstrongswan/crypto/crypto_tester.c
@@ -165,7 +165,7 @@ static u_int bench_crypter(private_crypto_tester_t *this,
METHOD(crypto_tester_t, test_crypter, bool,
private_crypto_tester_t *this, encryption_algorithm_t alg, size_t key_size,
- crypter_constructor_t create, u_int *speed)
+ crypter_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
crypter_test_vector_t *vector;
@@ -188,7 +188,11 @@ METHOD(crypto_tester_t, test_crypter, bool,
}
crypter = create(alg, vector->key_size);
if (!crypter)
- { /* key size not supported... */
+ {
+ DBG1(DBG_LIB, "%N[%s]: %u bit key size not supported",
+ encryption_algorithm_names, alg, plugin_name,
+ BITS_PER_BYTE * vector->key_size);
+ failed = TRUE;
continue;
}
@@ -231,31 +235,40 @@ METHOD(crypto_tester_t, test_crypter, bool,
crypter->destroy(crypter);
if (failed)
{
- DBG1(DBG_LIB, "disabled %N: %s test vector failed",
- encryption_algorithm_names, alg, get_name(vector));
+ DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
+ encryption_algorithm_names, alg, plugin_name, get_name(vector));
break;
}
}
enumerator->destroy(enumerator);
if (!tested)
{
- DBG1(DBG_LIB, "%s %N: no test vectors found",
- this->required ? "disabled" : "enabled ",
- encryption_algorithm_names, alg);
- return !this->required;
+ if (failed)
+ {
+ DBG1(DBG_LIB,"disable %N[%s]: no key size supported",
+ encryption_algorithm_names, alg, plugin_name);
+ return FALSE;
+ }
+ else
+ {
+ DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
+ this->required ? "disabled" : "enabled ",
+ encryption_algorithm_names, alg, plugin_name);
+ return !this->required;
+ }
}
if (!failed)
{
if (speed)
{
*speed = bench_crypter(this, alg, create);
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors, %d points",
- encryption_algorithm_names, alg, tested, *speed);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
+ encryption_algorithm_names, alg, tested, plugin_name, *speed);
}
else
{
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
- encryption_algorithm_names, alg, tested);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
+ encryption_algorithm_names, alg, plugin_name, tested);
}
}
return !failed;
@@ -311,7 +324,7 @@ static u_int bench_aead(private_crypto_tester_t *this,
METHOD(crypto_tester_t, test_aead, bool,
private_crypto_tester_t *this, encryption_algorithm_t alg, size_t key_size,
- aead_constructor_t create, u_int *speed)
+ aead_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
aead_test_vector_t *vector;
@@ -335,7 +348,11 @@ METHOD(crypto_tester_t, test_aead, bool,
}
aead = create(alg, vector->key_size);
if (!aead)
- { /* key size not supported... */
+ {
+ DBG1(DBG_LIB, "%N[%s]: %u bit key size not supported",
+ encryption_algorithm_names, alg, plugin_name,
+ BITS_PER_BYTE * vector->key_size);
+ failed = TRUE;
continue;
}
@@ -388,31 +405,40 @@ METHOD(crypto_tester_t, test_aead, bool,
aead->destroy(aead);
if (failed)
{
- DBG1(DBG_LIB, "disabled %N: %s test vector failed",
- encryption_algorithm_names, alg, get_name(vector));
+ DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
+ encryption_algorithm_names, alg, plugin_name, get_name(vector));
break;
}
}
enumerator->destroy(enumerator);
if (!tested)
{
- DBG1(DBG_LIB, "%s %N: no test vectors found",
- this->required ? "disabled" : "enabled ",
- encryption_algorithm_names, alg);
- return !this->required;
+ if (failed)
+ {
+ DBG1(DBG_LIB,"disable %N[%s]: no key size supported",
+ encryption_algorithm_names, alg, plugin_name);
+ return FALSE;
+ }
+ else
+ {
+ DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
+ this->required ? "disabled" : "enabled ",
+ encryption_algorithm_names, alg, plugin_name);
+ return !this->required;
+ }
}
if (!failed)
{
if (speed)
{
*speed = bench_aead(this, alg, create);
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors, %d points",
- encryption_algorithm_names, alg, tested, *speed);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
+ encryption_algorithm_names, alg, plugin_name, tested, *speed);
}
else
{
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
- encryption_algorithm_names, alg, tested);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
+ encryption_algorithm_names, alg, plugin_name, tested);
}
}
return !failed;
@@ -460,7 +486,7 @@ static u_int bench_signer(private_crypto_tester_t *this,
METHOD(crypto_tester_t, test_signer, bool,
private_crypto_tester_t *this, integrity_algorithm_t alg,
- signer_constructor_t create, u_int *speed)
+ signer_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
signer_test_vector_t *vector;
@@ -482,8 +508,8 @@ METHOD(crypto_tester_t, test_signer, bool,
signer = create(alg);
if (!signer)
{
- DBG1(DBG_LIB, "disabled %N: creating instance failed",
- integrity_algorithm_names, alg);
+ DBG1(DBG_LIB, "disabled %N[%s]: creating instance failed",
+ integrity_algorithm_names, alg, plugin_name);
failed = TRUE;
break;
}
@@ -538,17 +564,17 @@ METHOD(crypto_tester_t, test_signer, bool,
signer->destroy(signer);
if (failed)
{
- DBG1(DBG_LIB, "disabled %N: %s test vector failed",
- integrity_algorithm_names, alg, get_name(vector));
+ DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
+ integrity_algorithm_names, alg, plugin_name, get_name(vector));
break;
}
}
enumerator->destroy(enumerator);
if (!tested)
{
- DBG1(DBG_LIB, "%s %N: no test vectors found",
+ DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
this->required ? "disabled" : "enabled ",
- integrity_algorithm_names, alg);
+ integrity_algorithm_names, alg, plugin_name);
return !this->required;
}
if (!failed)
@@ -556,13 +582,13 @@ METHOD(crypto_tester_t, test_signer, bool,
if (speed)
{
*speed = bench_signer(this, alg, create);
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors, %d points",
- integrity_algorithm_names, alg, tested, *speed);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
+ integrity_algorithm_names, alg, plugin_name, tested, *speed);
}
else
{
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
- integrity_algorithm_names, alg, tested);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
+ integrity_algorithm_names, alg, plugin_name, tested);
}
}
return !failed;
@@ -604,7 +630,7 @@ static u_int bench_hasher(private_crypto_tester_t *this,
METHOD(crypto_tester_t, test_hasher, bool,
private_crypto_tester_t *this, hash_algorithm_t alg,
- hasher_constructor_t create, u_int *speed)
+ hasher_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
hasher_test_vector_t *vector;
@@ -626,8 +652,8 @@ METHOD(crypto_tester_t, test_hasher, bool,
hasher = create(alg);
if (!hasher)
{
- DBG1(DBG_LIB, "disabled %N: creating instance failed",
- hash_algorithm_names, alg);
+ DBG1(DBG_LIB, "disabled %N[%s]: creating instance failed",
+ hash_algorithm_names, alg, plugin_name);
failed = TRUE;
break;
}
@@ -669,17 +695,17 @@ METHOD(crypto_tester_t, test_hasher, bool,
hasher->destroy(hasher);
if (failed)
{
- DBG1(DBG_LIB, "disabled %N: %s test vector failed",
- hash_algorithm_names, alg, get_name(vector));
+ DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
+ hash_algorithm_names, alg, plugin_name, get_name(vector));
break;
}
}
enumerator->destroy(enumerator);
if (!tested)
{
- DBG1(DBG_LIB, "%s %N: no test vectors found",
+ DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
this->required ? "disabled" : "enabled ",
- hash_algorithm_names, alg);
+ hash_algorithm_names, alg, plugin_name);
return !this->required;
}
if (!failed)
@@ -687,13 +713,13 @@ METHOD(crypto_tester_t, test_hasher, bool,
if (speed)
{
*speed = bench_hasher(this, alg, create);
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors, %d points",
- hash_algorithm_names, alg, tested, *speed);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
+ hash_algorithm_names, alg, plugin_name, tested, *speed);
}
else
{
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
- hash_algorithm_names, alg, tested);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
+ hash_algorithm_names, alg, plugin_name, tested);
}
}
return !failed;
@@ -735,7 +761,7 @@ static u_int bench_prf(private_crypto_tester_t *this,
METHOD(crypto_tester_t, test_prf, bool,
private_crypto_tester_t *this, pseudo_random_function_t alg,
- prf_constructor_t create, u_int *speed)
+ prf_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
prf_test_vector_t *vector;
@@ -757,8 +783,8 @@ METHOD(crypto_tester_t, test_prf, bool,
prf = create(alg);
if (!prf)
{
- DBG1(DBG_LIB, "disabled %N: creating instance failed",
- pseudo_random_function_names, alg);
+ DBG1(DBG_LIB, "disabled %N[%s]: creating instance failed",
+ pseudo_random_function_names, alg, plugin_name);
failed = TRUE;
break;
}
@@ -811,17 +837,17 @@ METHOD(crypto_tester_t, test_prf, bool,
prf->destroy(prf);
if (failed)
{
- DBG1(DBG_LIB, "disabled %N: %s test vector failed",
- pseudo_random_function_names, alg, get_name(vector));
+ DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
+ pseudo_random_function_names, alg, plugin_name, get_name(vector));
break;
}
}
enumerator->destroy(enumerator);
if (!tested)
{
- DBG1(DBG_LIB, "%s %N: no test vectors found",
+ DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
this->required ? "disabled" : "enabled ",
- pseudo_random_function_names, alg);
+ pseudo_random_function_names, alg, plugin_name);
return !this->required;
}
if (!failed)
@@ -829,13 +855,13 @@ METHOD(crypto_tester_t, test_prf, bool,
if (speed)
{
*speed = bench_prf(this, alg, create);
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors, %d points",
- pseudo_random_function_names, alg, tested, *speed);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
+ pseudo_random_function_names, alg, plugin_name, tested, *speed);
}
else
{
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
- pseudo_random_function_names, alg, tested);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
+ pseudo_random_function_names, alg, plugin_name, tested);
}
}
return !failed;
@@ -874,7 +900,7 @@ static u_int bench_rng(private_crypto_tester_t *this,
METHOD(crypto_tester_t, test_rng, bool,
private_crypto_tester_t *this, rng_quality_t quality,
- rng_constructor_t create, u_int *speed)
+ rng_constructor_t create, u_int *speed, const char *plugin_name)
{
enumerator_t *enumerator;
rng_test_vector_t *vector;
@@ -883,8 +909,8 @@ METHOD(crypto_tester_t, test_rng, bool,
if (!this->rng_true && quality == RNG_TRUE)
{
- DBG1(DBG_LIB, "enabled %N: skipping test (disabled by config)",
- rng_quality_names, quality);
+ DBG1(DBG_LIB, "enabled %N[%s]: skipping test (disabled by config)",
+ rng_quality_names, quality, plugin_name);
return TRUE;
}
@@ -903,8 +929,8 @@ METHOD(crypto_tester_t, test_rng, bool,
rng = create(quality);
if (!rng)
{
- DBG1(DBG_LIB, "disabled %N: creating instance failed",
- rng_quality_names, quality);
+ DBG1(DBG_LIB, "disabled %N[%s]: creating instance failed",
+ rng_quality_names, quality, plugin_name);
failed = TRUE;
break;
}
@@ -933,17 +959,17 @@ METHOD(crypto_tester_t, test_rng, bool,
rng->destroy(rng);
if (failed)
{
- DBG1(DBG_LIB, "disabled %N: %s test vector failed",
- rng_quality_names, quality, get_name(vector));
+ DBG1(DBG_LIB, "disabled %N[%s]: %s test vector failed",
+ rng_quality_names, quality, plugin_name, get_name(vector));
break;
}
}
enumerator->destroy(enumerator);
if (!tested)
{
- DBG1(DBG_LIB, "%s %N: no test vectors found",
+ DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
this->required ? ", disabled" : "enabled ",
- rng_quality_names, quality);
+ rng_quality_names, quality, plugin_name);
return !this->required;
}
if (!failed)
@@ -951,13 +977,13 @@ METHOD(crypto_tester_t, test_rng, bool,
if (speed)
{
*speed = bench_rng(this, quality, create);
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors, %d points",
- rng_quality_names, quality, tested, *speed);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors, %d points",
+ rng_quality_names, quality, plugin_name, tested, *speed);
}
else
{
- DBG1(DBG_LIB, "enabled %N: passed %u test vectors",
- rng_quality_names, quality, tested);
+ DBG1(DBG_LIB, "enabled %N[%s]: passed %u test vectors",
+ rng_quality_names, quality, plugin_name, tested);
}
}
return !failed;
diff --git a/src/libstrongswan/crypto/crypto_tester.h b/src/libstrongswan/crypto/crypto_tester.h
index cef0b3c18..019c87c39 100644
--- a/src/libstrongswan/crypto/crypto_tester.h
+++ b/src/libstrongswan/crypto/crypto_tester.h
@@ -143,7 +143,7 @@ struct crypto_tester_t {
*/
bool (*test_crypter)(crypto_tester_t *this, encryption_algorithm_t alg,
size_t key_size, crypter_constructor_t create,
- u_int *speed);
+ u_int *speed, const char *plugin_name);
/**
* Test an aead algorithm, optionally using a specified key size.
@@ -156,7 +156,7 @@ struct crypto_tester_t {
*/
bool (*test_aead)(crypto_tester_t *this, encryption_algorithm_t alg,
size_t key_size, aead_constructor_t create,
- u_int *speed);
+ u_int *speed, const char *plugin_name);
/**
* Test a signer algorithm.
*
@@ -166,7 +166,8 @@ struct crypto_tester_t {
* @return TRUE if test passed
*/
bool (*test_signer)(crypto_tester_t *this, integrity_algorithm_t alg,
- signer_constructor_t create, u_int *speed);
+ signer_constructor_t create,
+ u_int *speed, const char *plugin_name);
/**
* Test a hasher algorithm.
*
@@ -176,7 +177,8 @@ struct crypto_tester_t {
* @return TRUE if test passed
*/
bool (*test_hasher)(crypto_tester_t *this, hash_algorithm_t alg,
- hasher_constructor_t create, u_int *speed);
+ hasher_constructor_t create,
+ u_int *speed, const char *plugin_name);
/**
* Test a PRF algorithm.
*
@@ -186,7 +188,8 @@ struct crypto_tester_t {
* @return TRUE if test passed
*/
bool (*test_prf)(crypto_tester_t *this, pseudo_random_function_t alg,
- prf_constructor_t create, u_int *speed);
+ prf_constructor_t create,
+ u_int *speed, const char *plugin_name);
/**
* Test a RNG implementation.
*
@@ -196,7 +199,8 @@ struct crypto_tester_t {
* @return TRUE if test passed
*/
bool (*test_rng)(crypto_tester_t *this, rng_quality_t quality,
- rng_constructor_t create, u_int *speed);
+ rng_constructor_t create,
+ u_int *speed, const char *plugin_name);
/**
* Add a test vector to test a crypter.
*