From 2b3e4932c26796e5c053f5663baa71973fe37dc0 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sat, 10 Dec 2022 20:19:26 +0100 Subject: [PATCH] In between commit implementation of main data encryption --- .gitignore | 5 ----- Readme.md | 5 ++++- data/.gitignore | 2 ++ data/decrypted/.gitignore | 1 + data/decrypted/group_files/.gitignore | 1 + data/decrypted/user_files/.gitignore | 1 + data/encrypted/group_files/.gitignore | 1 + data/encrypted/user_files/.gitignore | 1 + scripts/classes/AbstractSplittedSecret.py | 2 +- scripts/classes/Decryption.py | 6 +++++- scripts/classes/Encryption.py | 12 ++++++++---- 11 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 data/.gitignore create mode 100644 data/decrypted/.gitignore create mode 100644 data/decrypted/group_files/.gitignore create mode 100644 data/decrypted/user_files/.gitignore create mode 100644 data/encrypted/group_files/.gitignore create mode 100644 data/encrypted/user_files/.gitignore diff --git a/.gitignore b/.gitignore index e2ab9fc..ed8ebf5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1 @@ -data/decrypted/group_files/* -data/decrypted/user_files/* -data/encrypted/group_files/* -data/encrypted/user_files/* -accumulated.json* __pycache__ \ No newline at end of file diff --git a/Readme.md b/Readme.md index 73afacd..d8d7dff 100644 --- a/Readme.md +++ b/Readme.md @@ -39,6 +39,8 @@ END_OF_INPUTS ```bash pip install numpy gpg + ecryptfs-utils + ecryptfs-simple python pip ``` @@ -54,4 +56,5 @@ END_OF_INPUTS - https://wiki.ubuntuusers.de/GoCryptFS/ - https://pynative.com/python-generate-random-string/ - https://www.studimup.de/abitur/stochastik/anzahl-der-m%C3%B6glichketen-berechnen-kombinatorik/ -- https://numpy.org/doc/stable/reference/generated/numpy.base_repr.html?highlight=base_repr#numpy.base_repr \ No newline at end of file +- https://numpy.org/doc/stable/reference/generated/numpy.base_repr.html?highlight=base_repr#numpy.base_repr +- https://linuxconfig.org/how-to-create-compressed-encrypted-archives-with-tar-and-gpg \ No newline at end of file diff --git a/data/.gitignore b/data/.gitignore new file mode 100644 index 0000000..aec6b42 --- /dev/null +++ b/data/.gitignore @@ -0,0 +1,2 @@ +*.gpg +*.txt diff --git a/data/decrypted/.gitignore b/data/decrypted/.gitignore new file mode 100644 index 0000000..7274218 --- /dev/null +++ b/data/decrypted/.gitignore @@ -0,0 +1 @@ +main_data/* \ No newline at end of file diff --git a/data/decrypted/group_files/.gitignore b/data/decrypted/group_files/.gitignore new file mode 100644 index 0000000..314f02b --- /dev/null +++ b/data/decrypted/group_files/.gitignore @@ -0,0 +1 @@ +*.txt \ No newline at end of file diff --git a/data/decrypted/user_files/.gitignore b/data/decrypted/user_files/.gitignore new file mode 100644 index 0000000..94a2dd1 --- /dev/null +++ b/data/decrypted/user_files/.gitignore @@ -0,0 +1 @@ +*.json \ No newline at end of file diff --git a/data/encrypted/group_files/.gitignore b/data/encrypted/group_files/.gitignore new file mode 100644 index 0000000..3f2045d --- /dev/null +++ b/data/encrypted/group_files/.gitignore @@ -0,0 +1 @@ +*.gpg \ No newline at end of file diff --git a/data/encrypted/user_files/.gitignore b/data/encrypted/user_files/.gitignore new file mode 100644 index 0000000..3f2045d --- /dev/null +++ b/data/encrypted/user_files/.gitignore @@ -0,0 +1 @@ +*.gpg \ No newline at end of file diff --git a/scripts/classes/AbstractSplittedSecret.py b/scripts/classes/AbstractSplittedSecret.py index e8820b1..3ddb81d 100644 --- a/scripts/classes/AbstractSplittedSecret.py +++ b/scripts/classes/AbstractSplittedSecret.py @@ -4,7 +4,7 @@ class AbstractSplittedSecret(Cli): USER_PASSWORD_LENGTHS = 64 OVERALL_PASSWORD_LENGTHS = 128 - # At the moment the programm can used deal with one digit numbers. + # At the moment the programm can only deal with one digit numbers. MAXIMUM_SECRET_HOLDERS = 9 MINIMUM_SECRET_HOLDERS = 2 diff --git a/scripts/classes/Decryption.py b/scripts/classes/Decryption.py index 4feeab5..57bf58f 100644 --- a/scripts/classes/Decryption.py +++ b/scripts/classes/Decryption.py @@ -110,4 +110,8 @@ class Decryption(AbstractSplittedSecret): def decryptAccumulatedFile(self): input_file_path = self.getAccumulatedFilePath(AbstractSplittedSecret.TYPE_ENCRYPTED) output_file_path = self.getAccumulatedFilePath(AbstractSplittedSecret.TYPE_DECRYPTED) - self.decryptFile(self.user_password, input_file_path, output_file_path) \ No newline at end of file + self.decryptFile(self.user_password, input_file_path, output_file_path) + + def decryptMainData(self): + # gpg --batch --passphrase "helloworld" -d data/encrypted/main_data.tar.gz.gpg | tar -xvzf - + pass \ No newline at end of file diff --git a/scripts/classes/Encryption.py b/scripts/classes/Encryption.py index 92ef38f..6b1d01b 100644 --- a/scripts/classes/Encryption.py +++ b/scripts/classes/Encryption.py @@ -100,19 +100,23 @@ class Encryption(AbstractSplittedSecret): def encryptToJsonFile(self,data,file_path,password): self.encryptStringToFile(json.dumps(data,ensure_ascii=False), file_path, password) - def encryptUserData(self): + def encryptUserFile(self): for user_id in self.user_mapped_data: file_path=self.getUserFilePath(user_id,AbstractSplittedSecret.TYPE_ENCRYPTED) data=self.user_mapped_data[user_id] password=self.user_mapped_data[user_id]['user_password'] self.encryptToJsonFile(data,file_path,password) - def encryptAccumulatedData(self): + def encryptAccumulatedFile(self): file_path=self.getAccumulatedFilePath(AbstractSplittedSecret.TYPE_ENCRYPTED) data={"user_mapped": self.user_mapped_data, "group_mapped": self.group_mapped_data} self.encryptToJsonFile(data,file_path,self.master_password) + + def encryptMainData(self): + self.executeCommand('tar -cvzf - data/decrypted/main_data | gpg -c --batch --passphrase "' + self.master_password +'" > data/encrypted/main_data.tar.gz.gpg'); + pass def encrypt(self): - self.encryptUserData() - self.encryptAccumulatedData() + self.encryptUserFile() + self.encryptAccumulatedFile() self.encryptGroupFiles()