summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-20 16:07:06 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-20 16:07:06 +0000
commit36f1477f3faef4c1af37a6799d945c8499dd4217 (patch)
tree8ea17cfe28994cb072971c74066e4c58d565fb05
parente4906ffa48f7f335d23b3782f714e60647957556 (diff)
* Backported the fix at
Mon Sep 13 09:23:58 2010 NARUSE, Yui <[email protected]> * ext/openssl/ossl_bn.c (ossl_bn_is_prime): fix comparison with rb_scan_args. Before this fix, OpenSSL::BN#prime? is fully broken. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@30279 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--ext/openssl/ossl_bn.c2
-rw-r--r--test/openssl/test_bn.rb5
3 files changed, 15 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index c358a95ff1..222c7efab1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Tue Dec 21 00:58:21 2010 NAKAMURA, Hiroshi <[email protected]>
+
+ * Backported the fix at
+ Mon Sep 13 09:23:58 2010 NARUSE, Yui <[email protected]>
+
+ * ext/openssl/ossl_bn.c (ossl_bn_is_prime): fix comparison
+ with rb_scan_args. Before this fix, OpenSSL::BN#prime?
+ is fully broken.
+
Tue Dec 21 00:19:50 2010 NAKAMURA, Hiroshi <[email protected]>
* Backported the fix at
diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c
index 6db9670bb7..76f98d2cd1 100644
--- a/ext/openssl/ossl_bn.c
+++ b/ext/openssl/ossl_bn.c
@@ -669,7 +669,7 @@ ossl_bn_is_prime(int argc, VALUE *argv, VALUE self)
VALUE vchecks;
int checks = BN_prime_checks;
- if (rb_scan_args(argc, argv, "01", &vchecks) == 0) {
+ if (rb_scan_args(argc, argv, "01", &vchecks) == 1) {
checks = NUM2INT(vchecks);
}
GetBN(self, bn);
diff --git a/test/openssl/test_bn.rb b/test/openssl/test_bn.rb
index 8df4daad37..adbe4f12c3 100644
--- a/test/openssl/test_bn.rb
+++ b/test/openssl/test_bn.rb
@@ -11,6 +11,11 @@ class OpenSSL::TestBN < Test::Unit::TestCase
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
+
+ def test_prime_p
+ OpenSSL::BN.new((2 ** 107 - 1).to_s(16), 16).prime?
+ OpenSSL::BN.new((2 ** 127 - 1).to_s(16), 16).prime?(1)
+ end
end
end