Fixes --without-lobby for MSVC and clang, refs #2249.

Cleans up some whitespace.
Removes obsolete PCH files.

This was SVN commit r14117.
This commit is contained in:
historic_bruno
2013-11-09 02:57:10 +00:00
parent 3c47b12cbe
commit 9cc172b164
7 changed files with 315 additions and 349 deletions
+50 -48
View File
@@ -620,6 +620,7 @@ bool HasXmppClient(void* UNUSED(cbdata))
return (g_XmppClient ? true : false);
}
#if CONFIG2_LOBBY
void StartXmppClient(void* cbdata, std::string sUsername, std::string sPassword, std::string sRoom, std::string sNick)
{
CGUIManager* guiManager = static_cast<CGUIManager*> (cbdata);
@@ -807,6 +808,55 @@ std::string LobbyGetPlayerPresence(void* UNUSED(cbdata), std::string nickname)
return presence;
}
// Non-public secure PBKDF2 hash function with salting and 1,337 iterations
void EncryptPassword(const std::string& username, std::string& password)
{
const int DIGESTSIZE = SHA_DIGEST_SIZE;
const int ITERATIONS = 1337;
static const byte salt_base[DIGESTSIZE] = {
244, 243, 249, 244, 32, 33, 34, 35, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 32, 33, 244, 224, 127, 129, 130, 140, 153, 133, 123, 234, 123 };
// initialize the salt buffer
byte salt_buffer[DIGESTSIZE] = {0};
SHA256 hash;
hash.update(salt_base, username.length());
hash.update(username.c_str(), username.length());
hash.finish(salt_buffer);
// PBKDF2 to create the buffer
byte encrypted[DIGESTSIZE];
pbkdf2(encrypted, (byte*)password.c_str(), password.length(), salt_buffer, DIGESTSIZE, ITERATIONS);
static const char base16[] = "0123456789ABCDEF";
char hex[2 * DIGESTSIZE];
for(int i = 0; i < DIGESTSIZE; ++i)
{
hex[i*2] = base16[encrypted[i] >> 4]; // 4 high bits
hex[i*2 + 1] = base16[encrypted[i] & 0x0F];// 4 low bits
}
password.assign(hex, sizeof(hex));
}
// Public hash interface.
std::string EncryptPassword(void* UNUSED(cbdata), std::string user, std::string pass)
{
EncryptPassword(user, pass);
return pass;
}
bool IsRankedGame(void* UNUSED(cbdata))
{
return g_rankedGame;
}
void SetRankedGame(void* UNUSED(cbdata), bool isRanked)
{
g_rankedGame = isRanked;
}
#endif // CONFIG2_LOBBY
/* End lobby related functions */
void QuickSave(void* UNUSED(cbdata))
@@ -824,54 +874,6 @@ void SetBoundingBoxDebugOverlay(void* UNUSED(cbdata), bool enabled)
ICmpSelectable::ms_EnableDebugOverlays = enabled;
}
// Non-public secure PBKDF2 hash function with salting and 1,337 iterations
void EncryptPassword(const std::string& username, std::string& password)
{
const int DIGESTSIZE = SHA_DIGEST_SIZE;
const int ITERATIONS = 1337;
static const byte salt_base[DIGESTSIZE] = {
244, 243, 249, 244, 32, 33, 34, 35, 10, 11, 12, 13, 14, 15, 16, 17,
18, 19, 20, 32, 33, 244, 224, 127, 129, 130, 140, 153, 133, 123, 234, 123 };
// initialize the salt buffer
byte salt_buffer[DIGESTSIZE] = {0};
SHA256 hash;
hash.update(salt_base, username.length());
hash.update(username.c_str(), username.length());
hash.finish(salt_buffer);
// PBKDF2 to create the buffer
byte encrypted[DIGESTSIZE];
pbkdf2(encrypted, (byte*)password.c_str(), password.length(), salt_buffer, DIGESTSIZE, ITERATIONS);
static const char base16[] = "0123456789ABCDEF";
char hex[2 * DIGESTSIZE];
for(int i = 0; i < DIGESTSIZE; ++i)
{
hex[i*2] = base16[encrypted[i] >> 4]; // 4 high bits
hex[i*2 + 1] = base16[encrypted[i] & 0x0F];// 4 low bits
}
password.assign(hex, sizeof(hex));
}
// Public hash interface.
std::string EncryptPassword(void* UNUSED(cbdata), std::string user, std::string pass)
{
EncryptPassword(user, pass);
return pass;
}
bool IsRankedGame(void* UNUSED(cbdata))
{
return g_rankedGame;
}
void SetRankedGame(void* UNUSED(cbdata), bool isRanked)
{
g_rankedGame = isRanked;
}
} // namespace
void GuiScriptingInit(ScriptInterface& scriptInterface)