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

ruby-changes:21776

From: emboss <ko1@a...>
Date: Thu, 24 Nov 2011 10:10:07 +0900 (JST)
Subject: [ruby-changes:21776] emboss:r33825 (trunk): * test/openssl/test_engine.rb: Suppress output from 'openssl'

emboss	2011-11-24 10:09:55 +0900 (Thu, 24 Nov 2011)

  New Revision: 33825

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33825

  Log:
    * test/openssl/test_engine.rb: Suppress output from 'openssl'
      engine's RC4 cipher.
      [Bug #5633] [ruby-core:41026]

  Modified files:
    trunk/ChangeLog
    trunk/test/openssl/test_engine.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 33824)
+++ ChangeLog	(revision 33825)
@@ -1,3 +1,9 @@
+Thu Nov 24 10:05:02 2011  Martin Bosslet  <Martin.Bosslet@g...>
+
+	* test/openssl/test_engine.rb: Suppress output from 'openssl'
+	  engine's RC4 cipher.
+	  [Bug #5633] [ruby-core:41026]
+
 Thu Nov 24 08:05:02 2011  Martin Bosslet  <Martin.Bosslet@g...>
 
 	* ext/openssl/ossl_pkey_dsa.c: remove redundant colon from error
@@ -4,7 +10,7 @@
 	  message.
 	* ext/openssl/ossl_ssl.c: ditto.
 	* ext/openssl/ossl_pkey_rsa: ditto.
-	patched by Eric Hodel [Bug #5604] [ruby-core:40896]
+	  patched by Eric Hodel [Bug #5604] [ruby-core:40896]
 
 Wed Nov 23 20:03:43 2011  NARUSE, Yui  <naruse@r...>
 
Index: test/openssl/test_engine.rb
===================================================================
--- test/openssl/test_engine.rb	(revision 33824)
+++ test/openssl/test_engine.rb	(revision 33825)
@@ -45,27 +45,29 @@
     algo = "RC4" #AES is not supported by openssl Engine (<=1.0.0e)
     data = "a" * 1000
     key = OpenSSL::Random.random_bytes(16)
-
-    encipher = engine.cipher(algo)
-    encipher.encrypt
-    encipher.key = key
-
-    decipher = OpenSSL::Cipher.new(algo)
-    decipher.decrypt
-    decipher.key = key
-
-    encrypted = encipher.update(data) + encipher.final
-    decrypted = decipher.update(encrypted) + decipher.final
-
+    # suppress message from openssl Engine's RC4 cipher [ruby-core:41026]
+    err_back = $stderr.dup
+    $stderr.reopen(IO::NULL)
+    encrypted = crypt_data(data, key, :encrypt) { engine.cipher(algo) }
+    decrypted = crypt_data(encrypted, key, :decrypt) { OpenSSL::Cipher.new(algo) }
     assert_equal(data, decrypted)
     cleanup
-  end
+  ensure
+    $stderr = err_back if err_back
+  end 
 
   private
 
+  def crypt_data(data, key, mode)
+    cipher = yield
+    cipher.send mode
+    cipher.key = key
+    cipher.update(data) + cipher.final
+  end
+
   def cleanup
     OpenSSL::Engine.cleanup
-    assert_equal(0, OpenSSL::Engine::engines.size)
+    assert_equal(0, OpenSSL::Engine.engines.size)
   end
 
 end if defined?(OpenSSL)

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

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