Module: Chef::EncryptedAttribute::Assertions

Included in:
EncryptedMash::Version2
Defined in:
lib/chef/encrypted_attribute/assertions.rb

Overview

Include some assertions that throw exceptions if not met.

Instance Method Summary collapse

Instance Method Details

#assert_aead_requirements_met!(algorithm) ⇒ Object

Checks some assertions related with OpenSSL AEAD support, required to to use GCM.

Parameters:

  • algorithm (String)

    the name of the algorithm to use.

Returns:

  • void

Raises:


33
34
35
36
37
38
39
40
41
42
43
# File 'lib/chef/encrypted_attribute/assertions.rb', line 33

def assert_aead_requirements_met!(algorithm)
  unless OpenSSL::Cipher.method_defined?(:auth_data=)
    fail RequirementsFailure,
         'The used Encrypted Attributes protocol version requires Ruby '\
         '>= 1.9'
  end
  return if OpenSSL::Cipher.ciphers.include?(algorithm)
  fail RequirementsFailure,
       'The used Encrypted Attributes protocol version requires an '\
       "OpenSSL version with \"#{algorithm}\" algorithm support"
end