Class: Chef::EncryptedDataBagItem::Decryptor::Version0Decryptor
- Defined in:
- lib/chef/encrypted_data_bag_item.rb
Instance Attribute Summary collapse
-
#encrypted_data ⇒ Object
readonly
Returns the value of attribute encrypted_data.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
Instance Method Summary collapse
- #decrypted_data ⇒ Object
- #encrypted_bytes ⇒ Object
- #for_decrypted_item ⇒ Object
-
#initialize(encrypted_data, key) ⇒ Version0Decryptor
constructor
A new instance of Version0Decryptor.
- #openssl_decryptor ⇒ Object
Constructor Details
#initialize(encrypted_data, key) ⇒ Version0Decryptor
Returns a new instance of Version0Decryptor.
227 228 229 230 |
# File 'lib/chef/encrypted_data_bag_item.rb', line 227 def initialize(encrypted_data, key) @encrypted_data = encrypted_data @key = key end |
Instance Attribute Details
#encrypted_data ⇒ Object (readonly)
Returns the value of attribute encrypted_data.
224 225 226 |
# File 'lib/chef/encrypted_data_bag_item.rb', line 224 def encrypted_data @encrypted_data end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
225 226 227 |
# File 'lib/chef/encrypted_data_bag_item.rb', line 225 def key @key end |
Instance Method Details
#decrypted_data ⇒ Object
236 237 238 239 240 241 242 243 |
# File 'lib/chef/encrypted_data_bag_item.rb', line 236 def decrypted_data @decrypted_data ||= begin plaintext = openssl_decryptor.update(encrypted_bytes) plaintext << openssl_decryptor.final rescue OpenSSL::Cipher::CipherError => e raise DecryptionFailure, "Error decrypting data bag value: '#{e.}'. Most likely the provided key is incorrect" end end |
#encrypted_bytes ⇒ Object
245 246 247 |
# File 'lib/chef/encrypted_data_bag_item.rb', line 245 def encrypted_bytes Base64.decode64(@encrypted_data) end |
#for_decrypted_item ⇒ Object
232 233 234 |
# File 'lib/chef/encrypted_data_bag_item.rb', line 232 def for_decrypted_item YAML.load(decrypted_data) end |