// static int min=512; // static int preferred=1024; // static int max=2000; // com.jcraft.jsch.DH dh; //private byte[] f; /// <exception cref="System.Exception"></exception> public override void Init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte [] I_C) { this.session = session; this.V_S = V_S; this.V_C = V_C; this.I_S = I_S; this.I_C = I_C; try { Type c = Sharpen.Runtime.GetType(session.GetConfig("sha-1")); sha = (HASH)(System.Activator.CreateInstance(c)); sha.Init(); } catch (Exception e) { System.Console.Error.WriteLine(e); } buf = new Buffer(); packet = new Packet(buf); try { Type c = Sharpen.Runtime.GetType(session.GetConfig("dh")); dh = (NSch.DH)(System.Activator.CreateInstance(c)); dh.Init(); } catch (Exception e) { // System.err.println(e); throw; } packet.Reset(); buf.PutByte(unchecked ((byte)SSH_MSG_KEX_DH_GEX_REQUEST)); buf.PutInt(min); buf.PutInt(preferred); buf.PutInt(max); session.Write(packet); if (JSch.GetLogger().IsEnabled(Logger.INFO)) { JSch.GetLogger().Log(Logger.INFO, "SSH_MSG_KEX_DH_GEX_REQUEST(" + min + "<" + preferred + "<" + max + ") sent"); JSch.GetLogger().Log(Logger.INFO, "expecting SSH_MSG_KEX_DH_GEX_GROUP"); } state = SSH_MSG_KEX_DH_GEX_GROUP; }
// static int min=512; // static int preferred=1024; // static int max=2000; // com.jcraft.jsch.DH dh; //private byte[] f; /// <exception cref="System.Exception"></exception> public override void Init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte [] I_C) { this.session = session; this.V_S = V_S; this.V_C = V_C; this.I_S = I_S; this.I_C = I_C; try { Type c = Sharpen.Runtime.GetType(session.GetConfig("sha-1")); sha = (HASH)(System.Activator.CreateInstance(c)); sha.Init(); } catch (Exception e) { System.Console.Error.WriteLine(e); } buf = new Buffer(); packet = new Packet(buf); try { Type c = Sharpen.Runtime.GetType(session.GetConfig("dh")); dh = (NSch.DH)(System.Activator.CreateInstance(c)); dh.Init(); } catch (Exception e) { // System.err.println(e); throw; } packet.Reset(); buf.PutByte(unchecked((byte)SSH_MSG_KEX_DH_GEX_REQUEST)); buf.PutInt(min); buf.PutInt(preferred); buf.PutInt(max); session.Write(packet); if (JSch.GetLogger().IsEnabled(Logger.INFO)) { JSch.GetLogger().Log(Logger.INFO, "SSH_MSG_KEX_DH_GEX_REQUEST(" + min + "<" + preferred + "<" + max + ") sent"); JSch.GetLogger().Log(Logger.INFO, "expecting SSH_MSG_KEX_DH_GEX_GROUP"); } state = SSH_MSG_KEX_DH_GEX_GROUP; }
/// <exception cref="System.Exception"></exception> public override void Init(Session session, byte[] V_S, byte[] V_C, byte[] I_S, byte [] I_C) { throw new NotSupportedException (); // The crypto for this method is unusably slow this.session = session; this.V_S = V_S; this.V_C = V_C; this.I_S = I_S; this.I_C = I_C; try { Type c = Sharpen.Runtime.GetType(session.GetConfig("sha-1")); sha = (HASH)(System.Activator.CreateInstance(c)); sha.Init(); } catch (Exception ex) { System.Console.Error.WriteLine(e); } buf = new Buffer(); packet = new Packet(buf); try { Type c = Sharpen.Runtime.GetType(session.GetConfig("dh")); dh = (NSch.DH)(System.Activator.CreateInstance(c)); dh.Init(); } catch (Exception ex) { //System.err.println(e); throw; } dh.SetP(p); dh.SetG(g); // The client responds with: // byte SSH_MSG_KEXDH_INIT(30) // mpint e <- g^x mod p // x is a random number (1 < x < (p-1)/2) e = dh.GetE(); packet.Reset(); buf.PutByte(unchecked((byte)SSH_MSG_KEXDH_INIT)); buf.PutMPInt(e); if (V_S == null) { // This is a really ugly hack for Session.checkKexes ;-( return; } session.Write(packet); if (JSch.GetLogger().IsEnabled(Logger.INFO)) { JSch.GetLogger().Log(Logger.INFO, "SSH_MSG_KEXDH_INIT sent"); JSch.GetLogger().Log(Logger.INFO, "expecting SSH_MSG_KEXDH_REPLY"); } state = SSH_MSG_KEXDH_REPLY; }