public void Initialize() { Log.Info("Loading client manager."); Log.Info("Scrambling keypairs."); _scrambledPairs = new ScrambledKeyPair[ScrambleCount]; for (int i = 0; i < ScrambleCount; i++) { _scrambledPairs[i] = new ScrambledKeyPair(ScrambledKeyPair.genKeyPair()); } Log.Info($"Scrambled {_scrambledPairs.Length} keypairs."); Log.Info("Randomize blowfish keys."); _blowfishKeys = new byte[BlowfishCount][]; for (int i = 0; i < BlowfishCount; i++) { _blowfishKeys[i] = new byte[16]; new Random().NextBytes(_blowfishKeys[i]); } Log.Info($"Randomized {_blowfishKeys.Length} blowfish keys."); }
public void Initialize() { CLogger.info("Loading client manager."); CLogger.info("Scrambling keypairs."); ScrambledPairs = new ScrambledKeyPair[ScrambleCount]; for (int i = 0; i < ScrambleCount; i++) { ScrambledPairs[i] = new ScrambledKeyPair(ScrambledKeyPair.genKeyPair()); } CLogger.info("Scrambled " + ScrambledPairs.Length + " keypairs."); CLogger.info("Randomize blowfish keys."); BlowfishKeys = new Byte[BlowfishCount][]; for (int i = 0; i < BlowfishCount; i++) { BlowfishKeys[i] = new Byte[16]; new Random().NextBytes(BlowfishKeys[i]); } CLogger.info("Randomized " + BlowfishKeys.Length + " blowfish keys."); }
public void InitializeNetwork() { RsaPair = ClientManager.Instance.GetScrambledKeyPair(); BlowfishKey = ClientManager.Instance.GetBlowfishKey(); _loginCrypt = new LoginCrypt(); _loginCrypt.UpdateKey(BlowfishKey); new Thread(Read).Start(); new Thread(SendInit).Start(); }
public void InitializeNetwork() { RsaPair = _clientManager.GetScrambledKeyPair(); BlowfishKey = _clientManager.GetBlowfishKey(); _loginCrypt = new LoginCrypt(); _loginCrypt.UpdateKey(BlowfishKey); Task.Factory.StartNew(ReadAsync); Task.Factory.StartNew(SendInit); }
private void GenerateScrambledKeys() { Log.Info("Scrambling keypairs."); _scrambledPairs = new ScrambledKeyPair[ScrambleCount]; for (int i = 0; i < ScrambleCount; i++) { _scrambledPairs[i] = new ScrambledKeyPair(ScrambledKeyPair.genKeyPair()); } Log.Info($"Scrambled {_scrambledPairs.Length} keypairs."); }
public L2Client(Socket Conn) { Log.Info("接收到客户端连接!"); _Conn = Conn; _SessionId = Conn.GetHashCode(); ScrambledPair = new ScrambledKeyPair(); _PublicKey = ScrambledPair.GetScrambledModulus(); _PrivateKey = ScrambledPair.GetPrivateKey(); GenerateBlowfishKey(); Crypt = new LoginCrypt(_BlowfishKey); Conn.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, AynsReceive, null); ClientIp = ((IPEndPoint)_Conn.RemoteEndPoint).Address.ToString(); Log.Info("发送初始化封包!"); SendPacket(new Init(this)); }
/// <summary> /// Initializes user connections listener. /// </summary> /// <param name="localEndPoint">Local ip endpoint.</param> /// <param name="backlog">Backlog.</param> /// <param name="enableFirewall">True, if firewall must be enabled, otherwise false.</param> internal static void Initialize(IPEndPoint localEndPoint, int backlog, bool enableFirewall) { m_LocalEndPoint = localEndPoint; m_Backlog = backlog; m_EnableFirewall = enableFirewall; RSAManaged rsa = new RSAManaged(1024); PrivateKey = rsa.ExportParameters(true); PublicKey = rsa.ExportParameters(false); ScrambledKeysPair = new ScrambledKeyPair(ref PrivateKey, ref PublicKey); rsa = null; Enable(); }
public LoginClient(ScrambledKeyPair scrambledKeyPair, byte[] blowfishKey, L2Connection l2Connection) { this.L2Connection = l2Connection; Random rnd = new Random(); SessionId = rnd.Next(); SessionKey = new SessionKey(rnd.Next(), rnd.Next(), rnd.Next(), rnd.Next()); RsaPair = scrambledKeyPair; ie = GetPacketAction().GetEnumerator(); ie.MoveNext(); _ = Task.Factory.StartNew(() => SendAsync(ie.Current)); L2Connection.ReceivedPacket += LoggingReceivedPacket; L2Connection.SendingPacket += LoggingSendPacket; l2Connection.ReceivedPacket += OnReadAsync; l2Connection.Crypt.EnableCrypt(); }