def _compute_key(self, id, nbytes):
m = Message()<EOL>m.add_mpint(self.K)<EOL>m.add_bytes(self.H)<EOL>m.add_byte(b(id))<EOL>m.add_bytes(self.session_id)<EOL>hash_algo = getattr(self.kex_engine, "<STR_LIT>", None)<EOL>hash_select_msg = "<STR_LIT>".format(<EOL>self.kex_engine.__class__.__name__, hash_algo<EOL>)<EOL>if hash_algo is None:<EOL><INDENT>hash_algo = sha1<EOL>hash_select_msg += "<STR_LIT>"<EOL><DEDENT>if not hasattr(self, "<STR_LIT>"):<EOL><INDENT>self._log(DEBUG, hash_select_msg)<EOL>setattr(self, "<STR_LIT>", True)<EOL><DEDENT>out = sofar = hash_algo(m.asbytes()).digest()<EOL>while len(out) < nbytes:<EOL><INDENT>m = Message()<EOL>m.add_mpint(self.K)<EOL>m.add_bytes(self.H)<EOL>m.add_bytes(sofar)<EOL>digest = hash_algo(m.asbytes()).digest()<EOL>out += digest<EOL>sofar += digest<EOL><DEDENT>return out[:nbytes]<EOL>
id is 'A' - 'F' for the various keys used by ssh