X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=vg_steam_auth.h;fp=vg_steam_auth.h;h=7d4002bd55cc8e55fc452223a488c3471489bbfa;hb=4c48fe01a5d1983be89b7dce6f08e6b708cfbb05;hp=0000000000000000000000000000000000000000;hpb=3dd767bb10e6fee9cbffeb185d1a9685810c17b5;p=vg.git diff --git a/vg_steam_auth.h b/vg_steam_auth.h new file mode 100644 index 0000000..7d4002b --- /dev/null +++ b/vg_steam_auth.h @@ -0,0 +1,146 @@ +#ifndef VG_STEAM_AUTH_H +#define VG_STEAM_AUTH_H + +#include "vg/vg_platform.h" +#include "vg/vg_io.h" + +typedef u32 HAuthTicket; +enum{ k_HAuthTicketInvalid = 0 }; + +#include "vg_steam.h" +#if defined( VALVE_CALLBACK_PACK_SMALL ) + #pragma pack( push, 4 ) +#elif defined( VALVE_CALLBACK_PACK_LARGE ) + #pragma pack( push, 8 ) +#endif + +typedef struct EncryptedAppTicketResponse_t EncryptedAppTicketResponse_t; +struct EncryptedAppTicketResponse_t +{ + EResult m_eResult; +}; +enum{ k_iEncryptedAppTicketResponse = k_iSteamUserCallbacks + 54 }; + +typedef struct GetAuthSessionTicketResponse_t GetAuthSessionTicketResponse_t; +struct GetAuthSessionTicketResponse_t +{ + HAuthTicket m_hAuthTicket; + EResult m_eResult; +}; +enum{ k_iGetAuthSessionTicketResponse = k_iSteamUserCallbacks + 63 }; + +#pragma pack(pop) + +/* + * Regular authentication + */ + +typedef void ISteamUser; +ISteamUser *SteamAPI_SteamUser_v021(void); +ISteamUser *SteamAPI_SteamUser(void) +{ + return SteamAPI_SteamUser_v021(); +} + +HAuthTicket SteamAPI_ISteamUser_GetAuthSessionTicket( + ISteamUser *self, void *pTicket, + int cbMaxTicket, u32 *pcbTicket ); + +/* + * Application symetric-key ticket (Client) + */ + +SteamAPICall_t SteamAPI_ISteamUser_RequestEncryptedAppTicket( + ISteamUser *self, void *pDataToInclude, int cbDataToInclude ); + +int SteamAPI_ISteamUser_GetEncryptedAppTicket( + ISteamUser *self, void *pTicket, + int cbMaxTicket, u32 *pcbTicket ); + + +/* + * Application symetric-key ticket method (Server) + */ + +enum { k_nSteamEncryptedAppTicketSymmetricKeyLen = 32 }; + +int SteamEncryptedAppTicket_BDecryptTicket( u8 *rgubTicketEncrypted, + u32 cubTicketEncrypted, u8 *rgubTicketDecrypted, + u32 *pcubTicketDecrypted, + u8 rgubKey[k_nSteamEncryptedAppTicketSymmetricKeyLen], + int cubKey ); + +int SteamEncryptedAppTicket_BIsTicketForApp( u8 *rgubTicketDecrypted, + u32 cubTicketDecrypted, AppId_t nAppID ); + +RTime32 SteamEncryptedAppTicket_GetTicketIssueTime( u8 *rgubTicketDecrypted, + u32 cubTicketDecrypted ); + +void SteamEncryptedAppTicket_GetTicketSteamID( + u8 *rgubTicketDecrypted, u32 cubTicketDecrypted, CSteamID *psteamID ); + +AppId_t SteamEncryptedAppTicket_GetTicketAppID( u8 *rgubTicketDecrypted, + u32 cubTicketDecrypted ); + +int SteamEncryptedAppTicket_BUserOwnsAppInTicket( u8 *rgubTicketDecrypted, + u32 cubTicketDecrypted, AppId_t nAppID ); + +int SteamEncryptedAppTicket_BUserIsVacBanned( u8 *rgubTicketDecrypted, + u32 cubTicketDecrypted ); + +int SteamEncryptedAppTicket_BGetAppDefinedValue( u8 *rgubTicketDecrypted, + u32 cubTicketDecrypted, u32 *pValue ); + +u8 *SteamEncryptedAppTicket_GetUserVariableData( u8 *rgubTicketDecrypted, + u32 cubTicketDecrypted, u32 *pcubUserData ); + +int SteamEncryptedAppTicket_BIsTicketSigned( u8 *rgubTicketDecrypted, + u32 cubTicketDecrypted, u8 *pubRSAKey, u32 cubRSAKey ); + +int SteamEncryptedAppTicket_BIsLicenseBorrowed( u8 *rgubTicketDecrypted, + u32 cubTicketDecrypted ); + +int SteamEncryptedAppTicket_BIsLicenseTemporary( u8 *rgubTicketDecrypted, + u32 cubTicketDecrypted ); + +static u8 vg_char_base16( char c ) +{ + if( c >= '0' && c <= '9' ) + return c-'0'; + if( c >= 'a' && c <= 'f' ) + return (c-'a') + 10; + + return 0; +} + +static int vg_load_steam_symetric_key( const char *path, u8 *buf ) +{ + vg_linear_clear( vg_mem.scratch ); + u32 size; + char *src = vg_file_read( vg_mem.scratch, path, &size ); + + if( src ) + { + if( size < k_nSteamEncryptedAppTicketSymmetricKeyLen ) + { + vg_error( "Application key was invalid size\n" ); + return 0; + } + + for( int i=0; i