Exemple #1
0
 public PublicKeyCertifcateFormat(byte[] i_Buffer, int i_StartIndex)
 {
     StringBeforeParsing = new SshString(i_Buffer, i_StartIndex);
     i_StartIndex = 0;
     PublicKeyName = new SshString(StringBeforeParsing.ByteArray, i_StartIndex);
     if (PublicKeyName.ValueToString() == "ssh-rsa")
     {
         SshRsa = new SshRsaKeyFormat(StringBeforeParsing.ByteArray, PublicKeyName.LengthWithBufferLength);
     }
 }
Exemple #2
0
        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;
        }