Browse Source

Merge remote branch 'upstream/master'

Darryl Pogue 14 years ago
parent
commit
5ea12d43d5
  1. 3
      CMakeLists.txt
  2. 3
      Sources/Plasma/CoreLibExe/CMakeLists.txt
  3. 5
      Sources/Plasma/FeatureLib/pfAnimation/CMakeLists.txt
  4. 1
      Sources/Plasma/FeatureLib/pfAudio/CMakeLists.txt
  5. 2
      Sources/Plasma/FeatureLib/pfCamera/CMakeLists.txt
  6. 2
      Sources/Plasma/FeatureLib/pfCharacter/CMakeLists.txt
  7. 1
      Sources/Plasma/FeatureLib/pfConsole/CMakeLists.txt
  8. 16
      Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp
  9. 2
      Sources/Plasma/FeatureLib/pfGameMgr/CMakeLists.txt
  10. 2
      Sources/Plasma/FeatureLib/pfJournalBook/CMakeLists.txt
  11. 1
      Sources/Plasma/FeatureLib/pfPython/CMakeLists.txt
  12. 9
      Sources/Plasma/NucleusLib/pnNetCli/pnNcCli.cpp
  13. 2
      Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt
  14. 23
      Sources/Plasma/NucleusLib/pnUtils/Intern.h
  15. 1358
      Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBigNum.cpp
  16. 201
      Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBigNum.h
  17. 178
      Sources/Plasma/NucleusLib/pnUtils/Private/pnUtCrypt.cpp
  18. 2
      Sources/Plasma/PubUtilLib/plAgeDescription/CMakeLists.txt
  19. 2
      Sources/Plasma/PubUtilLib/plAgeLoader/CMakeLists.txt
  20. 1
      Sources/Plasma/PubUtilLib/plAvatar/CMakeLists.txt
  21. 2
      Sources/Plasma/PubUtilLib/plEncryption/CMakeLists.txt
  22. 2
      Sources/Plasma/PubUtilLib/plGLight/CMakeLists.txt
  23. 1
      Sources/Plasma/PubUtilLib/plInputCore/CMakeLists.txt
  24. 1
      Sources/Plasma/PubUtilLib/plModifier/CMakeLists.txt
  25. 2
      Sources/Plasma/PubUtilLib/plNetClient/CMakeLists.txt
  26. 2
      Sources/Plasma/PubUtilLib/plNetClientComm/CMakeLists.txt
  27. 2
      Sources/Plasma/PubUtilLib/plNetTransport/CMakeLists.txt
  28. 1
      Sources/Plasma/PubUtilLib/plPhysX/CMakeLists.txt
  29. 3
      Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp
  30. 2
      Sources/Plasma/PubUtilLib/plStatGather/CMakeLists.txt
  31. 1
      Sources/Tools/MaxMain/CMakeLists.txt

3
CMakeLists.txt

@ -82,5 +82,8 @@ if(MSVC)
add_definitions(-D_SCL_SECURE_NO_WARNINGS) add_definitions(-D_SCL_SECURE_NO_WARNINGS)
endif(MSVC) endif(MSVC)
#TODO: Make the OpenSSL includes less promiscuous so this isn't needed
include_directories(${OPENSSL_INCLUDE_DIR})
add_subdirectory(Sources/Plasma) add_subdirectory(Sources/Plasma)
add_subdirectory(Sources/Tools) add_subdirectory(Sources/Tools)

3
Sources/Plasma/CoreLibExe/CMakeLists.txt

