示例#1
0
        public void KeyExchange(string algorithm)
        {
            DiffieHellman dh = new DiffieHellman(2);
            BigInteger    e  = dh.GenerateExchangeValue();

            verify_e = e;
            PacketGeneral packet_dhkex = new PacketGeneral(Packet.SSH_MSG_KEXDH_INIT);

            packet_dhkex.GetStreamWriter().WriteMPInt(e);
            SendPacket(null, packet_dhkex);

            Packet packet = RecvPacket(null);

            PacketKeyExchangeDHReply packet_dhkex_reply = new PacketKeyExchangeDHReply(packet);

            packet_dhkex_reply.Parse();
            verify_k_s = packet_dhkex_reply.GetCertificates();
            verify_sig = packet_dhkex_reply.GetSignature();
            BigInteger f = packet_dhkex_reply.GetExchangeValue();

            verify_f = f;
            BigInteger K = dh.ComputeKey(f);

            verify_k = K;
        }
示例#2
0
        public void KeyExchange(string algorithm)
        {
            DiffieHellman dh = new DiffieHellman(2);
            BigInteger e = dh.GenerateExchangeValue();
            verify_e = e;
            PacketGeneral packet_dhkex = new PacketGeneral(Packet.SSH_MSG_KEXDH_INIT);
            packet_dhkex.GetStreamWriter().WriteMPInt(e);
            SendPacket(null, packet_dhkex);

            Packet packet = RecvPacket(null);

            PacketKeyExchangeDHReply packet_dhkex_reply = new PacketKeyExchangeDHReply(packet);
            packet_dhkex_reply.Parse();
            verify_k_s = packet_dhkex_reply.GetCertificates();
            verify_sig = packet_dhkex_reply.GetSignature();
            BigInteger f = packet_dhkex_reply.GetExchangeValue();
            verify_f = f;
            BigInteger K = dh.ComputeKey(f);
            verify_k = K;
        }