class method
OpenSSL::PKey::EC::Point.new
(::OpenSSL::PKey::EC::Point point) -> ::OpenSSL::PKey::EC::Point
(::OpenSSL::PKey::EC::Group group, ?::String | ::OpenSSL::BN encoded_point) -> ::OpenSSL::PKey::EC::Point
OpenSSL::PKey::EC::Point.new(point)
OpenSSL::PKey::EC::Point.new(group [, encoded_point])
ext/openssl/ossl_pkey_ec.c
View on GitHub ↗
static VALUE ossl_ec_point_initialize(int argc, VALUE *argv, VALUE self)
{
EC_POINT *point;
VALUE group_v, arg2;
const EC_GROUP *group;
TypedData_Get_Struct(self, EC_POINT, &ossl_ec_point_type, point);
if (point)
rb_raise(eEC_POINT, "EC_POINT already initialized");
rb_scan_args(argc, argv, "11", &group_v, &arg2);
if (rb_obj_is_kind_of(group_v, cEC_POINT)) {
if (argc != 1)
rb_raise(rb_eArgError, "invalid second argument");
return ossl_ec_point_initialize_copy(self, group_v);
}
GetECGroup(group_v, group);
if (argc == 1) {
point = EC_POINT_new(group);
if (!point)
ossl_raise(eEC_POINT, "EC_POINT_new");
}
else {
if (rb_obj_is_kind_of(arg2, cBN)) {
point = EC_POINT_bn2point(group, GetBNPtr(arg2), NULL, ossl_bn_ctx);
if (!point)
ossl_raise(eEC_POINT, "EC_POINT_bn2point");
}
else {
StringValue(arg2);
point = EC_POINT_new(group);
if (!point)
ossl_raise(eEC_POINT, "EC_POINT_new");
if (!EC_POINT_oct2point(group, point,
(unsigned char *)RSTRING_PTR(arg2),
RSTRING_LEN(arg2), ossl_bn_ctx)) {
EC_POINT_free(point);
ossl_raise(eEC_POINT, "EC_POINT_oct2point");
}
}
}
RTYPEDDATA_DATA(self) = point;
rb_ivar_set(self, id_i_group, group_v);
return self;
}
Creates a new instance of OpenSSL::PKey::EC::Point. If the only argument is an instance of EC::Point, a copy is returned. Otherwise, creates a point that belongs to group.
encoded_point is the octet string representation of the point. This must be either a String or an OpenSSL::BN.