ruby-changes:25937
From: nahi <ko1@a...>
Date: Thu, 29 Nov 2012 22:25:02 +0900 (JST)
Subject: [ruby-changes:25937] nahi:r37994 (trunk): * test/openssl/test_cipher.rb (test_ctr_if_exists): add CTR mode test
nahi 2012-11-29 22:24:42 +0900 (Thu, 29 Nov 2012) New Revision: 37994 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=37994 Log: * test/openssl/test_cipher.rb (test_ctr_if_exists): add CTR mode test if underlying OpenSSL supports it. Modified files: trunk/ChangeLog trunk/test/openssl/test_cipher.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 37993) +++ ChangeLog (revision 37994) @@ -1,3 +1,8 @@ +Thu Nov 29 22:23:31 2012 Hiroshi Nakamura <nahi@r...> + + * 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@r...> * vm_method.c (rb_method_entry_make): add a method entry with Index: test/openssl/test_cipher.rb =================================================================== --- test/openssl/test_cipher.rb (revision 37993) +++ test/openssl/test_cipher.rb (revision 37994) @@ -69,6 +69,21 @@ 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| -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/