Refactored compression and encryption.
This commit is contained in:
parent
ccb956a834
commit
ea1a829957
@ -118,7 +118,7 @@ void AutoTest_COD10_PS3::testFactory() {
|
|||||||
|
|
||||||
const QString testName = "Factory ingest: " + fastFilePath;
|
const QString testName = "Factory ingest: " + fastFilePath;
|
||||||
|
|
||||||
FastFile* fastFile = FastFileFactory::Create(fastFilePath);
|
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||||
|
|
||||||
const QString game = fastFile->GetGame();
|
const QString game = fastFile->GetGame();
|
||||||
bool correctGame = game == "COD10";
|
bool correctGame = game == "COD10";
|
||||||
|
|||||||
@ -118,7 +118,7 @@ void AutoTest_COD11_PS3::testFactory() {
|
|||||||
|
|
||||||
const QString testName = "Factory ingest: " + fastFilePath;
|
const QString testName = "Factory ingest: " + fastFilePath;
|
||||||
|
|
||||||
FastFile* fastFile = FastFileFactory::Create(fastFilePath);
|
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||||
|
|
||||||
const QString game = fastFile->GetGame();
|
const QString game = fastFile->GetGame();
|
||||||
bool correctGame = game == "COD11";
|
bool correctGame = game == "COD11";
|
||||||
|
|||||||
@ -211,7 +211,7 @@ void AutoTest_COD12_PS3::testFactory() {
|
|||||||
|
|
||||||
const QString testName = "Factory ingest: " + fastFilePath;
|
const QString testName = "Factory ingest: " + fastFilePath;
|
||||||
|
|
||||||
FastFile* fastFile = FastFileFactory::Create(fastFilePath);
|
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||||
|
|
||||||
const QString game = fastFile->GetGame();
|
const QString game = fastFile->GetGame();
|
||||||
bool correctGame = game == "COD12";
|
bool correctGame = game == "COD12";
|
||||||
|
|||||||
@ -157,7 +157,7 @@ void AutoTest_COD4_PS3::testFactory() {
|
|||||||
|
|
||||||
const QString testName = "Factory ingest: " + fastFilePath;
|
const QString testName = "Factory ingest: " + fastFilePath;
|
||||||
|
|
||||||
FastFile* fastFile = FastFileFactory::Create(fastFilePath);
|
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||||
|
|
||||||
const QString game = fastFile->GetGame();
|
const QString game = fastFile->GetGame();
|
||||||
bool correctGame = game == "COD4";
|
bool correctGame = game == "COD4";
|
||||||
|
|||||||
@ -155,7 +155,7 @@ void AutoTest_COD5_PS3::testFactory() {
|
|||||||
|
|
||||||
const QString testName = "Factory ingest: " + fastFilePath;
|
const QString testName = "Factory ingest: " + fastFilePath;
|
||||||
|
|
||||||
FastFile* fastFile = FastFileFactory::Create(fastFilePath);
|
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||||
|
|
||||||
const QString game = fastFile->GetGame();
|
const QString game = fastFile->GetGame();
|
||||||
bool correctGame = game == "COD5";
|
bool correctGame = game == "COD5";
|
||||||
|
|||||||
@ -118,7 +118,7 @@ void AutoTest_COD6_PS3::testFactory() {
|
|||||||
|
|
||||||
const QString testName = "Factory ingest: " + fastFilePath;
|
const QString testName = "Factory ingest: " + fastFilePath;
|
||||||
|
|
||||||
FastFile* fastFile = FastFileFactory::Create(fastFilePath);
|
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||||
|
|
||||||
const QString game = fastFile->GetGame();
|
const QString game = fastFile->GetGame();
|
||||||
bool correctGame = game == "COD6";
|
bool correctGame = game == "COD6";
|
||||||
|
|||||||
@ -5,6 +5,8 @@
|
|||||||
#include "autotest_cod.h"
|
#include "autotest_cod.h"
|
||||||
#include "compression.h"
|
#include "compression.h"
|
||||||
#include "encryption.h"
|
#include "encryption.h"
|
||||||
|
#include "fastfile.h"
|
||||||
|
#include "xdatastream.h"
|
||||||
|
|
||||||
class AutoTest_COD7_PS3 : public AutoTest_COD {
|
class AutoTest_COD7_PS3 : public AutoTest_COD {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -66,44 +68,6 @@ void AutoTest_COD7_PS3::testDecompression() {
|
|||||||
QByteArray fileName(32, Qt::Uninitialized);
|
QByteArray fileName(32, Qt::Uninitialized);
|
||||||
fastFileStream.readRawData(fileName.data(), 32);
|
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;
|
const QByteArray testZoneData = decompressedData;
|
||||||
|
|
||||||
// Verify the decompressed data via its embedded zone size.
|
// Verify the decompressed data via its embedded zone size.
|
||||||
@ -181,7 +145,7 @@ void AutoTest_COD7_PS3::testFactory() {
|
|||||||
|
|
||||||
const QString testName = "Factory ingest: " + fastFilePath;
|
const QString testName = "Factory ingest: " + fastFilePath;
|
||||||
|
|
||||||
FastFile* fastFile = FastFileFactory::Create(fastFilePath);
|
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||||
|
|
||||||
const QString game = fastFile->GetGame();
|
const QString game = fastFile->GetGame();
|
||||||
bool correctGame = game == "COD7";
|
bool correctGame = game == "COD7";
|
||||||
|
|||||||
@ -118,7 +118,7 @@ void AutoTest_COD8_PS3::testFactory() {
|
|||||||
|
|
||||||
const QString testName = "Factory ingest: " + fastFilePath;
|
const QString testName = "Factory ingest: " + fastFilePath;
|
||||||
|
|
||||||
FastFile* fastFile = FastFileFactory::Create(fastFilePath);
|
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||||
|
|
||||||
const QString game = fastFile->GetGame();
|
const QString game = fastFile->GetGame();
|
||||||
bool correctGame = game == "COD8";
|
bool correctGame = game == "COD8";
|
||||||
|
|||||||
@ -118,7 +118,7 @@ void AutoTest_COD9_PS3::testFactory() {
|
|||||||
|
|
||||||
const QString testName = "Factory ingest: " + fastFilePath;
|
const QString testName = "Factory ingest: " + fastFilePath;
|
||||||
|
|
||||||
FastFile* fastFile = FastFileFactory::Create(fastFilePath);
|
FastFile* fastFile = FastFile::Open(fastFilePath);
|
||||||
|
|
||||||
const QString game = fastFile->GetGame();
|
const QString game = fastFile->GetGame();
|
||||||
bool correctGame = game == "COD9";
|
bool correctGame = game == "COD9";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user