46: def self.get(name, options={})
47: ossl_name = SSH_TO_OSSL[name] or raise NotImplementedError, "unimplemented cipher `#{name}'"
48: return IdentityCipher if ossl_name == "none"
49:
50: cipher = OpenSSL::Cipher::Cipher.new(ossl_name)
51: cipher.send(options[:encrypt] ? :encrypt : :decrypt)
52:
53: cipher.padding = 0
54: cipher.iv = Net::SSH::Transport::KeyExpander.expand_key(cipher.iv_len, options[:iv], options) if ossl_name != "rc4"
55: key_len = KEY_LEN_OVERRIDE[name] || cipher.key_len
56: cipher.key_len = key_len
57: cipher.key = Net::SSH::Transport::KeyExpander.expand_key(key_len, options[:key], options)
58: cipher.update(" " * 1536) if ossl_name == "rc4"
59:
60: return cipher
61: end