Refactored compression and encryption.

This commit is contained in:
njohnson 2025-09-15 18:49:42 -04:00
parent ccb956a834
commit ea1a829957
9 changed files with 11 additions and 47 deletions

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";