private KeyExchange receive_kexinit(Buffer buf) { int j=buf.getInt(); if(j!=buf.getLength()) { // packet was compressed and buf.getByte(); // j is the size of deflated packet. I_S=new byte[buf.index-5]; } else { I_S=new byte[j-1-buf.getByte()]; } SharpSSH.SharpSsh.java.System.arraycopy(buf.buffer, buf.s, I_S, 0, I_S.Length); /* try{ byte[] tmp=new byte[I_S.Length]; SharpSSH.SharpSsh.java.System.arraycopy(I_S, 0, tmp, 0, I_S.Length); Buffer tmpb=new Buffer(tmp); System.Console.WriteLine("I_S: len="+I_S.Length); tmpb.setOffSet(17); System.Console.WriteLine("kex: "+new String(tmpb.getString())); System.Console.WriteLine("server_host_key: "+new String(tmpb.getString())); System.Console.WriteLine("cipher.c2s: "+new String(tmpb.getString())); System.Console.WriteLine("cipher.s2c: "+new String(tmpb.getString())); System.Console.WriteLine("mac.c2s: "+new String(tmpb.getString())); System.Console.WriteLine("mac.s2c: "+new String(tmpb.getString())); System.Console.WriteLine("compression.c2s: "+new String(tmpb.getString())); System.Console.WriteLine("compression.s2c: "+new String(tmpb.getString())); System.Console.WriteLine("lang.c2s: "+new String(tmpb.getString())); System.Console.WriteLine("lang.s2c: "+new String(tmpb.getString())); System.Console.WriteLine("?: "+(tmpb.getByte()&0xff)); System.Console.WriteLine("??: "+tmpb.getInt()); } catch(Exception e){ System.Console.WriteLine(e); } */ send_kexinit(); String[] guess=KeyExchange.guess(I_S, I_C); if(guess==null) { throw new JSchException("Algorithm negotiation fail"); } if(!isAuthed && (guess[KeyExchange.PROPOSAL_ENC_ALGS_CTOS].equals("none") || (guess[KeyExchange.PROPOSAL_ENC_ALGS_STOC].equals("none")))) { throw new JSchException("NONE Cipher should not be chosen before authentification is successed."); } KeyExchange kex=null; try { Class c=Class.forName(getConfig(guess[KeyExchange.PROPOSAL_KEX_ALGS])); kex=(KeyExchange)(c.newInstance()); } catch(Exception e){ System.Console.Error.WriteLine("kex: "+e); } kex._guess=guess; kex.init(this, V_S, V_C, I_S, I_C); return kex; }