From 05625acc2ab4ea225e39bde8333dbfc23c37f5ac Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Fri, 12 Jun 2026 17:07:32 +0200 Subject: [PATCH] wolfssl: Ensure X25519/X448 public key is valid --- .../plugins/wolfssl/wolfssl_x_diffie_hellman.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/libstrongswan/plugins/wolfssl/wolfssl_x_diffie_hellman.c b/src/libstrongswan/plugins/wolfssl/wolfssl_x_diffie_hellman.c index 8cf824918..68ff5bc7d 100644 --- a/src/libstrongswan/plugins/wolfssl/wolfssl_x_diffie_hellman.c +++ b/src/libstrongswan/plugins/wolfssl/wolfssl_x_diffie_hellman.c @@ -121,8 +121,9 @@ METHOD(key_exchange_t, set_public_key_25519, bool, { return FALSE; } - - if (wc_curve25519_import_public_ex(value.ptr, value.len, &this->pub.key25519, + if (wc_curve25519_check_public(value.ptr, value.len, + EC25519_LITTLE_ENDIAN) != 0 || + wc_curve25519_import_public_ex(value.ptr, value.len, &this->pub.key25519, EC25519_LITTLE_ENDIAN) != 0) { DBG1(DBG_LIB, "%N public value is malformed", @@ -211,7 +212,9 @@ METHOD(key_exchange_t, set_public_key_448, bool, return FALSE; } - if (wc_curve448_import_public_ex(value.ptr, value.len, &this->pub.key448, + if (wc_curve448_check_public(value.ptr, value.len, + EC448_LITTLE_ENDIAN) != 0 || + wc_curve448_import_public_ex(value.ptr, value.len, &this->pub.key448, EC448_LITTLE_ENDIAN) != 0) { DBG1(DBG_LIB, "%N public value is malformed",