From 856e1f17f1846a2ad077aa7b0da6a2b8399fd7b7 Mon Sep 17 00:00:00 2001 From: yugui Date: Mon, 15 Nov 2010 11:43:42 +0000 Subject: [PATCH] merges r29237 and r29238 from trunk into ruby_1_9_2. -- * ext/openssl/ossl_bn.c (ossl_bn_is_prime): fix comparison with rb_scan_args. Before this fix, OpenSSL::BN#prime? is fully broken. -- Add ML ref [ruby-dev:42225] for r29237. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_2@29794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ ext/openssl/ossl_bn.c | 2 +- test/openssl/test_bn.rb | 17 +++++++++++++++++ version.h | 2 +- 4 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 test/openssl/test_bn.rb diff --git a/ChangeLog b/ChangeLog index 8b689a8fa8..00a4395217 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Sep 13 09:23:58 2010 NARUSE, Yui + + * ext/openssl/ossl_bn.c (ossl_bn_is_prime): fix comparison + with rb_scan_args. Before this fix, OpenSSL::BN#prime? + is fully broken. [ruby-dev:42225] + Sun Sep 12 21:21:50 2010 Tadayoshi Funaba * lib/date.rb: [ruby-core:32096] Thanks Colin Bartlett. diff --git a/ext/openssl/ossl_bn.c b/ext/openssl/ossl_bn.c index bec5135f12..6adc59fc1a 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 new file mode 100644 index 0000000000..da77a556b0 --- /dev/null +++ b/test/openssl/test_bn.rb @@ -0,0 +1,17 @@ +begin + require "openssl" +rescue LoadError +end +require "digest/md5" +require "test/unit" + +if defined?(OpenSSL) + +class OpenSSL::TestBN < Test::Unit::TestCase + 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 diff --git a/version.h b/version.h index a16ba89083..18b68bedd2 100644 --- a/version.h +++ b/version.h @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.2" -#define RUBY_PATCHLEVEL 38 +#define RUBY_PATCHLEVEL 39 #define RUBY_VERSION_MAJOR 1 #define RUBY_VERSION_MINOR 9 #define RUBY_VERSION_TEENY 1