@ -1,6 +1,7 @@
include_directories("../../Plasma/CoreLib")
add_definitions(-D_LIB) add_definitions(-D_LIB)
include_directories("../../Plasma/CoreLib")
set(CoreLibExe_SOURCES set(CoreLibExe_SOURCES
hsExeError.cpp hsExeError.cpp
hsExeMalloc.cpp hsExeMalloc.cpp

5
Sources/Plasma/FeatureLib/pfAnimation/CMakeLists.txt

@ -3,11 +3,6 @@ include_directories("../../NucleusLib")
include_directories("../../NucleusLib/inc") include_directories("../../NucleusLib/inc")
include_directories("../../PubUtilLib") include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
# this is in the vcproj, but it seems silly for animation...
# find_package(OpenSSL REQUIRED)
set(pfAnimation_SOURCES set(pfAnimation_SOURCES
pfObjectFlocker.cpp pfObjectFlocker.cpp
plAnimDebugList.cpp plAnimDebugList.cpp

1
Sources/Plasma/FeatureLib/pfAudio/CMakeLists.txt

@ -5,7 +5,6 @@ include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib) include_directories(../../PubUtilLib)
#include_directories(../../PubUtilLib/inc) #include_directories(../../PubUtilLib/inc)
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${OPENAL_INCLUDE_DIR}) include_directories(${OPENAL_INCLUDE_DIR})
set(pfAudio_SOURCES set(pfAudio_SOURCES

2
Sources/Plasma/FeatureLib/pfCamera/CMakeLists.txt

@ -4,8 +4,6 @@ include_directories(../../NucleusLib)
include_directories(../../NucleusLib/inc) include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib) include_directories(../../PubUtilLib)
include_directories(${OPENSSL_INCLUDE_DIR})
set(pfCamera_SOURCES set(pfCamera_SOURCES
pfCameraProxy.cpp pfCameraProxy.cpp
plCameraBrain.cpp plCameraBrain.cpp

2
Sources/Plasma/FeatureLib/pfCharacter/CMakeLists.txt

@ -4,8 +4,6 @@ include_directories(../../NucleusLib)
include_directories(../../NucleusLib/inc) include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib) include_directories(../../PubUtilLib)
include_directories(${OPENSSL_INCLUDE_DIR})
set(pfCharacter_SOURCES set(pfCharacter_SOURCES
pfMarkerInfo.cpp pfMarkerInfo.cpp
pfMarkerMgr.cpp pfMarkerMgr.cpp

1
Sources/Plasma/FeatureLib/pfConsole/CMakeLists.txt

@ -4,7 +4,6 @@ include_directories(../../NucleusLib)
include_directories(../../NucleusLib/inc) include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib) include_directories(../../PubUtilLib)
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${OPENAL_INCLUDE_DIR}) include_directories(${OPENAL_INCLUDE_DIR})
include_directories(${PYTHON_INCLUDE_DIR}) include_directories(${PYTHON_INCLUDE_DIR})

16
Sources/Plasma/FeatureLib/pfConsoleCore/pfConsoleCommandsCore.cpp

@ -61,14 +61,6 @@ void PrintStringF(void pfun(const char *),const char * fmt, ...)
* *
***/ ***/
//TODO: Fix Plasma to use OpenSSL's byte order (or better yet, to use OpenSSL),
// so this hack isn't needed
static void swap_key_bytes(byte keyData[])
{
for (size_t i = 0; i < (kNetDiffieHellmanKeyBits / 16); ++i)
std::swap(keyData[i], keyData[ (kNetDiffieHellmanKeyBits / 8) - i - 1 ]);
}
//============================================================================ //============================================================================
// Server group // Server group
PF_CONSOLE_GROUP(Server) PF_CONSOLE_GROUP(Server)
@ -159,7 +151,6 @@ PF_CONSOLE_CMD(
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kAuthDhNData); kNetDiffieHellmanKeyBits / 8, kAuthDhNData);
swap_key_bytes(kAuthDhNData);
} }
//============================================================================ //============================================================================
@ -178,7 +169,6 @@ PF_CONSOLE_CMD(
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kAuthDhXData); kNetDiffieHellmanKeyBits / 8, kAuthDhXData);
swap_key_bytes(kAuthDhXData);
} }
@ -214,7 +204,6 @@ PF_CONSOLE_CMD(
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kCsrDhNData); kNetDiffieHellmanKeyBits / 8, kCsrDhNData);
swap_key_bytes(kCsrDhNData);
} }
//============================================================================ //============================================================================
@ -233,7 +222,6 @@ PF_CONSOLE_CMD(
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kCsrDhXData); kNetDiffieHellmanKeyBits / 8, kCsrDhXData);
swap_key_bytes(kCsrDhXData);
} }
@ -257,7 +245,6 @@ PF_CONSOLE_CMD(
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kGameDhNData); kNetDiffieHellmanKeyBits / 8, kGameDhNData);
swap_key_bytes(kGameDhNData);
} }
//============================================================================ //============================================================================
@ -276,7 +263,6 @@ PF_CONSOLE_CMD(
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kGameDhXData); kNetDiffieHellmanKeyBits / 8, kGameDhXData);
swap_key_bytes(kGameDhXData);
} }
@ -312,7 +298,6 @@ PF_CONSOLE_CMD(
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kGateKeeperDhNData); kNetDiffieHellmanKeyBits / 8, kGateKeeperDhNData);
swap_key_bytes(kGateKeeperDhNData);
} }
//============================================================================ //============================================================================
@ -331,5 +316,4 @@ PF_CONSOLE_CMD(
Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0], Base64Decode(hsStrlen((const char *)params[0]), (const char *)params[0],
kNetDiffieHellmanKeyBits / 8, kGateKeeperDhXData); kNetDiffieHellmanKeyBits / 8, kGateKeeperDhXData);
swap_key_bytes(kGateKeeperDhXData);
} }

