mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/openssl/test_engine.rb: Suppress output from 'openssl'
engine's RC4 cipher. [Bug #5633] [ruby-core:41026] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5c7e691e5d
commit
452b74c106
2 changed files with 23 additions and 15 deletions
|
@ -1,10 +1,16 @@
|
|||
Thu Nov 24 10:05:02 2011 Martin Bosslet <Martin.Bosslet@googlemail.com>
|
||||
|
||||
* 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@googlemail.com>
|
||||
|
||||
* ext/openssl/ossl_pkey_dsa.c: remove redundant colon from error
|
||||
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@ruby-lang.org>
|
||||
|
||||
|
|
|
@ -45,27 +45,29 @@ class OpenSSL::TestEngine < Test::Unit::TestCase
|
|||
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)
|
||||
|
|
Loading…
Add table
Reference in a new issue