i`m using this code to get dh key in proxy paradise
but i get this error : Non-negative number required.
Parameter name: count
at
BR.ReadBytes(JunkLength);//JUNK length
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using OpenSSL;
namespace ProxyParadise.Cryptography
{
public class ClientDHPacket
{
public string Client_PubKey;
int JunkLength;
public ClientDHPacket(byte[] Packet)
{
MemoryStream MS = new MemoryStream(Packet);
BinaryReader BR = new BinaryReader(MS);
BR.ReadBytes(7);//JUNK
BR.ReadUInt32();//Length
JunkLength = BR.ReadInt32();
BR.ReadBytes(JunkLength);
Client_PubKey = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadInt32()));
BR.Close();
MS.Close();
}
public void Edit(byte[] Packet, string NewKey)
{
MemoryStream MS = new MemoryStream(Packet);
BinaryWriter BW = new BinaryWriter(MS);
BW.Seek(19 + JunkLength, SeekOrigin.Current);
BW.Write(Encoding.ASCII.GetBytes(NewKey));
}
}
public class ServerDHPacket
{
public byte[] ServerIV;
public byte[] ClientIV;
public string P;
public string G;
public string Server_PubKey;
int JunkLength;
public ServerDHPacket(byte[] Packet)
{
MemoryStream MS = new MemoryStream(Packet);
BinaryReader BR = new BinaryReader(MS);
BR.ReadBytes(11);//JUNK
BR.ReadUInt32();//Length - Like i care of it
JunkLength = BR.ReadInt16();
BR.ReadBytes(JunkLength);//JUNK length
ServerIV = BR.ReadBytes(BR.ReadInt32());
ClientIV = BR.ReadBytes(BR.ReadInt32());
P = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadInt32()));
G = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadInt32()));
Server_PubKey = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadInt32()));
BR.Close();
MS.Close();
}
public void Edit(byte[] Packet, string EditedPubKey)
{
MemoryStream MS = new MemoryStream(Packet);
BinaryWriter BW = new BinaryWriter(MS);
BW.Seek(55 + JunkLength + P.Length + G.Length, SeekOrigin.Current);
BW.Write(Encoding.ASCII.GetBytes(EditedPubKey));
BW.Close();
MS.Close();
}
}
}
Parameter name: count
at
BR.ReadBytes(JunkLength);//JUNK length