From ea1a829957af0ca82813cf7ab00463c7d9608139 Mon Sep 17 00:00:00 2001 From: njohnson Date: Mon, 15 Sep 2025 18:49:42 -0400 Subject: [PATCH] Refactored compression and encryption. --- tests/PS3/autotest_cod10_ps3.cpp | 2 +- tests/PS3/autotest_cod11_ps3.cpp | 2 +- tests/PS3/autotest_cod12_ps3.cpp | 2 +- tests/PS3/autotest_cod4_ps3.cpp | 2 +- tests/PS3/autotest_cod5_ps3.cpp | 2 +- tests/PS3/autotest_cod6_ps3.cpp | 2 +- tests/PS3/autotest_cod7_ps3.cpp | 42 +++----------------------------- tests/PS3/autotest_cod8_ps3.cpp | 2 +- tests/PS3/autotest_cod9_ps3.cpp | 2 +- 9 files changed, 11 insertions(+), 47 deletions(-) diff --git a/tests/PS3/autotest_cod10_ps3.cpp b/tests/PS3/autotest_cod10_ps3.cpp index f9763b4..e4a2763 100644 --- a/tests/PS3/autotest_cod10_ps3.cpp +++ b/tests/PS3/autotest_cod10_ps3.cpp @@ -118,7 +118,7 @@ void AutoTest_COD10_PS3::testFactory() { const QString testName = "Factory ingest: " + fastFilePath; - FastFile* fastFile = FastFileFactory::Create(fastFilePath); + FastFile* fastFile = FastFile::Open(fastFilePath); const QString game = fastFile->GetGame(); bool correctGame = game == "COD10"; diff --git a/tests/PS3/autotest_cod11_ps3.cpp b/tests/PS3/autotest_cod11_ps3.cpp index a92168f..526c4d8 100644 --- a/tests/PS3/autotest_cod11_ps3.cpp +++ b/tests/PS3/autotest_cod11_ps3.cpp @@ -118,7 +118,7 @@ void AutoTest_COD11_PS3::testFactory() { const QString testName = "Factory ingest: " + fastFilePath; - FastFile* fastFile = FastFileFactory::Create(fastFilePath); + FastFile* fastFile = FastFile::Open(fastFilePath); const QString game = fastFile->GetGame(); bool correctGame = game == "COD11"; diff --git a/tests/PS3/autotest_cod12_ps3.cpp b/tests/PS3/autotest_cod12_ps3.cpp index a357884..6b638c8 100644 --- a/tests/PS3/autotest_cod12_ps3.cpp +++ b/tests/PS3/autotest_cod12_ps3.cpp @@ -211,7 +211,7 @@ void AutoTest_COD12_PS3::testFactory() { const QString testName = "Factory ingest: " + fastFilePath; - FastFile* fastFile = FastFileFactory::Create(fastFilePath); + FastFile* fastFile = FastFile::Open(fastFilePath); const QString game = fastFile->GetGame(); bool correctGame = game == "COD12"; diff --git a/tests/PS3/autotest_cod4_ps3.cpp b/tests/PS3/autotest_cod4_ps3.cpp index 5f6cd3b..bd48113 100644 --- a/tests/PS3/autotest_cod4_ps3.cpp +++ b/tests/PS3/autotest_cod4_ps3.cpp @@ -157,7 +157,7 @@ void AutoTest_COD4_PS3::testFactory() { const QString testName = "Factory ingest: " + fastFilePath; - FastFile* fastFile = FastFileFactory::Create(fastFilePath); + FastFile* fastFile = FastFile::Open(fastFilePath); const QString game = fastFile->GetGame(); bool correctGame = game == "COD4"; diff --git a/tests/PS3/autotest_cod5_ps3.cpp b/tests/PS3/autotest_cod5_ps3.cpp index 040c6f4..35486de 100644 --- a/tests/PS3/autotest_cod5_ps3.cpp +++ b/tests/PS3/autotest_cod5_ps3.cpp @@ -155,7 +155,7 @@ void AutoTest_COD5_PS3::testFactory() { const QString testName = "Factory ingest: " + fastFilePath; - FastFile* fastFile = FastFileFactory::Create(fastFilePath); + FastFile* fastFile = FastFile::Open(fastFilePath); const QString game = fastFile->GetGame(); bool correctGame = game == "COD5"; diff --git a/tests/PS3/autotest_cod6_ps3.cpp b/tests/PS3/autotest_cod6_ps3.cpp index d5b20c2..ed64438 100644 --- a/tests/PS3/autotest_cod6_ps3.cpp +++ b/tests/PS3/autotest_cod6_ps3.cpp @@ -118,7 +118,7 @@ void AutoTest_COD6_PS3::testFactory() { const QString testName = "Factory ingest: " + fastFilePath; - FastFile* fastFile = FastFileFactory::Create(fastFilePath); + FastFile* fastFile = FastFile::Open(fastFilePath); const QString game = fastFile->GetGame(); bool correctGame = game == "COD6"; diff --git a/tests/PS3/autotest_cod7_ps3.cpp b/tests/PS3/autotest_cod7_ps3.cpp index ca54aa9..443a55e 100644 --- a/tests/PS3/autotest_cod7_ps3.cpp +++ b/tests/PS3/autotest_cod7_ps3.cpp @@ -5,6 +5,8 @@ #include "autotest_cod.h" #include "compression.h" #include "encryption.h" +#include "fastfile.h" +#include "xdatastream.h" class AutoTest_COD7_PS3 : public AutoTest_COD { Q_OBJECT @@ -66,44 +68,6 @@ void AutoTest_COD7_PS3::testDecompression() { QByteArray fileName(32, Qt::Uninitialized); fastFileStream.readRawData(fileName.data(), 32); - // Build the IV table from the fileName. - QByteArray ivTable = Encryption::InitIVTable(fileName); - - // Skip the RSA signature (256 bytes). - QByteArray rsaSignature(256, Qt::Uninitialized); - fastFileStream.readRawData(rsaSignature.data(), 256); - - // Now the stream should be positioned at 0x13C, where sections begin. - int sectionIndex = 0; - while (true) { - qint32 sectionSize = 0; - fastFileStream >> sectionSize; - if (sectionSize == 0) - break; - - // Read the section data. - QByteArray sectionData; - sectionData.resize(sectionSize); - fastFileStream.readRawData(sectionData.data(), sectionSize); - - // Compute the IV for this section. - QByteArray iv = Encryption::GetIV(ivTable, sectionIndex); - - // Decrypt the section using Salsa20. - QByteArray decData = Encryption::salsa20DecryptSection(sectionData, key, iv); - - // Compute SHA1 hash of the decrypted data. - QByteArray sectionHash = QCryptographicHash::hash(decData, QCryptographicHash::Sha1); - - // Update the IV table based on the section hash. - Encryption::UpdateIVTable(ivTable, sectionIndex, sectionHash); - - // Build a compressed data buffer by prepending the two-byte zlib header. - decompressedData.append(Compression::DecompressDeflate(decData)); - - sectionIndex++; - } - const QByteArray testZoneData = decompressedData; // Verify the decompressed data via its embedded zone size. @@ -181,7 +145,7 @@ void AutoTest_COD7_PS3::testFactory() { const QString testName = "Factory ingest: " + fastFilePath; - FastFile* fastFile = FastFileFactory::Create(fastFilePath); + FastFile* fastFile = FastFile::Open(fastFilePath); const QString game = fastFile->GetGame(); bool correctGame = game == "COD7"; diff --git a/tests/PS3/autotest_cod8_ps3.cpp b/tests/PS3/autotest_cod8_ps3.cpp index 4113302..abd5384 100644 --- a/tests/PS3/autotest_cod8_ps3.cpp +++ b/tests/PS3/autotest_cod8_ps3.cpp @@ -118,7 +118,7 @@ void AutoTest_COD8_PS3::testFactory() { const QString testName = "Factory ingest: " + fastFilePath; - FastFile* fastFile = FastFileFactory::Create(fastFilePath); + FastFile* fastFile = FastFile::Open(fastFilePath); const QString game = fastFile->GetGame(); bool correctGame = game == "COD8"; diff --git a/tests/PS3/autotest_cod9_ps3.cpp b/tests/PS3/autotest_cod9_ps3.cpp index a146f92..96fa5a3 100644 --- a/tests/PS3/autotest_cod9_ps3.cpp +++ b/tests/PS3/autotest_cod9_ps3.cpp @@ -118,7 +118,7 @@ void AutoTest_COD9_PS3::testFactory() { const QString testName = "Factory ingest: " + fastFilePath; - FastFile* fastFile = FastFileFactory::Create(fastFilePath); + FastFile* fastFile = FastFile::Open(fastFilePath); const QString game = fastFile->GetGame(); bool correctGame = game == "COD9";