@@ -1478,19 +1478,16 @@ static VALUE ossl_ec_point_add(VALUE self, VALUE other)
14781478/*
14791479 * call-seq:
14801480 * point.mul(bn1 [, bn2]) => point
1481- * point.mul(bns, points [, bn2]) => point
14821481 *
14831482 * Performs elliptic curve point multiplication.
14841483 *
14851484 * The first form calculates <tt>bn1 * point + bn2 * G</tt>, where +G+ is the
14861485 * generator of the group of _point_. _bn2_ may be omitted, and in that case,
14871486 * the result is just <tt>bn1 * point</tt>.
14881487 *
1489- * The second form calculates <tt>bns[0] * point + bns[1] * points[0] + ...
1490- * + bns[-1] * points[-1] + bn2 * G</tt>. _bn2_ may be omitted. _bns_ must be
1491- * an array of OpenSSL::BN. _points_ must be an array of
1492- * OpenSSL::PKey::EC::Point. Please note that <tt>points[0]</tt> is not
1493- * multiplied by <tt>bns[0]</tt>, but <tt>bns[1]</tt>.
1488+ * Before version 4.0.0, and when compiled with OpenSSL 1.1.1 or older, this
1489+ * method allowed another form:
1490+ * point.mul(bns, points [, bn2]) => point
14941491 */
14951492static VALUE ossl_ec_point_mul (int argc , VALUE * argv , VALUE self )
14961493{
@@ -1508,62 +1505,15 @@ static VALUE ossl_ec_point_mul(int argc, VALUE *argv, VALUE self)
15081505 GetECPoint (result , point_result );
15091506
15101507 rb_scan_args (argc , argv , "12" , & arg1 , & arg2 , & arg3 );
1511- if (!RB_TYPE_P (arg1 , T_ARRAY )) {
1512- BIGNUM * bn = GetBNPtr (arg1 );
1513-
1514- if (!NIL_P (arg2 ))
1515- bn_g = GetBNPtr (arg2 );
1516- if (EC_POINT_mul (group , point_result , bn_g , point_self , bn , ossl_bn_ctx ) != 1 )
1517- ossl_raise (eEC_POINT , NULL );
1518- } else {
1519- #if (defined(OPENSSL_VERSION_MAJOR ) && OPENSSL_VERSION_MAJOR >= 3 ) || defined(LIBRESSL_VERSION_NUMBER )
1520- rb_raise (rb_eNotImpError , "calling #mul with arrays is not" \
1521- "supported by this OpenSSL version" );
1522- #else
1523- /*
1524- * bignums | arg1[0] | arg1[1] | arg1[2] | ...
1525- * points | self | arg2[0] | arg2[1] | ...
1526- */
1527- long i , num ;
1528- VALUE bns_tmp , tmp_p , tmp_b ;
1529- const EC_POINT * * points ;
1530- const BIGNUM * * bignums ;
1531-
1532- Check_Type (arg1 , T_ARRAY );
1533- Check_Type (arg2 , T_ARRAY );
1534- if (RARRAY_LEN (arg1 ) != RARRAY_LEN (arg2 ) + 1 ) /* arg2 must be 1 larger */
1535- ossl_raise (rb_eArgError , "bns must be 1 longer than points; see the documentation" );
1536-
1537- rb_warning ("OpenSSL::PKey::EC::Point#mul(ary, ary) is deprecated; " \
1538- "use #mul(bn) form instead" );
1539-
1540- num = RARRAY_LEN (arg1 );
1541- bns_tmp = rb_ary_tmp_new (num );
1542- bignums = ALLOCV_N (const BIGNUM * , tmp_b , num );
1543- for (i = 0 ; i < num ; i ++ ) {
1544- VALUE item = RARRAY_AREF (arg1 , i );
1545- bignums [i ] = GetBNPtr (item );
1546- rb_ary_push (bns_tmp , item );
1547- }
1548-
1549- points = ALLOCV_N (const EC_POINT * , tmp_p , num );
1550- points [0 ] = point_self ; /* self */
1551- for (i = 0 ; i < num - 1 ; i ++ )
1552- GetECPoint (RARRAY_AREF (arg2 , i ), points [i + 1 ]);
1553-
1554- if (!NIL_P (arg3 ))
1555- bn_g = GetBNPtr (arg3 );
1556-
1557- if (EC_POINTs_mul (group , point_result , bn_g , num , points , bignums , ossl_bn_ctx ) != 1 ) {
1558- ALLOCV_END (tmp_b );
1559- ALLOCV_END (tmp_p );
1560- ossl_raise (eEC_POINT , NULL );
1561- }
1562-
1563- ALLOCV_END (tmp_b );
1564- ALLOCV_END (tmp_p );
1565- #endif
1566- }
1508+ if (RB_TYPE_P (arg1 , T_ARRAY ) || argc > 2 )
1509+ rb_raise (rb_eNotImpError , "OpenSSL::PKey::EC::Point#mul with arrays " \
1510+ "is no longer supported" );
1511+
1512+ BIGNUM * bn = GetBNPtr (arg1 );
1513+ if (!NIL_P (arg2 ))
1514+ bn_g = GetBNPtr (arg2 );
1515+ if (EC_POINT_mul (group , point_result , bn_g , point_self , bn , ossl_bn_ctx ) != 1 )
1516+ ossl_raise (eEC_POINT , NULL );
15671517
15681518 return result ;
15691519}
0 commit comments