aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_cipher.rb
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-10-04 02:35:06 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-10-04 16:46:17 +0900
commit5edbfadba6fd3fb842730da6a265e9e85ae32fe9 (patch)
treed82a92895b981bd60595396f1d187804a4acf946 /test/test_cipher.rb
parentaab6051dbdc0cef47c203a95d471bd0417f013fa (diff)
downloadruby-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.rb22
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|