Exemplo n.º 1
0
    void OnEncryptedAppTicketResponse(EncryptedAppTicketResponse_t pCallback, bool bIOFailure)
    {
        Debug.Log("[" + EncryptedAppTicketResponse_t.k_iCallback + " - EncryptedAppTicketResponse] - " + pCallback.m_eResult);

        // This code is taken directly from SteamworksExample/SpaceWar
        if (pCallback.m_eResult == EResult.k_EResultOK)
        {
            byte[] rgubTicket = new byte[1024];
            uint   cubTicket;
            SteamUser.GetEncryptedAppTicket(rgubTicket, 1024, out cubTicket);

            // normally at this point you transmit the encrypted ticket to the service that knows the decryption key
            // this code is just to demonstrate the ticket cracking library

            // included is the "secret" key for spacewar. normally this is secret
            byte[] rgubKey = new byte[32] {
                0xed, 0x93, 0x86, 0x07, 0x36, 0x47, 0xce, 0xa5, 0x8b, 0x77, 0x21, 0x49, 0x0d, 0x59, 0xed, 0x44, 0x57, 0x23, 0xf0, 0xf6, 0x6e, 0x74, 0x14, 0xe1, 0x53, 0x3b, 0xa3, 0x3c, 0xd8, 0x03, 0xbd, 0xbd
            };

            byte[] rgubDecrypted = new byte[1024];
            uint   cubDecrypted  = 1024;
            if (!SteamEncryptedAppTicket.BDecryptTicket(rgubTicket, cubTicket, rgubDecrypted, ref cubDecrypted, rgubKey, rgubKey.Length))
            {
                Debug.Log("Ticket failed to decrypt");
                return;
            }

            if (!SteamEncryptedAppTicket.BIsTicketForApp(rgubDecrypted, cubDecrypted, SteamUtils.GetAppID()))
            {
                Debug.Log("Ticket for wrong app id");
            }

            CSteamID steamIDFromTicket;
            SteamEncryptedAppTicket.GetTicketSteamID(rgubDecrypted, cubDecrypted, out steamIDFromTicket);
            if (steamIDFromTicket != SteamUser.GetSteamID())
            {
                Debug.Log("Ticket for wrong user");
            }

            uint   cubData;
            byte[] punSecretData = SteamEncryptedAppTicket.GetUserVariableData(rgubDecrypted, cubDecrypted, out cubData);
            if (cubData != sizeof(uint))
            {
                Debug.Log("Secret data size is wrong.");
            }
            Debug.Log(punSecretData.Length);
            Debug.Log(System.BitConverter.ToUInt32(punSecretData, 0));
            if (System.BitConverter.ToUInt32(punSecretData, 0) != 0x5444)
            {
                Debug.Log("Failed to retrieve secret data");
                return;
            }

            Debug.Log("Successfully retrieved Encrypted App Ticket");
        }
    }
Exemplo n.º 2
0
        // SteamAPICall_t
        public CallbackHandle RequestEncryptedAppTicket(IntPtr pDataToInclude /*void **/, int cbDataToInclude /*int*/, Action <EncryptedAppTicketResponse_t, bool> CallbackFunction = null /*Action<EncryptedAppTicketResponse_t, bool>*/)
        {
            SteamAPICall_t callback = 0;

            callback = platform.ISteamUser_RequestEncryptedAppTicket((IntPtr)pDataToInclude, cbDataToInclude);

            if (CallbackFunction == null)
            {
                return(null);
            }

            return(EncryptedAppTicketResponse_t.CallResult(steamworks, callback, CallbackFunction));
        }
Exemplo n.º 3
0
 private void onEncryptedAppTicketResponse(EncryptedAppTicketResponse_t response, bool ioFailure)
 {
     if (response.m_eResult == EResult.k_EResultOK)
     {
         byte[] ticket = new byte[1024];
         SteamUser.GetEncryptedAppTicket(ticket, 1024, out uint ticketSize);
         Console.WriteLine("Signing into GalaxySDK");
         GalaxyInstance.User().SignInSteam(ticket, ticketSize, SteamFriends.GetPersonaName());
         ConnectionProgress++;
     }
     else
     {
         Console.WriteLine("Failed to retrieve encrypted app ticket: " + response.m_eResult + ", " + ioFailure.ToString());
         ConnectionFinished = true;
     }
 }