mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-03 00:00:24 -04:00
botan: Remove unused drbg_t instance when building without testable KE
This commit is contained in:
parent
37ec770758
commit
07a9926464
@ -76,12 +76,16 @@ struct private_key_exchange_t {
|
||||
*/
|
||||
chunk_t shared_secret;
|
||||
|
||||
#ifdef TESTABLE_KE
|
||||
/**
|
||||
* DRBG for testing.
|
||||
*/
|
||||
drbg_t *drbg;
|
||||
#endif
|
||||
};
|
||||
|
||||
#ifdef TESTABLE_KE
|
||||
|
||||
CALLBACK(get_random, int,
|
||||
drbg_t *drbg, uint8_t *out, size_t out_len)
|
||||
{
|
||||
@ -92,17 +96,21 @@ CALLBACK(get_random, int,
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* TESTABLE_KE */
|
||||
|
||||
/**
|
||||
* Initializes the given RNG, either based on a DRBG during testing or using
|
||||
* the plugin's configured RNG.
|
||||
*/
|
||||
static bool get_rng(private_key_exchange_t *this, botan_rng_t *rng)
|
||||
{
|
||||
#ifdef TESTABLE_KE
|
||||
if (this->drbg)
|
||||
{
|
||||
return !botan_rng_init_custom(rng, "kem-drbg", this->drbg,
|
||||
get_random, NULL, NULL);
|
||||
}
|
||||
#endif
|
||||
return botan_get_rng(rng, RNG_STRONG);
|
||||
}
|
||||
|
||||
@ -121,6 +129,7 @@ CALLBACK(botan_view_to_chunk, int,
|
||||
*/
|
||||
static bool generate_keypair(private_key_exchange_t *this)
|
||||
{
|
||||
#ifdef TESTABLE_KE
|
||||
if (this->drbg)
|
||||
{
|
||||
uint8_t random[ML_KEM_SEED_LEN];
|
||||
@ -135,6 +144,7 @@ static bool generate_keypair(private_key_exchange_t *this)
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif /* TESTABLE_KE */
|
||||
{
|
||||
botan_rng_t rng = NULL;
|
||||
|
||||
@ -313,7 +323,9 @@ METHOD(key_exchange_t, destroy, void,
|
||||
chunk_clear(&this->shared_secret);
|
||||
chunk_free(&this->ciphertext);
|
||||
botan_privkey_destroy(this->kem);
|
||||
#ifdef TESTABLE_KE
|
||||
DESTROY_IF(this->drbg);
|
||||
#endif
|
||||
free(this->name);
|
||||
free(this);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user