diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-08-22 17:42:31 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-08-22 17:46:47 +0900 |
commit | b099663eb81f4ef6ff8963271a04442cef2667dd (patch) | |
tree | 7cf3da2faefbc205da5f5adc4e61a60bd40a3a8e /ext/openssl/ossl_pkey_ec.c | |
parent | 5c1045ea40aa0ca76d8288fa0e91fdaa412bbb83 (diff) | |
download | ruby-openssl-b099663eb81f4ef6ff8963271a04442cef2667dd.tar.gz |
pkey: allow non-BN object as the multiplier in PKey::EC::Point#mul
Diffstat (limited to 'ext/openssl/ossl_pkey_ec.c')
-rw-r--r-- | ext/openssl/ossl_pkey_ec.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/ext/openssl/ossl_pkey_ec.c b/ext/openssl/ossl_pkey_ec.c index 5ddc4f26..e55e8971 100644 --- a/ext/openssl/ossl_pkey_ec.c +++ b/ext/openssl/ossl_pkey_ec.c @@ -1698,11 +1698,11 @@ static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self) Require_EC_POINT(result, point_result); rb_scan_args(argc, argv, "12", &arg1, &arg2, &arg3); - if (rb_obj_is_kind_of(arg1, cBN)) { + if (!RB_TYPE_P(arg1, T_ARRAY)) { BIGNUM *bn = GetBNPtr(arg1); - if (argc >= 2) - bn_g = GetBNPtr(arg2); + if (!NIL_P(arg2)) + bn_g = GetBNPtr(arg2); if (EC_POINT_mul(group, point_result, bn_g, point_self, bn, ossl_bn_ctx) != 1) ossl_raise(eEC_POINT, NULL); } else { @@ -1715,9 +1715,8 @@ static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self) const EC_POINT **points; const BIGNUM **bignums; - if (!rb_obj_is_kind_of(arg1, rb_cArray) || - !rb_obj_is_kind_of(arg2, rb_cArray)) - ossl_raise(rb_eTypeError, "points must be array"); + Check_Type(arg1, T_ARRAY); + Check_Type(arg2, T_ARRAY); if (RARRAY_LEN(arg1) != RARRAY_LEN(arg2) + 1) /* arg2 must be 1 larger */ ossl_raise(rb_eArgError, "bns must be 1 longer than points; see the documentation"); @@ -1731,7 +1730,7 @@ static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self) for (i = 0; i < num - 1; i++) SafeRequire_EC_POINT(RARRAY_AREF(arg2, i), points[i + 1]); - if (argc >= 3) + if (!NIL_P(arg3)) bn_g = GetBNPtr(arg3); if (EC_POINTs_mul(group, point_result, bn_g, num, points, bignums, ossl_bn_ctx) != 1) { |