69: def self.get(name, options={})
70: ossl_name = SSH_TO_OSSL[name] or raise NotImplementedError, "unimplemented cipher `#{name}'"
71: return IdentityCipher if ossl_name == "none"
72: cipher = OpenSSL::Cipher::Cipher.new(ossl_name)
73:
74: cipher.send(options[:encrypt] ? :encrypt : :decrypt)
75:
76: cipher.padding = 0
77:
78: cipher.extend(Net::SSH::Transport::CTR) if (name =~ /-ctr(@openssh.org)?$/)
79:
80: cipher.iv = Net::SSH::Transport::KeyExpander.expand_key(cipher.iv_len, options[:iv], options) if ossl_name != "rc4"
81:
82: key_len = KEY_LEN_OVERRIDE[name] || cipher.key_len
83: cipher.key_len = key_len
84: cipher.key = Net::SSH::Transport::KeyExpander.expand_key(key_len, options[:key], options)
85: cipher.update(" " * 1536) if (ossl_name == "rc4" && name != "arcfour")
86:
87: return cipher
88: end