Add configure option to disable testing key exchange methods
If this is used, the functionality to set a private key/value/seed for key exchange methods is removed (including from the interface to avoid accidentally forgetting to wrap implementations and uses of set_seed()). The set_seed() method is assigned outside the INIT() macro to avoid potentially undefined behavior (preprocessing directives in macro arguments). The test done by the crypto tester is a simple functionality test.
This commit is contained in:
@@ -135,6 +135,8 @@ METHOD(key_exchange_t, get_public_key, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#ifdef TESTABLE_KE
|
||||
|
||||
METHOD(key_exchange_t, set_seed, bool,
|
||||
private_gmp_diffie_hellman_t *this, chunk_t value, drbg_t *drbg)
|
||||
{
|
||||
@@ -144,6 +146,8 @@ METHOD(key_exchange_t, set_seed, bool,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif /* TESTABLE_KE */
|
||||
|
||||
METHOD(key_exchange_t, get_shared_secret, bool,
|
||||
private_gmp_diffie_hellman_t *this, chunk_t *secret)
|
||||
{
|
||||
@@ -228,7 +232,6 @@ static gmp_diffie_hellman_t *create_generic(key_exchange_method_t group,
|
||||
.get_shared_secret = _get_shared_secret,
|
||||
.set_public_key = _set_public_key,
|
||||
.get_public_key = _get_public_key,
|
||||
.set_seed = _set_seed,
|
||||
.get_method = _get_method,
|
||||
.destroy = _destroy,
|
||||
},
|
||||
@@ -237,6 +240,10 @@ static gmp_diffie_hellman_t *create_generic(key_exchange_method_t group,
|
||||
.p_len = p.len,
|
||||
);
|
||||
|
||||
#ifdef TESTABLE_KE
|
||||
this->public.ke.set_seed = _set_seed;
|
||||
#endif
|
||||
|
||||
mpz_init(this->p);
|
||||
mpz_init(this->yb);
|
||||
mpz_init(this->ya);
|
||||
|
||||
Reference in New Issue
Block a user