2
Sources/Plasma/FeatureLib/pfGameMgr/CMakeLists.txt

@ -4,8 +4,6 @@ include_directories(../../NucleusLib)
include_directories(../../NucleusLib/inc) include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib) include_directories(../../PubUtilLib)
include_directories(${OPENSSL_INCLUDE_DIR})
set(pfGameMgr_SOURCES set(pfGameMgr_SOURCES
pfGameMgr.cpp pfGameMgr.cpp
BlueSpiral/pfGmBlueSpiral.cpp BlueSpiral/pfGmBlueSpiral.cpp

2
Sources/Plasma/FeatureLib/pfJournalBook/CMakeLists.txt

@ -4,8 +4,6 @@ include_directories(../../NucleusLib)
include_directories(../../NucleusLib/inc) include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib) include_directories(../../PubUtilLib)
include_directories(${OPENSSL_INCLUDE_DIR})
set(pfJournalBook_SOURCES set(pfJournalBook_SOURCES
pfJournalBook.cpp pfJournalBook.cpp
) )

1
Sources/Plasma/FeatureLib/pfPython/CMakeLists.txt

@ -7,7 +7,6 @@ include_directories(../../)
include_directories(${PYTHON_INCLUDE_DIR}) include_directories(${PYTHON_INCLUDE_DIR})
include_directories(${OPENAL_INCLUDE_DIR}) include_directories(${OPENAL_INCLUDE_DIR})
include_directories(${OPENSSL_INCLUDE_DIR})
set(pfPython_SOURCES set(pfPython_SOURCES
cyAccountManagement.cpp cyAccountManagement.cpp

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

@ -589,20 +589,22 @@ static void ClientConnect (NetCli * cli) {
{ {
ZERO(cli->seed); ZERO(cli->seed);
unsigned bytes; unsigned bytes;
const void * data = clientSeed.GetData(&bytes); unsigned char * data = clientSeed.GetData_LE(&bytes);
MemCopy(cli->seed, data, min(bytes, sizeof(cli->seed))); MemCopy(cli->seed, data, min(bytes, sizeof(cli->seed)));
delete [] data;
} }
// Send server seed // Send server seed
if (cli->sock) { if (cli->sock) {
unsigned bytes; unsigned bytes;
NetCli_Cli2Srv_Connect msg; NetCli_Cli2Srv_Connect msg;
const void * data = serverSeed.GetData(&bytes); unsigned char * data = serverSeed.GetData_LE(&bytes);
ASSERTMSG(bytes <= sizeof(msg.dh_y_data), "4"); ASSERTMSG(bytes <= sizeof(msg.dh_y_data), "4");
msg.message = kNetCliCli2SrvConnect; msg.message = kNetCliCli2SrvConnect;
msg.length = (byte) (sizeof(msg) - sizeof(msg.dh_y_data) + bytes); msg.length = (byte) (sizeof(msg) - sizeof(msg.dh_y_data) + bytes);
MemCopy(msg.dh_y_data, data, bytes); MemCopy(msg.dh_y_data, data, bytes);
AsyncSocketSend(cli->sock, &msg, msg.length); AsyncSocketSend(cli->sock, &msg, msg.length);
delete [] data;
} }
} }
@ -643,8 +645,9 @@ static bool ServerRecvConnect (
ZERO(clientSeed); ZERO(clientSeed);
unsigned bytes; unsigned bytes;
const void * data = clientSeedValue.GetData(&bytes); unsigned char * data = clientSeedValue.GetData_LE(&bytes);
MemCopy(clientSeed, data, min(bytes, sizeof(clientSeed))); MemCopy(clientSeed, data, min(bytes, sizeof(clientSeed)));
delete [] data;
} }
// Create the symmetric key from a combination // Create the symmetric key from a combination

2
Sources/Plasma/NucleusLib/pnUtils/CMakeLists.txt

@ -1,8 +1,6 @@
include_directories("../../CoreLib") include_directories("../../CoreLib")
include_directories("../../NucleusLib") include_directories("../../NucleusLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(pnUtils_HEADERS set(pnUtils_HEADERS
Intern.h Intern.h
Pch.h Pch.h

23
Sources/Plasma/NucleusLib/pnUtils/Intern.h

@ -51,27 +51,4 @@ public:
virtual unsigned GetBlockSize () const = 0; virtual unsigned GetBlockSize () const = 0;
}; };
//============================================================================
class KeyRc4 : public KeyBase {
private:
unsigned m_x;
unsigned m_y;
byte m_state[256];
void Initialize (unsigned bytes, const void * data);
public:
KeyRc4 (unsigned bytes, const void * data) { Initialize(bytes, data); }
void Codec (bool encrypt, ARRAY(byte) * dest, unsigned sourceBytes, const void * sourceData);
unsigned GetBlockSize () const { return 1; }
static void KeyGen (
unsigned randomBytes,
const void * randomData,
ARRAY(byte) * privateData
);
};
} // namespace Crypt } // namespace Crypt

