Add ways to provide the password for encrypted archives.
git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2965 dfc29bdd-3216-0410-991c-e03cc46cb475master
parent
7862d83a33
commit
3d4ff2a67e
|
@ -1,5 +1,9 @@
|
|||
Changes in 1.7
|
||||
|
||||
- Support AES-encrypted zip files. Should work with 128, 196, and 256 bit AES. This addition also adds a new PRNG, SHA, and other algorithms to the engine, though no interface is yet added for them. The implementation of the encryption algorithms is provided by Dr Brian Gladman.
|
||||
|
||||
- Added geometry shaders for OpenGL. A first version of the code was submitted by Matthew Kielan (devsh).
|
||||
|
||||
- Bugfix: irrArray should no longer crash when using other allocators.
|
||||
|
||||
- Add MaterialViewer example.
|
||||
|
|
|
@ -71,6 +71,13 @@ public:
|
|||
|
||||
//! get the archive type
|
||||
virtual E_FILE_ARCHIVE_TYPE getType() const { return EFAT_UNKNOWN; }
|
||||
|
||||
//! An optionally used password string
|
||||
/** This variable is publicly accessible from the interface in order to
|
||||
avoid single access patterns to this place, and hence allow some more
|
||||
obscurity.
|
||||
*/
|
||||
core::stringc Password;
|
||||
};
|
||||
|
||||
//! Class which is able to create an archive from a file.
|
||||
|
|
|
@ -92,26 +92,32 @@ public:
|
|||
virtual IWriteFile* createAndWriteFile(const path& filename, bool append=false) =0;
|
||||
|
||||
//! Adds an archive to the file system.
|
||||
/** After calling this, the Irrlicht Engine will also search and open files directly from this archive.
|
||||
This is useful for hiding data from the end user, speeding up file access and making it possible to
|
||||
access for example Quake3 .pk3 files, which are no different than .zip files.
|
||||
By default Irrlicht supports ZIP, PAK, TAR and directories as archives. You can provide your own archive
|
||||
types by implementing IArchiveLoader and passing an instance to addArchiveLoader.
|
||||
/** After calling this, the Irrlicht Engine will also search and open
|
||||
files directly from this archive. This is useful for hiding data from
|
||||
the end user, speeding up file access and making it possible to access
|
||||
for example Quake3 .pk3 files, which are just renamed .zip files. By
|
||||
default Irrlicht supports ZIP, PAK, TAR, PNK, and directories as
|
||||
archives. You can provide your own archive types by implementing
|
||||
IArchiveLoader and passing an instance to addArchiveLoader.
|
||||
\param filename: Filename of the archive to add to the file system.
|
||||
\param ignoreCase: If set to true, files in the archive can be accessed without
|
||||
writing all letters in the right case.
|
||||
\param ignorePaths: If set to true, files in the added archive can be accessed
|
||||
without its complete path.
|
||||
\param archiveType: If no specific E_FILE_ARCHIVE_TYPE is selected then the type of archive will depend on
|
||||
the extension of the file name. If you use a different extension then you can use this parameter to force
|
||||
\param archiveType: If no specific E_FILE_ARCHIVE_TYPE is selected then
|
||||
the type of archive will depend on the extension of the file name. If
|
||||
you use a different extension then you can use this parameter to force
|
||||
a specific type of archive.
|
||||
\param password An optional password, which is used in case of encrypted archives.
|
||||
\return Returns true if the archive was added successfully, false if not. */
|
||||
virtual bool addFileArchive(const path& filename, bool ignoreCase=true, bool ignorePaths=true,
|
||||
E_FILE_ARCHIVE_TYPE archiveType=EFAT_UNKNOWN) =0;
|
||||
virtual bool addFileArchive(const path& filename, bool ignoreCase=true,
|
||||
bool ignorePaths=true,
|
||||
E_FILE_ARCHIVE_TYPE archiveType=EFAT_UNKNOWN,
|
||||
const core::stringc& password="") =0;
|
||||
|
||||
//! Adds an external archive loader to the engine.
|
||||
/** Use this function to add support for new archive types to the engine, for example propiatrary or
|
||||
encyrpted file storage. */
|
||||
/** Use this function to add support for new archive types to the
|
||||
engine, for example proprietary or encrypted file storage. */
|
||||
virtual void addArchiveLoader(IArchiveLoader* loader) =0;
|
||||
|
||||
//! Returns the number of archives currently attached to the file system
|
||||
|
|
|
@ -190,7 +190,8 @@ bool CFileSystem::moveFileArchive(u32 sourceIndex, s32 relative)
|
|||
|
||||
//! Adds an archive to the file system.
|
||||
bool CFileSystem::addFileArchive(const io::path& filename, bool ignoreCase,
|
||||
bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType)
|
||||
bool ignorePaths, E_FILE_ARCHIVE_TYPE archiveType,
|
||||
const core::stringc& password)
|
||||
{
|
||||
IFileArchive* archive = 0;
|
||||
bool ret = false;
|
||||
|
@ -200,7 +201,11 @@ bool CFileSystem::addFileArchive(const io::path& filename, bool ignoreCase,
|
|||
for (i = 0; i < FileArchives.size(); ++i)
|
||||
{
|
||||
if (getAbsolutePath(filename) == FileArchives[i]->getFileList()->getPath())
|
||||
{
|
||||
if (password.size())
|
||||
FileArchives[i]->Password=password;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// do we know what type it should be?
|
||||
|
@ -281,6 +286,8 @@ bool CFileSystem::addFileArchive(const io::path& filename, bool ignoreCase,
|
|||
if (archive)
|
||||
{
|
||||
FileArchives.push_back(archive);
|
||||
if (password.size())
|
||||
archive->Password=password;
|
||||
ret = true;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -46,8 +46,10 @@ public:
|
|||
virtual IWriteFile* createAndWriteFile(const io::path& filename, bool append=false);
|
||||
|
||||
//! Adds an archive to the file system.
|
||||
virtual bool addFileArchive(const io::path& filename, bool ignoreCase = true,
|
||||
bool ignorePaths = true, E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN);
|
||||
virtual bool addFileArchive(const io::path& filename,
|
||||
bool ignoreCase = true, bool ignorePaths = true,
|
||||
E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN,
|
||||
const core::stringc& password="");
|
||||
|
||||
//! move the hirarchy of the filesystem. moves sourceIndex relative up or down
|
||||
virtual bool moveFileArchive( u32 sourceIndex, s32 relative );
|
||||
|
|
|
@ -503,11 +503,10 @@ IReadFile* CZipReader::createAndOpenFile(u32 index)
|
|||
char pwVerificationFile[2];
|
||||
File->read(pwVerification, 2);
|
||||
fcrypt_ctx zctx; // the encryption context
|
||||
const char* Password="0123456789";
|
||||
int rc = fcrypt_init(
|
||||
(e.header.Sig & 0x00ff0000) >>16,
|
||||
(const unsigned char*)Password, // the password
|
||||
strlen(Password), // number of bytes in password
|
||||
(const unsigned char*)Password.c_str(), // the password
|
||||
Password.size(), // number of bytes in password
|
||||
salt, // the salt
|
||||
(unsigned char*)pwVerificationFile, // on return contains password verifier
|
||||
&zctx); // encryption context
|
||||
|
|
|
@ -231,3 +231,4 @@ namespace io
|
|||
|
||||
#endif // __IRR_COMPILE_WITH_ZIP_ARCHIVE_LOADER_
|
||||
#endif // __C_ZIP_READER_H_INCLUDED__
|
||||
|
||||
|
|
Loading…
Reference in New Issue