simplify gitignore
[vg.git] / src / vg / vg_steam_auth.h
1 #ifndef VG_STEAM_AUTH_H
2 #define VG_STEAM_AUTH_H
3
4 #include "vg/vg_platform.h"
5
6 typedef u32 HAuthTicket;
7 enum{ k_HAuthTicketInvalid = 0 };
8
9 #include "vg_steam.h"
10 #if defined( VALVE_CALLBACK_PACK_SMALL )
11 #pragma pack( push, 4 )
12 #elif defined( VALVE_CALLBACK_PACK_LARGE )
13 #pragma pack( push, 8 )
14 #endif
15
16 typedef struct EncryptedAppTicketResponse_t EncryptedAppTicketResponse_t;
17 struct EncryptedAppTicketResponse_t
18 {
19 EResult m_eResult;
20 };
21 enum{ k_iEncryptedAppTicketResponse = k_iSteamUserCallbacks + 54 };
22
23 typedef struct GetAuthSessionTicketResponse_t GetAuthSessionTicketResponse_t;
24 struct GetAuthSessionTicketResponse_t
25 {
26 HAuthTicket m_hAuthTicket;
27 EResult m_eResult;
28 };
29 enum{ k_iGetAuthSessionTicketResponse = k_iSteamUserCallbacks + 63 };
30
31 #pragma pack(pop)
32
33 /*
34 * Regular authentication
35 */
36
37 typedef void ISteamUser;
38 ISteamUser *SteamAPI_SteamUser_v021(void);
39 ISteamUser *SteamAPI_SteamUser(void)
40 {
41 return SteamAPI_SteamUser_v021();
42 }
43
44 HAuthTicket SteamAPI_ISteamUser_GetAuthSessionTicket(
45 ISteamUser *self, void *pTicket,
46 int cbMaxTicket, u32 *pcbTicket );
47
48 /*
49 * Application symetric-key ticket (Client)
50 */
51
52 SteamAPICall_t SteamAPI_ISteamUser_RequestEncryptedAppTicket(
53 ISteamUser *self, void *pDataToInclude, int cbDataToInclude );
54
55 int SteamAPI_ISteamUser_GetEncryptedAppTicket(
56 ISteamUser *self, void *pTicket,
57 int cbMaxTicket, u32 *pcbTicket );
58
59
60 /*
61 * Application symetric-key ticket method (Server)
62 */
63
64 enum { k_nSteamEncryptedAppTicketSymmetricKeyLen = 32 };
65
66 int SteamEncryptedAppTicket_BDecryptTicket( u8 *rgubTicketEncrypted,
67 u32 cubTicketEncrypted, u8 *rgubTicketDecrypted,
68 u32 *pcubTicketDecrypted,
69 u8 rgubKey[k_nSteamEncryptedAppTicketSymmetricKeyLen],
70 int cubKey );
71
72 int SteamEncryptedAppTicket_BIsTicketForApp( u8 *rgubTicketDecrypted,
73 u32 cubTicketDecrypted, AppId_t nAppID );
74
75 RTime32 SteamEncryptedAppTicket_GetTicketIssueTime( u8 *rgubTicketDecrypted,
76 u32 cubTicketDecrypted );
77
78 void SteamEncryptedAppTicket_GetTicketSteamID(
79 u8 *rgubTicketDecrypted, u32 cubTicketDecrypted, CSteamID *psteamID );
80
81 AppId_t SteamEncryptedAppTicket_GetTicketAppID( u8 *rgubTicketDecrypted,
82 u32 cubTicketDecrypted );
83
84 int SteamEncryptedAppTicket_BUserOwnsAppInTicket( u8 *rgubTicketDecrypted,
85 u32 cubTicketDecrypted, AppId_t nAppID );
86
87 int SteamEncryptedAppTicket_BUserIsVacBanned( u8 *rgubTicketDecrypted,
88 u32 cubTicketDecrypted );
89
90 int SteamEncryptedAppTicket_BGetAppDefinedValue( u8 *rgubTicketDecrypted,
91 u32 cubTicketDecrypted, u32 *pValue );
92
93 u8 *SteamEncryptedAppTicket_GetUserVariableData( u8 *rgubTicketDecrypted,
94 u32 cubTicketDecrypted, u32 *pcubUserData );
95
96 int SteamEncryptedAppTicket_BIsTicketSigned( u8 *rgubTicketDecrypted,
97 u32 cubTicketDecrypted, u8 *pubRSAKey, u32 cubRSAKey );
98
99 int SteamEncryptedAppTicket_BIsLicenseBorrowed( u8 *rgubTicketDecrypted,
100 u32 cubTicketDecrypted );
101
102 int SteamEncryptedAppTicket_BIsLicenseTemporary( u8 *rgubTicketDecrypted,
103 u32 cubTicketDecrypted );
104
105 static u8 vg_char_base16( char c )
106 {
107 if( c >= '0' && c <= '9' )
108 return c-'0';
109 if( c >= 'a' && c <= 'f' )
110 return (c-'a') + 10;
111
112 return 0;
113 }
114
115 static int vg_load_steam_symetric_key( const char *path, u8 *buf )
116 {
117 vg_linear_clear( vg_mem.scratch );
118 u32 size;
119 char *src = vg_file_read( vg_mem.scratch, path, &size );
120
121 if( src )
122 {
123 if( size < k_nSteamEncryptedAppTicketSymmetricKeyLen )
124 {
125 vg_error( "Application key was invalid size\n" );
126 return 0;
127 }
128
129 for( int i=0; i<k_nSteamEncryptedAppTicketSymmetricKeyLen; i++ )
130 {
131 buf[i] = (vg_char_base16( src[i*2+0] ) << 4) |
132 vg_char_base16( src[i*2+1] );
133 }
134
135 return 1;
136 }
137 else
138 {
139 vg_error( "Application key path was invalid\n" );
140 return 0;
141 }
142 }
143
144
145 #endif /* VG_STEAM_AUTH_H */