1358
Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBigNum.cpp

File diff suppressed because it is too large Load Diff

201
Sources/Plasma/NucleusLib/pnUtils/Private/pnUtBigNum.h

@ -41,70 +41,169 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
* *
***/ ***/
class BigNum : private ARRAY(dword) { #include <openssl/bn.h>
public:
typedef dword Val; // must match base array
typedef qword DVal; // must be twice as large as Val
class BigNum {
private: private:
bool m_isTemp; BIGNUM m_number;
mutable BN_CTX * m_context;
void DivNormalized (const BigNum & a, const BigNum & b, BigNum * remainder);
void ModNormalized (const BigNum & a, const BigNum & b);
inline static DVal Mul (Val a, Val b);
inline void SetVal (unsigned index, Val value); BN_CTX * GetContext () const
inline void SetVal (unsigned index, DVal value, Val * carry); {
inline void Trim (unsigned count); if (!m_context)
inline BigNum * UseTempAlloc (Val * ptr, unsigned count); m_context = BN_CTX_new();
return m_context;
}
public: public:
BigNum (); BigNum ();
BigNum (const BigNum & a); BigNum (const BigNum & a);
BigNum (unsigned a); BigNum (unsigned a);
BigNum (unsigned bytes, const void * data); BigNum (unsigned bytes, const void * data, bool le=false);
BigNum (const wchar str[], Val radix);
~BigNum (); ~BigNum ();
BigNum & operator= (const BigNum & a)
{
BN_copy(&m_number, &a.m_number);
return *this;
}
// Constant parameters need not be distinct from the destination or from // Constant parameters need not be distinct from the destination or from
// each other // each other
void Add (const BigNum & a, Val b); void Add (const BigNum & a, dword b)
void Add (const BigNum & a, const BigNum & b); {
int Compare (Val a) const; // this = a + b
int Compare (const BigNum & a) const; BN_copy(&m_number, &a.m_number);
void Div (const BigNum & a, Val b, Val * remainder); BN_add_word(&m_number, b);
void Div (const BigNum & a, const BigNum & b, BigNum * remainder); }
void FromData (unsigned bytes, const void * data);
void FromStr (const wchar str[], Val radix); void Add (const BigNum & a, const BigNum & b)
void Gcd (const BigNum & a, const BigNum & b); {
const void * GetData (unsigned * bytes) const; // this = a + b
unsigned HighBitPos () const; BN_add(&m_number, &a.m_number, &b.m_number);
bool InverseMod (const BigNum & a, const BigNum & b); }
bool IsMultiple (Val a) const;
bool IsOdd () const; int Compare (dword a) const;
bool IsPrime () const; int Compare (const BigNum & a) const
unsigned LowBitPos () const; {
void Mod (const BigNum & a, const BigNum & b); return BN_cmp(&m_number, &a.m_number);
void Mul (const BigNum & a, Val b); }
void Mul (const BigNum & a, const BigNum & b);
void MulMod (const BigNum & a, const BigNum & b, const BigNum & c); void Div (const BigNum & a, dword b, dword * remainder)
void PowMod (Val a, const BigNum & b, const BigNum & c); {
void PowMod (const BigNum & a, const BigNum & b, const BigNum & c); // this = a / b, remainder = a % b
void Rand (const BigNum & a, BigNum * seed); BN_copy(&m_number, &a.m_number);
*remainder = (dword)BN_div_word(&m_number, b);
}
void Div (const BigNum & a, const BigNum & b, BigNum * remainder)
{
// this = a / b, remainder = a % b
// either this or remainder may be nil
BN_div(this ? &m_number : nil, remainder ? &remainder->m_number : nil,
&a.m_number, &b.m_number, GetContext());
}
void FromData_BE (unsigned bytes, const void * data)
{
BN_bin2bn((const unsigned char *)data, bytes, &m_number);
}
void FromData_LE (unsigned bytes, const void * data);
unsigned char * GetData_BE (unsigned * bytes) const;
unsigned char * GetData_LE (unsigned * bytes) const;
bool IsPrime () const
{
// Cyan's code uses 3 checks, so we'll follow suit.
// This provides an accurate answer to p < 0.015625
return BN_is_prime_fasttest(&m_number, 3, nil, GetContext(), nil, 1) > 0;
}
void Mod (const BigNum & a, const BigNum & b)
{
// this = a % b
BN_div(nil, &m_number, &a.m_number, &b.m_number, GetContext());
}
void Mul (const BigNum & a, dword b)
{
// this = a * b
BN_copy(&m_number, &a.m_number);
BN_mul_word(&m_number, b);
}
void Mul (const BigNum & a, const BigNum & b)
{
// this = a * b
BN_mul(&m_number, &a.m_number, &b.m_number, GetContext());
}
void PowMod (dword a, const BigNum & b, const BigNum & c)
{
// this = a ^ b % c
PowMod(BigNum(a), b, c);
}
void PowMod (const BigNum & a, const BigNum & b, const BigNum & c)
{
// this = a ^ b % c
BN_mod_exp(&m_number, &a.m_number, &b.m_number, &c.m_number, GetContext());
}
void Rand (const BigNum & a, BigNum * seed)
{
// this = random number less than a
unsigned bits = BN_num_bits(&a.m_number);
do
Rand(bits, seed);
while (Compare(a) >= 0);
}
void Rand (unsigned bits, BigNum * seed); void Rand (unsigned bits, BigNum * seed);
void RandPrime (unsigned bits, BigNum * seed);
void Set (const BigNum & a);
void Set (unsigned a);
void SetBits (unsigned setBitsOffset, unsigned setBitsCount);
void SetOne ();
void SetZero ();
void Shl (const BigNum & a, unsigned b);
void Shr (const BigNum & a, unsigned b);
void Square (const BigNum & a);
void Sub (const BigNum & a, Val b);
void Sub (const BigNum & a, const BigNum & b);
void ToStr (BigNum * buffer, Val radix) const;
void RandPrime (unsigned bits, BigNum * seed)
{
BN_generate_prime(&m_number, bits, 1, nil, nil, nil, nil);
}
void Set (const BigNum & a)
{
BN_copy(&m_number, &a.m_number);
}
void Set (unsigned a)
{
BN_set_word(&m_number, a);
}
void SetOne () { Set(1); }
void SetZero () { Set(0); }
void Shl (const BigNum & a, unsigned b)
{
// this = a << b
BN_lshift(&m_number, &a.m_number, b);
}
void Shr (const BigNum & a, unsigned b)
{
// this = a >> b
BN_rshift(&m_number, &a.m_number, b);
}
void Sub (const BigNum & a, dword b)
{
// this = a - b
BN_copy(&m_number, &a.m_number);
BN_sub_word(&m_number, b);
}
void Sub (const BigNum & a, const BigNum & b)
{
// this = a - b
BN_sub(&m_number, &a.m_number, &b.m_number);
}
}; };

