mirror of
https://github.com/kevinveenbirkenbach/splitted-secret.git
synced 2024-11-22 02:01:05 +01:00
Optimized decryption
This commit is contained in:
parent
7a7fddee81
commit
a00550e0b6
@ -22,8 +22,9 @@ python scripts/main.py --mode decrypt --master-password "ewrwerwerew" &&
|
|||||||
python scripts/main.py --mode decrypt --user "1"
|
python scripts/main.py --mode decrypt --user "1"
|
||||||
|
|
||||||
|
|
||||||
python scripts/main.py --mode cleanup --user "1" && python scripts/main.py --mode decrypt --user "1" --user-password "O3ITMWXZED9FKYQ0PB2WNVRWSCSCYVXCD00PJ6GQ4MFPIUWBVDCYSSSX9ZDBW5QU" << END_OF_INPUTS
|
python scripts/main.py --mode cleanup --file-types decrypted && python scripts/main.py --mode decrypt --user "1" --user-password "O3ITMWXZED9FKYQ0PB2WNVRWSCSCYVXCD00PJ6GQ4MFPIUWBVDCYSSSX9ZDBW5QU" << END_OF_INPUTS
|
||||||
2
|
2
|
||||||
|
YGC6FLI5FIFL4WV4JPZZI7RVOZTWLROCLY4HVGDMWWSTAIQJTLUQK1VBBY0E24PN
|
||||||
END_OF_INPUTS
|
END_OF_INPUTS
|
||||||
```
|
```
|
||||||
# Requirements to know
|
# Requirements to know
|
||||||
|
@ -84,8 +84,8 @@ class Decryption(AbstractSplittedSecret):
|
|||||||
def getPasswordShare(self):
|
def getPasswordShare(self):
|
||||||
return self.user_data['groups'][str(self.getDecryptersGroupName())]
|
return self.user_data['groups'][str(self.getDecryptersGroupName())]
|
||||||
|
|
||||||
def getNeededCoDecryptersAmount(self):
|
def getNeededDecryptersAmount(self):
|
||||||
return self.needed_decrypters_amount -1
|
return self.needed_decrypters_amount
|
||||||
|
|
||||||
def loadTxtFile(self,file_path):
|
def loadTxtFile(self,file_path):
|
||||||
return Path(file_path).read_text()
|
return Path(file_path).read_text()
|
||||||
|
@ -10,14 +10,24 @@ cleanup = Cleanup()
|
|||||||
|
|
||||||
def clean_exit():
|
def clean_exit():
|
||||||
print("Cleaning up.")
|
print("Cleaning up.")
|
||||||
cleanup.cleanupFiles(AbstractSplittedSecret.TYPE_DECRYPTED)
|
try:
|
||||||
print("Leaving program. Goodby :)")
|
cleanup.cleanupFiles(AbstractSplittedSecret.TYPE_DECRYPTED)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
print("Leaving program.")
|
||||||
exit()
|
exit()
|
||||||
pass
|
|
||||||
|
def dirty_exit():
|
||||||
|
print("ATTENTION: SECURITY RISK !!!\nPROGRAM DIDN'T CLEAN UP DECRYPTED DATA. \nDECRYPTED DATA EXISTS AND CAN BE READ BY EVERYBODY!")
|
||||||
|
print("TO REMOVE DECRYPTED DATA EXECUTE:\nmain.py --mode cleanup --file-types " + AbstractSplittedSecret.TYPE_DECRYPTED)
|
||||||
|
print("Leaving program.")
|
||||||
|
exit()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('--mode',type=str, dest='mode',required=True,choices=['cleanup','encrypt','decrypt'])
|
parser.add_argument('--mode',type=str, dest='mode',required=True,choices=['cleanup','encrypt','decrypt'])
|
||||||
|
parser.add_argument('--file-types',type=str, dest='file_types',required=False,choices=[AbstractSplittedSecret.TYPE_DECRYPTED, AbstractSplittedSecret.TYPE_ENCRYPTED])
|
||||||
parser.add_argument('--amount',type=int, dest='amount_of_secret_holders',required=False,choices=AbstractSplittedSecret.getCoSecretHoldersRange())
|
parser.add_argument('--amount',type=int, dest='amount_of_secret_holders',required=False,choices=AbstractSplittedSecret.getCoSecretHoldersRange())
|
||||||
parser.add_argument('--quota', type=int, dest='decryption_quota', choices=range(1,101),required=False)
|
parser.add_argument('--quota', type=int, dest='decryption_quota', choices=range(1,101),required=False)
|
||||||
parser.add_argument('--master-password',type=str, dest='master_password',required=False)
|
parser.add_argument('--master-password',type=str, dest='master_password',required=False)
|
||||||
@ -26,16 +36,21 @@ try:
|
|||||||
parser.add_argument('--add-user-information',type=bool, dest='add_user_information', default=False, required=False, action=argparse.BooleanOptionalAction)
|
parser.add_argument('--add-user-information',type=bool, dest='add_user_information', default=False, required=False, action=argparse.BooleanOptionalAction)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
print("Splitted Secret Interface started.")
|
print("Application started.")
|
||||||
print("Selected Mode: " + args.mode)
|
print("Selected Mode: " + args.mode)
|
||||||
|
|
||||||
if args.mode == 'cleanup':
|
if args.mode == 'cleanup':
|
||||||
if args.user is None:
|
print("Cleaning up.")
|
||||||
print("Delete all files.")
|
if args.file_types is None:
|
||||||
cleanup.deleteAll()
|
if args.user is None:
|
||||||
|
print("Deleting all encrypted and decrypted files.")
|
||||||
|
cleanup.deleteAll()
|
||||||
|
clean_exit()
|
||||||
|
print("Deleting all files which aren't related to user: " + str(args.user));
|
||||||
|
cleanup.cleanupForUser(args.user)
|
||||||
clean_exit()
|
clean_exit()
|
||||||
print("Delete files for user <<" + str(args.user) + ">>");
|
print("Deleting all " + args.file_types + " files.")
|
||||||
cleanup.cleanupForUser(args.user)
|
cleanup.cleanupFiles(args.file_types)
|
||||||
clean_exit()
|
clean_exit()
|
||||||
|
|
||||||
if args.mode == 'decrypt':
|
if args.mode == 'decrypt':
|
||||||
@ -64,22 +79,23 @@ try:
|
|||||||
except Exception as error:
|
except Exception as error:
|
||||||
print("An error occured. Propably you passed a wrong password :( The error is: " + str(error))
|
print("An error occured. Propably you passed a wrong password :( The error is: " + str(error))
|
||||||
clean_exit()
|
clean_exit()
|
||||||
print("Contact the following persons and tell them that you need help to encrypt the data: \n")
|
print("\nContact the following persons and request their password share: \n")
|
||||||
for contact_id in decrypt.user_data['contacts']:
|
for contact_id in decrypt.user_data['contacts']:
|
||||||
print("user_id: " + contact_id)
|
print("user_id: " + contact_id)
|
||||||
for label in decrypt.user_data['contacts'][contact_id]:
|
for label in decrypt.user_data['contacts'][contact_id]:
|
||||||
print(label + ": " + decrypt.user_data['contacts'][contact_id][label])
|
print(label + ": " + decrypt.user_data['contacts'][contact_id][label])
|
||||||
print()
|
|
||||||
while True:
|
while True:
|
||||||
|
print("\nReset password shares.\n")
|
||||||
decrypt.resetDecrypterIds()
|
decrypt.resetDecrypterIds()
|
||||||
try:
|
try:
|
||||||
person_counter = 1
|
password_shares_count = 1
|
||||||
while person_counter <= decrypt.getNeededCoDecryptersAmount():
|
while password_shares_count < decrypt.getNeededDecryptersAmount():
|
||||||
print("The following user id's are in the decryption list: " + str(decrypt.getDecrypterIds()))
|
print(str(password_shares_count) + " password shares had been added.")
|
||||||
print("You need at least <<" + str(decrypt.getNeededCoDecryptersAmount()) +">> other person to decrypt the secret.")
|
print("Password shares for the the users " + str(decrypt.getDecrypterIds()) + " been added. ")
|
||||||
print("Type in the user id of another encrypter:")
|
print("You need to add " + str((decrypt.getNeededDecryptersAmount()-password_shares_count)) +" more password shares.")
|
||||||
|
print("\nType in the user id of another decrypter:")
|
||||||
decrypt.addDecrypterId(int(input()))
|
decrypt.addDecrypterId(int(input()))
|
||||||
person_counter += 1
|
password_shares_count += 1
|
||||||
break
|
break
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
print("The following error occured <<" + str(error) + ">> :( \n Try again :)")
|
print("The following error occured <<" + str(error) + ">> :( \n Try again :)")
|
||||||
@ -92,9 +108,8 @@ try:
|
|||||||
decrypt.resetPasswordShare()
|
decrypt.resetPasswordShare()
|
||||||
co_decrypter_ids = decrypt.getCoDecrypterIds()
|
co_decrypter_ids = decrypt.getCoDecrypterIds()
|
||||||
for co_decrypter_id in decrypt.getCoDecrypterIds():
|
for co_decrypter_id in decrypt.getCoDecrypterIds():
|
||||||
print("Execute this script for user: " + str(co_decrypter_id) + ".")
|
print("Type in the password share for: \n")
|
||||||
print("Type in the password share.\n")
|
print("FOR PASSWORD GROUP: " + decrypt.getDecryptersGroupName())
|
||||||
print("\nFOR PASSWORD GROUP: " + decrypt.getDecryptersGroupName())
|
|
||||||
print("FOR USER: " + str(co_decrypter_id))
|
print("FOR USER: " + str(co_decrypter_id))
|
||||||
print("PASSWORD SHARE IS: ")
|
print("PASSWORD SHARE IS: ")
|
||||||
decrypt.addPasswordShare(co_decrypter_id, input())
|
decrypt.addPasswordShare(co_decrypter_id, input())
|
||||||
@ -105,7 +120,7 @@ try:
|
|||||||
break;
|
break;
|
||||||
except:
|
except:
|
||||||
print("An unexpected error occured: \n" + traceback.format_exc())
|
print("An unexpected error occured: \n" + traceback.format_exc())
|
||||||
clean_exit()
|
dirty_exit()
|
||||||
print("Decrypting accumulated file...")
|
print("Decrypting accumulated file...")
|
||||||
decrypt.setUserPassword(args.master_password)
|
decrypt.setUserPassword(args.master_password)
|
||||||
decrypt.decryptAccumulatedFile()
|
decrypt.decryptAccumulatedFile()
|
||||||
@ -128,6 +143,4 @@ try:
|
|||||||
clean_exit()
|
clean_exit()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
print("Program interrupted by user.")
|
print("Program interrupted by user.")
|
||||||
except:
|
|
||||||
print("An unexpected error occured: \n" + traceback.format_exc())
|
|
||||||
clean_exit()
|
clean_exit()
|
Loading…
Reference in New Issue
Block a user