// *************************************************************** // Function: AuthPasswordRequest.cpp // *************************************************************** #include "Main.h" #include "../../src/sha256.h" bool HashPassword(unsigned char* pSource, unsigned char* pDest); //************************************ // Name: IcProcessAuthPassRequest // // Processes the request for the auth password from the login server. Sends the pass hash. // // Parameters: // pData - Network message // s - Outgoing network message // pDest - Src data buffer // // Return: // //************************************ void IcProcessAuthPassRequest(NetMessage* pData, NetMessage* s, unsigned char* pDest) { unsigned char packet[40]={GS_REQUEST_AUTHORIZATION, 38}; HashPassword(gServerConfig.authorizationPassword, packet+2); s->Set(40, packet); memcpy(s->pData+34, gServerConfig.ip, 4); memcpy(s->pData+38, &gServerConfig.maxPlayers, 2); gpInternalComm->SendData(s); } //************************************ // Name: HashPassword // // Makes a SHA256 hash of the password // // Parameters: // pSource - Source data // pDest - Destination buffer (32 bytes) // // Return: // - true //************************************ bool HashPassword(unsigned char* pSource, unsigned char* pDest) { sha256_context ctx; assert(pSource!=NULL); assert(pDest!=NULL); sha256_starts( &ctx ); sha256_update( &ctx, pSource, strlen( (char*)pSource ) ); sha256_finish( &ctx, pDest ); return true; }