Adds PCK encryption support (using script encryption key for export).
Change default encryption mode from ECB to CFB.
This commit is contained in:
@ -33,6 +33,8 @@
|
||||
|
||||
#include "core/os/file_access.h"
|
||||
|
||||
#define ENCRYPTED_HEADER_MAGIC 0x43454447
|
||||
|
||||
class FileAccessEncrypted : public FileAccess {
|
||||
public:
|
||||
enum Mode {
|
||||
@ -42,7 +44,6 @@ public:
|
||||
};
|
||||
|
||||
private:
|
||||
Mode mode = MODE_MAX;
|
||||
Vector<uint8_t> key;
|
||||
bool writing = false;
|
||||
FileAccess *file = nullptr;
|
||||
@ -51,13 +52,17 @@ private:
|
||||
Vector<uint8_t> data;
|
||||
mutable int pos = 0;
|
||||
mutable bool eofed = false;
|
||||
bool use_magic = true;
|
||||
|
||||
void _release();
|
||||
|
||||
public:
|
||||
Error open_and_parse(FileAccess *p_base, const Vector<uint8_t> &p_key, Mode p_mode);
|
||||
Error open_and_parse(FileAccess *p_base, const Vector<uint8_t> &p_key, Mode p_mode, bool p_with_magic = true);
|
||||
Error open_and_parse_password(FileAccess *p_base, const String &p_key, Mode p_mode);
|
||||
|
||||
virtual Error _open(const String &p_path, int p_mode_flags); ///< open a file
|
||||
virtual void close(); ///< close a file
|
||||
virtual void release(); ///< finish and keep base file open
|
||||
virtual bool is_open() const; ///< true when file is open
|
||||
|
||||
virtual String get_path() const; /// returns the path for the current open file
|
||||
|
||||
Reference in New Issue
Block a user