new build method
[vg.git] / src / vg / vg_steam_auth.h
index dec590a43757c8b3bbb1a51c0a3adf01075662b4..9d06c9c852c1bdac329cc16d97b469dc90cbc709 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef VG_STEAM_AUTH_H
 #define VG_STEAM_AUTH_H
 
+typedef u32 HAuthTicket;
+enum{ k_HAuthTicketInvalid = 0 };
+
 #include "vg_steam.h"
 #if defined( VALVE_CALLBACK_PACK_SMALL )
  #pragma pack( push, 4 )
  #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 )
+{
+   i64 len;
+   char *text_src = vg_textasset_read_s( path, &len );
+
+   if( text_src )
+   {
+      if( len < k_nSteamEncryptedAppTicketSymmetricKeyLen )
+      {
+         vg_error( "Application key was invalid size\n" );
+         free( text_src );
+         return 0;
+      }
+      
+      for( int i=0; i<k_nSteamEncryptedAppTicketSymmetricKeyLen; i++ )
+      {
+         buf[i] = (vg_char_base16( text_src[i*2+0] ) << 4) |
+                   vg_char_base16( text_src[i*2+1] );
+      }
+
+      free( text_src );
+      return 1;
+   }
+   else
+   {
+      vg_error( "Application key path was invalid\n" );
+      return 0;
+   }
+}
+
+
 #endif /* VG_STEAM_AUTH_H */