Method: OpenSSL::PKey::EC::Point#initialize
- Defined in:
- ext/openssl/ossl_pkey_ec.c
#OpenSSL::PKey::EC::Point.new(point) ⇒ Object #OpenSSL::PKey::EC::Point.new(group[, encoded_point]) ⇒ Object
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.
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 |
# File 'ext/openssl/ossl_pkey_ec.c', line 1156
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;
}
|