From cb0ea9ddfdfd152de3321283dda1038e2c18a809 Mon Sep 17 00:00:00 2001 From: nahi Date: Mon, 20 Dec 2010 15:21:52 +0000 Subject: [PATCH] * Backported the fix at Mon Oct 4 09:30:42 2010 NARUSE, Yui * ext/openssl/lib/openssl/bn.rb (Integer#to_bn): OpenSSL::BN.new accepts only Strings, so call Integer#to_s(16). 16 is for an optimization. [ruby-dev:42336] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@30275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 9 +++++++++ ext/openssl/lib/openssl/bn.rb | 2 +- test/openssl/test_bn.rb | 12 ++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/openssl/test_bn.rb diff --git a/ChangeLog b/ChangeLog index 39078dc836..c358a95ff1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +Tue Dec 21 00:19:50 2010 NAKAMURA, Hiroshi + + * Backported the fix at + Mon Oct 4 09:30:42 2010 NARUSE, Yui + + * ext/openssl/lib/openssl/bn.rb (Integer#to_bn): OpenSSL::BN.new + accepts only Strings, so call Integer#to_s(16). + 16 is for an optimization. [ruby-dev:42336] + Sat Dec 11 05:48:28 2010 Hidetoshi NAGAI * ext/tk/lib/multi-tk.rb: infinite loop on method_missing at loading diff --git a/ext/openssl/lib/openssl/bn.rb b/ext/openssl/lib/openssl/bn.rb index e7cbf2cfaf..624c13715c 100644 --- a/ext/openssl/lib/openssl/bn.rb +++ b/ext/openssl/lib/openssl/bn.rb @@ -29,7 +29,7 @@ end # OpenSSL # class Integer def to_bn - OpenSSL::BN::new(self) + OpenSSL::BN::new(self.to_s(16), 16) end end # Integer diff --git a/test/openssl/test_bn.rb b/test/openssl/test_bn.rb new file mode 100644 index 0000000000..98ceb7dd30 --- /dev/null +++ b/test/openssl/test_bn.rb @@ -0,0 +1,12 @@ +require_relative 'utils' + +if defined?(OpenSSL) + +class OpenSSL::TestBN < Test::Unit::TestCase + def test_integer_to_bn + assert_equal(999.to_bn, OpenSSL::BN.new(999.to_s(16), 16)) + assert_equal((2 ** 107 - 1).to_bn, OpenSSL::BN.new((2 ** 107 - 1).to_s(16), 16)) + end +end + +end