trace back crypto algorithms to the plugins that registered them

This commit is contained in:
Andreas Steffen
2010-12-18 16:31:12 +01:00
parent ae09bc62bc
commit 5932f41fcc
30 changed files with 587 additions and 400 deletions
+92 -41
View File
@@ -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,
},
+22 -7
View File
@@ -144,11 +144,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 +169,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 +201,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 +219,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 +237,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 +254,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.
@@ -302,6 +310,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.
*
+64 -64
View File
@@ -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;
@@ -231,17 +231,17 @@ 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",
DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
this->required ? "disabled" : "enabled ",
encryption_algorithm_names, alg);
encryption_algorithm_names, alg, plugin_name);
return !this->required;
}
if (!failed)
@@ -249,13 +249,13 @@ METHOD(crypto_tester_t, test_crypter, bool,
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 +311,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;
@@ -388,17 +388,17 @@ 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",
DBG1(DBG_LIB, "%s %N[%s]: no test vectors found",
this->required ? "disabled" : "enabled ",
encryption_algorithm_names, alg);
encryption_algorithm_names, alg, plugin_name);
return !this->required;
}
if (!failed)
@@ -406,13 +406,13 @@ METHOD(crypto_tester_t, test_aead, bool,
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 +460,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 +482,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 +538,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 +556,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 +604,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 +626,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 +669,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 +687,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 +735,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 +757,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 +811,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 +829,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 +874,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 +883,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 +903,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 +933,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 +951,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;
+10 -6
View File
@@ -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.
*