Convert the EC point into an octet
string and store in an OpenSSL::BN. If
conversion_form is given, the point data is converted using the
specified form. If not given, the default form set in the EC::Group object
is used.
See also EC::Point#point_conversion_form=.
static VALUE
ossl_ec_point_to_bn(int argc, VALUE *argv, VALUE self)
{
EC_POINT *point;
VALUE form_obj, bn_obj;
const EC_GROUP *group;
point_conversion_form_t form;
BIGNUM *bn;
GetECPoint(self, point);
GetECPointGroup(self, group);
rb_scan_args(argc, argv, "01", &form_obj);
if (NIL_P(form_obj))
form = EC_GROUP_get_point_conversion_form(group);
else
form = parse_point_conversion_form_symbol(form_obj);
bn_obj = rb_obj_alloc(cBN);
bn = GetBNPtr(bn_obj);
if (EC_POINT_point2bn(group, point, form, bn, ossl_bn_ctx) == NULL)
ossl_raise(eEC_POINT, "EC_POINT_point2bn");
return bn_obj;
}