summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-05 18:33:37 +0000
committeremboss <emboss@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-11-05 18:33:37 +0000
commit600fcacc7551d9957feac8a32f7639dcc3fc49cd (patch)
treeed193684be3a6b1078d52ada8b4caec73ccb605b
parent273c900be84bea453a07b96896c426041180790c (diff)
* test/openssl/test_engine.rb: add test for engine cipher. RC4 is used
because AES is not supported by the "openssl" engine currently. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--test/openssl/test_engine.rb22
2 files changed, 27 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index a9ff0d6..071f8fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Nov 06 03:22:36 2011 Martin Bosslet <Martin.Bosslet@googlemail.com>
+
+ * test/openssl/test_engine.rb: add test for engine cipher. RC4 is used
+ because AES is not supported by the "openssl" engine currently.
+
Sun Nov 6 00:11:52 2011 Tanaka Akira <akr@fsij.org>
* lib/test/unit.rb (Test::Unit::Options#non_options): options[:ruby]
diff --git a/test/openssl/test_engine.rb b/test/openssl/test_engine.rb
index f9106c0..fce5f76 100644
--- a/test/openssl/test_engine.rb
+++ b/test/openssl/test_engine.rb
@@ -37,6 +37,28 @@ class OpenSSL::TestEngine < Test::Unit::TestCase
assert_not_nil(digest)
data = "test"
assert_equal(OpenSSL::Digest::SHA1.digest(data), digest.digest(data))
+ cleanup
+ end
+
+ def test_openssl_engine_cipher_rc4
+ engine = OpenSSL::Engine.by_id("openssl")
+ 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
+
+ assert_equal(data, decrypted)
+ cleanup
end
private