method
mul
v2_2_9 -
Show latest stable
-
0 notes -
Class: Point
- 1_8_6_287
- 1_8_7_72
- 1_8_7_330
- 1_9_1_378
- 1_9_2_180
- 1_9_3_125
- 1_9_3_392
- 2_1_10 (0)
- 2_2_9 (0)
- 2_4_6 (38)
- 2_5_5 (0)
- 2_6_3 (0)
- What's this?
mul(p1, p2 = v2, p3 = v3)
public
Hide source
static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self) { EC_POINT *point1, *point2; const EC_GROUP *group; VALUE group_v = rb_iv_get(self, "@group"); VALUE bn_v1, bn_v2, r, points_v; BIGNUM *bn1 = NULL, *bn2 = NULL; Require_EC_POINT(self, point1); SafeRequire_EC_GROUP(group_v, group); r = rb_obj_alloc(cEC_POINT); ossl_ec_point_initialize(1, &group_v, r); Require_EC_POINT(r, point2); argc = rb_scan_args(argc, argv, "12", &bn_v1, &points_v, &bn_v2); if (rb_obj_is_kind_of(bn_v1, cBN)) { bn1 = GetBNPtr(bn_v1); if (argc >= 2) { bn2 = GetBNPtr(points_v); } if (EC_POINT_mul(group, point2, bn2, point1, bn1, ossl_bn_ctx) != 1) ossl_raise(eEC_POINT, "Multiplication failed"); } else { size_t i, points_len, bignums_len; const EC_POINT **points; const BIGNUM **bignums; Check_Type(bn_v1, T_ARRAY); bignums_len = RARRAY_LEN(bn_v1); bignums = (const BIGNUM **)OPENSSL_malloc(bignums_len * (int)sizeof(BIGNUM *)); for (i = 0; i < bignums_len; ++i) { bignums[i] = GetBNPtr(rb_ary_entry(bn_v1, i)); } if (!rb_obj_is_kind_of(points_v, rb_cArray)) { OPENSSL_free((void *)bignums); rb_raise(rb_eTypeError, "Argument2 must be an array"); } rb_ary_unshift(points_v, self); points_len = RARRAY_LEN(points_v); points = (const EC_POINT **)OPENSSL_malloc(points_len * (int)sizeof(EC_POINT *)); for (i = 0; i < points_len; ++i) { Get_EC_POINT(rb_ary_entry(points_v, i), points[i]); } if (argc >= 3) { bn2 = GetBNPtr(bn_v2); } if (EC_POINTs_mul(group, point2, bn2, points_len, points, bignums, ossl_bn_ctx) != 1) { OPENSSL_free((void *)bignums); OPENSSL_free((void *)points); ossl_raise(eEC_POINT, "Multiplication failed"); } OPENSSL_free((void *)bignums); OPENSSL_free((void *)points); } return r; }