public byte[] toBuffer() { MemoryStream m = new MemoryStream(); m.Write(sessionKey, 0, 16); Helper.WriteU32(m, serverPID); Helper.WriteU32(m, (uint)ticket.Length); m.Write(ticket, 0, ticket.Length); byte[] buff = m.ToArray(); byte[] key = Helper.DeriveKey(userPID); buff = Helper.Encrypt(key, buff); byte[] hmac = Helper.MakeHMAC(key, buff); m = new MemoryStream(); m.Write(buff, 0, buff.Length); m.Write(hmac, 0, hmac.Length); return(m.ToArray()); }