From: Tobias Brunner Date: Fri, 23 May 2025 09:33:32 +0000 (+0200) Subject: botan: Remove unused drbg_t instance when building without testable KE X-Git-Tag: 6.0.2dr1~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07a9926464d25d255a21854abee6bac82aa71250;p=thirdparty%2Fstrongswan.git botan: Remove unused drbg_t instance when building without testable KE --- diff --git a/src/libstrongswan/plugins/botan/botan_kem.c b/src/libstrongswan/plugins/botan/botan_kem.c index e01dbdfeef..8a1219dcc1 100644 --- a/src/libstrongswan/plugins/botan/botan_kem.c +++ b/src/libstrongswan/plugins/botan/botan_kem.c @@ -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); }