]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
wolfssl: Properly initialize ECC private key object
authorJuliusz Sosinowicz <juliusz@wolfssl.com>
Wed, 23 Apr 2025 13:56:09 +0000 (15:56 +0200)
committerTobias Brunner <tobias@strongswan.org>
Mon, 2 Jun 2025 07:15:05 +0000 (09:15 +0200)
src/libstrongswan/plugins/wolfssl/wolfssl_ec_private_key.c

index addd3bda2a8dcd083e8ab54aff24cdd3e03d331f..2d04d0764ccc23545c24d91c905a7d872be43efa 100644 (file)
@@ -339,9 +339,16 @@ static private_wolfssl_ec_private_key_t *create_empty(void)
                .ref = 1,
        );
 
-       if (wc_InitRng(&this->rng) < 0)
+       if (wc_ecc_init(&this->ec) != 0)
        {
-               DBG1(DBG_LIB, "RNG init failed");
+               DBG1(DBG_LIB, "EC private key initialization failed");
+               free(this);
+               return NULL;
+       }
+       if (wc_InitRng(&this->rng) != 0)
+       {
+               DBG1(DBG_LIB, "RNG initialization for EC private key failed");
+               wc_ecc_free(&this->ec);
                free(this);
                return NULL;
        }