Browse Source

Merge pull request #150 from dpogue/pnEncryption

Refactor hash digest code

--HG--
rename : Sources/Plasma/PubUtilLib/plMath/plRandom.h => Sources/Plasma/NucleusLib/pnEncryption/plRandom.h
Adam Johnson 13 years ago
parent
commit
a2a7bd7e77
  1. 2
      Sources/Plasma/Apps/CMakeLists.txt
  2. 2
      Sources/Plasma/Apps/plClient/CMakeLists.txt
  3. 25
      Sources/Plasma/Apps/plClient/winmain.cpp
  4. 2
      Sources/Plasma/Apps/plClientPatcher/Pch.h
  5. 19
      Sources/Plasma/Apps/plMD5/CMakeLists.txt
  6. 21
      Sources/Plasma/Apps/plMD5/Main.cpp
  7. 2
      Sources/Plasma/Apps/plPlasmaUpdate/plManifest.cpp
  8. 19
      Sources/Plasma/Apps/plSHA/CMakeLists.txt
  9. 39
      Sources/Plasma/Apps/plSHA/Main.cpp
  10. 2
      Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt
  11. 2
      Sources/Plasma/Apps/plUruLauncher/Pch.h
  12. 2
      Sources/Plasma/FeatureLib/pfAnimation/pfObjectFlocker.cpp
  13. 2
      Sources/Plasma/FeatureLib/pfAnimation/plBlower.h
  14. 19
      Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp
  15. 2
      Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp
  16. 1
      Sources/Plasma/NucleusLib/CMakeLists.txt
  17. 20
      Sources/Plasma/NucleusLib/pnEncryption/CMakeLists.txt
  18. 119
      Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp
  19. 24
      Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.h
  20. 482
      Sources/Plasma/NucleusLib/pnEncryption/plChecksum.cpp
  21. 187
      Sources/Plasma/NucleusLib/pnEncryption/plChecksum.h
  22. 0
      Sources/Plasma/NucleusLib/pnEncryption/plRandom.h
  23. 2
      Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp
  24. 220
      Sources/Plasma/NucleusLib/pnUtils/pnUtCrypt.cpp
  25. 55
      Sources/Plasma/NucleusLib/pnUtils/pnUtCrypt.h
  26. 1
      Sources/Plasma/PubUtilLib/CMakeLists.txt
  27. 2
      Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.h
  28. 2
      Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp
  29. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp
  30. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp
  31. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp
  32. 2
      Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp
  33. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDynaBulletMgr.cpp
  34. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp
  35. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDynaFootMgr.cpp
  36. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp
  37. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp
  38. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDynaTorpedoMgr.cpp
  39. 2
      Sources/Plasma/PubUtilLib/plDrawable/plDynaWakeMgr.cpp
  40. 2
      Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.h
  41. 16
      Sources/Plasma/PubUtilLib/plEncryption/CMakeLists.txt
  42. 226
      Sources/Plasma/PubUtilLib/plEncryption/plChecksum.cpp
  43. 105
      Sources/Plasma/PubUtilLib/plEncryption/plChecksum.h
  44. 1
      Sources/Plasma/PubUtilLib/plMath/CMakeLists.txt
  45. 2
      Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h
  46. 7
      Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp
  47. 26
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp
  48. 6
      Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.cpp
  49. 2
      Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp
  50. 2
      Sources/Plasma/PubUtilLib/plParticleSystem/plParticleGenerator.cpp
  51. 2
      Sources/Tools/MaxComponent/plClusterComponent.cpp
  52. 2
      Sources/Tools/MaxComponent/plObjectFlockerComponent.cpp
  53. 2
      Sources/Tools/MaxConvert/plDistributor.h
  54. 2
      Sources/Tools/MaxMain/CMakeLists.txt
  55. 2
      Sources/Tools/MaxPlasmaLights/CMakeLists.txt

2
Sources/Plasma/Apps/CMakeLists.txt

@ -5,4 +5,6 @@ add_subdirectory(plUruLauncher)
add_subdirectory(plFileSecure)
add_subdirectory(plFileEncrypt)
add_subdirectory(plLogDecrypt)
add_subdirectory(plMD5)
add_subdirectory(plPageInfo)
add_subdirectory(plSHA)

2
Sources/Plasma/Apps/plClient/CMakeLists.txt

@ -101,7 +101,6 @@ target_link_libraries(plClient plClientResMgr)
target_link_libraries(plClient plCompression)
target_link_libraries(plClient plContainer)
target_link_libraries(plClient plDrawable)
target_link_libraries(plClient plEncryption)
target_link_libraries(plClient plFile)
target_link_libraries(plClient plGImage)
target_link_libraries(plClient plGLight)
@ -140,6 +139,7 @@ target_link_libraries(plClient pnAsyncCore)
target_link_libraries(plClient pnAsyncCoreExe)
target_link_libraries(plClient pnCsrNet)
target_link_libraries(plClient pnDispatch)
target_link_libraries(plClient pnEncryption)
target_link_libraries(plClient pnFactory)
target_link_libraries(plClient pnGameMgr)
target_link_libraries(plClient pnIni)

25
Sources/Plasma/Apps/plClient/winmain.cpp

@ -65,6 +65,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plResMgr/plLocalization.h"
#include "plFile/plEncryptedStream.h"
#include "pnEncryption/plChallengeHash.h"
#include "plStatusLog/plStatusLog.h"
#include "pnProduct/pnProduct.h"
#include "plNetGameLib/plNetGameLib.h"
@ -989,21 +991,14 @@ static void SaveUserPass (LoginDialogParam *pLoginParam, char *password)
PathSplitEmail(wusername, nil, 0, domain, arrsize(domain), nil, 0, nil, 0, 0);
if (StrLen(domain) == 0 || StrCmpI(domain, L"gametap") == 0) {
CryptDigest(
kCryptSha1,
&pLoginParam->namePassHash,
StrLen(password) * sizeof(password[0]),
password
);
pLoginParam->namePassHash.data[0] = hsToBE32(pLoginParam->namePassHash.data[0]);
pLoginParam->namePassHash.data[1] = hsToBE32(pLoginParam->namePassHash.data[1]);
pLoginParam->namePassHash.data[2] = hsToBE32(pLoginParam->namePassHash.data[2]);
pLoginParam->namePassHash.data[3] = hsToBE32(pLoginParam->namePassHash.data[3]);
pLoginParam->namePassHash.data[4] = hsToBE32(pLoginParam->namePassHash.data[4]);
plSHA1Checksum shasum(StrLen(password) * sizeof(password[0]), (uint8_t*)password);
memcpy(pLoginParam->namePassHash, shasum.GetValue(), sizeof(ShaDigest));
}
else
CryptHashPassword(wusername, wpassword, &pLoginParam->namePassHash);
{
CryptHashPassword(_TEMP_CONVERT_FROM_WCHAR_T(wusername), _TEMP_CONVERT_FROM_WCHAR_T(wpassword), pLoginParam->namePassHash);
}
}
NetCommSetAccountUsernamePassword(wusername, pLoginParam->namePassHash);
@ -1029,7 +1024,7 @@ static void SaveUserPass (LoginDialogParam *pLoginParam, char *password)
stream->WriteSafeString(pLoginParam->username);
stream->Writebool(pLoginParam->remember);
if (pLoginParam->remember)
stream->Write(sizeof(pLoginParam->namePassHash.data), pLoginParam->namePassHash.data);
stream->Write(sizeof(pLoginParam->namePassHash), pLoginParam->namePassHash);
stream->Close();
delete stream;
}
@ -1076,7 +1071,7 @@ static void LoadUserPass (LoginDialogParam *pLoginParam)
if (pLoginParam->remember)
{
stream->Read(sizeof(pLoginParam->namePassHash.data), pLoginParam->namePassHash.data);
stream->Read(sizeof(pLoginParam->namePassHash), pLoginParam->namePassHash);
pLoginParam->focus = IDOK;
}
else

2
Sources/Plasma/Apps/plClientPatcher/Pch.h

@ -58,7 +58,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnProduct/pnProduct.h"
#include "pnNetCli/pnNetCli.h"
#include "plNetGameLib/plNetGameLib.h"
#include "plEncryption/plChecksum.h"
#include "pnEncryption/plChecksum.h"
#include "plAgeDescription/plAgeManifest.h"
#include "plAudioCore/plAudioFileReader.h"

