diff --git a/Sources/Plasma/Apps/plClient/winmain.cpp b/Sources/Plasma/Apps/plClient/winmain.cpp index 36ef2cf6..abbbbd5f 100644 --- a/Sources/Plasma/Apps/plClient/winmain.cpp +++ b/Sources/Plasma/Apps/plClient/winmain.cpp @@ -1076,7 +1076,7 @@ static void LoadUserPass (LoginDialogParam *pLoginParam) if (PathDoesFileExist(localFileAndPath)) StrCopy(fileAndPath, localFileAndPath, arrsize(localFileAndPath)); #endif - hsStream* stream = plEncryptedStream::OpenEncryptedFile(fileAndPath, true, cryptKey); + hsStream* stream = plEncryptedStream::OpenEncryptedFile(fileAndPath, cryptKey); if (stream && !stream->AtEnd()) { uint32_t savedKey[4]; diff --git a/Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp b/Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp index f73c74d0..a5757415 100644 --- a/Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp +++ b/Sources/Plasma/FeatureLib/pfLocalizationMgr/pfLocalizationDataMgr.cpp @@ -394,7 +394,7 @@ bool LocalizationXMLFile::Parse(const std::string & fileName) XML_SetCharacterDataHandler(fParser, HandleData); XML_SetUserData(fParser, (void*)this); - hsStream *xmlStream = plEncryptedStream::OpenEncryptedFile(fileName.c_str(), false); + hsStream *xmlStream = plEncryptedStream::OpenEncryptedFile(fileName.c_str()); if (!xmlStream) { wchar_t *wFilename = hsStringToWString(fileName.c_str()); diff --git a/Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.cpp b/Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.cpp index 3922a853..62309f9e 100644 --- a/Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.cpp +++ b/Sources/Plasma/PubUtilLib/plAgeDescription/plAgeManifest.cpp @@ -216,9 +216,6 @@ bool plManifest::Read(hsStream* stream) plInitFileReader reader(readers, 4096); // Allow extra long lines reader.SetUnhandledSectionReader(&baseReader); - - // manifests don't need to be encrypted - reader.SetRequireEncrypted(false); if (!reader.Open(stream)) return false; @@ -242,9 +239,6 @@ bool plManifest::Read(const char* filename) plInitFileReader reader(readers, 4096); // Allow extra long lines reader.SetUnhandledSectionReader(&baseReader); - // manifests don't need to be encrypted - reader.SetRequireEncrypted(false); - if (!reader.Open(filename)) return false; diff --git a/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp b/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp index e624fb63..f95530c6 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp +++ b/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.cpp @@ -543,29 +543,24 @@ bool plEncryptedStream::IsEncryptedFile(const wchar_t* fileName) return isEncrypted; } -hsStream* plEncryptedStream::OpenEncryptedFile(const char* fileName, bool requireEncrypted, uint32_t* cryptKey) +hsStream* plEncryptedStream::OpenEncryptedFile(const char* fileName, uint32_t* cryptKey) { wchar_t* wFilename = hsStringToWString(fileName); - hsStream* ret = OpenEncryptedFile(wFilename, requireEncrypted, cryptKey); + hsStream* ret = OpenEncryptedFile(wFilename, cryptKey); delete [] wFilename; return ret; } -hsStream* plEncryptedStream::OpenEncryptedFile(const wchar_t* fileName, bool requireEncrypted, uint32_t* cryptKey) +hsStream* plEncryptedStream::OpenEncryptedFile(const wchar_t* fileName, uint32_t* cryptKey) { -#ifndef PLASMA_EXTERNAL_RELEASE - requireEncrypted = false; -#endif bool isEncrypted = IsEncryptedFile(fileName); hsStream* s = nil; if (isEncrypted) s = new plEncryptedStream(cryptKey); - // If this isn't an external release, let them use unencrypted data else - if (!requireEncrypted) - s = new hsUNIXStream; + s = new hsUNIXStream; if (s) s->Open(fileName, L"rb"); diff --git a/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.h b/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.h index 6aa0f1fb..86ca0f5f 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.h +++ b/Sources/Plasma/PubUtilLib/plFile/plEncryptedStream.h @@ -107,8 +107,8 @@ public: // Attempts to create a read-binary stream for the requested file. If it's // encrypted, you'll get a plEncryptedStream, otherwise just a standard // hsUNIXStream. Remember to delete the stream when you're done with it. - static hsStream* OpenEncryptedFile(const char* fileName, bool requireEncrypted = true, uint32_t* cryptKey = nil); - static hsStream* OpenEncryptedFile(const wchar_t* fileName, bool requireEncrypted = true, uint32_t* cryptKey = nil); + static hsStream* OpenEncryptedFile(const char* fileName, uint32_t* cryptKey = nil); + static hsStream* OpenEncryptedFile(const wchar_t* fileName, uint32_t* cryptKey = nil); static hsStream* OpenEncryptedFileWrite(const char* fileName, uint32_t* cryptKey = nil); static hsStream* OpenEncryptedFileWrite(const wchar_t* fileName, uint32_t* cryptKey = nil); }; diff --git a/Sources/Plasma/PubUtilLib/plFile/plInitFileReader.cpp b/Sources/Plasma/PubUtilLib/plFile/plInitFileReader.cpp index 87d934a4..fab1dfdf 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plInitFileReader.cpp +++ b/Sources/Plasma/PubUtilLib/plFile/plInitFileReader.cpp @@ -83,7 +83,6 @@ void plInitFileReader::IInitReaders( plInitSectionReader **readerArray ) plInitFileReader::plInitFileReader( plInitSectionReader **readerArray, uint16_t lineSize ) { - fRequireEncrypted = true; fCurrLine = nil; fLineSize = lineSize; fStream = fOurStream = nil; @@ -93,7 +92,6 @@ plInitFileReader::plInitFileReader( plInitSectionReader **readerArray, uint16_t plInitFileReader::plInitFileReader( const char *fileName, plInitSectionReader **readerArray, uint16_t lineSize ) { - fRequireEncrypted = true; fCurrLine = nil; fLineSize = lineSize; fStream = fOurStream = nil; @@ -105,7 +103,6 @@ plInitFileReader::plInitFileReader( const char *fileName, plInitSectionReader ** plInitFileReader::plInitFileReader( hsStream *stream, plInitSectionReader **readerArray, uint16_t lineSize ) { - fRequireEncrypted = true; fCurrLine = nil; fLineSize = lineSize; fStream = fOurStream = nil; @@ -129,7 +126,7 @@ bool plInitFileReader::Open( const char *fileName ) return false; } - fOurStream = plEncryptedStream::OpenEncryptedFile( fileName, fRequireEncrypted ); + fOurStream = plEncryptedStream::OpenEncryptedFile( fileName ); if( fOurStream == nil ) return false; diff --git a/Sources/Plasma/PubUtilLib/plFile/plInitFileReader.h b/Sources/Plasma/PubUtilLib/plFile/plInitFileReader.h index f395b609..92016d30 100644 --- a/Sources/Plasma/PubUtilLib/plFile/plInitFileReader.h +++ b/Sources/Plasma/PubUtilLib/plFile/plInitFileReader.h @@ -118,7 +118,6 @@ class plInitFileReader hsStream *fOurStream; char *fCurrLine; uint32_t fLineSize; - bool fRequireEncrypted; plInitSectionReader *fCurrSection; hsTArray fSections; @@ -138,8 +137,6 @@ class plInitFileReader plInitFileReader( hsStream *stream, plInitSectionReader **readerArray, uint16_t lineSize = 256 ); virtual ~plInitFileReader(); - void SetRequireEncrypted(bool require) { fRequireEncrypted = require; } - bool GetRequireEncrypted() const { return fRequireEncrypted; } void SetUnhandledSectionReader(plInitSectionReader* reader) { fUnhandledSection = reader; } bool Open( const char *fileName ); diff --git a/Sources/Plasma/PubUtilLib/plStatusLog/plEncryptLogLine.cpp b/Sources/Plasma/PubUtilLib/plStatusLog/plEncryptLogLine.cpp index feeddc20..22cd112a 100644 --- a/Sources/Plasma/PubUtilLib/plStatusLog/plEncryptLogLine.cpp +++ b/Sources/Plasma/PubUtilLib/plStatusLog/plEncryptLogLine.cpp @@ -53,29 +53,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com #include -void plStatusEncrypt::Encrypt( uint8_t *line, uint8_t hint ) -{ - // Current encryption scheme: rotate all characters right by 2 bits, - // then rotate the whole damn line by 3 bits to the right - uint32_t i, len = strlen( (char *)line ); - uint8_t newHi, hiBits = ( ( line[ len - 1 ] ) << ( 5 - 2 ) ) & 0xe0; - - for( i = 0; i < len; i++ ) - { - // So each character will be the src char rotated right 2 bits, then shifted - // right 3 bits, or'ed with the last high bits, and the 3 discarded bits - // become the new high bits - // Too bad C doesn't have a bit-rotate op - - line[ i ] = ( line[ i ] << 6 ) | ( line[ i ] >> 2 ); - newHi = line[ i ] << 5; - line[ i ] = ( line[ i ] >> 3 ) | hiBits; - line[ i ] ^= hint; // Should wrap around - - hiBits = newHi; - } -} - void plStatusEncrypt::Decrypt( uint8_t *line, int32_t len, uint8_t hint ) { // Da reverse, of course! diff --git a/Sources/Plasma/PubUtilLib/plStatusLog/plEncryptLogLine.h b/Sources/Plasma/PubUtilLib/plStatusLog/plEncryptLogLine.h index 7a0e268d..313e1ba4 100644 --- a/Sources/Plasma/PubUtilLib/plStatusLog/plEncryptLogLine.h +++ b/Sources/Plasma/PubUtilLib/plStatusLog/plEncryptLogLine.h @@ -56,7 +56,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com namespace plStatusEncrypt { - void Encrypt( uint8_t *line, uint8_t hint ); void Decrypt( uint8_t *line, int32_t length, uint8_t hint ); }; diff --git a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp index 00193189..c102dcef 100644 --- a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp +++ b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.cpp @@ -475,12 +475,6 @@ bool plStatusLog::IReOpen( void ) wchar_t fileNoExt[MAX_PATH]; wchar_t* ext=nil; IParseFileName(file, MAX_PATH, fileNoExt, &ext); - fEncryptMe = false; -#ifdef PLASMA_EXTERNAL_RELEASE - fEncryptMe = ( wcsicmp( fFilename.c_str(), L"chat.log" ) != 0 ) ? true : false; - if( fEncryptMe ) - ext = L".elf"; -#endif wchar_t fileToOpen[MAX_PATH]; hsSnwprintf(fileToOpen, MAX_PATH, L"%s.0%s", fileNoExt, ext); if (!(fFlags & kDontRotateLogs)) @@ -497,11 +491,11 @@ bool plStatusLog::IReOpen( void ) if (fFlags & kAppendToLast) { - fFileHandle = hsWFopen( fileToOpen, fEncryptMe ? L"ab" : L"at" ); + fFileHandle = hsWFopen( fileToOpen, L"at" ); } else { - fFileHandle = hsWFopen( fileToOpen, fEncryptMe ? L"wb" : L"wt" ); + fFileHandle = hsWFopen( fileToOpen, L"wt" ); // if we need to reopen lets just append fFlags |= kAppendToLast; } @@ -843,58 +837,18 @@ bool plStatusLog::IPrintLineToFile( const char *line, uint32_t count ) } size_t remaining = arrsize(buf) - strlen(buf) - 1; - if (!fEncryptMe) remaining -= 1; + remaining -= 1; if (count <= remaining) { strncat(buf, line, count); } else { strncat(buf, line, remaining); } - if(!fEncryptMe ) - { - strncat(buf, "\n", 1); - } + strncat(buf, "\n", 1); } unsigned length = strlen(buf); -#ifdef PLASMA_EXTERNAL_RELEASE - // Print to a separate line, since we have to encrypt it - if( fEncryptMe ) - { - // Encrypt! - plStatusEncrypt::Encrypt( (uint8_t *)buf, hint ); - - // xor the line length, then write it out, then the line, no terminating character - uint16_t encrySize = length ^ ((uint16_t)fSize); - - // try the first write, if it fails reopen and try again - int err; - err = fputc( encrySize & 0xff, fFileHandle ); - if (err == EOF && IReOpen()) - { - err = fputc( encrySize & 0xff, fFileHandle ); - } - - if (err != EOF) - { - fSize++; // inc for the last putc - err = fputc( encrySize >> 8, fFileHandle ); - if (err != EOF) - fSize++; // inc for the last putc - err = fwrite( buf, 1, length, fFileHandle ); - fSize += err; - - if (!(fFlags & kNonFlushedLog)) - fflush(fFileHandle); - } - else - { - ret = false; - } - } - else -#endif { int err; err = fwrite(buf,1,length,fFileHandle); diff --git a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.h b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.h index 07b29815..e84c4828 100644 --- a/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.h +++ b/Sources/Plasma/PubUtilLib/plStatusLog/plStatusLog.h @@ -90,7 +90,6 @@ class plStatusLog hsSemaphore* fSema; FILE* fFileHandle; uint32_t fSize; - bool fEncryptMe; bool fForceLog; plStatusLog *fNext, **fBack;