*/
bool bench;
+ /**
+ * Number of failed test vectors during "add".
+ */
+ u_int test_failures;
+
/**
* rwlock to lock access to modules
*/
this->lock->unlock(this->lock);
}
-METHOD(crypto_factory_t, add_crypter, void,
- private_crypto_factory_t *this, encryption_algorithm_t algo,
+METHOD(crypto_factory_t, add_crypter, bool,
+ private_crypto_factory_t *this, encryption_algorithm_t algo,
const char *plugin_name, crypter_constructor_t create)
{
u_int speed = 0;
this->bench ? &speed : NULL, plugin_name))
{
add_entry(this, this->crypters, algo, plugin_name, speed, create);
+ return TRUE;
}
+ this->test_failures++;
+ return FALSE;
}
METHOD(crypto_factory_t, remove_crypter, void,
this->lock->unlock(this->lock);
}
-METHOD(crypto_factory_t, add_aead, void,
- private_crypto_factory_t *this, encryption_algorithm_t algo,
+METHOD(crypto_factory_t, add_aead, bool,
+ private_crypto_factory_t *this, encryption_algorithm_t algo,
const char *plugin_name, aead_constructor_t create)
{
u_int speed = 0;
this->bench ? &speed : NULL, plugin_name))
{
add_entry(this, this->aeads, algo, plugin_name, speed, create);
+ return TRUE;
}
+ this->test_failures++;
+ return FALSE;
}
METHOD(crypto_factory_t, remove_aead, void,
this->lock->unlock(this->lock);
}
-METHOD(crypto_factory_t, add_signer, void,
- private_crypto_factory_t *this, integrity_algorithm_t algo,
+METHOD(crypto_factory_t, add_signer, bool,
+ private_crypto_factory_t *this, integrity_algorithm_t algo,
const char *plugin_name, signer_constructor_t create)
{
u_int speed = 0;
this->bench ? &speed : NULL, plugin_name))
{
add_entry(this, this->signers, algo, plugin_name, speed, create);
+ return TRUE;
}
+ this->test_failures++;
+ return FALSE;
}
METHOD(crypto_factory_t, remove_signer, void,
this->lock->unlock(this->lock);
}
-METHOD(crypto_factory_t, add_hasher, void,
- private_crypto_factory_t *this, hash_algorithm_t algo,
+METHOD(crypto_factory_t, add_hasher, bool,
+ private_crypto_factory_t *this, hash_algorithm_t algo,
const char *plugin_name, hasher_constructor_t create)
{
u_int speed = 0;
this->bench ? &speed : NULL, plugin_name))
{
add_entry(this, this->hashers, algo, plugin_name, speed, create);
+ return TRUE;
}
+ this->test_failures++;
+ return FALSE;
}
METHOD(crypto_factory_t, remove_hasher, void,
this->lock->unlock(this->lock);
}
-METHOD(crypto_factory_t, add_prf, void,
- private_crypto_factory_t *this, pseudo_random_function_t algo,
+METHOD(crypto_factory_t, add_prf, bool,
+ private_crypto_factory_t *this, pseudo_random_function_t algo,
const char *plugin_name, prf_constructor_t create)
{
u_int speed = 0;
this->bench ? &speed : NULL, plugin_name))
{
add_entry(this, this->prfs, algo, plugin_name, speed, create);
+ return TRUE;
}
+ this->test_failures++;
+ return FALSE;
}
METHOD(crypto_factory_t, remove_prf, void,
this->lock->unlock(this->lock);
}
-METHOD(crypto_factory_t, add_rng, void,
+METHOD(crypto_factory_t, add_rng, bool,
private_crypto_factory_t *this, rng_quality_t quality,
const char *plugin_name, rng_constructor_t create)
{
this->bench ? &speed : NULL, plugin_name))
{
add_entry(this, this->rngs, quality, plugin_name, speed, create);
+ return TRUE;
}
+ this->test_failures++;
+ return FALSE;
}
METHOD(crypto_factory_t, remove_rng, void,
this->lock->unlock(this->lock);
}
-METHOD(crypto_factory_t, add_nonce_gen, void,
+METHOD(crypto_factory_t, add_nonce_gen, bool,
private_crypto_factory_t *this, const char *plugin_name,
nonce_gen_constructor_t create)
{
add_entry(this, this->nonce_gens, 0, plugin_name, 0, create);
+ return TRUE;
}
METHOD(crypto_factory_t, remove_nonce_gen, void,
this->lock->unlock(this->lock);
}
-METHOD(crypto_factory_t, add_dh, void,
- private_crypto_factory_t *this, diffie_hellman_group_t group,
- const char *plugin_name, dh_constructor_t create)
+METHOD(crypto_factory_t, add_dh, bool,
+ private_crypto_factory_t *this, diffie_hellman_group_t group,
+ const char *plugin_name, dh_constructor_t create)
{
add_entry(this, this->dhs, group, plugin_name, 0, create);
+ return TRUE;
}
METHOD(crypto_factory_t, remove_dh, void,
}
}
+METHOD(crypto_factory_t, get_test_vector_failures, u_int,
+ private_crypto_factory_t *this)
+{
+ return this->test_failures;
+}
+
METHOD(crypto_factory_t, destroy, void,
private_crypto_factory_t *this)
{
.create_rng_enumerator = _create_rng_enumerator,
.create_nonce_gen_enumerator = _create_nonce_gen_enumerator,
.add_test_vector = _add_test_vector,
+ .get_test_vector_failures = _get_test_vector_failures,
.destroy = _destroy,
},
.crypters = linked_list_create(),
return &this->public;
}
-
* @param algo algorithm to constructor
* @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
- * @return
+ * @return TRUE if registered, FALSE if test vector failed
*/
- void (*add_crypter)(crypto_factory_t *this, encryption_algorithm_t algo,
+ bool (*add_crypter)(crypto_factory_t *this, encryption_algorithm_t algo,
const char *plugin_name, crypter_constructor_t create);
/**
* @param algo algorithm to constructor
* @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
- * @return
+ * @return TRUE if registered, FALSE if test vector failed
*/
- void (*add_aead)(crypto_factory_t *this, encryption_algorithm_t algo,
+ bool (*add_aead)(crypto_factory_t *this, encryption_algorithm_t algo,
const char *plugin_name, aead_constructor_t create);
/**
* @param algo algorithm to constructor
* @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
- * @return
+ * @return TRUE if registered, FALSE if test vector failed
*/
- void (*add_signer)(crypto_factory_t *this, integrity_algorithm_t algo,
+ bool (*add_signer)(crypto_factory_t *this, integrity_algorithm_t algo,
const char *plugin_name, signer_constructor_t create);
/**
* @param algo algorithm to constructor
* @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
- * @return
+ * @return TRUE if registered, FALSE if test vector failed
*/
- void (*add_hasher)(crypto_factory_t *this, hash_algorithm_t algo,
+ bool (*add_hasher)(crypto_factory_t *this, hash_algorithm_t algo,
const char *plugin_name, hasher_constructor_t create);
/**
* @param algo algorithm to constructor
* @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
- * @return
+ * @return TRUE if registered, FALSE if test vector failed
*/
- void (*add_prf)(crypto_factory_t *this, pseudo_random_function_t algo,
+ bool (*add_prf)(crypto_factory_t *this, pseudo_random_function_t algo,
const char *plugin_name, prf_constructor_t create);
/**
* @param quality quality of randomness this RNG serves
* @param plugin_name plugin that registered this algorithm
* @param create constructor function for such a quality
+ * @return TRUE if registered, FALSE if test vector failed
*/
- void (*add_rng)(crypto_factory_t *this, rng_quality_t quality,
+ bool (*add_rng)(crypto_factory_t *this, rng_quality_t quality,
const char *plugin_name, rng_constructor_t create);
/**
*
* @param plugin_name plugin that registered this algorithm
* @param create constructor function for that nonce generator
+ * @return TRUE if registered, FALSE if test vector failed
*/
- void (*add_nonce_gen)(crypto_factory_t *this, const char *plugin_name,
+ bool (*add_nonce_gen)(crypto_factory_t *this, const char *plugin_name,
nonce_gen_constructor_t create);
/**
* @param group dh group to constructor
* @param plugin_name plugin that registered this algorithm
* @param create constructor function for that algorithm
- * @return
+ * @return TRUE if registered, FALSE if test vector failed
*/
- void (*add_dh)(crypto_factory_t *this, diffie_hellman_group_t group,
+ bool (*add_dh)(crypto_factory_t *this, diffie_hellman_group_t group,
const char *plugin_name, dh_constructor_t create);
/**
void (*add_test_vector)(crypto_factory_t *this, transform_type_t type,
void *vector);
+ /**
+ * Get the number of test vector failures encountered during add.
+ *
+ * This counter gets incremented only if transforms get tested during
+ * registration.
+ *
+ * @return number of failed test vectors
+ */
+ u_int (*get_test_vector_failures)(crypto_factory_t *this);
+
/**
* Destroy a crypto_factory instance.
*/