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