internal bool ComputePublicKeyToServer() { bool ret = false; if (SshPacket.PayLoad[0] == (byte)eSshMsgKexDhGex.SSH_MSG_KEX_DH_GEX_GROUP) { m_DhModulesP = new MpInt(SshPacket.PayLoad, 1); m_DhBaseG = new MpInt(SshPacket.PayLoad, (int)m_DhModulesP.Length + 5); // Step 3 in DH //3. C generates a random number x, where 1 < x < (p-1)/2. It computes e = g^x mod p, and sends "e" to S. RandomSecret = m_Random.Next(); PublicKey = BigInteger.ModPow(m_DhBaseG.Value, RandomSecret, m_DhModulesP.Value); ret = true; } return ret; }
internal bool ParseServerSshMsgKexDhGexReply() { bool ret = false; int startIndex = 0; if (SshPacket.PayLoad[startIndex] == (byte)eSshMsgKexDhGex.SSH_MSG_KEX_DH_GEX_REPLY) { startIndex = 1; ServerPublicKeyHostAndCertifcates = new PublicKeyCertifcateFormat(SshPacket.PayLoad, startIndex); // TODO: program crash here startIndex += ServerPublicKeyHostAndCertifcates.TotalLength; DhServerF = new MpInt(SshPacket.PayLoad, startIndex); startIndex += (int)DhServerF.Length; KexDhH = new SshString(SshPacket.PayLoad, startIndex); // Step 5, computes K = f^x mod p SecretKey = BigInteger.ModPow(DhServerF.Value, this.RandomSecret, this.DhModulesP.Value); // TODO: check what to do with MAC ret = true; } return ret; }
public SshRsaKeyFormat(byte[] io_Buffer, int i_StartIndex) { E = new MpInt(io_Buffer, i_StartIndex); N = new MpInt(io_Buffer, i_StartIndex + 4 + (int)E.Length); // TODO: comlepete rsa_signature_blob }