aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-08-22 17:42:31 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-08-22 17:46:47 +0900
commitb099663eb81f4ef6ff8963271a04442cef2667dd (patch)
tree7cf3da2faefbc205da5f5adc4e61a60bd40a3a8e /test
parent5c1045ea40aa0ca76d8288fa0e91fdaa412bbb83 (diff)
downloadruby-openssl-b099663eb81f4ef6ff8963271a04442cef2667dd.tar.gz
pkey: allow non-BN object as the multiplier in PKey::EC::Point#mul
Diffstat (limited to 'test')
-rw-r--r--test/test_pkey_ec.rb15
1 files changed, 8 insertions, 7 deletions
diff --git a/test/test_pkey_ec.rb b/test/test_pkey_ec.rb
index b89fa38d..53aa5a10 100644
--- a/test/test_pkey_ec.rb
+++ b/test/test_pkey_ec.rb
@@ -262,24 +262,25 @@ class OpenSSL::TestEC < OpenSSL::PKeyTestCase
# y^2 = x^3 + 2x + 2 over F_17
# generator is (5, 1)
group = OpenSSL::PKey::EC::Group.new(:GFp, 17, 2, 2)
+ group.point_conversion_form = :uncompressed
gen = OpenSSL::PKey::EC::Point.new(group, OpenSSL::BN.new("040501", 16))
group.set_generator(gen, 0, 0)
# 3 * (6, 3) = (16, 13)
point_a = OpenSSL::PKey::EC::Point.new(group, OpenSSL::BN.new("040603", 16))
- result_a1 = point_a.mul(3.to_bn)
+ result_a1 = point_a.mul(3)
assert_equal("04100D", result_a1.to_bn.to_s(16))
# 3 * (6, 3) + 3 * (5, 1) = (7, 6)
- result_a2 = point_a.mul(3.to_bn, 3.to_bn)
+ result_a2 = point_a.mul(3, 3)
assert_equal("040706", result_a2.to_bn.to_s(16))
# 3 * point_a = 3 * (6, 3) = (16, 13)
- result_b1 = point_a.mul([3.to_bn], [])
+ result_b1 = point_a.mul([3], [])
assert_equal("04100D", result_b1.to_bn.to_s(16))
# 3 * point_a + 2 * point_a = 3 * (6, 3) + 2 * (6, 3) = (7, 11)
- result_b1 = point_a.mul([3.to_bn, 2.to_bn], [point_a])
+ result_b1 = point_a.mul([3, 2], [point_a])
assert_equal("04070B", result_b1.to_bn.to_s(16))
# 3 * point_a + 5 * point_a.group.generator = 3 * (6, 3) + 5 * (5, 1) = (13, 10)
- result_b1 = point_a.mul([3.to_bn], [], 5)
+ result_b1 = point_a.mul([3], [], 5)
assert_equal("040D0A", result_b1.to_bn.to_s(16))
rescue OpenSSL::PKey::EC::Group::Error
# CentOS patches OpenSSL to reject curves defined over Fp where p < 256 bits
@@ -293,8 +294,8 @@ class OpenSSL::TestEC < OpenSSL::PKeyTestCase
# invalid argument
point = p256_key.public_key
assert_raise(TypeError) { point.mul(nil) }
- assert_raise(ArgumentError) { point.mul([1.to_bn], [point]) }
- assert_raise(TypeError) { point.mul([1.to_bn], nil) }
+ assert_raise(ArgumentError) { point.mul([1], [point]) }
+ assert_raise(TypeError) { point.mul([1], nil) }
assert_raise(TypeError) { point.mul([nil], []) }
end