[前][次][番号順一覧][スレッド一覧]

ruby-changes:43208

From: rhe <ko1@a...>
Date: Sun, 5 Jun 2016 21:38:42 +0900 (JST)
Subject: [ruby-changes:43208] rhe:r55282 (trunk): openssl: check existence of RAND_pseudo_bytes()

rhe	2016-06-05 21:38:34 +0900 (Sun, 05 Jun 2016)

  New Revision: 55282

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55282

  Log:
    openssl: check existence of RAND_pseudo_bytes()
    
    * ext/openssl/extconf.rb: Check if RAND_pseudo_bytes() is usable. It is
      marked as deprecated in OpenSSL 1.1.0.
      [ruby-core:75225] [Feature #12324]
    
    * ext/openssl/ossl_rand.c: Disable Random.pseudo_bytes if
      RAND_pseudo_bytes() is unavailable.
    
    * test/openssl/test_random.rb: Don't test Random.pseudo_bytes if not
      defined.

  Modified files:
    trunk/ChangeLog
    trunk/ext/openssl/extconf.rb
    trunk/ext/openssl/ossl_rand.c
    trunk/test/openssl/test_random.rb
Index: test/openssl/test_random.rb
===================================================================
--- test/openssl/test_random.rb	(revision 55281)
+++ test/openssl/test_random.rb	(revision 55282)
@@ -8,7 +8,8 @@ class OpenSSL::TestRandom < OpenSSL::Tes https://github.com/ruby/ruby/blob/trunk/test/openssl/test_random.rb#L8
   end
 
   def test_pseudo_bytes
+    # deprecated as of OpenSSL 1.1.0
     assert_equal("", OpenSSL::Random.pseudo_bytes(0))
     assert_equal(12, OpenSSL::Random.pseudo_bytes(12).bytesize)
-  end
+  end if OpenSSL::Random.methods.include?(:pseudo_bytes)
 end if defined?(OpenSSL::TestCase)
Index: ext/openssl/ossl_rand.c
===================================================================
--- ext/openssl/ossl_rand.c	(revision 55281)
+++ ext/openssl/ossl_rand.c	(revision 55282)
@@ -124,6 +124,7 @@ ossl_rand_bytes(VALUE self, VALUE len) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_rand.c#L124
     return str;
 }
 
+#if defined(HAVE_RAND_PSEUDO_BYTES)
 /*
  *  call-seq:
  *	pseudo_bytes(length) -> string
@@ -151,6 +152,7 @@ ossl_rand_pseudo_bytes(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_rand.c#L152
 
     return str;
 }
+#endif
 
 #ifdef HAVE_RAND_EGD
 /*
@@ -224,7 +226,9 @@ Init_ossl_rand(void) https://github.com/ruby/ruby/blob/trunk/ext/openssl/ossl_rand.c#L226
     rb_define_module_function(mRandom, "load_random_file", ossl_rand_load_file, 1);
     rb_define_module_function(mRandom, "write_random_file", ossl_rand_write_file, 1);
     rb_define_module_function(mRandom, "random_bytes", ossl_rand_bytes, 1);
+#if defined(HAVE_RAND_PSEUDO_BYTES)
     rb_define_module_function(mRandom, "pseudo_bytes", ossl_rand_pseudo_bytes, 1);
+#endif
 #ifdef HAVE_RAND_EGD
     rb_define_module_function(mRandom, "egd", ossl_rand_egd, 1);
     rb_define_module_function(mRandom, "egd_bytes", ossl_rand_egd_bytes, 2);
Index: ext/openssl/extconf.rb
===================================================================
--- ext/openssl/extconf.rb	(revision 55281)
+++ ext/openssl/extconf.rb	(revision 55282)
@@ -107,6 +107,7 @@ OpenSSL.check_func_or_macro("SSL_CTX_set https://github.com/ruby/ruby/blob/trunk/ext/openssl/extconf.rb#L107
 OpenSSL.check_func_or_macro("SSL_get_server_tmp_key", "openssl/ssl.h")
 
 # added in 1.1.0
+OpenSSL.check_func("RAND_pseudo_bytes", "openssl/rand.h") # deprecated
 have_func("X509_STORE_get_ex_data")
 have_func("X509_STORE_set_ex_data")
 OpenSSL.check_func_or_macro("SSL_CTX_set_tmp_ecdh_callback", "openssl/ssl.h") # removed
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55281)
+++ ChangeLog	(revision 55282)
@@ -1,3 +1,15 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sun Jun  5 21:38:13 2016  Kazuki Yamaguchi  <k@r...>
+
+	* ext/openssl/extconf.rb: Check if RAND_pseudo_bytes() is usable. It is
+	  marked as deprecated in OpenSSL 1.1.0.
+	  [ruby-core:75225] [Feature #12324]
+
+	* ext/openssl/ossl_rand.c: Disable Random.pseudo_bytes if
+	  RAND_pseudo_bytes() is unavailable.
+
+	* test/openssl/test_random.rb: Don't test Random.pseudo_bytes if not
+	  defined.
+
 Sun Jun  5 19:06:40 2016  Martin Duerst  <duerst@i...>
 
 	* NEWS: Add news about Unicode-wide case mapping for

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]