public async Task HandleAuthSession(CMSG_AUTH_SESSION auth, UInt32 ServerSeed) { if (SessionKey == 0) { await GetSessionKeyFromAuthAccount(auth.Account); } if (SessionKey == 0) { await SendAuthResponse(LoginErrorCode.AUTH_UNKNOWN_ACCOUNT); return; } byte[] t = new byte[4]; var accountbytes = Encoding.UTF8.GetBytes(Account.GetPrimaryKeyString()); var clientseed = BitConverter.GetBytes(auth.Seed); var serverseed = BitConverter.GetBytes(ServerSeed); var sess_key = SessionKey; var sesskeybytes = sess_key.GetBytes(); BigInteger ServerProof = BigInt.Hash(accountbytes, t, clientseed, serverseed, sesskeybytes); BigInteger ClientProof = new BigInteger(auth.Digest); if (ClientProof != ServerProof) { await SendAuthResponse(LoginErrorCode.AUTH_UNKNOWN_ACCOUNT); return; } Authed = true; await Account.AddSession(this); //set realm session (and disconnect any others) //TODO: add queues PacketOut p = new PacketOut(RealmOp.SMSG_AUTH_RESPONSE); p.Write((byte)LoginErrorCode.AUTH_OK); p.Write((int)0); p.Write((byte)0); p.Write(0); p.Write((byte)0); //expansionLevel await SendPacket(p); }