178
Sources/Plasma/NucleusLib/pnUtils/Private/pnUtCrypt.cpp

@ -34,12 +34,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include <openssl/md5.h> #include <openssl/md5.h>
#include <openssl/sha.h> #include <openssl/sha.h>
// OpenSSL's RC4 algorithm has bugs and randomly corrupts data
//#define OPENSSL_RC4
#ifdef OPENSSL_RC4
#include <openssl/rc4.h> #include <openssl/rc4.h>
#endif
/***************************************************************************** /*****************************************************************************
* *
@ -134,7 +129,6 @@ void Sha1Process (
* *
***/ ***/
#ifdef OPENSSL_RC4
//============================================================================ //============================================================================
static void Rc4Codec ( static void Rc4Codec (
CryptKey * key, CryptKey * key,
@ -161,105 +155,6 @@ static void Rc4Codec (
MemCopy(data, temp, bytes); MemCopy(data, temp, bytes);
} }
#else // OPENSSL_RC4
//===========================================================================
void KeyRc4::Codec (bool encrypt, ARRAY(byte) * dest, unsigned sourceBytes, const void * sourceData) {
// RC4 uses the same algorithm to both encrypt and decrypt
dest->SetCount(sourceBytes);
byte * destDataPtr = (byte *)dest->Ptr();
const byte * sourceDataPtr = (const byte *)sourceData;
for (unsigned index = 0; index < sourceBytes; ++index) {
m_x = (m_x + 1) & 0xff;
m_y = (m_state[m_x] + m_y) & 0xff;
SWAP(m_state[m_x], m_state[m_y]);
const unsigned offset = (m_state[m_x] + m_state[m_y]) & 0xff;
destDataPtr[index] = (byte)(sourceDataPtr[index] ^ m_state[offset]);
}
}
//===========================================================================
void KeyRc4::KeyGen (
unsigned randomBytes,
const void * randomData,
ARRAY(byte) * privateData
) {
// Allocate an output digest
struct Digest { dword data[5]; };
privateData->SetCount(sizeof(Digest));
Digest * digest = (Digest *)privateData->Ptr();
// Perform the hash
{
// Initialize the hash values with the repeating pattern of random
// data
unsigned offset = 0;
for (; offset < sizeof(Digest); ++offset)
((byte *)digest)[offset] = ((const byte *)randomData)[offset % randomBytes];
for (; offset < randomBytes; ++offset)
((byte *)digest)[offset % sizeof(Digest)] ^= ((const byte *)randomData)[offset];
// 32-bit rotate left
#ifdef _MSC_VER
#define ROTL(n, X) _rotl(X, n)
#else
#define ROTL(n, X) (((X) << (n)) | ((X) >> (32 - (n))))
#endif
#define f1(x,y,z) (z ^ (x & (y ^ z))) // Rounds 0-19
#define K1 0x5A827999L // Rounds 0-19
#define subRound(a, b, c, d, e, f, k, data) (e += ROTL(5, a) + f(b, c, d) + k + data, b = ROTL(30, b))
// first five subrounds from SHA1
dword A = 0x67452301;
dword B = 0xEFCDAB89;
dword C = 0x98BADCFE;
dword D = 0x10325476;
dword E = 0xC3D2E1F0;
subRound(A, B, C, D, E, f1, K1, digest->data[ 0]);
subRound(E, A, B, C, D, f1, K1, digest->data[ 1]);
subRound(D, E, A, B, C, f1, K1, digest->data[ 2]);
subRound(C, D, E, A, B, f1, K1, digest->data[ 3]);
subRound(B, C, D, E, A, f1, K1, digest->data[ 4]);
digest->data[0] += A;
digest->data[1] += B;
digest->data[2] += C;
digest->data[3] += D;
digest->data[4] += E;
}
}
//===========================================================================
void KeyRc4::Initialize (unsigned bytes, const void * data) {
ASSERT(bytes);
ASSERT(data);
// Initialize key with default values
{
m_x = 0;
m_y = 0;
for (unsigned offset = 0; offset < arrsize(m_state); ++offset)
m_state[offset] = (byte) offset;
}
// Seed key from digest
{
unsigned index1 = 0;
unsigned index2 = 0;
for (unsigned offset = 0; offset < arrsize(m_state); ++offset) {
ASSERT(index1 < bytes);
index2 = (((const byte *)data)[index1] + m_state[offset] + index2) & 0xff;
SWAP(m_state[offset], m_state[index2]);
if (++index1 == bytes)
index1 = 0;
}
}
}
#endif // OPENSSL_RC4
} using namespace Crypt; } using namespace Crypt;
@ -319,18 +214,11 @@ CryptKey * CryptKeyCreate (
CryptKey * key = nil; CryptKey * key = nil;
switch (algorithm) { switch (algorithm) {
case kCryptRc4: { case kCryptRc4: {
#ifdef OPENSSL_RC4
RC4_KEY * rc4 = NEW(RC4_KEY); RC4_KEY * rc4 = NEW(RC4_KEY);
RC4_set_key(rc4, bytes, (const unsigned char *)data); RC4_set_key(rc4, bytes, (const unsigned char *)data);
key = NEW(CryptKey); key = NEW(CryptKey);
key->algorithm = kCryptRc4; key->algorithm = kCryptRc4;
key->handle = rc4; key->handle = rc4;
#else
KeyRc4 * rc4 = NEWZERO(KeyRc4)(bytes, data);
key = NEW(CryptKey);
key->algorithm = kCryptRc4;
key->handle = rc4;
#endif
} }
break; break;
@ -343,43 +231,6 @@ CryptKey * CryptKeyCreate (
return key; return key;
} }
//===========================================================================
// Not exposed in header because is not used at the moment and I don't want a big rebuild right now :)
void CryptKeyGenerate (
ECryptAlgorithm algorithm,
unsigned keyBits, // used for algorithms with variable key strength
unsigned randomBytes,
const void * randomData,
ARRAY(byte) * privateData,
ARRAY(byte) * publicData // only for public key cryptography
) {
// Allocate and fill in private and/or public key classes
switch (algorithm) {
case kCryptRc4:
KeyRc4::KeyGen(
randomBytes,
randomData,
privateData
);
break;
case kCryptRsa:
#if 0
KeyRsa::KeyGen(
keyBits,
randomBytes,
randomData,
privateData,
publicData
);
break;
#endif // fall thru to fatal...
DEFAULT_FATAL(algorithm);
}
}
//============================================================================ //============================================================================
void CryptKeyClose ( void CryptKeyClose (
CryptKey * key CryptKey * key
@ -397,12 +248,7 @@ unsigned CryptKeyGetBlockSize (
) { ) {
switch (key->algorithm) { switch (key->algorithm) {
case kCryptRc4: { case kCryptRc4: {
#ifdef OPENSSL_RC4
return 1; return 1;
#else
KeyRc4 * rc4 = (KeyRc4 *)key->handle;
return rc4->GetBlockSize();
#endif
} }
break; break;
@ -537,12 +383,7 @@ void CryptEncrypt (
) { ) {
switch (key->algorithm) { switch (key->algorithm) {
case kCryptRc4: { case kCryptRc4: {
#ifdef OPENSSL_RC4
Rc4Codec(key, true, dest, sourceBytes, sourceData); Rc4Codec(key, true, dest, sourceBytes, sourceData);
#else
KeyRc4 * rc4 = (KeyRc4 *)key->handle;
rc4->Codec(true, dest, sourceBytes, sourceData);
#endif
} }
break; break;
@ -564,14 +405,7 @@ void CryptEncrypt (
switch (key->algorithm) { switch (key->algorithm) {
case kCryptRc4: { case kCryptRc4: {
#ifdef OPENSSL_RC4
Rc4Codec(key, true, bytes, data); Rc4Codec(key, true, bytes, data);
#else
ARRAY(byte) dest;
dest.Reserve(bytes);
CryptEncrypt(key, &dest, bytes, data);
MemCopy(data, dest.Ptr(), bytes);
#endif
} }
break; break;
@ -592,12 +426,7 @@ void CryptDecrypt (
) { ) {
switch (key->algorithm) { switch (key->algorithm) {
case kCryptRc4: { case kCryptRc4: {
#ifdef OPENSSL_RC4
Rc4Codec(key, false, dest, sourceBytes, sourceData); Rc4Codec(key, false, dest, sourceBytes, sourceData);
#else
KeyRc4 * rc4 = (KeyRc4 *)key->handle;
rc4->Codec(false, dest, sourceBytes, sourceData);
#endif
} }
break; break;
@ -619,14 +448,7 @@ void CryptDecrypt (
switch (key->algorithm) { switch (key->algorithm) {
case kCryptRc4: { case kCryptRc4: {
#ifdef OPENSSL_RC4
Rc4Codec(key, false, bytes, data); Rc4Codec(key, false, bytes, data);
#else
ARRAY(byte) dest;
dest.Reserve(bytes);
CryptDecrypt(key, &dest, bytes, data);
MemCopy(data, dest.Ptr(), bytes);
#endif
} }
break; break;

2
Sources/Plasma/PubUtilLib/plAgeDescription/CMakeLists.txt

@ -3,8 +3,6 @@ include_directories("../../FeatureLib")
include_directories("../../NucleusLib") include_directories("../../NucleusLib")
include_directories("../../PubUtilLib") include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(plAgeDescription_SOURCES set(plAgeDescription_SOURCES
plAgeDescription.cpp plAgeDescription.cpp
plAgeManifest.cpp plAgeManifest.cpp

2
Sources/Plasma/PubUtilLib/plAgeLoader/CMakeLists.txt

@ -4,8 +4,6 @@ include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib") include_directories("../../NucleusLib")
include_directories("../../PubUtilLib") include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(plAgeLoader_SOURCES set(plAgeLoader_SOURCES
plAgeLoader.cpp plAgeLoader.cpp
plAgeLoaderPaging.cpp plAgeLoaderPaging.cpp

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

@ -4,7 +4,6 @@ include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib") include_directories("../../NucleusLib")
include_directories("../../PubUtilLib") include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${OPENAL_INCLUDE_DIR}) include_directories(${OPENAL_INCLUDE_DIR})
set(plAvatar_SOURCES set(plAvatar_SOURCES

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

@ -2,8 +2,6 @@ include_directories("../../CoreLib")
include_directories("../../NucleusLib") include_directories("../../NucleusLib")
include_directories("../../PubUtilLib") include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(plEncryption_SOURCES set(plEncryption_SOURCES
plChecksum.cpp plChecksum.cpp
) )

2
Sources/Plasma/PubUtilLib/plGLight/CMakeLists.txt

@ -3,8 +3,6 @@ include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib") include_directories("../../NucleusLib")
include_directories("../../PubUtilLib") include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(plGLight_SOURCES set(plGLight_SOURCES
plDirectShadowMaster.cpp plDirectShadowMaster.cpp
plLightInfo.cpp plLightInfo.cpp

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

@ -4,7 +4,6 @@ include_directories("../../NucleusLib")
include_directories("../../PubUtilLib") include_directories("../../PubUtilLib")
include_directories(${DirectX_INCLUDE_DIR}) include_directories(${DirectX_INCLUDE_DIR})
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${OPENAL_INCLUDE_DIR}) include_directories(${OPENAL_INCLUDE_DIR})
set(plInputCore_SOURCES set(plInputCore_SOURCES

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

@ -6,7 +6,6 @@ include_directories("../../PubUtilLib")
include_directories(${PHYSX_INCLUDE_DIRS}) include_directories(${PHYSX_INCLUDE_DIRS})
include_directories(${OPENAL_INCLUDE_DIR}) include_directories(${OPENAL_INCLUDE_DIR})
include_directories(${OPENSSL_INCLUDE_DIR})
set(plModifier_SOURCES set(plModifier_SOURCES
plAnimEventModifier.cpp plAnimEventModifier.cpp

2
Sources/Plasma/PubUtilLib/plNetClient/CMakeLists.txt

@ -4,8 +4,6 @@ include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib") include_directories("../../NucleusLib")
include_directories("../../PubUtilLib") include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(plNetClient_SOURCES set(plNetClient_SOURCES
plLinkEffectsMgr.cpp plLinkEffectsMgr.cpp
plNetCliAgeJoiner.cpp plNetCliAgeJoiner.cpp

2
Sources/Plasma/PubUtilLib/plNetClientComm/CMakeLists.txt

@ -4,8 +4,6 @@ include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib") include_directories("../../NucleusLib")
include_directories("../../PubUtilLib") include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(plNetClientComm_SOURCES set(plNetClientComm_SOURCES
plNetClientComm.cpp plNetClientComm.cpp
) )

2
Sources/Plasma/PubUtilLib/plNetTransport/CMakeLists.txt

@ -3,8 +3,6 @@ include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib") include_directories("../../NucleusLib")
include_directories("../../PubUtilLib") include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(plNetTransport_SOURCES set(plNetTransport_SOURCES
plNetTransport.cpp plNetTransport.cpp
plNetTransportMember.cpp plNetTransportMember.cpp

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

@ -4,7 +4,6 @@ include_directories("../../NucleusLib")
include_directories("../../PubUtilLib") include_directories("../../PubUtilLib")
include_directories(${PHYSX_INCLUDE_DIRS}) include_directories(${PHYSX_INCLUDE_DIRS})
include_directories(${OPENSSL_INCLUDE_DIR})
set(plPhysX_SOURCES set(plPhysX_SOURCES
plLOSDispatch.cpp plLOSDispatch.cpp

3
Sources/Plasma/PubUtilLib/plPipeline/plDXPipeline.cpp

@ -9019,7 +9019,10 @@ hsBool plDXPipeline::TestVisibleWorld( const hsBounds3Ext& wBnd )
{ {
if( fView.fCullTreeDirty ) if( fView.fCullTreeDirty )
IRefreshCullTree(); IRefreshCullTree();
if (wBnd.GetType() == kBoundsNormal)
return fView.fCullTree.BoundsVisible(wBnd); return fView.fCullTree.BoundsVisible(wBnd);
else
return false;
} }
hsBool plDXPipeline::TestVisibleWorld( const plSceneObject* sObj ) hsBool plDXPipeline::TestVisibleWorld( const plSceneObject* sObj )

2
Sources/Plasma/PubUtilLib/plStatGather/CMakeLists.txt

@ -3,8 +3,6 @@ include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib") include_directories("../../NucleusLib")
include_directories("../../PubUtilLib") include_directories("../../PubUtilLib")
include_directories(${OPENSSL_INCLUDE_DIR})
set(plStatGather_SOURCES set(plStatGather_SOURCES
plAutoProfile.cpp plAutoProfile.cpp
plCalculatedProfiles.cpp plCalculatedProfiles.cpp

1
Sources/Tools/MaxMain/CMakeLists.txt

@ -7,7 +7,6 @@ include_directories("../../Plasma/NucleusLib/inc")
include_directories("../../Plasma/PubUtilLib") include_directories("../../Plasma/PubUtilLib")
include_directories("../../Plasma/PubUtilLib/inc") include_directories("../../Plasma/PubUtilLib/inc")
include_directories(${3dsm_INCLUDE_DIR}) include_directories(${3dsm_INCLUDE_DIR})
include_directories(${OPENSSL_INCLUDE_DIR})
include_directories(${OPENAL_INCLUDE_DIR}) include_directories(${OPENAL_INCLUDE_DIR})
include_directories(${PHYSX_INCLUDE_DIRS}) include_directories(${PHYSX_INCLUDE_DIRS})
include_directories(${PYTHON_INCLUDE_DIR}) include_directories(${PYTHON_INCLUDE_DIR})

Loading…
Cancel
Save