diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 13:24:42 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-11-29 13:24:42 +0000 |
commit | 361f6b250312b56fc4ec76a4efe90160109cb459 (patch) | |
tree | 0db71b906fec5fb75214a99cae689d41f75fc6f2 | |
parent | 421314cf4e532cd4b840924b73f73fe33f25647b (diff) | |
download | ruby-361f6b250312b56fc4ec76a4efe90160109cb459.tar.gz |
* 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
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/openssl/test_cipher.rb | 15 |
2 files changed, 20 insertions, 0 deletions
@@ -1,3 +1,8 @@ +Thu Nov 29 22:23:31 2012 Hiroshi Nakamura <nahi@ruby-lang.org> + + * test/openssl/test_cipher.rb (test_ctr_if_exists): add CTR mode test + if underlying OpenSSL supports it. + Thu Nov 29 21:42:16 2012 Shugo Maeda <shugo@ruby-lang.org> * vm_method.c (rb_method_entry_make): add a method entry with 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| |