X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=src%2Fvg%2Fvg_steam_auth.h;h=9ad1a2d36d69160b876b0b00f3ec7b42929f120f;hb=3dd767bb10e6fee9cbffeb185d1a9685810c17b5;hp=dec590a43757c8b3bbb1a51c0a3adf01075662b4;hpb=e99cbefb033306f6e500a6c0860e9bea6dbebf99;p=vg.git diff --git a/src/vg/vg_steam_auth.h b/src/vg/vg_steam_auth.h index dec590a..9ad1a2d 100644 --- a/src/vg/vg_steam_auth.h +++ b/src/vg/vg_steam_auth.h @@ -1,6 +1,11 @@ #ifndef VG_STEAM_AUTH_H #define VG_STEAM_AUTH_H +#include "vg/vg_platform.h" + +typedef u32 HAuthTicket; +enum{ k_HAuthTicketInvalid = 0 }; + #include "vg_steam.h" #if defined( VALVE_CALLBACK_PACK_SMALL ) #pragma pack( push, 4 ) @@ -8,19 +13,133 @@ #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) -typedef u32 HAuthTicket; -enum{ k_HAuthTicketInvalid = 0 }; +/* + * Regular authentication + */ -void *SteamAPI_SteamUser_v021(void); -void *SteamAPI_SteamUser(void) +typedef void ISteamUser; +ISteamUser *SteamAPI_SteamUser_v021(void); +ISteamUser *SteamAPI_SteamUser(void) { return SteamAPI_SteamUser_v021(); } HAuthTicket SteamAPI_ISteamUser_GetAuthSessionTicket( - void *self, void *pTicket, + 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