ruby-changes:17237
From: naruse <ko1@a...>
Date: Mon, 13 Sep 2010 09:45:23 +0900 (JST)
Subject: [ruby-changes:17237] Ruby:r29237 (trunk): * ext/openssl/ossl_bn.c (ossl_bn_is_prime): fix comparison
naruse 2010-09-13 09:40:10 +0900 (Mon, 13 Sep 2010) New Revision: 29237 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29237 Log: * ext/openssl/ossl_bn.c (ossl_bn_is_prime): fix comparison with rb_scan_args. Before this fix, OpenSSL::BN#prime? is fully broken. Added files: trunk/test/openssl/test_bn.rb Modified files: trunk/ChangeLog trunk/ext/openssl/ossl_bn.c Index: ChangeLog =================================================================== --- ChangeLog (revision 29236) +++ ChangeLog (revision 29237) @@ -1,3 +1,9 @@ +Mon Sep 13 09:23:58 2010 NARUSE, Yui <naruse@r...> + + * ext/openssl/ossl_bn.c (ossl_bn_is_prime): fix comparison + with rb_scan_args. Before this fix, OpenSSL::BN#prime? + is fully broken. + Mon Sep 13 06:45:24 2010 Tanaka Akira <akr@f...> * ext/pathname/pathname.c (path_writable_real_p): Index: ext/openssl/ossl_bn.c =================================================================== --- ext/openssl/ossl_bn.c (revision 29236) +++ ext/openssl/ossl_bn.c (revision 29237) @@ -669,7 +669,7 @@ 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); Index: test/openssl/test_bn.rb =================================================================== --- test/openssl/test_bn.rb (revision 0) +++ test/openssl/test_bn.rb (revision 29237) @@ -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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/