Module: Chef::EncryptedDataBagItem::Encryptor

Defined in:
lib/chef/encrypted_data_bag_item/encryptor.rb

Overview

Implementation class for converting plaintext data bag item values to an encrypted value, including any necessary wrappers and metadata.

Defined Under Namespace

Classes: Version1Encryptor, Version2Encryptor, Version3Encryptor

Class Method Summary collapse

Class Method Details

.new(value, secret, iv = nil) ⇒ Object

“factory” method that creates an encryptor object with the proper class for the desired encrypted data bag format version.

Chef::Config[:data_bag_encrypt_version] determines which version is used.


38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/chef/encrypted_data_bag_item/encryptor.rb', line 38

def self.new(value, secret, iv = nil)
  format_version = Chef::Config[:data_bag_encrypt_version]
  case format_version
  when 1
    Version1Encryptor.new(value, secret, iv)
  when 2
    Version2Encryptor.new(value, secret, iv)
  when 3
    Version3Encryptor.new(value, secret, iv)
  else
    raise UnsupportedEncryptedDataBagItemFormat,
      "Invalid encrypted data bag format version `#{format_version}'. Supported versions are '1', '2', '3'"
  end
end