OpenMoHAA 0.82.0
Loading...
Searching...
No Matches
AuthService.h
1
3#ifndef __AUTHSERVICE_H__
4#define __AUTHSERVICE_H__
5
6
7// ***** Authentication web services.
8//
9// ***** PUBLIC INTERFACE AT THE BOTTOM OF THE FILE
10
11#include "../common/gsSoap.h"
12#include "../common/gsCrypt.h"
13#include "../common/gsLargeInt.h"
14
15#if defined(__cplusplus)
16extern "C"
17{
18#endif
19
22
23// URL for sc services.
24#define WS_LOGIN_MAX_URL_LEN (128)
25extern char wsAuthServiceURL[WS_LOGIN_MAX_URL_LEN];
26
27
30#define WSLogin_PARTNERCODE_GAMESPY 0
31#define WSLogin_NAMESPACE_SHARED_NONUNIQUE 0
32#define WSLogin_NAMESPACE_SHARED_UNIQUE 1
33
34typedef enum WSLoginValue
35{
36 // Login response code (mResponseCode)
37 // -- GameSpy Devs: Must match server
38 WSLogin_Success = 0,
39 WSLogin_ServerInitFailed,
40
41 WSLogin_UserNotFound,
42 WSLogin_InvalidPassword,
43 WSLogin_InvalidProfile,
44 WSLogin_UniqueNickExpired,
45
46 WSLogin_DBError,
47 WSLogin_ServerError,
48 WSLogin_FailureMax, // must be the last failure
49
50 // Login result (mLoginResult)
51 WSLogin_HttpError = 100, // ghttp reported an error, response ignored
52 WSLogin_ParseError, // couldn't parse http response
53 WSLogin_InvalidCertificate, // login success but certificate was invalid!
54 WSLogin_LoginFailed, // failed login or other error condition
55 WSLogin_OutOfMemory, // could not process due to insufficient memory
56 WSLogin_InvalidParameters, // check the function arguments
57 WSLogin_NoAvailabilityCheck,// No availability check was performed
58 WSLogin_Cancelled, // login request was cancelled
59 WSLogin_UnknownError // error occured, but detailed information not available
60
61} WSLoginValue;
62
63
66#define WS_LOGIN_SIGKEY_LEN_BITS (GS_CRYPT_RSA_BINARY_SIZE)
67#define WS_LOGIN_PEERKEY_LEN_BITS (GS_CRYPT_RSA_BINARY_SIZE)
68
69#define WS_LOGIN_NICK_LEN (30+1)
70#define WS_LOGIN_EMAIL_LEN (50+1)
71#define WS_LOGIN_PASSWORD_LEN (30+1)
72#define WS_LOGIN_UNIQUENICK_LEN (20+1)
73#define WS_LOGIN_CDKEY_LEN (64+1)
74#define WS_LOGIN_PEERKEYMOD_LEN (WS_LOGIN_PEERKEY_LEN_BITS/8)
75#define WS_LOGIN_PEERKEYEXP_LEN (WS_LOGIN_PEERKEY_LEN_BITS/8)
76#define WS_LOGIN_PEERKEYPRV_LEN (WS_LOGIN_PEERKEY_LEN_BITS/8)
77#define WS_LOGIN_KEYHASH_LEN (33) // 16 byte hash in hexstr +1 for NULL
78#define WS_LOGIN_SIGNATURE_LEN (WS_LOGIN_SIGKEY_LEN_BITS/8)
79#define WS_LOGIN_SERVERDATA_LEN (WS_LOGIN_PEERKEY_LEN_BITS/8)
80#define WS_LOGIN_AUTHTOKEN_LEN (256)
81#define WS_LOGIN_PARTNERCHALLENGE_LEN (256)
82
83// A user's login certificate, signed by the GameSpy AuthService
84// The certificate is public and may be freely passed around
85// Avoid use of pointer members so that structure may be easily copied
86typedef struct GSLoginCertificate
87{
88 gsi_bool mIsValid;
89
90 gsi_u32 mLength;
91 gsi_u32 mVersion;
92 gsi_u32 mPartnerCode; // aka Account space
93 gsi_u32 mNamespaceId;
94 gsi_u32 mUserId;
95 gsi_u32 mProfileId;
96 gsi_u32 mExpireTime;
97 gsi_char mProfileNick[WS_LOGIN_NICK_LEN];
98 gsi_char mUniqueNick[WS_LOGIN_UNIQUENICK_LEN];
99 gsi_char mCdKeyHash[WS_LOGIN_KEYHASH_LEN]; // hexstr - bigendian
100 gsCryptRSAKey mPeerPublicKey;
101 gsi_u8 mSignature[GS_CRYPT_RSA_BYTE_SIZE]; // binary - bigendian
102 gsi_u8 mServerData[WS_LOGIN_SERVERDATA_LEN]; // binary - bigendian
104
105// Private information for the owner of the certificate only
106// -- careful! private key information must be kept secret --
108{
109 gsCryptRSAKey mPeerPrivateKey;
110 char mKeyHash[GS_CRYPT_MD5_HASHSIZE];
111} GSLoginPrivateData;
112
113//typedef char GSLoginCertificateKeyHash[GS_CRYPT_MD5_HASHSIZE]; // Hash of private key, for simple auth
114
115typedef enum
116{
117 wsLoginType_INVALID,
118 wsLoginType_PROFILE,
119 wsLoginType_UNIQUENICK,
120 wsLoginType_GPTICKET,
121 wsLoginType_REMOTEAUTH
122} WSLoginType;
123
124/*
125typedef struct WSLoginProfileRequest
126{
127 int mPartnerCode;
128 char mProfileName[WS_LOGIN_NICK_LEN];
129 char mEmailAddress[WS_LOGIN_EMAIL_LEN];
130 char mPassword[WS_LOGIN_PASSWORD_LEN];
131 char mCdKeyHash[WS_LOGIN_KEYHASH_LEN];
132 void * mUserData;
133} WSLoginProfileRequest;
134
135typedef struct WSLoginUniqueRequest
136{
137 int mPartnerCode;
138 char mUniqueNick[WS_LOGIN_NICK_LEN];
139 char mPassword[WS_LOGIN_PASSWORD_LEN];
140 char mCdKeyHash[WS_LOGIN_KEYHASH_LEN];
141 void * mUserData;
142} WSLoginUniqueRequest;*/
143
144
147// CERTIFICATE login callback format
148typedef struct WSLoginResponse
149{
150 WSLoginValue mLoginResult; // SDK high level result, e.g. LoginFailed
151 WSLoginValue mResponseCode; // server's result code, e.g. BadPassword
152 GSLoginCertificate mCertificate; // Show this to others (prooves: "Bill is a valid user")
153 GSLoginPrivateData mPrivateData; // Keep this secret! (prooves: "I am Bill")
154 void * mUserData;
156
157typedef void (*WSLoginCallback)(GHTTPResult httpResult, WSLoginResponse * response, void * userData);
158
159
162// PS3 login callback format
164{
165 WSLoginValue mLoginResult; // SDK high level result, e.g. LoginFailed
166 WSLoginValue mResponseCode; // server's result code, e.g. BadPassword
167 char mRemoteAuthToken[WS_LOGIN_AUTHTOKEN_LEN]; // Show this to others
168 char mPartnerChallenge[WS_LOGIN_PARTNERCHALLENGE_LEN]; // keep this secret! (It's a "password" for the token.)
169 void * mUserData;
171
172typedef void (*WSLoginPs3CertCallback)(GHTTPResult httpResult, WSLoginPs3CertResponse * response, void * userData);
173
174
177// Services to obtain a certificate
178gsi_u32 wsLoginProfile(int partnerCode, int namespaceId, const gsi_char * profileNick, const gsi_char * email, const gsi_char * password, const gsi_char * cdkeyhash, WSLoginCallback callback, void * userData);
179gsi_u32 wsLoginUnique (int partnerCode, int namespaceId, const gsi_char * uniqueNick, const gsi_char * password, const gsi_char * cdkeyhash, WSLoginCallback callback, void * userData);
180gsi_u32 wsLoginRemoteAuth(int partnerCode, int namespaceId, const gsi_char authtoken[WS_LOGIN_AUTHTOKEN_LEN], const gsi_char partnerChallenge[WS_LOGIN_PARTNERCHALLENGE_LEN], WSLoginCallback callback, void * userData);
181
182// Services to obtain a remote auth token
183gsi_u32 wsLoginPs3Cert(int gameId, int partnerCode, int namespaceId, const gsi_u8 * ps3cert, int certLen, WSLoginPs3CertCallback callback, void * userData);
184
185// Certificate Utilities, for use after obtaining a certificate
186gsi_bool wsLoginCertIsValid (const GSLoginCertificate * cert);
187gsi_bool wsLoginCertWriteXML (const GSLoginCertificate * cert, const char * anamespace, GSXmlStreamWriter writer);
188gsi_bool wsLoginCertWriteBinary(const GSLoginCertificate * cert, char * bufout, unsigned int maxlen, unsigned int * lenout);
189gsi_bool wsLoginCertReadBinary (GSLoginCertificate * certOut, char * bufin, unsigned int maxlen);
190gsi_bool wsLoginCertReadXML (GSLoginCertificate * cert, GSXmlStreamReader reader);
191
192
195#if defined(__cplusplus)
196} // extern "C"
197#endif
198
199#endif //__AUTHSERVICE_H__
Definition AuthService.h:108
Definition AuthService.h:87
Definition AuthService.h:164
Definition AuthService.h:149
Definition gsCrypt.h:48