to_octet_string(p1)
public
Returns the octet string representation of the elliptic curve point.
conversion_form specifies how the point is converted. Possible
values are:
-
:compressed
-
:uncompressed
-
:hybrid
static VALUE
ossl_ec_point_to_octet_string(VALUE self, VALUE conversion_form)
{
EC_POINT *point;
const EC_GROUP *group;
point_conversion_form_t form;
VALUE str;
size_t len;
GetECPoint(self, point);
GetECPointGroup(self, group);
form = parse_point_conversion_form_symbol(conversion_form);
len = EC_POINT_point2oct(group, point, form, NULL, 0, ossl_bn_ctx);
if (!len)
ossl_raise(eEC_POINT, "EC_POINT_point2oct");
str = rb_str_new(NULL, (long)len);
if (!EC_POINT_point2oct(group, point, form,
(unsigned char *)RSTRING_PTR(str), len,
ossl_bn_ctx))
ossl_raise(eEC_POINT, "EC_POINT_point2oct");
return str;
}