summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--ext/openssl/ossl_bn.c6
-rw-r--r--test/openssl/test_bn.rb4
-rw-r--r--version.h6
4 files changed, 15 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index d24adc3290..9c525fbb24 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Fri Apr 5 00:54:08 2013 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * ext/openssl/ossl_bn.c (ossl_bn_initialize): fix can't create from bn.
+
Thu Apr 4 02:27:12 2013 Tanaka Akira <akr@fsij.org>
* lib/resolv-replace.rb (TCPSocket#initialize): resolve the 3rd
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c
index 5d690af52d..822b854efe 100644
--- a/ext/openssl/ossl_bn.c
+++ b/ext/openssl/ossl_bn.c
@@ -119,11 +119,11 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
if (rb_scan_args(argc, argv, "11", &str, &bs) == 2) {
base = NUM2INT(bs);
}
- StringValue(str);
- GetBN(self, bn);
+
if (RTEST(rb_obj_is_kind_of(str, cBN))) {
BIGNUM *other;
+ GetBN(self, bn);
GetBN(str, other); /* Safe - we checked kind_of? above */
if (!BN_copy(bn, other)) {
ossl_raise(eBNError, NULL);
@@ -131,6 +131,8 @@ ossl_bn_initialize(int argc, VALUE *argv, VALUE self)
return self;
}
+ StringValue(str);
+ GetBN(self, bn);
switch (base) {
case 0:
if (!BN_mpi2bn((unsigned char *)RSTRING_PTR(str), RSTRING_LENINT(str), bn)) {
diff --git a/test/openssl/test_bn.rb b/test/openssl/test_bn.rb
index 7136de9a27..af1c72c8e9 100644
--- a/test/openssl/test_bn.rb
+++ b/test/openssl/test_bn.rb
@@ -3,6 +3,10 @@ require_relative 'utils'
if defined?(OpenSSL)
class OpenSSL::TestBN < Test::Unit::TestCase
+ def test_bn_to_bn
+ assert_equal(999.to_bn, OpenSSL::BN.new(999.to_bn))
+ end
+
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))
diff --git a/version.h b/version.h
index 880e8adbdc..d495107fb0 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2013-04-04"
-#define RUBY_PATCHLEVEL 105
+#define RUBY_RELEASE_DATE "2013-04-05"
+#define RUBY_PATCHLEVEL 106
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 4
-#define RUBY_RELEASE_DAY 4
+#define RUBY_RELEASE_DAY 5
#include "ruby/version.h"