19
Sources/Plasma/Apps/plMD5/CMakeLists.txt

@ -0,0 +1,19 @@
include_directories("../../Apps")
include_directories("../../CoreLib")
include_directories("../../FeatureLib/inc")
include_directories("../../FeatureLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib/inc")
include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(plMD5_SOURCES
Main.cpp
)
add_executable(plMD5 ${plMD5_SOURCES})
target_link_libraries(plMD5 CoreLib pnUtils pnProduct pnEncryption)
target_link_libraries(plMD5 ${OPENSSL_LIBRARIES})
source_group("Source Files" FILES ${plMD5_SOURCES})

21
Sources/Plasma/Apps/plMD5/Main.cpp

@ -39,24 +39,13 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/Apps/plMD5/Main.cpp
*
***/
#include "Pch.h"
#pragma hdrstop
#include "pnProduct/pnProduct.h"
#include "pnEncryption/plChecksum.h"
#include <stdio.h>
/*****************************************************************************
*
* Exports
*
***/
//============================================================================
int __cdecl main (int argc, char ** argv) {
int main (int argc, char ** argv) {
if (argc < 2) {
fprintf(stderr, "ERROR: Please specify filename.\n");
@ -68,7 +57,7 @@ int __cdecl main (int argc, char ** argv) {
fprintf(stderr, "ERROR: MD5 failed.\n");
return 1;
}
fprintf(stdout, "%s\n", md5.GetAsHexString());
return 0;
}

2
Sources/Plasma/Apps/plPlasmaUpdate/plManifest.cpp

@ -42,7 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "plManifest.h"
#include "../plEncryption/plChecksum.h"
#include "../pnEncryption/plChecksum.h"
#include "../plCompression/plZlibStream.h"
#include "../plFile/plEncryptedStream.h"
#include "../plFile/plFileUtils.h"

19
Sources/Plasma/Apps/plSHA/CMakeLists.txt

@ -0,0 +1,19 @@
include_directories("../../Apps")
include_directories("../../CoreLib")
include_directories("../../FeatureLib/inc")
include_directories("../../FeatureLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib/inc")
include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(plSHA_SOURCES
Main.cpp
)
add_executable(plSHA ${plSHA_SOURCES})
target_link_libraries(plSHA CoreLib pnUtils pnProduct pnEncryption)
target_link_libraries(plSHA ${OPENSSL_LIBRARIES})
source_group("Source Files" FILES ${plSHA_SOURCES})

39
Sources/Plasma/Apps/plMD5/Pch.h → Sources/Plasma/Apps/plSHA/Main.cpp

@ -39,19 +39,32 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/Apps/plMD5/Pch.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLMD5_PCH_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plMD5/Pch.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLMD5_PCH_H
#include "pnUtils/pnUtils.h"
#include "pnProduct/pnProduct.h"
#include "plEncryption/plChecksum.h"
#include "pnEncryption/plChecksum.h"
#include <stdio.h>
int main (int argc, char** argv) {
if (argc < 2) {
fprintf(stderr, "ERROR: Please specify filename.\n");
return 1;
}
plSHAChecksum sha(argv[1]);
if (!sha.IsValid()) {
fprintf(stderr, "ERROR: SHA failed.\n");
return 1;
}
plSHA1Checksum sha1(argv[1]);
if (!sha1.IsValid()) {
fprintf(stderr, "ERROR: SHA1 failed.\n");
return 1;
}
fprintf(stdout, "%s\tSHA\n", sha.GetAsHexString());
fprintf(stdout, "%s\tSHA1\n", sha1.GetAsHexString());
return 0;
}

2
Sources/Plasma/Apps/plUruLauncher/CMakeLists.txt

@ -37,7 +37,6 @@ target_link_libraries(plUruLauncher pfConsoleCore)
target_link_libraries(plUruLauncher plAudioCore)
target_link_libraries(plUruLauncher plClientPatcher)
target_link_libraries(plUruLauncher plCompression)
target_link_libraries(plUruLauncher plEncryption)
target_link_libraries(plUruLauncher plFile)
target_link_libraries(plUruLauncher plNetClient)
target_link_libraries(plUruLauncher plNetClientComm)
@ -47,6 +46,7 @@ target_link_libraries(plUruLauncher plNetTransport)
target_link_libraries(plUruLauncher plUnifiedTime)
target_link_libraries(plUruLauncher pnAsyncCore)
target_link_libraries(plUruLauncher pnAsyncCoreExe)
target_link_libraries(plUruLauncher pnEncryption)
target_link_libraries(plUruLauncher pnNetBase)
target_link_libraries(plUruLauncher pnNetCli)
target_link_libraries(plUruLauncher pnNetCommon)

2
Sources/Plasma/Apps/plUruLauncher/Pch.h

@ -61,7 +61,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnProduct/pnProduct.h"
#include "pnNetCli/pnNetCli.h"
#include "plNetGameLib/plNetGameLib.h"
#include "plEncryption/plChecksum.h"
#include "pnEncryption/plChecksum.h"
#include "plCompression/plZlibStream.h"
#include "plClientPatcher/UruPlayer.h"

2
Sources/Plasma/FeatureLib/pfAnimation/pfObjectFlocker.cpp

@ -50,7 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMessage/plAgeLoadedMsg.h"
#include "pnSceneObject/plSceneObject.h"
#include "hsTimer.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
#include "pnMessage/plEnableMsg.h"
#include "plMessage/plAnimCmdMsg.h"
#include "plMessage/plLoadCloneMsg.h"

2
Sources/Plasma/FeatureLib/pfAnimation/plBlower.h

@ -45,7 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnModifier/plSingleModifier.h"
#include "hsGeometry3.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
#include "hsTemplates.h"
class plSceneObject;

19
Sources/Plasma/FeatureLib/pfPython/pyAgeInfoStruct.cpp

@ -42,6 +42,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pyAgeInfoStruct.h"
#include "hsStlUtils.h"
#include "pnUtils/pnUtCrypt.h"
#include "pnEncryption/plChecksum.h"
///////////////////////////////////////////////////////////////////////////
@ -129,9 +130,23 @@ void pyAgeInfoStruct::SetAgeInstanceGuid( const char * guid )
// if it starts with an @ then do a meta kind of GUID
std::string curInst = fAgeInfo.GetAgeInstanceName();
std::string y = curInst + guid;
plUUID instanceGuid;
CryptDigest(kCryptMd5, instanceGuid.fData , y.length(), y.c_str());
plMD5Checksum hash;
hash.Start();
hash.AddTo(y.length(), (uint8_t*)y.c_str());
hash.Finish();
const char* md5sum = hash.GetAsHexString();
plStringStream ss;
for (size_t i = 0; i < 16; i++) {
ss << md5sum[2*i];
ss << md5sum[(2*i)+1];
if (i == 3 || i == 5 || i == 7 || i == 9)
ss << '-';
}
instanceGuid.FromString(ss.GetString());
fAgeInfo.SetAgeInstanceGuid(&instanceGuid);
}
else {

2
Sources/Plasma/FeatureLib/pfSecurePreloader/pfSecurePreloader.cpp

@ -45,7 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h"
#include "plgDispatch.h"
#include "plCompression/plZlibStream.h"
#include "plEncryption/plChecksum.h"
#include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h"
#include "plFile/plSecureStream.h"
#include "plFile/plStreamSource.h"

1
Sources/Plasma/NucleusLib/CMakeLists.txt

@ -9,6 +9,7 @@ add_subdirectory(pnAsyncCoreExe)
#add_subdirectory(pnCsrCli) # Not being used in any current sln
add_subdirectory(pnCsrNet)
add_subdirectory(pnDispatch)
add_subdirectory(pnEncryption)
add_subdirectory(pnFactory)
add_subdirectory(pnGameMgr)
add_subdirectory(pnIni)

20
Sources/Plasma/NucleusLib/pnEncryption/CMakeLists.txt

@ -0,0 +1,20 @@
include_directories("../../CoreLib")
include_directories("../../NucleusLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(pnEncryption_SOURCES
plChallengeHash.cpp
plChecksum.cpp
)
set(pnEncryption_HEADERS
plChallengeHash.h
plChecksum.h
plRandom.h
)
add_library(pnEncryption STATIC ${pnEncryption_SOURCES} ${pnEncryption_HEADERS})
target_link_libraries(pnEncryption ${OPENSSL_LIBRARIES})
source_group("Source Files" FILES ${pnEncryption_SOURCES})
source_group("Header Files" FILES ${pnEncryption_HEADERS})

119
Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.cpp

@ -0,0 +1,119 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "plChallengeHash.h"
#include "pnUtils/pnUtils.h"
ShaDigest fSeed;
void CryptCreateRandomSeed(size_t length, uint8_t* data)
{
uint32_t seedIdx = 0;
uint32_t dataIdx = 0;
uint32_t cur = 0;
uint32_t end = max(length, sizeof(ShaDigest));
// Combine seed with input data
for (; cur < end; cur++) {
fSeed[seedIdx] ^= data[dataIdx];
if (++seedIdx >= sizeof(ShaDigest))
seedIdx = 0;
if (++dataIdx >= length)
dataIdx = 0;
}
((uint32_t*)fSeed)[2] ^= (uint32_t)((uintptr_t)&length);
((uint32_t*)fSeed)[3] ^= (uint32_t)length;
((uint32_t*)fSeed)[4] ^= (uint32_t)((uintptr_t)data);
// Hash seed
plSHAChecksum sum(sizeof(ShaDigest), (uint8_t*)fSeed);
ShaDigest digest;
memcpy(digest, sum.GetValue(), sizeof(ShaDigest));
seedIdx = 0;
dataIdx = 0;
cur = 0;
// Update output with contents of digest
for (; cur < end; cur++) {
data[dataIdx] ^= digest[seedIdx];
if (++seedIdx >= sizeof(ShaDigest))
seedIdx = 0;
if (++dataIdx >= length)
dataIdx = 0;
}
// Combine seed with digest
for (size_t i = 0; i < sizeof(ShaDigest); i++) {
fSeed[i] ^= digest[i];
}
}
void CryptHashPassword(const plString& username, const plString& password, ShaDigest dest)
{
/* This should be unnecessary once plString has ToLower() */
wchar_t* w_name = (wchar_t*)_TEMP_CONVERT_TO_WCHAR_T(username);
StrLower(w_name);
plString buf = password;
buf += _TEMP_CONVERT_FROM_WCHAR_T(w_name);
plSHAChecksum sum(buf.GetSize() * sizeof(wchar_t), (uint8_t*)_TEMP_CONVERT_TO_WCHAR_T(buf));
memcpy(dest, sum.GetValue(), sizeof(ShaDigest));
}
void CryptHashPasswordChallenge(uint32_t clientChallenge, uint32_t serverChallenge, ShaDigest namePassHash, ShaDigest challengeHash)
{
plSHAChecksum sum;
sum.Start();
sum.AddTo(sizeof(uint32_t), (uint8_t*)&clientChallenge);
sum.AddTo(sizeof(uint32_t), (uint8_t*)&serverChallenge);
sum.AddTo(sizeof(ShaDigest), namePassHash);
sum.Finish();
memcpy(challengeHash, sum.GetValue(), sizeof(ShaDigest));
}

24
Sources/Plasma/Apps/plMD5/Intern.h → Sources/Plasma/NucleusLib/pnEncryption/plChallengeHash.h

@ -39,13 +39,17 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
Mead, WA 99021
*==LICENSE==*/
/*****************************************************************************
*
* $/Plasma20/Sources/Plasma/Apps/plMD5/Intern.h
*
***/
#ifdef PLASMA20_SOURCES_PLASMA_APPS_PLMD5_INTERN_H
#error "Header $/Plasma20/Sources/Plasma/Apps/plMD5/Intern.h included more than once"
#endif
#define PLASMA20_SOURCES_PLASMA_APPS_PLMD5_INTERN_H
#ifndef PL_CHALLENGE_HASH_H
#define PL_CHALLENGE_HASH_H
#include "HeadSpin.h"
#include "plChecksum.h"
#include "plString.h"
void CryptCreateRandomSeed(size_t length, uint8_t* data);
void CryptHashPassword(const plString& username, const plString& password, ShaDigest dest);
void CryptHashPasswordChallenge(uint32_t clientChallenge, uint32_t serverChallenge, ShaDigest namePassHash, ShaDigest challengeHash);
#endif //PL_CHALLENGE_HASH_H

482
Sources/Plasma/NucleusLib/pnEncryption/plChecksum.cpp

@ -0,0 +1,482 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "plChecksum.h"
#include "hsStream.h"
#include <cstring>
static uint8_t IHexCharToInt(char c)
{
switch( c )
{
// yes, it's ugly, but it'll be fast :)
case '0': return 0;
case '1': return 1;
case '2': return 2;
case '3': return 3;
case '4': return 4;
case '5': return 5;
case '6': return 6;
case '7': return 7;
case '8': return 8;
case '9': return 9;
case 'a': return 10;
case 'b': return 11;
case 'c': return 12;
case 'd': return 13;
case 'e': return 14;
case 'f': return 15;
case 'A': return 10;
case 'B': return 11;
case 'C': return 12;
case 'D': return 13;
case 'E': return 14;
case 'F': return 15;
}
return 0xff;
}
plChecksum::plChecksum(unsigned int bufsize, const char* buffer)
{
unsigned int wndsz = GetWindowSize(),i = 0;
fSum = 0;
const char* bufferAbsEnd = buffer + bufsize;
const char* bufferEnvenEnd = buffer + bufsize - (bufsize % wndsz);
while (buffer < bufferEnvenEnd)
{
fSum += hsToLE32(*((SumStorage*)buffer));
buffer += wndsz;
}
SumStorage last = 0;
while (buffer < bufferAbsEnd)
{
((char*)&last)[i % wndsz] = *buffer;
buffer++;
}
fSum+= hsToLE32(last);
}
//============================================================================
plMD5Checksum::plMD5Checksum(size_t size, uint8_t *buffer )
{
fValid = false;
Start();
AddTo( size, buffer );
Finish();
}
plMD5Checksum::plMD5Checksum()
{
Clear();
}
plMD5Checksum::plMD5Checksum( const plMD5Checksum &rhs )
{
memcpy( fChecksum, rhs.fChecksum, sizeof( fChecksum ) );
fValid = rhs.fValid;
}
plMD5Checksum::plMD5Checksum( const char *fileName )
{
CalcFromFile( fileName );
}
plMD5Checksum::plMD5Checksum( hsStream* stream )
{
CalcFromStream(stream);
}
void plMD5Checksum::Clear()
{
memset( fChecksum, 0, sizeof( fChecksum ) );
fValid = false;
}
void plMD5Checksum::CalcFromFile( const char *fileName )
{
hsUNIXStream s;
fValid = false;
if( s.Open(fileName) )
{
CalcFromStream(&s);
s.Close();
}
}
void plMD5Checksum::CalcFromStream( hsStream* stream )
{
uint32_t sPos = stream->GetPosition();
unsigned loadLen = 1024 * 1024;
Start();
uint8_t *buf = new uint8_t[loadLen];
while(int read = stream->Read(loadLen, buf))
AddTo( read, buf );
delete[] buf;
Finish();
stream->SetPosition(sPos);
}
void plMD5Checksum::Start()
{
MD5_Init( &fContext );
fValid = false;
}
void plMD5Checksum::AddTo(size_t size, const uint8_t *buffer )
{
MD5_Update( &fContext, buffer, size );
}
void plMD5Checksum::Finish()
{
MD5_Final( fChecksum, &fContext );
fValid = true;
}
const char *plMD5Checksum::GetAsHexString() const
{
const int kHexStringSize = ( 2 * MD5_DIGEST_LENGTH ) + 1;
static char tempString[ kHexStringSize ];
int i;
char *ptr;
hsAssert( fValid, "Trying to get string version of invalid checksum" );
for( i = 0, ptr = tempString; i < sizeof( fChecksum ); i++, ptr += 2 )
sprintf( ptr, "%02x", fChecksum[ i ] );
*ptr = 0;
return tempString;
}
void plMD5Checksum::SetFromHexString( const char *string )
{
const char *ptr;
int i;
hsAssert( strlen( string ) == 2 * MD5_DIGEST_LENGTH, "Invalid string in MD5Checksum Set()" );
for( i = 0, ptr = string; i < sizeof( fChecksum ); i++, ptr += 2 )
fChecksum[ i ] = ( IHexCharToInt( ptr[ 0 ] ) << 4 ) | IHexCharToInt( ptr[ 1 ] );
fValid = true;
}
void plMD5Checksum::SetValue(uint8_t* checksum)
{
fValid = true;
memcpy(fChecksum, checksum, sizeof(fChecksum));
}
bool plMD5Checksum::operator==( const plMD5Checksum &rhs ) const
{
return (fValid && rhs.fValid && memcmp(fChecksum, rhs.fChecksum, sizeof(fChecksum)) == 0);
}
//============================================================================
plSHAChecksum::plSHAChecksum(size_t size, uint8_t *buffer )
{
fValid = false;
Start();
AddTo(size, buffer);
Finish();
}
plSHAChecksum::plSHAChecksum()
{
Clear();
}
plSHAChecksum::plSHAChecksum(const plSHAChecksum& rhs)
{
memcpy(fChecksum, rhs.fChecksum, sizeof(fChecksum));
fValid = rhs.fValid;
}
plSHAChecksum::plSHAChecksum(const char* fileName)
{
CalcFromFile(fileName);
}
plSHAChecksum::plSHAChecksum(hsStream* stream)
{
CalcFromStream(stream);
}
void plSHAChecksum::Clear()
{
memset(fChecksum, 0, sizeof(fChecksum));
fValid = false;
}
void plSHAChecksum::CalcFromFile(const char* fileName)
{
hsUNIXStream s;
fValid = false;
if (s.Open(fileName))
{
CalcFromStream(&s);
s.Close();
}
}
void plSHAChecksum::CalcFromStream(hsStream* stream)
{
uint32_t sPos = stream->GetPosition();
unsigned loadLen = 1024 * 1024;
Start();
uint8_t* buf = new uint8_t[loadLen];
while (int read = stream->Read(loadLen, buf))
{
AddTo( read, buf );
}
delete[] buf;
Finish();
stream->SetPosition(sPos);
}
void plSHAChecksum::Start()
{
SHA_Init(&fContext);
fValid = false;
}
void plSHAChecksum::AddTo(size_t size, const uint8_t* buffer)
{
SHA_Update(&fContext, buffer, size);
}
void plSHAChecksum::Finish()
{
SHA_Final(fChecksum, &fContext);
fValid = true;
}
const char *plSHAChecksum::GetAsHexString() const
{
const int kHexStringSize = (2 * SHA_DIGEST_LENGTH) + 1;
static char tempString[kHexStringSize];
int i;
char* ptr;
hsAssert(fValid, "Trying to get string version of invalid checksum");
for (i = 0, ptr = tempString; i < sizeof(fChecksum); i++, ptr += 2)
sprintf(ptr, "%02x", fChecksum[i]);
*ptr = 0;
return tempString;
}
void plSHAChecksum::SetFromHexString(const char* string)
{
const char* ptr;
int i;
hsAssert(strlen(string) == (2 * SHA_DIGEST_LENGTH), "Invalid string in SHAChecksum Set()");
for (i = 0, ptr = string; i < sizeof(fChecksum); i++, ptr += 2)
fChecksum[i] = (IHexCharToInt(ptr[0]) << 4) | IHexCharToInt(ptr[1]);
fValid = true;
}
void plSHAChecksum::SetValue(uint8_t* checksum)
{
fValid = true;
memcpy(fChecksum, checksum, sizeof(fChecksum));
}
bool plSHAChecksum::operator==(const plSHAChecksum& rhs) const
{
return (fValid && rhs.fValid && memcmp(fChecksum, rhs.fChecksum, sizeof(fChecksum)) == 0);
}
//============================================================================
plSHA1Checksum::plSHA1Checksum(size_t size, uint8_t *buffer )
{
fValid = false;
Start();
AddTo(size, buffer);
Finish();
}
plSHA1Checksum::plSHA1Checksum()
{
Clear();
}
plSHA1Checksum::plSHA1Checksum(const plSHA1Checksum& rhs)
{
memcpy(fChecksum, rhs.fChecksum, sizeof(fChecksum));
fValid = rhs.fValid;
}
plSHA1Checksum::plSHA1Checksum(const char* fileName)
{
CalcFromFile(fileName);
}
plSHA1Checksum::plSHA1Checksum(hsStream* stream)
{
CalcFromStream(stream);
}
void plSHA1Checksum::Clear()
{
memset(fChecksum, 0, sizeof(fChecksum));
fValid = false;
}
void plSHA1Checksum::CalcFromFile(const char* fileName)
{
hsUNIXStream s;
fValid = false;
if (s.Open(fileName))
{
CalcFromStream(&s);
s.Close();
}
}
void plSHA1Checksum::CalcFromStream(hsStream* stream)
{
uint32_t sPos = stream->GetPosition();
unsigned loadLen = 1024 * 1024;
Start();
uint8_t* buf = new uint8_t[loadLen];
while (int read = stream->Read(loadLen, buf))
{
AddTo( read, buf );
}
delete[] buf;
Finish();
stream->SetPosition(sPos);
}
void plSHA1Checksum::Start()
{
SHA1_Init(&fContext);
fValid = false;
}
void plSHA1Checksum::AddTo(size_t size, const uint8_t* buffer)
{
SHA1_Update(&fContext, buffer, size);
}
void plSHA1Checksum::Finish()
{
SHA1_Final(fChecksum, &fContext);
fValid = true;
}
const char *plSHA1Checksum::GetAsHexString() const
{
const int kHexStringSize = (2 * SHA_DIGEST_LENGTH) + 1;
static char tempString[kHexStringSize];
int i;
char* ptr;
hsAssert(fValid, "Trying to get string version of invalid checksum");
for (i = 0, ptr = tempString; i < sizeof(fChecksum); i++, ptr += 2)
sprintf(ptr, "%02x", fChecksum[i]);
*ptr = 0;
return tempString;
}
void plSHA1Checksum::SetFromHexString(const char* string)
{
const char* ptr;
int i;
hsAssert(strlen(string) == (2 * SHA_DIGEST_LENGTH), "Invalid string in SHA1Checksum Set()");
for (i = 0, ptr = string; i < sizeof(fChecksum); i++, ptr += 2)
fChecksum[i] = (IHexCharToInt(ptr[0]) << 4) | IHexCharToInt(ptr[1]);
fValid = true;
}
void plSHA1Checksum::SetValue(uint8_t* checksum)
{
fValid = true;
memcpy(fChecksum, checksum, sizeof(fChecksum));
}
bool plSHA1Checksum::operator==(const plSHA1Checksum& rhs) const
{
return (fValid && rhs.fValid && memcmp(fChecksum, rhs.fChecksum, sizeof(fChecksum)) == 0);
}

187
Sources/Plasma/NucleusLib/pnEncryption/plChecksum.h

@ -0,0 +1,187 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef PL_CHECKSUM_H
#define PL_CHECKSUM_H
#include "HeadSpin.h"
#include <openssl/md5.h>
#include <openssl/sha.h>
class plChecksum
{
public:
typedef uint32_t SumStorage;
private:
SumStorage fSum;
public:
plChecksum(unsigned int bufsize, const char* buffer);
static int GetChecksumSize() { return sizeof(SumStorage); }
static int GetWindowSize() { return sizeof(SumStorage); }
SumStorage GetChecksum() { return fSum; }
};
class hsStream;
class plMD5Checksum
{
protected:
hsBool fValid;
MD5_CTX fContext;
uint8_t fChecksum[MD5_DIGEST_LENGTH];
public:
plMD5Checksum(size_t size, uint8_t *buffer);
plMD5Checksum();
plMD5Checksum(const plMD5Checksum &rhs);
plMD5Checksum(const char *fileName);
plMD5Checksum(hsStream* stream);
hsBool IsValid() const { return fValid; }
void Clear();
void CalcFromFile(const char *fileName);
void CalcFromStream(hsStream* stream);
void Start();
void AddTo(size_t size, const uint8_t *buffer);
void Finish();
const uint8_t *GetValue() const { return fChecksum; }
size_t GetSize() const { return sizeof(fChecksum); }
// Backdoor for cached checksums (ie, if you loaded it off disk)
void SetValue(uint8_t* checksum);
// Note: GetAsHexString() returns a pointer to a static string;
// do not rely on the contents of this string between calls!
const char *GetAsHexString() const;
void SetFromHexString( const char *string );
bool operator==(const plMD5Checksum &rhs) const;
bool operator!=(const plMD5Checksum &rhs) const { return !operator==(rhs); }
};
/* A bunch of things might store either a SHA or a SHA1 checksum, this provides
* them a way to store the checksum itself, rather than a union of the classes.
*/
typedef uint8_t ShaDigest[SHA_DIGEST_LENGTH];
class plSHAChecksum
{
protected:
hsBool fValid;
SHA_CTX fContext;
ShaDigest fChecksum;
public:
plSHAChecksum(size_t size, uint8_t* buffer);
plSHAChecksum();
plSHAChecksum(const plSHAChecksum& rhs);
plSHAChecksum(const char* fileName);
plSHAChecksum(hsStream* stream);
hsBool IsValid() const { return fValid; }
void Clear();
void CalcFromFile(const char* fileName);
void CalcFromStream(hsStream* stream);
void Start();
void AddTo(size_t size, const uint8_t* buffer);
void Finish();
const uint8_t* GetValue() const { return fChecksum; }
size_t GetSize() const { return sizeof(fChecksum); }
// Backdoor for cached checksums (ie, if you loaded it off disk)
void SetValue(uint8_t* checksum);
// Note: GetAsHexString() returns a pointer to a static string;
// do not rely on the contents of this string between calls!
const char* GetAsHexString() const;
void SetFromHexString(const char* string);
bool operator==(const plSHAChecksum& rhs) const;
bool operator!=(const plSHAChecksum& rhs) const { return !operator==(rhs); }
};
class plSHA1Checksum
{
protected:
hsBool fValid;
SHA_CTX fContext;
ShaDigest fChecksum;
public:
plSHA1Checksum(size_t size, uint8_t* buffer);
plSHA1Checksum();
plSHA1Checksum(const plSHA1Checksum& rhs);
plSHA1Checksum(const char* fileName);
plSHA1Checksum(hsStream* stream);
hsBool IsValid() const { return fValid; }
void Clear();
void CalcFromFile(const char* fileName);
void CalcFromStream(hsStream* stream);
void Start();
void AddTo(size_t size, const uint8_t* buffer);
void Finish();
const uint8_t* GetValue() const { return fChecksum; }
size_t GetSize() const { return sizeof(fChecksum); }
// Backdoor for cached checksums (ie, if you loaded it off disk)
void SetValue(uint8_t* checksum);
// Note: GetAsHexString() returns a pointer to a static string;
// do not rely on the contents of this string between calls!
const char* GetAsHexString() const;
void SetFromHexString(const char* string);
bool operator==(const plSHA1Checksum& rhs) const;
bool operator!=(const plSHA1Checksum& rhs) const { return !operator==(rhs); }
};
#endif // PL_CHECKSUM_H

0
Sources/Plasma/PubUtilLib/plMath/plRandom.h → Sources/Plasma/NucleusLib/pnEncryption/plRandom.h

2
Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp

@ -48,6 +48,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "Pch.h"
#pragma hdrstop
#include "pnEncryption/plChallengeHash.h"
//#define NCCLI_DEBUGGING
#ifdef NCCLI_DEBUGGING
# pragma message("Compiling pnNetCli with debugging on")

220
Sources/Plasma/NucleusLib/pnUtils/pnUtCrypt.cpp

@ -49,8 +49,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnUtStr.h"
#include "pnUtTime.h"
#include <openssl/md5.h>
#include <openssl/sha.h>
#include <openssl/rc4.h>
/*****************************************************************************
@ -73,8 +71,6 @@ struct CryptKey {
namespace Crypt {
ShaDigest s_shaSeed;
/*****************************************************************************
*
@ -82,64 +78,6 @@ ShaDigest s_shaSeed;
*
***/
//============================================================================
void Md5Process (
void * dest,
unsigned sourceCount,
const unsigned sourceBytes[],
const void * sourcePtrs[]
) {
// initialize digest
MD5_CTX md5;
MD5_Init(&md5);
// hash data streams
for (unsigned index = 0; index < sourceCount; ++index)
MD5_Update(&md5, sourcePtrs[index], sourceBytes[index]);
// complete hashing
MD5_Final((unsigned char *)dest, &md5);
}
//============================================================================
void ShaProcess (
void * dest,
unsigned sourceCount,
const unsigned sourceBytes[],
const void * sourcePtrs[]
) {
// initialize digest
SHA_CTX sha;
SHA_Init(&sha);
// hash data streams
for (unsigned index = 0; index < sourceCount; ++index)
SHA_Update(&sha, sourcePtrs[index], sourceBytes[index]);
// complete hashing
SHA_Final((unsigned char *)dest, &sha);
}
//============================================================================
void Sha1Process (
void * dest,
unsigned sourceCount,
const unsigned sourceBytes[],
const void * sourcePtrs[]
) {
// initialize digest
SHA_CTX sha;
SHA1_Init(&sha);
// hash data streams
for (unsigned index = 0; index < sourceCount; ++index)
SHA1_Update(&sha, sourcePtrs[index], sourceBytes[index]);
// complete hashing
SHA1_Final((unsigned char *)dest, &sha);
}
/*****************************************************************************
*
* RC4
@ -183,47 +121,6 @@ static void Rc4Codec (
*
***/
//============================================================================
void CryptDigest (
ECryptAlgorithm algorithm,
void * dest, // must be sized to the algorithm's digest size
const unsigned sourceBytes,
const void * sourceData
) {
CryptDigest(
algorithm,
dest,
1,
&sourceBytes,
&sourceData
);
}
//============================================================================
void CryptDigest (
ECryptAlgorithm algorithm,
void * dest, // must be sized to the algorithm's digest size
unsigned sourceCount,
const unsigned sourceBytes[], // [sourceCount]
const void * sourcePtrs[] // [sourceCount]
) {
switch (algorithm) {
case kCryptMd5:
Md5Process(dest, sourceCount, sourceBytes, sourcePtrs);
break;
case kCryptSha:
ShaProcess(dest, sourceCount, sourceBytes, sourcePtrs);
break;
case kCryptSha1:
Sha1Process(dest, sourceCount, sourceBytes, sourcePtrs);
break;
DEFAULT_FATAL(algorithm);
}
}
//============================================================================
CryptKey * CryptKeyCreate (
ECryptAlgorithm algorithm,
@ -278,123 +175,6 @@ unsigned CryptKeyGetBlockSize (
}
}
//============================================================================
void CryptCreateRandomSeed (
unsigned bytes,
uint8_t * data
) {
COMPILER_ASSERT(SHA_DIGEST_LENGTH == 20);
// Combine seed with input data
{
unsigned seedIndex = 0;
unsigned dataIndex = 0;
unsigned cur = 0;
unsigned end = max(bytes, sizeof(s_shaSeed));
for (; cur < end; ++cur) {
((uint8_t *) &s_shaSeed)[seedIndex] ^= data[dataIndex];
if (++seedIndex >= sizeof(s_shaSeed))
seedIndex = 0;
if (++dataIndex >= bytes)
dataIndex = 0;
}
s_shaSeed.data[2] ^= (uint32_t) &bytes;
s_shaSeed.data[3] ^= (uint32_t) bytes;
s_shaSeed.data[4] ^= (uint32_t) data;
}
// Hash seed
ShaDigest digest;
CryptDigest(kCryptSha, &digest, sizeof(s_shaSeed), &s_shaSeed);
// Update output with contents of digest
{
unsigned src = 0;
unsigned dst = 0;
unsigned cur = 0;
unsigned end = max(bytes, sizeof(digest));
for (; cur < end; ++cur) {
data[dst] ^= ((const uint8_t *) &digest)[src];
if (++src >= sizeof(digest))
src = 0;
if (++dst >= bytes)
dst = 0;
}
}
// Combine seed with digest
s_shaSeed.data[0] ^= digest.data[0];
s_shaSeed.data[1] ^= digest.data[1];
s_shaSeed.data[2] ^= digest.data[2];
s_shaSeed.data[3] ^= digest.data[3];
s_shaSeed.data[4] ^= digest.data[4];
}
//============================================================================
void CryptHashPassword (
const wchar_t username[],
const wchar_t password[],
ShaDigest * namePassHash
) {
unsigned passlen = StrLen(password);
unsigned userlen = StrLen(username);
wchar_t * buffer = (wchar_t*)malloc(sizeof(wchar_t) * (passlen + userlen));
StrCopy(buffer, password, passlen);
StrCopy(buffer + passlen, username, userlen);
StrLower(buffer + passlen); // lowercase the username
CryptDigest(
kCryptSha,
namePassHash,
(userlen + passlen) * sizeof(buffer[0]),
buffer
);
free(buffer);
}
//============================================================================
void CryptHashPasswordChallenge (
unsigned clientChallenge,
unsigned serverChallenge,
const ShaDigest & namePassHash,
ShaDigest * challengeHash
) {
#pragma pack(push, 1)
struct {
uint32_t clientChallenge;
uint32_t serverChallenge;
ShaDigest namePassHash;
} buffer;
#pragma pack(pop)
buffer.clientChallenge = clientChallenge;
buffer.serverChallenge = serverChallenge;
buffer.namePassHash = namePassHash;
CryptDigest(kCryptSha, challengeHash, sizeof(buffer), &buffer);
}
//============================================================================
void CryptCreateFastWeakChallenge (
unsigned * challenge,
unsigned val1,
unsigned val2
) {
s_shaSeed.data[0] ^= TimeGetMs(); // looping time
s_shaSeed.data[0] ^= _rotl(s_shaSeed.data[0], 1);
s_shaSeed.data[0] ^= (unsigned) TimeGetTime(); // global time
s_shaSeed.data[0] ^= _rotl(s_shaSeed.data[0], 1);
s_shaSeed.data[0] ^= *challenge; // unknown
s_shaSeed.data[0] ^= _rotl(s_shaSeed.data[0], 1);
s_shaSeed.data[0] ^= (unsigned) challenge; // variable address
s_shaSeed.data[0] ^= _rotl(s_shaSeed.data[0], 1);
s_shaSeed.data[0] ^= val1;
s_shaSeed.data[0] ^= _rotl(s_shaSeed.data[0], 1);
s_shaSeed.data[0] ^= val2;
*challenge = s_shaSeed.data[0];
}
//============================================================================
void CryptEncrypt (
CryptKey * key,

55
Sources/Plasma/NucleusLib/pnUtils/pnUtCrypt.h

@ -50,6 +50,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "Pch.h"
#include "pnUtArray.h"
#include "pnEncryption/plChecksum.h"
/*****************************************************************************
*
@ -60,40 +61,11 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
struct CryptKey;
enum ECryptAlgorithm {
kCryptSha,
kCryptSha1,
kCryptMd5,
kCryptRc4,
kCryptRsa,
kNumCryptAlgorithms
};
struct ShaDigest {
uint32_t data[5];
};
/*****************************************************************************
*
* Digest functions
*
***/
void CryptDigest (
ECryptAlgorithm algorithm,
void * dest, // must be sized to the algorithm's digest size
const unsigned sourceBytes,
const void * sourceData
);
void CryptDigest (
ECryptAlgorithm algorithm,
void * dest, // must be sized to the algorithm's digest size
unsigned sourceCount,
const unsigned sourceBytes[], // [sourceCount]
const void * sourcePtrs[] // [sourceCount]
);
/*****************************************************************************
*
@ -124,31 +96,6 @@ unsigned CryptKeyGetBlockSize (
CryptKey * key
);
void CryptCreateRandomSeed (
unsigned bytes,
uint8_t * data
);
void CryptHashPassword (
const wchar_t username[],
const wchar_t password[],
ShaDigest * namePassHash
);
void CryptHashPasswordChallenge (
unsigned clientChallenge,
unsigned serverChallenge,
const ShaDigest & namePassHash,
ShaDigest * challengeHash
);
void CryptCreateFastWeakChallenge (
unsigned * challenge,
unsigned val1,
unsigned val2
);
/*****************************************************************************
*
* Encryption and Decryption

1
Sources/Plasma/PubUtilLib/CMakeLists.txt

@ -11,7 +11,6 @@ add_subdirectory(plCompression)
add_subdirectory(plContainer)
#add_subdirectory(plDeviceSelector) # Not being used by any current slns
add_subdirectory(plDrawable)
add_subdirectory(plEncryption)
add_subdirectory(plFile)
#add_subdirectory(plGClip) # Not being used by any current slns
#add_subdirectory(plGeometry) # Not being used by any current slns

2
Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.h

@ -55,7 +55,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plUnifiedTime/plUnifiedTime.h"
#include "plFile/plInitFileReader.h"
#include "plEncryption/plChecksum.h"
#include "pnEncryption/plChecksum.h"
//// Small Container Classes for a Single File ///////////////////////////////

2
Sources/Plasma/PubUtilLib/plAgeLoader/plResPatcher.cpp

@ -45,7 +45,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeLoader/plAgeLoader.h"
#include "plCompression/plZlibStream.h"
#include "plEncryption/plChecksum.h"
#include "pnEncryption/plChecksum.h"
#include "plFile/plFileUtils.h"
#include "plMessage/plResPatcherMsg.h"
#include "pnNetBase/pnNbError.h"

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainCritter.cpp

@ -55,7 +55,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plPipeline/plDebugText.h"
#include "pnSceneObject/plCoordinateInterface.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
#include "plNetClient/plNetClientMgr.h"
#include "plNetTransport/plNetTransportMember.h"

2
Sources/Plasma/PubUtilLib/plAvatar/plAvBrainHuman.cpp

@ -73,7 +73,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnSceneObject/plCoordinateInterface.h"
#include "plInputCore/plAvatarInputInterface.h"
#include "plInputCore/plInputDevice.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
#include "plPipeline/plDebugText.h"
#include "plNetClient/plNetLinkingMgr.h"

2
Sources/Plasma/PubUtilLib/plAvatar/plAvatarClothing.cpp

@ -73,7 +73,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plDrawable/plSpaceTree.h"
#include "plSurface/hsGMaterial.h"
#include "plSurface/plLayer.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
#include "plSDL/plSDL.h"
#include "plVault/plVault.h"
#include "plResMgr/plKeyFinder.h"

2
Sources/Plasma/PubUtilLib/plAvatar/plAvatarMgr.cpp

@ -74,7 +74,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plModifier/plSpawnModifier.h"
#include "plModifier/plMaintainersMarkerModifier.h"
#include "plVault/plDniCoordinateInfo.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
#include "pnMessage/plPlayerPageMsg.h"
#include "pnMessage/plWarpMsg.h"

2
Sources/Plasma/PubUtilLib/plDrawable/plDynaBulletMgr.cpp

@ -58,7 +58,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsFastMath.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
static plRandom sRand;

2
Sources/Plasma/PubUtilLib/plDrawable/plDynaDecalMgr.cpp

@ -75,7 +75,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnMessage/plTimeMsg.h"
#include "plgDispatch.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
#include "hsFastMath.h"
#include "hsStream.h"

2
Sources/Plasma/PubUtilLib/plDrawable/plDynaFootMgr.cpp

@ -60,7 +60,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAvatar/plArmatureMod.h"
#include "plAvatar/plAvBrainHuman.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
static plRandom sRand;
static const uint32_t kNumPrintIDs = 2;

2
Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgr.cpp

@ -61,7 +61,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAvatar/plAvBrainHuman.h"
#include "plAvatar/plArmatureMod.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
static plRandom sRand;
#include "plTweak.h"

2
Sources/Plasma/PubUtilLib/plDrawable/plDynaRippleMgrVS.cpp

@ -68,7 +68,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAvatar/plAvBrainHuman.h"
#include "plAvatar/plArmatureMod.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
static plRandom sRand;
#include "plTweak.h"

2
Sources/Plasma/PubUtilLib/plDrawable/plDynaTorpedoMgr.cpp

@ -54,7 +54,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTimer.h"
#include "plTweak.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
static const uint32_t kNumPrintIDs = 0;

2
Sources/Plasma/PubUtilLib/plDrawable/plDynaWakeMgr.cpp

@ -64,7 +64,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plInterp/plAnimPath.h"
#include "hsFastMath.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
static plRandom sRand;

2
Sources/Plasma/PubUtilLib/plDrawable/plWaveSet7.h

@ -46,7 +46,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsGeometry3.h"
#include "hsTemplates.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
#include "hsBounds.h"
#include "plFixedWaterState7.h"

16
Sources/Plasma/PubUtilLib/plEncryption/CMakeLists.txt

@ -1,16 +0,0 @@
include_directories("../../CoreLib")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib")
set(plEncryption_SOURCES
plChecksum.cpp
)
set(plEncryption_HEADERS
plChecksum.h
)
add_library(plEncryption STATIC ${plEncryption_SOURCES} ${plEncryption_HEADERS})
source_group("Source Files" FILES ${plEncryption_SOURCES})
source_group("Header Files" FILES ${plEncryption_HEADERS})

226
Sources/Plasma/PubUtilLib/plEncryption/plChecksum.cpp

@ -1,226 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "plChecksum.h"
#include "hsStream.h"
#include <cstring>
plChecksum::plChecksum(unsigned int bufsize, const char* buffer)
{
unsigned int wndsz = GetWindowSize(),i = 0;
fSum = 0;
const char* bufferAbsEnd = buffer + bufsize;
const char* bufferEnvenEnd = buffer + bufsize - (bufsize % wndsz);
while (buffer < bufferEnvenEnd)
{
fSum += hsToLE32(*((SumStorage*)buffer));
buffer += wndsz;
}
SumStorage last = 0;
while (buffer < bufferAbsEnd)
{
((char*)&last)[i % wndsz] = *buffer;
buffer++;
}
fSum+= hsToLE32(last);
}
plMD5Checksum::plMD5Checksum( uint32_t size, uint8_t *buffer )
{
fValid = false;
Start();
AddTo( size, buffer );
Finish();
}
plMD5Checksum::plMD5Checksum()
{
Clear();
}
plMD5Checksum::plMD5Checksum( const plMD5Checksum &rhs )
{
memcpy( fChecksum, rhs.fChecksum, sizeof( fChecksum ) );
fValid = rhs.fValid;
}
plMD5Checksum::plMD5Checksum( const char *fileName )
{
CalcFromFile( fileName );
}
plMD5Checksum::plMD5Checksum( hsStream* stream )
{
CalcFromStream(stream);
}
void plMD5Checksum::Clear()
{
memset( fChecksum, 0, sizeof( fChecksum ) );
fValid = false;
}
void plMD5Checksum::CalcFromFile( const char *fileName )
{
hsUNIXStream s;
fValid = false;
if( s.Open(fileName) )
{
CalcFromStream(&s);
s.Close();
}
}
void plMD5Checksum::CalcFromStream( hsStream* stream )
{
uint32_t sPos = stream->GetPosition();
unsigned loadLen = 1024 * 1024;
Start();
uint8_t *buf = new uint8_t[loadLen];
while(int read = stream->Read(loadLen, buf))
AddTo( read, buf );
delete[] buf;
Finish();
stream->SetPosition(sPos);
}
void plMD5Checksum::Start( void )
{
MD5_Init( &fContext );
fValid = false;
}
void plMD5Checksum::AddTo( uint32_t size, const uint8_t *buffer )
{
MD5_Update( &fContext, buffer, size );
}
void plMD5Checksum::Finish( void )
{
MD5_Final( fChecksum, &fContext );
fValid = true;
}
const char *plMD5Checksum::GetAsHexString( void ) const
{
const int kHexStringSize = ( 2 * MD5_DIGEST_LENGTH ) + 1;
static char tempString[ kHexStringSize ];
int i;
char *ptr;
hsAssert( fValid, "Trying to get string version of invalid checksum" );
for( i = 0, ptr = tempString; i < sizeof( fChecksum ); i++, ptr += 2 )
sprintf( ptr, "%02x", fChecksum[ i ] );
*ptr = 0;
return tempString;
}
uint8_t plMD5Checksum::IHexCharToInt( char c ) const
{
switch( c )
{
// yes, it's ugly, but it'll be fast :)
case '0': return 0;
case '1': return 1;
case '2': return 2;
case '3': return 3;
case '4': return 4;
case '5': return 5;
case '6': return 6;
case '7': return 7;
case '8': return 8;
case '9': return 9;
case 'a': return 10;
case 'b': return 11;
case 'c': return 12;
case 'd': return 13;
case 'e': return 14;
case 'f': return 15;
case 'A': return 10;
case 'B': return 11;
case 'C': return 12;
case 'D': return 13;
case 'E': return 14;
case 'F': return 15;
}
return 0xff;
}
void plMD5Checksum::SetFromHexString( const char *string )
{
const char *ptr;
int i;
hsAssert( strlen( string ) == 2 * MD5_DIGEST_LENGTH, "Invalid string in MD5Checksum Set()" );
for( i = 0, ptr = string; i < sizeof( fChecksum ); i++, ptr += 2 )
fChecksum[ i ] = ( IHexCharToInt( ptr[ 0 ] ) << 4 ) | IHexCharToInt( ptr[ 1 ] );
fValid = true;
}
void plMD5Checksum::SetValue(uint8_t* checksum)
{
fValid = true;
memcpy(fChecksum, checksum, sizeof(fChecksum));
}
bool plMD5Checksum::operator==( const plMD5Checksum &rhs ) const
{
return (fValid && rhs.fValid && memcmp(fChecksum, rhs.fChecksum, sizeof(fChecksum)) == 0);
}

105
Sources/Plasma/PubUtilLib/plEncryption/plChecksum.h

@ -1,105 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef PL_CHECKSUM_H
#define PL_CHECKSUM_H
#include "HeadSpin.h"
#include <openssl/md5.h>
class plChecksum
{
public:
typedef uint32_t SumStorage;
private:
SumStorage fSum;
public:
plChecksum(unsigned int bufsize, const char* buffer);
static int GetChecksumSize() { return sizeof(SumStorage); }
static int GetWindowSize() { return sizeof(SumStorage); }
SumStorage GetChecksum() { return fSum; }
};
class hsStream;
class plMD5Checksum
{
protected:
hsBool fValid;
MD5_CTX fContext;
uint8_t fChecksum[ MD5_DIGEST_LENGTH ];
uint8_t IHexCharToInt( char c ) const;
public:
plMD5Checksum( uint32_t size, uint8_t *buffer );
plMD5Checksum();
plMD5Checksum( const plMD5Checksum &rhs );
plMD5Checksum( const char *fileName );
plMD5Checksum( hsStream* stream );
hsBool IsValid( void ) const { return fValid; }
void Clear();
void CalcFromFile( const char *fileName );
void CalcFromStream( hsStream* stream );
void Start( void );
void AddTo( uint32_t size, const uint8_t *buffer );
void Finish( void );
const uint8_t *GetValue( void ) const { return fChecksum; }
uint32_t GetSize( void ) const { return sizeof( fChecksum ); }
// Backdoor for cached checksums (ie, if you loaded it off disk)
void SetValue(uint8_t* checksum);
// Note: GetAsHexString() returns a pointer to a static string; do not rely on the contents of this string between calls!
const char *GetAsHexString( void ) const;
void SetFromHexString( const char *string );
bool operator==( const plMD5Checksum &rhs ) const;
bool operator!=( const plMD5Checksum &rhs ) const { return !operator==( rhs ); }
};
#endif // PL_CHECKSUM_H

1
Sources/Plasma/PubUtilLib/plMath/CMakeLists.txt

@ -14,7 +14,6 @@ set(plMath_HEADERS
hsRadixSort.h
hsSearchVersion.h
plAvg.h
plRandom.h
plTriUtils.h
)

2
Sources/Plasma/PubUtilLib/plNetClient/plNetClientMgr.h

@ -54,7 +54,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnNetCommon/plNetApp.h"
#include "plNetTransport/plNetTransport.h"
#include "plEncryption/plChecksum.h"
#include "pnEncryption/plChecksum.h"
#include "plNetCommon/plNetServerSessionInfo.h"
#include "plNetClientComm/plNetClientComm.h"
#include "plUnifiedTime/plUnifiedTime.h"

7
Sources/Plasma/PubUtilLib/plNetClientComm/plNetClientComm.cpp

@ -52,6 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnNetCli/pnNetCli.h"
#include "plNetGameLib/plNetGameLib.h"
#include "pnIni/pnIni.h"
#include "pnEncryption/plChallengeHash.h"
#include "plMessage/plNetCommMsgs.h"
#include "plMessage/plNetClientMgrMsg.h"
@ -775,7 +776,7 @@ static void IReadNetIni() {
L""
);
CryptHashPassword(s_iniAccountUsername, password, &s_namePassHash);
CryptHashPassword(_TEMP_CONVERT_FROM_WCHAR_T(s_iniAccountUsername), _TEMP_CONVERT_FROM_WCHAR_T(password), s_namePassHash);
}
else {
StrCopy(s_iniStartupAgeName, L"StartUp", arrsize(s_iniStartupAgeName));
@ -1210,7 +1211,7 @@ void NetCommSetAccountUsernamePassword (
const ShaDigest & namePassHash
) {
StrCopy(s_iniAccountUsername, username, arrsize(s_iniAccountUsername));
s_namePassHash = namePassHash;
memcpy(s_namePassHash, namePassHash, sizeof(ShaDigest));
s_iniReadAccountInfo = false;
}
@ -1252,7 +1253,7 @@ void NetCommAuthenticate (
s_iniAccountUsername,
arrsize(s_account.accountNameAnsi)
);
s_account.accountNamePassHash = s_namePassHash;
memcpy(s_account.accountNamePassHash, s_namePassHash, sizeof(ShaDigest));
NetCliAuthLoginRequest(
s_account.accountName,

26
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglAuth.cpp

@ -48,6 +48,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "../Pch.h"
#pragma hdrstop
#include "pnEncryption/plChallengeHash.h"
namespace Ngl { namespace Auth {
/*****************************************************************************
*
@ -2649,7 +2651,7 @@ bool LoginRequestTrans::Send () {
PathSplitEmail(s_accountName, nil, 0, domain, arrsize(domain), nil, 0, nil, 0, 0);
if (StrLen(domain) == 0 || StrCmpI(domain, L"gametap") == 0) {
challengeHash = s_accountNamePassHash;
memcpy(challengeHash, s_accountNamePassHash, sizeof(ShaDigest));
}
else {
CryptCreateRandomSeed(
@ -2661,7 +2663,7 @@ bool LoginRequestTrans::Send () {
clientChallenge,
s_active->serverChallenge,
s_accountNamePassHash,
&challengeHash
challengeHash
);
}
@ -2818,9 +2820,9 @@ AccountCreateRequestTrans::AccountCreateRequestTrans (
StrCopy(m_accountName, accountName, arrsize(m_accountName));
CryptHashPassword(
m_accountName,
password,
&m_namePassHash
_TEMP_CONVERT_FROM_WCHAR_T(m_accountName),
_TEMP_CONVERT_FROM_WCHAR_T(password),
m_namePassHash
);
}
@ -2888,9 +2890,9 @@ AccountCreateFromKeyRequestTrans::AccountCreateFromKeyRequestTrans (
StrCopy(m_accountName, accountName, arrsize(m_accountName));
CryptHashPassword(
m_accountName,
password,
&m_namePassHash
_TEMP_CONVERT_FROM_WCHAR_T(m_accountName),
_TEMP_CONVERT_FROM_WCHAR_T(password),
m_namePassHash
);
}
@ -3186,9 +3188,9 @@ AccountChangePasswordRequestTrans::AccountChangePasswordRequestTrans (
StrCopy(m_accountName, accountName, arrsize(m_accountName));
CryptHashPassword(
m_accountName,
password,
&m_namePassHash
_TEMP_CONVERT_FROM_WCHAR_T(m_accountName),
_TEMP_CONVERT_FROM_WCHAR_T(password),
m_namePassHash
);
}
@ -5253,7 +5255,7 @@ void NetCliAuthLoginRequest (
if (accountName)
StrCopy(s_accountName, accountName, arrsize(s_accountName));
if (accountNamePassHash)
s_accountNamePassHash = *accountNamePassHash;
memcpy(s_accountNamePassHash, *accountNamePassHash, sizeof(ShaDigest));
if (authToken)
StrCopy(s_authToken, authToken, arrsize(s_authToken));
if (os)

6
Sources/Plasma/PubUtilLib/plNetGameLib/Private/plNglCsr.cpp

@ -48,6 +48,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "../Pch.h"
#pragma hdrstop
#include "pnEncryption/plChallengeHash.h"
namespace Ngl { namespace Csr {
/*****************************************************************************
@ -633,11 +635,11 @@ LoginRequestTrans::LoginRequestTrans (
FNetCliCsrLoginCallback callback,
void * param
) : NetCsrTrans(kCsrLoginTrans)
, m_namePassHash(namePassHash)
, m_callback(callback)
, m_param(param)
{
ASSERT(callback);
memcpy(m_namePassHash, namePassHash, sizeof(ShaDigest));
StrCopy(m_csrName, csrName, arrsize(m_csrName));
}
@ -659,7 +661,7 @@ bool LoginRequestTrans::Send () {
clientChallenge,
s_active->serverChallenge,
m_namePassHash,
&challengeHash
challengeHash
);
const uintptr_t msg[] = {

2
Sources/Plasma/PubUtilLib/plParticleSystem/plParticleEffect.cpp

@ -49,7 +49,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsResMgr.h"
#include "plPipeline.h"
#include "hsFastMath.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
#include "plParticleSystem.h"
#include "plMessage/plParticleUpdateMsg.h"

2
Sources/Plasma/PubUtilLib/plParticleSystem/plParticleGenerator.cpp

@ -52,7 +52,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMessage/plParticleUpdateMsg.h"
#include "plInterp/plController.h"
#include "hsResMgr.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
static const float DEFAULT_INVERSE_MASS = 1.f;

2
Sources/Tools/MaxComponent/plClusterComponent.cpp

@ -57,7 +57,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsBitVector.h"
#include "plMath/hsRadixSort.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
#include "pfAnimation/plBlower.h"
#include "plDicer.h"

2
Sources/Tools/MaxComponent/plObjectFlockerComponent.cpp

@ -44,7 +44,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "resource.h"
#include "plComponent.h"
#include "plComponentReg.h"
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
#include "plObjectFlockerComponent.h"
#include "pnKeyedObject/plUoid.h"
#include "MaxMain/plMaxNode.h"

2
Sources/Tools/MaxConvert/plDistributor.h

@ -43,7 +43,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#ifndef plDistributor_inc
#define plDistributor_inc
#include "plMath/plRandom.h"
#include "pnEncryption/plRandom.h"
#include "plDistTree.h"
class INode;

2
Sources/Tools/MaxMain/CMakeLists.txt

@ -139,7 +139,6 @@ target_link_libraries(MaxMain plCompression)
target_link_libraries(MaxMain plContainer)
target_link_libraries(MaxMain plClientResMgr)
target_link_libraries(MaxMain plDrawable)
target_link_libraries(MaxMain plEncryption)
target_link_libraries(MaxMain plFile)
target_link_libraries(MaxMain plGImage)
target_link_libraries(MaxMain plGLight)
@ -178,6 +177,7 @@ target_link_libraries(MaxMain pnAsyncCore)
target_link_libraries(MaxMain pnAsyncCoreExe)
target_link_libraries(MaxMain pnCsrNet)
target_link_libraries(MaxMain pnDispatch)
target_link_libraries(MaxMain pnEncryption)
target_link_libraries(MaxMain pnFactory)
target_link_libraries(MaxMain pnGameMgr)
target_link_libraries(MaxMain pnIni)

2
Sources/Tools/MaxPlasmaLights/CMakeLists.txt

@ -73,7 +73,6 @@ target_link_libraries(MaxPlasmaLights plAvatar)
target_link_libraries(MaxPlasmaLights plCompression)
target_link_libraries(MaxPlasmaLights plContainer)
target_link_libraries(MaxPlasmaLights plDrawable)
target_link_libraries(MaxPlasmaLights plEncryption)
target_link_libraries(MaxPlasmaLights plFile)
target_link_libraries(MaxPlasmaLights plGImage)
target_link_libraries(MaxPlasmaLights plGLight)
@ -112,6 +111,7 @@ target_link_libraries(MaxPlasmaLights pnAsyncCore)
target_link_libraries(MaxPlasmaLights pnAsyncCoreExe)
target_link_libraries(MaxPlasmaLights pnCsrNet)
target_link_libraries(MaxPlasmaLights pnDispatch)
target_link_libraries(MaxPlasmaLights pnEncryption)
target_link_libraries(MaxPlasmaLights pnFactory)
target_link_libraries(MaxPlasmaLights pnGameMgr)
target_link_libraries(MaxPlasmaLights pnIni)

Loading…
Cancel
Save