Commit 04be1cd5 authored by hybrid's avatar hybrid

Fix aes loader, seems like no tables won't work. Added test to ensure proper decryption.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2982 dfc29bdd-3216-0410-991c-e03cc46cb475
parent e0bec83b
...@@ -334,8 +334,9 @@ ...@@ -334,8 +334,9 @@
statically into the binary file. Otherwise the subroutine gen_tabs() statically into the binary file. Otherwise the subroutine gen_tabs()
must be called to compute them before the code is first used. must be called to compute them before the code is first used.
*/ */
#if 0 #if 1
#define FIXED_TABLES #define FIXED_TABLES
#define DO_TABLES
#endif #endif
/* 9. TABLE ALIGNMENT /* 9. TABLE ALIGNMENT
......
...@@ -66,7 +66,7 @@ bool testArchive(IFileSystem* fs, const io::path& archiveName) ...@@ -66,7 +66,7 @@ bool testArchive(IFileSystem* fs, const io::path& archiveName)
IReadFile* readFile = fs->createAndOpenFile(filename); IReadFile* readFile = fs->createAndOpenFile(filename);
if ( !readFile ) if ( !readFile )
{ {
logTestString("createAndOpenFilefailed\n"); logTestString("createAndOpenFile failed\n");
return false; return false;
} }
...@@ -90,6 +90,95 @@ bool testArchive(IFileSystem* fs, const io::path& archiveName) ...@@ -90,6 +90,95 @@ bool testArchive(IFileSystem* fs, const io::path& archiveName)
return true; return true;
} }
bool testEncryptedZip(IFileSystem* fs)
{
// make sure there is no archive mounted
if ( fs->getFileArchiveCount() )
{
logTestString("Already mounted archives found\n");
return false;
}
const char* archiveName = "media/enc.zip";
if ( !fs->addFileArchive(archiveName, /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
{
logTestString("Mounting archive failed\n");
return false;
}
// make sure there is an archive mounted
if ( !fs->getFileArchiveCount() )
{
logTestString("Mounted archive not in list\n");
return false;
}
// mount again
if ( !fs->addFileArchive(archiveName, /*bool ignoreCase=*/true, /*bool ignorePaths=*/false) )
{
logTestString("Mounting a second time failed\n");
return false;
}
// make sure there is exactly one archive mounted
if ( fs->getFileArchiveCount() != 1 )
{
logTestString("Duplicate mount not recognized\n");
return false;
}
// log what we got
io::IFileArchive* archive = fs->getFileArchive(fs->getFileArchiveCount()-1);
const io::IFileList* fileList = archive->getFileList();
for ( u32 f=0; f < fileList->getFileCount(); ++f)
{
logTestString("File name: %s\n", fileList->getFileName(f).c_str());
logTestString("Full path: %s\n", fileList->getFullFileName(f).c_str());
}
io::path filename("doc/readme.txt");
if (!fs->existFile(filename))
{
logTestString("existFile failed\n");
return false;
}
IReadFile* readFile = fs->createAndOpenFile(filename);
if ( readFile )
{
logTestString("createAndOpenFile succeeded, even though no password was set.\n");
return false;
}
archive->Password="33445";
readFile = fs->createAndOpenFile(filename);
if ( !readFile )
{
logTestString("createAndOpenFile failed\n");
return false;
}
char tmp[13] = {'\0'};
readFile->read(tmp, 12);
if (strncmp(tmp, "Linux Users:", 12))
{
logTestString("Read bad data from archive: %s\n", tmp);
return false;
}
if (!fs->removeFileArchive(fs->getFileArchiveCount()-1))
{
logTestString("Couldn't remove archive.\n");
return false;
}
// make sure there is no archive mounted
if ( fs->getFileArchiveCount() )
return false;
return true;
}
bool archiveReader() bool archiveReader()
{ {
IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1)); IrrlichtDevice * device = irr::createDevice(video::EDT_NULL, dimension2d<u32>(1, 1));
...@@ -108,6 +197,8 @@ bool archiveReader() ...@@ -108,6 +197,8 @@ bool archiveReader()
ret &= testArchive(fs, "media/sample_pakfile.pak"); ret &= testArchive(fs, "media/sample_pakfile.pak");
logTestString("Testing npk files.\n"); logTestString("Testing npk files.\n");
ret &= testArchive(fs, "media/file_with_path.npk"); ret &= testArchive(fs, "media/file_with_path.npk");
logTestString("Testing encrypted zip files.\n");
ret &= testEncryptedZip(fs);
return ret; return ret;
} }
Test suite pass at GMT Wed Dec 2 15:59:13 2009 Test suite pass at GMT Fri Dec 4 18:41:12 2009
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment