Utilitários para decodificar/descriptografar tickets criptografados de aplicativos.
Consulte
Tickets criptografados de aplicativo para mais informações.
Para usar essas funções, inclua o cabeçalho
steamencryptedappticket.h
e vincule ao binário sdkencryptedappticket. Dessa forma, é possível usar as funções em um aplicativo off-line, executado em um servidor confiável para autenticar os tickets recebidos de clientes.
Aviso: um ticket criptografado de aplicativo pode conter no máximo 140 AppIDs de conteúdos adicionais. Caso planeje ter mais conteúdo, você precisará usar tickets de sessão/WebAPI para verificação de titularidade.
Funções
Estas são funções globais, que não precisam de uma interface para serem usadas.
SteamEncryptedAppTicket_BDecryptTicket
S_API bool SteamEncryptedAppTicket_BDecryptTicket( const uint8 *rgubTicketEncrypted, uint32 cubTicketEncrypted,
uint8 *rgubTicketDecrypted, uint32 *pcubTicketDecrypted,
const uint8 rgubKey[k_nSteamEncryptedAppTicketSymmetricKeyLen], int cubKey );
Nome | Tipo | Descrição |
rgubTicketEncrypted | const uint8 * | O ticket criptografado de autenticação de usuário a descriptografar. |
cubTicketEncrypted | uint32 | O tamanho de rgubTicketEncrypted , em bytes. |
rgubTicketDecrypted | uint8 * | O buffer para o qual o ticket descriptografado será copiado. |
pcubTicketDecrypted | uint32 * | O tamanho alocado para o buffer rgubTicketDecrypted , em bytes. |
rgubKey | const uint8[[apitype]SteamEncryptedAppTicket::k_nSteamEncryptedAppTicketSymmetricKeyLen[/apitype]] | A chave usada para criptografar e descriptografar o ticket. Não pode ultrapassar o tamanho definido pela constante k_nSteamEncryptedAppTicketSymmetricKeyLen. |
cubKey | int | O tamanho de rgubKey . |
Descriptografa um ticket criptografado de aplicativo.
A chave de criptografia pode ser obtida na página de
chave de ticket criptografado de aplicativo na administração do seu aplicativo.
Se a chamada for bem-sucedida, use as outras funções da biblioteca SteamEncryptedAppTicket para recuperar dados sobre o ticket descriptografado.
Retorna: bool
true se o ticket for descriptografado com sucesso.
false sob as seguintes condições:
-
cubKey
for 0;
- O tamanho do buffer de saída
rgubTicketDecrypted
é pequeno demais; ele precisa ser pelo menos do tamanho de rgubTicketEncrypted
.
- Falha na leitura de
rgubTicketEncrypted
, o que pode ocorrer se contiver um valor NULL ou vazio.
- Falha na criptografia, possivelmente devido a uma chave incorreta.
Consulte também: ISteamUser::RequestEncryptedAppTicketExemplo:void DecryptTicket( uint8* rgubTicket, uint32 cubTicket )
{
// Inclui a chave secreta do ticket criptografado de aplicativo do Spacewar. Nunca envie essa chave a clientes.
const uint8 rgubKey[k_nSteamEncryptedAppTicketSymmetricKeyLen] = { 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 };
uint8 rgubDecrypted[1024];
uint32 cubDecrypted = sizeof( rgubDecrypted );
if ( !SteamEncryptedAppTicket_BDecryptTicket( rgubTicket, cubTicket, rgubDecrypted, &cubDecrypted, rgubKey, sizeof( rgubKey ) ) )
{
printf( "Falha ao descriptografar ticket\n" );
return;
}
if ( !SteamEncryptedAppTicket_BIsTicketForApp( rgubDecrypted, cubDecrypted, SteamUtils()->GetAppID() ) )
printf( "Ticket para AppID invalido\n" );
CSteamID steamIDFromTicket;
SteamEncryptedAppTicket_GetTicketSteamID( rgubDecrypted, cubDecrypted, &steamIDFromTicket );
if ( steamIDFromTicket != SteamUser()->GetSteamID() )
printf( "Ticket do usuario errado\n" );
uint32 cubData;
uint32 *punSecretData = (uint32 *)SteamEncryptedAppTicket_GetUserVariableData( rgubDecrypted, cubDecrypted, &cubData );
if ( cubData != sizeof( uint32 ) || *punSecretData != k_unSecretData )
printf( "Falha ao recuperar dados secretos\n" );
}
SteamEncryptedAppTicket_BIsTicketForApp
S_API bool SteamEncryptedAppTicket_BIsTicketForApp( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, AppId_t nAppID );
Nome | Tipo | Descrição |
rgubTicketDecrypted | uint8 * | O ticket descriptografado a verificar. |
pcubTicketDecrypted | uint32 * | O tamanho de rgubTicketDecrypted , em bytes. |
nAppID | AppId_t | O AppID a comparar. |
Verifica se um ticket descriptografado de aplicativo é para o aplicativo esperado.
Retorna: bool
true se o ticket for do AppID informado;
false se não for ou se o ticket for inválido.
SteamEncryptedAppTicket_BUserIsVacBanned
S_API bool SteamEncryptedAppTicket_BUserIsVacBanned( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted );
Nome | Tipo | Descrição |
rgubTicketDecrypted | uint8 * | O ticket descriptografado a verificar. |
pcubTicketDecrypted | uint32 * | O tamanho de rgubTicketDecrypted , em bytes. |
Verifica se o usuário associado ao ticket foi banido pelo
VAC.
Retorna: AppId_ttrue se o usuário foi banido pelo VAC;
false se o usuário não estiver banido pelo VAC, não for válido ou o ticket não tiver esses dados.
SteamEncryptedAppTicket_BUserOwnsAppInTicket
S_API bool SteamEncryptedAppTicket_BUserOwnsAppInTicket( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, AppId_t nAppID );
Nome | Tipo | Descrição |
rgubTicketDecrypted | uint8 * | O ticket descriptografado a verificar. |
pcubTicketDecrypted | uint32 * | O tamanho de rgubTicketDecrypted , em bytes. |
nAppID | AppId_t | O AppID cuja titularidade verificar. |
Verifica se o ticket prova que o usuário possui o AppID informado.
Pode ser usado para conteúdos adicionais e AppIDs relacionados que foram adicionados ao ticket, não apenas o AppID principal do ticket.
Retorna: bool
true se o ticket for do AppID informado;
false se não for ou se o ticket for inválido.
SteamEncryptedAppTicket_GetTicketAppID
S_API AppId_t SteamEncryptedAppTicket_GetTicketAppID( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted );
Nome | Tipo | Descrição |
rgubTicketDecrypted | uint8 * | O ticket descriptografado a verificar. |
pcubTicketDecrypted | uint32 * | O tamanho de rgubTicketDecrypted , em bytes. |
Recupera o AppID associado a um ticket.
Retorna: AppId_tRetorna o AppID associado ao ticket. Retorna 0 se o ticket não for válido.
SteamEncryptedAppTicket_GetTicketIssueTime
S_API RTime32 SteamEncryptedAppTicket_GetTicketIssueTime( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted );
Nome | Tipo | Descrição |
rgubTicketDecrypted | uint8 * | O ticket descriptografado a verificar. |
pcubTicketDecrypted | uint32 * | O tamanho de rgubTicketDecrypted , em bytes. |
Recupera o horário de emissão de um ticket.
Retorna: RTime32Retorna o horário no formato de Era Unix (segundos a partir de 1º de janeiro de 1970). Retorna 0 se o ticket não for válido.
SteamEncryptedAppTicket_GetTicketSteamID
S_API void SteamEncryptedAppTicket_GetTicketSteamID( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, CSteamID *psteamID );
Nome | Tipo | Descrição |
rgubTicketDecrypted | uint8 * | O ticket descriptografado a verificar. |
pcubTicketDecrypted | uint32 * | O tamanho de rgubTicketDecrypted , em bytes. |
psteamID | CSteamID * | Retorna o ID Steam associado ao ticket. Retorna k_steamIDNil se o ticket for inválido. |
Recupera o ID Steam associado a um ticket.
SteamEncryptedAppTicket_GetUserVariableData
S_API const uint8 *SteamEncryptedAppTicket_GetUserVariableData( uint8 *rgubTicketDecrypted, uint32 cubTicketDecrypted, uint32 *pcubUserData );
Nome | Tipo | Descrição |
rgubTicketDecrypted | uint8 * | O ticket descriptografado a verificar. |
pcubTicketDecrypted | uint32 * | O tamanho de rgubTicketDecrypted , em bytes. |
pcubUserData | uint32 * | Retorna o tamanho dos dados do usuário. |
Recupera os dados do usuário informados durante a criação do ticket. Tamanho variável.
Retorna: const uint8 *
Retorna um ponteiro aos dados do usuário. Retorna o tamanho dos dados no parâmetro
pcubUserData
.
Constantes
Estas são as constantes definidas para uso com SteamEncryptedAppTicket.
Nome | Tipo | Valor | Descrição |
k_nSteamEncryptedAppTicketSymmetricKeyLen | int | 32 | O tamanho de uma chave usada com BDecryptTicket. |