crypto-tester: Support testing DH groups using DH test vectors

This commit is contained in:
Martin Willi
2015-04-15 14:37:38 +02:00
parent 3941545fb9
commit a94955e88a
3 changed files with 224 additions and 2 deletions
+41
View File
@@ -31,6 +31,7 @@ typedef struct signer_test_vector_t signer_test_vector_t;
typedef struct hasher_test_vector_t hasher_test_vector_t;
typedef struct prf_test_vector_t prf_test_vector_t;
typedef struct rng_test_vector_t rng_test_vector_t;
typedef struct dh_test_vector_t dh_test_vector_t;
struct crypter_test_vector_t {
/** encryption algorithm this vector tests */
@@ -129,6 +130,27 @@ struct rng_test_vector_t {
void *user;
};
struct dh_test_vector_t {
/** diffie hellman group to test */
diffie_hellman_group_t group;
/** private value of alice */
u_char *priv_a;
/** private value of bob */
u_char *priv_b;
/** length of private values */
size_t priv_len;
/** expected public value of alice */
u_char *pub_a;
/** expected public value of bob */
u_char *pub_b;
/** size of public values */
size_t pub_len;
/** expected shared secret */
u_char *shared;
/** size of shared secret */
size_t shared_len;
};
/**
* Cryptographic primitive testing framework.
*/
@@ -205,6 +227,18 @@ struct crypto_tester_t {
bool (*test_rng)(crypto_tester_t *this, rng_quality_t quality,
rng_constructor_t create,
u_int *speed, const char *plugin_name);
/**
* Test a Diffie-Hellman implementation.
*
* @param group group to test
* @param create constructor function for the DH backend
* @param speed speeed test result, NULL to omit
* @return TRUE if test passed
*/
bool (*test_dh)(crypto_tester_t *this, diffie_hellman_group_t group,
dh_constructor_t create,
u_int *speed, const char *plugin_name);
/**
* Add a test vector to test a crypter.
*
@@ -247,6 +281,13 @@ struct crypto_tester_t {
*/
void (*add_rng_vector)(crypto_tester_t *this, rng_test_vector_t *vector);
/**
* Add a test vector to test a Diffie-Hellman backend.
*
* @param vector pointer to test vector
*/
void (*add_dh_vector)(crypto_tester_t *this, dh_test_vector_t *vector);
/**
* Destroy a crypto_tester_t.
*/