diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-10-04 02:35:06 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-10-04 16:46:17 +0900 |
commit | 5edbfadba6fd3fb842730da6a265e9e85ae32fe9 (patch) | |
tree | d82a92895b981bd60595396f1d187804a4acf946 /test/test_cipher.rb | |
parent | aab6051dbdc0cef47c203a95d471bd0417f013fa (diff) | |
download | ruby-openssl-5edbfadba6fd3fb842730da6a265e9e85ae32fe9.tar.gz |
cipher: always define Cipher#authenticated?
Implement Cipher#authenticated? even when the OpenSSL version does not
support AEAD. It just returns false.
Diffstat (limited to 'test/test_cipher.rb')
-rw-r--r-- | test/test_cipher.rb | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/test/test_cipher.rb b/test/test_cipher.rb index 015bb561..0d79eabe 100644 --- a/test/test_cipher.rb +++ b/test/test_cipher.rb @@ -4,20 +4,18 @@ require_relative 'utils' if defined?(OpenSSL::TestUtils) class OpenSSL::TestCipher < OpenSSL::TestCase - - @ciphers = OpenSSL::Cipher.ciphers - - class << self - + module Helper def has_cipher?(name) + @ciphers ||= OpenSSL::Cipher.ciphers @ciphers.include?(name) end def has_ciphers?(list) list.all? { |name| has_cipher?(name) } end - end + include Helper + extend Helper def setup @c1 = OpenSSL::Cipher.new("DES-EDE3-CBC") @@ -144,14 +142,16 @@ class OpenSSL::TestCipher < OpenSSL::TestCase end end - if has_ciphers?(['aes-128-gcm', 'aes-192-gcm', 'aes-256-gcm']) - - def test_authenticated + def test_authenticated + if has_cipher?('aes-128-gcm') cipher = OpenSSL::Cipher.new('aes-128-gcm') assert_predicate(cipher, :authenticated?) - cipher = OpenSSL::Cipher.new('aes-128-cbc') - assert_not_predicate(cipher, :authenticated?) end + cipher = OpenSSL::Cipher.new('aes-128-cbc') + assert_not_predicate(cipher, :authenticated?) + end + + if has_ciphers?(['aes-128-gcm', 'aes-192-gcm', 'aes-256-gcm']) def test_aes_gcm ['aes-128-gcm', 'aes-192-gcm', 'aes-256-gcm'].each do |algo| |