summaryrefslogtreecommitdiff
path: root/test/openssl
diff options
context:
space:
mode:
authornahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-29 13:24:42 +0000
committernahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-29 13:24:42 +0000
commit361f6b250312b56fc4ec76a4efe90160109cb459 (patch)
tree0db71b906fec5fb75214a99cae689d41f75fc6f2 /test/openssl
parent421314cf4e532cd4b840924b73f73fe33f25647b (diff)
* test/openssl/test_cipher.rb (test_ctr_if_exists): add CTR mode test
if underlying OpenSSL supports it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37994 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/openssl')
-rw-r--r--test/openssl/test_cipher.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/openssl/test_cipher.rb b/test/openssl/test_cipher.rb
index 0e4a7759fe..ab131b8b1f 100644
--- a/test/openssl/test_cipher.rb
+++ b/test/openssl/test_cipher.rb
@@ -69,6 +69,21 @@ class OpenSSL::TestCipher < Test::Unit::TestCase
assert_raise(RuntimeError) {OpenSSL::Cipher.allocate.final}
end
+ def test_ctr_if_exists
+ begin
+ cipher = OpenSSL::Cipher.new('aes-128-ctr')
+ cipher.encrypt
+ cipher.pkcs5_keyivgen('password')
+ c = cipher.update('hello,world') + cipher.final
+ cipher.decrypt
+ cipher.pkcs5_keyivgen('password')
+ assert_equal('hello,world', cipher.update(c) + cipher.final)
+ rescue RuntimeError => e
+ # CTR is from OpenSSL 1.0.1, and for an environment that disables CTR; No idea it exists.
+ assert_match(/unsupported cipher algorithm/, e.message)
+ end
+ end
+
if OpenSSL::OPENSSL_VERSION_NUMBER > 0x00907000
def test_ciphers
OpenSSL::Cipher.ciphers.each{|name|