Introduce and use ec_encode_scalar()
authortb <tb@openbsd.org>
Wed, 26 Jul 2023 12:24:28 +0000 (12:24 +0000)
committertb <tb@openbsd.org>
Wed, 26 Jul 2023 12:24:28 +0000 (12:24 +0000)
commitd9134140658b0db975af355f4ffb745b511ee95e
treeae5bb8fa07ef43f0bd68026ee782941db26fb3cb
parent75da7a821c9f4678a8fb12a9c2ecd63e132006de
Introduce and use ec_encode_scalar()

This introduces two "inverses" of the ec_decode_scalar() function that take
a BIGNUM, reduce it modulo p and then encodes it into the curve's field
representation. For setting projective coordinates, we need a specialized
helper that deals with the Z_is_one optimization that is used to optimize
for calculations in standard affine coordinates of the projective plane.
This is used for simplifying EC_POINT_set_Jprojective_coordinates() and
for cleaning up and streamlining EC_GROUP_set_curve().

ok jsing
lib/libcrypto/ec/ecp_smpl.c