module Chef::EncryptedAttribute::Assertions

Include some assertions that throw exceptions if not met.

Public Instance Methods

assert_aead_requirements_met!(algorithm) click to toggle source

Checks some assertions related with OpenSSL AEAD support, required to to use [GCM](en.wikipedia.org/wiki/Galois/Counter_Mode).

@param algorithm [String] the name of the algorithm to use. @return void @raise [RequirementsFailure] if any of the requirements to use AEAD is

not met.
# 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