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