]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
ml: Remove unused drbg_t instance when building without testable KE
authorTobias Brunner <tobias@strongswan.org>
Fri, 23 May 2025 09:34:18 +0000 (11:34 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 27 May 2025 15:38:32 +0000 (17:38 +0200)
src/libstrongswan/plugins/ml/ml_kem.c

index a19a7a4f1639f8a83e0c1a71ff220479eb3edef1..9da72ea6114cd330620411f87eb94d38ac0274cf 100644 (file)
@@ -89,10 +89,12 @@ struct private_key_exchange_t {
         */
        hasher_t *H;
 
+#ifdef TESTABLE_KE
        /**
         * DRBG used during testing.
         */
        drbg_t *drbg;
+#endif
 };
 
 /**
@@ -102,10 +104,13 @@ static bool get_random(private_key_exchange_t *this, size_t len, uint8_t *out)
 {
        rng_t *rng;
 
+#ifdef TESTABLE_KE
        if (this->drbg)
        {
                return this->drbg->generate(this->drbg, len, out);
        }
+#endif
+
        rng = lib->crypto->create_rng(lib->crypto, RNG_STRONG);
        if (!rng || !rng->get_bytes(rng, len, out))
        {
@@ -961,7 +966,9 @@ METHOD(key_exchange_t, destroy, void,
        chunk_clear(&this->shared_secret);
        chunk_free(&this->public_key);
        chunk_free(&this->ciphertext);
+#ifdef TESTABLE_KE
        DESTROY_IF(this->drbg);
+#endif
        DESTROY_IF(this->shake128);
        DESTROY_IF(this->shake256);
        DESTROY_IF(this->G);