Compare commits

..

No commits in common. "07ba9b21640d1f12b9c0796dda72da0c52252509" and "42a5b93d67c77802deb864c67e5bed4551aff8c0" have entirely different histories.

3 changed files with 11 additions and 25 deletions

View File

@ -71,3 +71,7 @@ To encrypt the master-password file and to create the neccessary encrypted meta
```bash ```bash
python scripts/main.py --secret-holders-amount "<<amount>>" --quota "<<quota>>" --mode encrypt --add-user-information --master-password "<<master_password>>" --create-meta-data python scripts/main.py --secret-holders-amount "<<amount>>" --quota "<<quota>>" --mode encrypt --add-user-information --master-password "<<master_password>>" --create-meta-data
``` ```
## todo
- add data-input attribut
- add data-output attribut

View File

@ -1 +0,0 @@
*.json.pgp

View File

@ -120,33 +120,16 @@ class Encryption():
data=self.user_mapped_data[user_id] data=self.user_mapped_data[user_id]
password=self.user_mapped_data[user_id]['user_password'] password=self.user_mapped_data[user_id]['user_password']
self.encryptToJsonFile(data,file_path,password) self.encryptToJsonFile(data,file_path,password)
'''
This saving as decrypted file is necessary due to the reason that the shell can't deal with unlimited string length.
See: https://stackoverflow.com/questions/30650841/why-am-i-getting-errno-7-argument-list-too-long-and-oserror-errno-24-too-ma
'''
def encryptFileToFile(self,input_file,output_file,password):
self.cli.executeCommand('cat \'' + input_file + '\' | gpg --symmetric --armor --batch --passphrase "' + password + '" -o "' + output_file + '"')
def deleteDecryptedAccumulatedFile(self):
self.cli.executeCommand('rm ' + self.paths.getAccumulatedFilePath(Paths.TYPE_DECRYPTED))
def saveDecryptedAccumulatedFile(self):
file_path=self.paths.getAccumulatedFilePath(Paths.TYPE_DECRYPTED)
data={"user_mapped": self.user_mapped_data, "group_mapped": self.group_mapped_data}
with open(file_path, 'w') as file:
json.dump(data, file)
def encryptAccumulatedFile(self): def encryptAccumulatedFile(self):
self.saveDecryptedAccumulatedFile() file_path=self.paths.getAccumulatedFilePath(Paths.TYPE_ENCRYPTED)
encrypted_file_path=self.paths.getAccumulatedFilePath(Paths.TYPE_ENCRYPTED) data={"user_mapped": self.user_mapped_data, "group_mapped": self.group_mapped_data}
decrypted_file_path=self.paths.getAccumulatedFilePath(Paths.TYPE_DECRYPTED) self.encryptToJsonFile(data,file_path,self.master_password)
self.encryptFileToFile(decrypted_file_path,encrypted_file_path,self.master_password)
self.deleteDecryptedAccumulatedFile()
def encryptMainData(self,input_directory): def encryptMainData(self,input_directory):
self.cli.executeCommand('tar -C"' + input_directory + '" -cvzf - ./ | gpg -c --batch --passphrase "' + self.master_password +'" > "' + self.paths.getEncryptedMainDataFile() + '"') self.cli.executeCommand('tar -C"' + input_directory + '" -cvzf - ./ | gpg -c --batch --passphrase "' + self.master_password +'" > "' + self.paths.getEncryptedMainDataFile() + '"')
def encryptMetaData(self): def encryptMetaData(self):
self.encryptUserFile() self.encryptUserFile()
self.encryptGroupFiles()
self.encryptAccumulatedFile() self.encryptAccumulatedFile()
self.encryptGroupFiles()