# class Chef::EncryptedDataBagItem::Decryptor::Version2Decryptor

### Public Instance Methods

decrypted_data() click to toggle source
Calls superclass method Chef::EncryptedDataBagItem::Decryptor::Version1Decryptor#decrypted_data

    # File lib/chef/encrypted_data_bag_item/decryptor.rb, line 173
    def decrypted_data
      validate_hmac! unless @decrypted_data
      super
    end

validate_hmac!() click to toggle source

    # File lib/chef/encrypted_data_bag_item/decryptor.rb, line 178
    def validate_hmac!
      digest = OpenSSL::Digest::Digest.new("sha256")
      raw_hmac = OpenSSL::HMAC.digest(digest, key, @encrypted_data["encrypted_data"])

      if candidate_hmac_matches?(raw_hmac)
        true
      else
        raise DecryptionFailure, "Error decrypting data bag value: invalid hmac. Most likely the provided key is incorrect"
      end
    end