From 361f6b250312b56fc4ec76a4efe90160109cb459 Mon Sep 17 00:00:00 2001 From: nahi Date: Thu, 29 Nov 2012 13:24:42 +0000 Subject: * 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 --- ChangeLog | 5 +++++ test/openssl/test_cipher.rb | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 49e0d61cbb..60404ec3bb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Nov 29 22:23:31 2012 Hiroshi Nakamura + + * 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 * 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| -- cgit v1.2.3