summaryrefslogtreecommitdiffstats
path: root/core/io/file_access_encrypted.h
diff options
context:
space:
mode:
authorbruvzg <7645683+bruvzg@users.noreply.github.com>2020-04-28 20:51:29 +0300
committerbruvzg <7645683+bruvzg@users.noreply.github.com>2020-09-05 14:53:39 +0300
commitf043eabdd84a509abf5266bb444d19af3e26b7c6 (patch)
treeb919d337e8edce9be6b1403b29b58707eee478be /core/io/file_access_encrypted.h
parent52f6ac81be14fe3f7dacb2e2b75d9bf9a668b628 (diff)
downloadredot-engine-f043eabdd84a509abf5266bb444d19af3e26b7c6.tar.gz
Adds PCK encryption support (using script encryption key for export).
Change default encryption mode from ECB to CFB.
Diffstat (limited to 'core/io/file_access_encrypted.h')
-rw-r--r--core/io/file_access_encrypted.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h
index e269c1e30c..fddc6842f3 100644
--- a/core/io/file_access_encrypted.h
+++ b/core/io/file_access_encrypted.h
@@ -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