Commit b03a09e519 for strongswan.org
commit b03a09e5191588668528f0d67d4e5d4ebcece54c
Author: Tobias Brunner <tobias@strongswan.org>
Date: Fri Mar 13 17:02:16 2026 +0100
wolfssl: Make sure we have an ECDSA public key
The ECPrivateKey structures in composite keys don't contain the public
key, so get_public_key() as well as get_encoding() would fail due to
the missing public key.
We really don't want to include the public key when encoding, however,
we can't avoid that anyway (OpenSSL does that too). So we'll have to
fix that afterwards.
diff --git a/src/libstrongswan/plugins/wolfssl/wolfssl_ec_private_key.c b/src/libstrongswan/plugins/wolfssl/wolfssl_ec_private_key.c
index 3a0aa347ad..1fabebb867 100644
--- a/src/libstrongswan/plugins/wolfssl/wolfssl_ec_private_key.c
+++ b/src/libstrongswan/plugins/wolfssl/wolfssl_ec_private_key.c
@@ -446,6 +446,7 @@ wolfssl_ec_private_key_t *wolfssl_ec_private_key_load(key_type_t type,
chunk_t params = chunk_empty, key = chunk_empty;
word32 idx;
ecc_curve_id oid = -1;
+ WC_RNG rng;
while (TRUE)
{
@@ -481,7 +482,19 @@ wolfssl_ec_private_key_t *wolfssl_ec_private_key_load(key_type_t type,
destroy(this);
return NULL;
}
-
+ if (wc_InitRng(&rng) != 0)
+ {
+ destroy(this);
+ return NULL;
+ }
+ if (this->ec.type == ECC_PRIVATEKEY_ONLY &&
+ wc_ecc_make_pub_ex(&this->ec, NULL, &rng) != 0)
+ {
+ destroy(this);
+ wc_FreeRng(&rng);
+ return NULL;
+ }
+ wc_FreeRng(&rng);
if (params.ptr)
{
/* if ECParameters is passed, ensure we guessed correctly */