From 1c2b9e345c36450e477ab25e7c5ece37c8cd2436 Mon Sep 17 00:00:00 2001 From: Kazuki Yamaguchi Date: Wed, 7 Sep 2016 16:50:32 +0900 Subject: pkey: allow specifying conversion form in EC::Point#to_bn Currently, when we want to convert a point data into an octet string with non-default conversion form, we have to set the desirable form to the associated EC::Group beforehand. This is inconvenient and counterintuitive because the conversion form is not actually related to the EC group. point = ... point.group.point_conversion_form = :compressed point.to_bn So, allow specifying the form as an optional parameter, like this: point = ... point.to_bn(:compressed) --- test/test_pkey_ec.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test') diff --git a/test/test_pkey_ec.rb b/test/test_pkey_ec.rb index 53aa5a10..0058d8bf 100644 --- a/test/test_pkey_ec.rb +++ b/test/test_pkey_ec.rb @@ -244,6 +244,10 @@ class OpenSSL::TestEC < OpenSSL::PKeyTestCase raise end + assert_equal 0x040603.to_bn, point.to_bn(:uncompressed) + assert_equal 0x0306.to_bn, point.to_bn(:compressed) + assert_equal 0x070603.to_bn, point.to_bn(:hybrid) + assert_equal 0x040603.to_bn, point.to_bn assert_equal true, point.on_curve? point.invert! # 8.5 -- cgit v1.2.3