class Origami::Encryption::EncryptionDictionary
Common class for encryption dictionaries.
Public Instance Methods
encryption_cipher(name)
click to toggle source
Returns the encryption cipher corresponding to a crypt filter name.
# File lib/origami/encryption.rb, line 687 def encryption_cipher(name) case self.V.to_i when 1, 2 Encryption::RC4 when 4, 5 return Encryption::Identity if name == :Identity raise EncryptionError, "Broken CF entry" unless self.CF.is_a?(Dictionary) self.CF.select { |key, dict| key == name and dict.is_a?(Dictionary) } .map { |_, dict| cipher_from_crypt_filter_method(dict[:CFM] || :None) } .first else raise EncryptionNotSupportedError, "Unsupported encryption version: #{handler.V}" end end
stream_encryption_cipher()
click to toggle source
Returns the default stream encryption cipher.
# File lib/origami/encryption.rb, line 680 def stream_encryption_cipher encryption_cipher(self.StmF || :Identity) end
string_encryption_cipher()
click to toggle source
Returns the default string encryption cipher.
# File lib/origami/encryption.rb, line 673 def string_encryption_cipher encryption_cipher(self.StrF || :Identity) end
Private Instance Methods
cipher_from_crypt_filter_method(name)
click to toggle source
Converts a crypt filter method identifier to its cipher class.
# File lib/origami/encryption.rb, line 708 def cipher_from_crypt_filter_method(name) case name.to_sym when :None then Encryption::Identity when :V2 then Encryption::RC4 when :AESV2 then Encryption::AES when :AESV3 raise EncryptionNotSupportedError, "AESV3 requires a version 5 handler" if self.V.to_i != 5 Encryption::AES else raise EncryptionNotSupportedError, "Unsupported crypt filter method: #{name}" end end