From: Gihyeon Ryu Date: Thu, 26 Nov 2026 14:38:58 +0000 (+0100) Subject: BUG/MINOR: jwe: check that the EC point is on the curve X-Git-Url: https://git.kaiwu.me/http/%22../$%7BGITURL%7D/static/gitweb.js?a=commitdiff_plain;h=a505d952ca56e19184b2465c95b15f7a9bd2b601;p=haproxy.git BUG/MINOR: jwe: check that the EC point is on the curve EC_POINT_set_affine_coordinates() returns 0 when the point is not on the curve, but curve_param_to_pubkey() only treats a negative value as an error, as do the two tests of the OpenSSL 1.1.1 branch. An off-curve ECDH-ES "epk" is then rejected later by OpenSSL itself in the tested version (3.0), so no impact was found, but the check should not rely on it. The three tests now require a return value of 1. This may be backported up to 3.4. --- diff --git a/src/jwe.c b/src/jwe.c index 59cd2515f..f5155a0c5 100644 --- a/src/jwe.c +++ b/src/jwe.c @@ -1572,7 +1572,8 @@ static inline int curve_param_to_pubkey(int nid, BIGNUM *x, BIGNUM *y, struct bu if (!ec_point) goto end; - if (EC_POINT_set_affine_coordinates(group, ec_point, x, y, bnctx) < 0) + /* returns 0, not a negative value, for a point which is not on the curve */ + if (EC_POINT_set_affine_coordinates(group, ec_point, x, y, bnctx) != 1) goto end; out->data = EC_POINT_point2oct(group, ec_point, POINT_CONVERSION_UNCOMPRESSED, @@ -1666,10 +1667,10 @@ end: if (!ec_key) goto end; - if (nums[EC_BIGNUM_D] && EC_KEY_set_private_key(ec_key, nums[EC_BIGNUM_D]) < 0) + if (nums[EC_BIGNUM_D] && EC_KEY_set_private_key(ec_key, nums[EC_BIGNUM_D]) != 1) goto end; - if (EC_KEY_set_public_key_affine_coordinates(ec_key, nums[EC_BIGNUM_X], nums[EC_BIGNUM_Y]) < 0) + if (EC_KEY_set_public_key_affine_coordinates(ec_key, nums[EC_BIGNUM_X], nums[EC_BIGNUM_Y]) != 1) goto end; if (EC_KEY_check_key(ec_key) == 0)