Simplify EC_GROUP_new_by_curve_name()
authortb <tb@openbsd.org>
Tue, 2 May 2023 10:44:20 +0000 (10:44 +0000)
committertb <tb@openbsd.org>
Tue, 2 May 2023 10:44:20 +0000 (10:44 +0000)
commitb1c4c3493572e1bb7fc6e90d4f9a398ac6ffb211
treee825559bc367ba377f83f6783d921d06a5877d6b
parent158e7cafb192e0731982796768038bd07019206e
Simplify EC_GROUP_new_by_curve_name()

Pull the setting of the name a.k.a. nid into ec_group_new_from_data().
This way, we can return early on finding the nid in the curve_list[].
This also avoids a silly bug where a bogus ERR_R_UNKNOWN_BUG is pushed
onto the error stack when ec_group_new_from_data() failed.

While there rework the exit path of ec_group_new_from_data() a bit.
Instead of an ok variable we can use an additional pointer to keep
track of the return value and free the EC_GROUP unconditionally.

ok jsing
lib/libcrypto/ec/ec_curve.c