diff options
author | nahi <nahi@ruby-lang.org> | 2011-07-28 13:48:05 +0000 |
---|---|---|
committer | nahi <nahi@ruby-lang.org> | 2011-07-28 13:48:05 +0000 |
commit | 4b95249fe7380a74799611c8aade1338608b5126 (patch) | |
tree | 344b379c8746e1ebeea3a6b158c8f38d98038c12 /test | |
parent | a2cdb84bb1fd7e77ae61c7bd65413ef2282db05e (diff) | |
download | ruby-openssl-history-4b95249fe7380a74799611c8aade1338608b5126.tar.gz |
* ext/openssl/ossl_cipher.c (ossl_cipher_initialize): Avoid possible
SEGV from AES encryption/decryption. Processing data by
Cipher#update without initializing key (meaningless usage of Cipher
object since we don't offer a way to export a key) could cause SEGV.
In OpenSSL, the EVP which has EVP_CIPH_RAND_KEY flag (such as DES3)
allows uninitialized key, but other EVPs (such as AES) does not
allow it. Calling EVP_CipherUpdate() without initializing key causes
SEGV so we set the data filled with "\0" as the key by default. See
#2768.
* test/openssl/test_cipher.rb: test it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/test_cipher.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/test_cipher.rb b/test/test_cipher.rb index 70c963b..eb2f4fe 100644 --- a/test/test_cipher.rb +++ b/test/test_cipher.rb @@ -90,6 +90,15 @@ class OpenSSL::TestCipher < Test::Unit::TestCase assert_equal(pt, c2.update(ct) + c2.final) } end + + def test_AES_crush + 500.times do + assert_nothing_raised("[Bug #2768]") do + # it caused OpenSSL SEGV by uninitialized key + OpenSSL::Cipher::AES128.new("ECB").update "." * 17 + end + end + end end end |