mirror of
https://github.com/ruby/ruby.git
synced 2025-09-20 19:14:00 +02:00
Update rubygems to 2.0.6. [Bug #13935]
The patch is provided by Kazuki Yamaguchi. From: Kazuki Yamaguchi <k@rhe.jp> Date: Mon, 25 Sep 2017 01:32:02 +0900 Subject: [PATCH] openssl: import v2.0.6 Import Ruby/OpenSSL 2.0.6. This contains only bug fixes and test improvements. The full commit log since v2.0.5 (imported at r59567, to trunk) can be found at: https://github.com/ruby/openssl/compare/v2.0.5...v2.0.6 All the changes included in this patch are already imported to trunk by r59734, r59751, r59857, and r60013. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@62842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
093c6ce7c2
commit
b503ff8b43
43 changed files with 1255 additions and 1146 deletions
|
@ -1,8 +1,9 @@
|
|||
# frozen_string_literal: false
|
||||
require_relative 'utils'
|
||||
|
||||
class OpenSSL::TestEngine < OpenSSL::TestCase
|
||||
if defined?(OpenSSL::TestUtils) && defined?(OpenSSL::Engine)
|
||||
|
||||
class OpenSSL::TestEngine < OpenSSL::TestCase
|
||||
def test_engines_free # [ruby-dev:44173]
|
||||
with_openssl <<-'end;'
|
||||
OpenSSL::Engine.load("openssl")
|
||||
|
@ -51,32 +52,28 @@ class OpenSSL::TestEngine < OpenSSL::TestCase
|
|||
end
|
||||
|
||||
def test_openssl_engine_cipher_rc4
|
||||
with_openssl <<-'end;'
|
||||
begin
|
||||
engine = get_engine
|
||||
algo = "RC4" #AES is not supported by openssl Engine (<=1.0.0e)
|
||||
data = "a" * 1000
|
||||
key = OpenSSL::Random.random_bytes(16)
|
||||
# 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)
|
||||
ensure
|
||||
if err_back
|
||||
$stderr.reopen(err_back)
|
||||
err_back.close
|
||||
end
|
||||
end
|
||||
begin
|
||||
OpenSSL::Cipher.new("rc4")
|
||||
rescue OpenSSL::Cipher::CipherError
|
||||
pend "RC4 is not supported"
|
||||
end
|
||||
|
||||
with_openssl(<<-'end;', ignore_stderr: true)
|
||||
engine = get_engine
|
||||
algo = "RC4"
|
||||
data = "a" * 1000
|
||||
key = OpenSSL::Random.random_bytes(16)
|
||||
encrypted = crypt_data(data, key, :encrypt) { engine.cipher(algo) }
|
||||
decrypted = crypt_data(encrypted, key, :decrypt) { OpenSSL::Cipher.new(algo) }
|
||||
assert_equal(data, decrypted)
|
||||
end;
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# this is required because OpenSSL::Engine methods change global state
|
||||
def with_openssl(code)
|
||||
assert_separately([{ "OSSL_MDEBUG" => nil }, "-ropenssl"], <<~"end;")
|
||||
def with_openssl(code, **opts)
|
||||
assert_separately([{ "OSSL_MDEBUG" => nil }, "-ropenssl"], <<~"end;", **opts)
|
||||
require #{__FILE__.dump}
|
||||
include OpenSSL::TestEngine::Utils
|
||||
#{code}
|
||||
|
@ -95,5 +92,6 @@ class OpenSSL::TestEngine < OpenSSL::TestCase
|
|||
cipher.update(data) + cipher.final
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end if defined?(OpenSSL::TestUtils) && defined?(OpenSSL::Engine)
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue