public override void ConstructResponse() { base.ConstructResponse(); // 2. Prepare two keys ChatCrypt.Init(_session.UserInfo.ClientCTX, ChatServer.ClientKey, _session.UserInfo.GameSecretKey); ChatCrypt.Init(_session.UserInfo.ServerCTX, ChatServer.ServerKey, _session.UserInfo.GameSecretKey); // 3. Response the crypt command _sendingBuffer = _cryptCmd.BuildResponse(ChatServer.ClientKey, ChatServer.ServerKey); }
protected override void DataOperation() { base.DataOperation(); string secretKey; if (!DataOperationExtensions.GetSecretKey(_request.GameName, out secretKey) || secretKey == null) { LogWriter.ToLog(LogEventLevel.Error, "secret key not found!"); _errorCode = ChatError.UnSupportedGame; return; } _session.UserInfo.SetGameSecretKey(secretKey); _session.UserInfo.SetGameName(_request.GameName); // 2. Prepare two keys ChatCrypt.Init(_session.UserInfo.ClientCTX, ChatServer.ClientKey, _session.UserInfo.GameSecretKey); ChatCrypt.Init(_session.UserInfo.ServerCTX, ChatServer.ServerKey, _session.UserInfo.GameSecretKey); }
/// <summary> /// Elevates security, for use with CRYPT method. /// </summary> public void ElevateSecurity(string secretKey) { string Info = $"{ServerName} Elevating security for user {Id} with game {chatUserInfo.gameName}"; ToLog(Info); // 1. Generate the two keys string clientKey = GameSpyRandom.GenerateRandomString(16, GameSpyRandom.StringType.Alpha); string serverKey = GameSpyRandom.GenerateRandomString(16, GameSpyRandom.StringType.Alpha); // 2. Prepare two keys ChatCrypt.Init(chatUserInfo.ClientCTX, clientKey, secretKey); ChatCrypt.Init(chatUserInfo.ServerCTX, serverKey, secretKey); // 3. Response the crypt command SendCommand(ChatRPL.SecureKey, "* " + clientKey + " " + serverKey); // 4. Start using encrypted connection chatUserInfo.encrypted = true; }