figenc

[RADIOACTIVE] rsa and symmetric key encryption scripts and executables
git clone git://git.figbert.com/figenc.git
Log | Files | Refs | README

commit d6d2c19542b4821a78b956662dfc957b3e258ea2
parent c6a003988d1aaa8db7a32673a884bf6168bc8fa6
Author: therealFIGBERT <naomi@FIGBERT-Mini.local>
Date:   Sun,  7 Jul 2019 21:42:45 -1000

Adding three additional cross-platform encryption/decryption options, updating the buttons and color theme of the MacOS script, syncronizing the graphic loading system across platforms, and other miscellanious changes

Diffstat:
MMacOS/decrypt.py | 33+++++++++++++++++++++++++++++++++
MMacOS/figENC_MacOS.py | 212++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------
MMacOS/initiate_key.py | 38+++++++++++++++++++++++++++++++++++++-
MWindows/decrypt.py | 33+++++++++++++++++++++++++++++++++
MWindows/figENC_Windows.py | 111+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------
MWindows/initiate_key.py | 37+++++++++++++++++++++++++++++++++++++
6 files changed, 421 insertions(+), 43 deletions(-)

diff --git a/MacOS/decrypt.py b/MacOS/decrypt.py @@ -37,4 +37,37 @@ def rsa_dec(target_file_raw, save_folder, passkey): with open(file_to_decrypt, 'wb') as write_file: write_file.write(original_message) with open(symmetric_key_source, 'wb') as symmetric_file: + symmetric_file.write(symmetric_key_data) + +def weak_dec(target_file_raw, save_folder): + target_file_list = target_file_raw.split(":") + if save_folder[-1] != '/': + save_folder += '/' + private_key_source = save_folder + 'private_key.pem' + symmetric_key_source = save_folder + 'symmetric_key.key' + for target_file in target_file_list: + with open(private_key_source, 'rb') as private_key_file: + private_key = serialization.load_pem_private_key( + private_key_file.read(), + password=None, + backend=default_backend() + ) + with open(symmetric_key_source, 'rb') as symmetric_key_file: + encoded_key_data = symmetric_key_file.read() + symmetric_key_data = private_key.decrypt( + encoded_key_data, + padding.OAEP( + mgf=padding.MGF1(algorithm=hashes.SHA256()), + algorithm=hashes.SHA256(), + label=None + ) + ) + symmetric_key = Fernet(symmetric_key_data) + file_to_decrypt = target_file + with open(file_to_decrypt, 'rb') as read_file: + encrypted_data = read_file.read() + original_message = symmetric_key.decrypt(encrypted_data) + with open(file_to_decrypt, 'wb') as write_file: + write_file.write(original_message) + with open(symmetric_key_source, 'wb') as symmetric_file: symmetric_file.write(symmetric_key_data) \ No newline at end of file diff --git a/MacOS/figENC_MacOS.py b/MacOS/figENC_MacOS.py @@ -1,6 +1,8 @@ from initiate_key import rsa_key +from initiate_key import weak_key from encrypt import rsa_enc from decrypt import rsa_dec +from decrypt import weak_dec import tkinter as tk from os import makedirs from os import path as Path @@ -10,130 +12,272 @@ def setup(mode): mode = mode[0] global crypto_mode if mode == 0: + file_frame.pack_forget() + file_label.pack_forget() + file_instructions.pack_forget() + file_input.pack_forget() + passcode_frame.pack_forget() passcode_label.pack_forget() passcode_instructions.pack_forget() passcode_input.pack_forget() + save.pack_forget() + save_label.pack_forget() + save_instructions.pack_forget() + save_input.pack_forget() + submit.pack_forget() + file_frame.pack(fill="both") file_label.config(text="Filepath/s to the file/s to encrypt") file_label.pack() file_instructions.pack() file_input.pack(fill='x') + passcode_frame.pack(fill="both") passcode_label.config(text="Set private key passcode") passcode_label.pack() passcode_instructions.config(text="CRITICAL: DO NOT FORGET YOUR PASSCODE.\nWITHOUT IT, YOUR DATA WILL BE LOST.") passcode_instructions.pack() passcode_input.pack(fill='x') + save.pack(fill="both") + save_label.config(text="Save location for keys") save_label.pack() + save_instructions.config(text="Save the keys to an empty folder, and store them somewhere secure\nIf other key files exist in the same folder, they will be overwritten") save_instructions.pack() save_input.pack(fill="both") submit.config(text="Encrypt file/s") - submit.pack() + submit.pack(pady="10") crypto_mode = "key_enc" elif mode == 1: + file_frame.pack_forget() + file_label.pack_forget() + file_instructions.pack_forget() + file_input.pack_forget() + passcode_frame.pack_forget() + passcode_label.pack_forget() + passcode_instructions.pack_forget() + passcode_input.pack_forget() + save.pack_forget() + save_label.pack_forget() + save_instructions.pack_forget() + save_input.pack_forget() + submit.pack_forget() + file_frame.pack(fill="both") file_label.config(text="Filepath/s to the file/s to encrypt") file_label.pack() file_instructions.pack() file_input.pack(fill='x') + save.pack(fill="both") + save_label.config(text="Save location for keys") + save_label.pack() + save_instructions.config(text="Save the keys to an empty folder, and store them somewhere secure\nIf other key files exist in the same folder, they will be overwritten") + save_instructions.pack() + save_input.pack(fill="both") + submit.config(text="Encrypt file/s") + submit.pack(pady="10") + crypto_mode = "weak_key_enc" + elif mode == 2: + file_frame.pack_forget() + file_label.pack_forget() + file_instructions.pack_forget() + file_input.pack_forget() + passcode_frame.pack_forget() passcode_label.pack_forget() passcode_instructions.pack_forget() passcode_input.pack_forget() + save.pack_forget() + save_label.pack_forget() + save_instructions.pack_forget() + save_input.pack_forget() + submit.pack_forget() + file_frame.pack(fill="both") + file_label.config(text="Filepath/s to the file/s to encrypt") + file_label.pack() + file_instructions.pack() + file_input.pack(fill='x') + save.pack(fill="both") save_label.config(text="Key location") save_label.pack() save_instructions.config(text="Filepath to matching key trio") save_instructions.pack() save_input.pack(fill="both") submit.config(text="Encrypt file/s") - submit.pack() + submit.pack(pady="10") crypto_mode = "enc" - elif mode == 2: + elif mode == 3: + file_frame.pack_forget() + file_label.pack_forget() + file_instructions.pack_forget() + file_input.pack_forget() + passcode_frame.pack_forget() passcode_label.pack_forget() passcode_instructions.pack_forget() passcode_input.pack_forget() + save.pack_forget() + save_label.pack_forget() + save_instructions.pack_forget() + save_input.pack_forget() + submit.pack_forget() + file_frame.pack(fill="both") file_label.config(text="Filepath/s to the file/s to decrypt") file_label.pack() file_instructions.pack() file_input.pack(fill='x') + passcode_frame.pack(fill="both") passcode_label.config(text="Private key passcode") passcode_label.pack() passcode_instructions.config(text="Passcode must be the same passcode used when the keys were created") passcode_instructions.pack() passcode_input.pack(fill='x') + save.pack(fill="both") + save_label.config(text="Key location") save_label.pack() - save_instructions.config(text="Location of the stored keys") + save_instructions.config(text="Filepath to matching key trio") save_instructions.pack() save_input.pack(fill="both") submit.config(text="Decrypt file/s") - submit.pack() + submit.pack(pady="10") crypto_mode = "dec" - elif mode == 3: + elif mode == 4: + file_frame.pack_forget() + file_label.pack_forget() + file_instructions.pack_forget() + file_input.pack_forget() + passcode_frame.pack_forget() passcode_label.pack_forget() passcode_instructions.pack_forget() passcode_input.pack_forget() + save.pack_forget() + save_label.pack_forget() + save_instructions.pack_forget() + save_input.pack_forget() + submit.pack_forget() + file_frame.pack(fill="both") + file_label.config(text="Filepath/s to the file/s to decrypt") + file_label.pack() + file_instructions.pack() + file_input.pack(fill='x') + save.pack(fill="both") + save_label.config(text="Key location") + save_label.pack() + save_instructions.config(text="Filepath to matching key trio") + save_instructions.pack() + save_input.pack(fill="both") + submit.config(text="Decrypt file/s") + submit.pack(pady="10") + crypto_mode = "weak_dec" + elif mode == 5: + file_frame.pack_forget() file_label.pack_forget() file_instructions.pack_forget() file_input.pack_forget() + passcode_frame.pack_forget() + passcode_label.pack_forget() + passcode_instructions.pack_forget() + passcode_input.pack_forget() + save.pack_forget() + save_label.pack_forget() + save_instructions.pack_forget() + save_input.pack_forget() + submit.pack_forget() + passcode_frame.pack(fill="both") passcode_label.config(text="Set private key passcode") passcode_label.pack() passcode_instructions.config(text="CRITICAL: DO NOT FORGET YOUR PASSCODE.\nWITHOUT IT, YOUR DATA WILL BE LOST.") passcode_instructions.pack() passcode_input.pack(fill='x') + save.pack(fill="both") + save_label.config(text="Save location for keys") save_label.pack() + save_instructions.config(text="Save the keys to an empty folder, and store them somewhere secure\nIf other key files exist in the same folder, they will be overwritten") save_instructions.pack() save_input.pack(fill="both") submit.config(text="Create keys") - submit.pack() + submit.pack(pady="10") crypto_mode = "just_key" + elif mode == 6: + file_frame.pack_forget() + file_label.pack_forget() + file_instructions.pack_forget() + file_input.pack_forget() + passcode_frame.pack_forget() + passcode_label.pack_forget() + passcode_instructions.pack_forget() + passcode_input.pack_forget() + save.pack_forget() + save_label.pack_forget() + save_instructions.pack_forget() + save_input.pack_forget() + submit.pack_forget() + save.pack(fill="both") + save_label.config(text="Save location for keys") + save_label.pack() + save_instructions.config(text="Save the keys to an empty folder, and store them somewhere secure\nIf other key files exist in the same folder, they will be overwritten") + save_instructions.pack() + save_input.pack(fill="both") + submit.config(text="Create keys") + submit.pack(pady="10") + crypto_mode = "weak_key" def go(mode, save_folder, target_file, passkey=None): if mode == "key_enc": rsa_key(passkey, save_folder) rsa_enc(target_file, save_folder) + elif mode == "weak_key_enc": + weak_key(save_folder) + rsa_enc(target_file, save_folder) elif mode == "enc": rsa_enc(target_file, save_folder) elif mode == "dec": rsa_dec(target_file, save_folder, passkey) + elif mode == "weak_dec": + weak_dec(target_file, save_folder) elif mode == "just_key": rsa_key(passkey, save_folder) + elif mode == "weak_key": + weak_key(save_folder) root = tk.Tk() root.wm_title("figENC") canvas = tk.Canvas(root, height=700, width=500) canvas.pack() -frame = tk.Frame(root, bg='white') +frame = tk.Frame(root, bg="#1A181C") frame.place(relwidth=1, relheight=1) -header = tk.Label(frame, text="figENC\nIndustry leading encryption by FIGBERT", bg="gray", fg="black", justify="center", font=("Arial", "24"), relief=tk.GROOVE) -header.pack(fill="x", side="top", ipady="5") +header = tk.Label(frame, text="figENC", justify="center", font=("Arial", "24"), bg="#643181", fg="#B494C7") +subheader = tk.Label(frame, text="Industry leading encryption by FIGBERT", justify="center", font=("Arial", "18"), bg="#643181", fg="#B494C7", pady="5") +header.pack(fill="x", side="top") +subheader.pack(fill="x", side="top") -action = tk.Frame(frame, bg="white") +action = tk.Frame(frame, bg="#1A181C", pady="5") action.pack(fill='both') -action_label = tk.Label(action, text="Action:", bg="white", justify='left', font=("Arial", "14")) +action_label = tk.Label(action, text="Action:", bg="#1A181C", fg="#ACA0B2", justify='left', font=("Arial", "14")) action_label.pack() -action_list = tk.Listbox(action, bg="white", selectmode="single", font=("Arial", "12"), height=4, bd=1, relief=tk.SUNKEN) -action_list.insert(1, "Encrypt with fresh keys") -action_list.insert(2, "Encrypt with generated keys") -action_list.insert(3, "Decrypt with generated keys") -action_list.insert(4, "Only create fresh keys") -action_list.pack(fill='both') -submit_action = tk.Button(action, text="Begin Process", font=("Arial", "12"), command=lambda: setup(action_list.curselection())) +action_list = tk.Listbox(action, bg="#1A181C", fg="#b494C7", selectbackground="#643181", selectmode="single", font=("Arial", "12"), height=7, bd=1, relief=tk.SUNKEN) +action_list.insert(1, "Encrypt with fresh keys (password locked)") +action_list.insert(2, "Encrypt with fresh keys (no password)") +action_list.insert(3, "Encrypt with generated keys") +action_list.insert(4, "Decrypt with generated keys (password locked)") +action_list.insert(5, "Decrypt with generated keys (no password)") +action_list.insert(6, "Only create fresh keys (password locked)") +action_list.insert(7, "Only create fresh keys (no password)") +action_list.pack(fill='both', pady="10") +submit_action = tk.Button(action, text="Begin Process", command=lambda: setup(action_list.curselection()), font=("Arial", "12"), fg="#643181", highlightthickness=0, highlightbackground="#1A181C", pady="3") submit_action.pack() -step_two =tk.Frame(frame, bg="white") +step_two = tk.Frame(frame, bg="#1A181C") step_two.pack(fill="both") -modifiers = tk.Frame(step_two, bg="white") -modifiers.pack(fill="both") -file_label = tk.Label(modifiers, text="If you see this, the app broke", font=("Arial", "14")) -file_instructions = tk.Label(modifiers, text="Separate filepaths with colons (:)", font=("Arial", "11")) -file_input = tk.Entry(modifiers, font=("Arial", "12"), justify=tk.CENTER, textvariable=tk.StringVar, relief=tk.SUNKEN) -passcode_label = tk.Label(modifiers, text="If you see this, the app broke", font=("Arial", "14")) -passcode_instructions = tk.Label(modifiers, text="If you see this, the app broke", font=("Arial", "11")) -passcode_input = tk.Entry(modifiers, font=("Arial", "12"), justify=tk.CENTER, textvariable=tk.StringVar, relief=tk.SUNKEN, show="*") +file_frame = tk.Frame(step_two, bg="#1A181C", pady="8") +file_label = tk.Label(file_frame, text="If you see this, the app broke", font=("Arial", "14"), bg="#1A181C", fg="#ACA0B2") +file_instructions = tk.Label(file_frame, text="Separate filepaths with colons (:)", font=("Arial", "11"), bg="#1A181C", fg="#B494C7") +file_input = tk.Entry(file_frame, font=("Arial", "12"), justify=tk.CENTER, textvariable=tk.StringVar, relief=tk.SUNKEN, bg="#1A181C", fg="#ACA0B2", borderwidth=0.5, insertbackground="#ACA0B2") +passcode_frame = tk.Frame(step_two, bg="#1A181C", pady="8") +passcode_label = tk.Label(passcode_frame, text="If you see this, the app broke", font=("Arial", "14"), bg="#1A181C", fg="#ACA0B2") +passcode_instructions = tk.Label(passcode_frame, text="If you see this, the app broke", font=("Arial", "11"), bg="#1A181C", fg="#B494C7") +passcode_input = tk.Entry(passcode_frame, font=("Arial", "12"), justify=tk.CENTER, textvariable=tk.StringVar, relief=tk.SUNKEN, show="*", bg="#1A181C", fg="#ACA0B2", borderwidth=0.5, insertbackground="#ACA0B2") -save = tk.Frame(step_two, bg='white') -save.pack(fill='both') -save_label = tk.Label(save, text="Save location for keys", font=("Arial", "14")) -save_instructions = tk.Label(save, text="Save the keys to an empty folder, and store them somewhere secure\nIf other key files exist in the same folder, they will be overwritten", font=("Arial", "11")) -save_input = tk.Entry(save, font=("Arial", "12"), justify=tk.CENTER, textvariable=tk.StringVar, relief=tk.SUNKEN) -submit = tk.Button(save, text="If you see this, the app broke", font=("Arial", "12"), command=lambda: go(mode=crypto_mode, save_folder=save_input.get(), target_file=file_input.get(), passkey=passcode_input.get())) +save = tk.Frame(step_two, bg="#1A181C", pady="8") +save_label = tk.Label(save, text="Save location for keys", font=("Arial", "14"), bg="#1A181C", fg="#ACA0B2") +save_instructions = tk.Label(save, text="If you see this, the app broke", font=("Arial", "11"), bg="#1A181C", fg="#B494C7") +save_input = tk.Entry(save, font=("Arial", "12"), justify=tk.CENTER, textvariable=tk.StringVar, relief=tk.SUNKEN, bg="#1A181C", fg="#ACA0B2", borderwidth=0.5, insertbackground="#ACA0B2") +submit = tk.Button(save, text="If you see this, the app broke", font=("Arial", "12"), command=lambda: go(mode=crypto_mode, save_folder=save_input.get(), target_file=file_input.get(), passkey=passcode_input.get()), fg="#643181", highlightthickness=0, highlightbackground="#1A181C", pady="3") root.mainloop() \ No newline at end of file diff --git a/MacOS/initiate_key.py b/MacOS/initiate_key.py @@ -17,7 +17,6 @@ def rsa_key(passkey, savefolder): ) # Generating the public key object for use decrypting the symmetric key public_key = private_key.public_key() - # Collecting user input to add a password to the private key for additional security private_key_passcode = passkey # Turning the private key object to readable text for export private_key_text = private_key.private_bytes( @@ -42,4 +41,41 @@ def rsa_key(passkey, savefolder): with open(public_key_file, 'wb') as public_file: public_file.write(public_key_text) with open(symmetric_key_file, 'wb') as symmetric_file: + symmetric_file.write(symmetric_key) + +#weak_key() generates a symmetric key as well as a public and private key +def weak_key(savefolder): + # Generating the symmetric key for use encrypting the file + symmetric_key = Fernet.generate_key() + # Generating the private key object for use encrypting the symmetric key + private_key = rsa.generate_private_key( + public_exponent=65537, + key_size=4096, + backend=default_backend() + ) + # Generating the public key object for use decrypting the symmetric key + public_key = private_key.public_key() + # Turning the private key object to readable text for export + private_key_text = private_key.private_bytes( + encoding=serialization.Encoding.PEM, + format=serialization.PrivateFormat.PKCS8, + encryption_algorithm=serialization.NoEncryption() + ) + # Turning the public key object to readable text for export + public_key_text = public_key.public_bytes( + encoding=serialization.Encoding.PEM, + format=serialization.PublicFormat.SubjectPublicKeyInfo + ) + # Checking the validity of the filepath provided + if savefolder[-1] != '/': + savefolder += '/' + # Writing the keys to their respective files + private_key_file = savefolder + 'private_key.pem' + public_key_file = savefolder + 'public_key.pem' + symmetric_key_file = savefolder + 'symmetric_key.key' + with open(private_key_file, 'wb') as private_file: + private_file.write(private_key_text) + with open(public_key_file, 'wb') as public_file: + public_file.write(public_key_text) + with open(symmetric_key_file, 'wb') as symmetric_file: symmetric_file.write(symmetric_key) \ No newline at end of file diff --git a/Windows/decrypt.py b/Windows/decrypt.py @@ -37,4 +37,37 @@ def rsa_dec(target_file_raw, save_folder, passkey): with open(file_to_decrypt, 'wb') as write_file: write_file.write(original_message) with open(symmetric_key_source, 'wb') as symmetric_file: + symmetric_file.write(symmetric_key_data) + +def weak_dec(target_file_raw, save_folder): + target_file_list = target_file_raw.split(":") + if save_folder[-1] != '/': + save_folder += '/' + private_key_source = save_folder + 'private_key.pem' + symmetric_key_source = save_folder + 'symmetric_key.key' + for target_file in target_file_list: + with open(private_key_source, 'rb') as private_key_file: + private_key = serialization.load_pem_private_key( + private_key_file.read(), + password=None, + backend=default_backend() + ) + with open(symmetric_key_source, 'rb') as symmetric_key_file: + encoded_key_data = symmetric_key_file.read() + symmetric_key_data = private_key.decrypt( + encoded_key_data, + padding.OAEP( + mgf=padding.MGF1(algorithm=hashes.SHA256()), + algorithm=hashes.SHA256(), + label=None + ) + ) + symmetric_key = Fernet(symmetric_key_data) + file_to_decrypt = target_file + with open(file_to_decrypt, 'rb') as read_file: + encrypted_data = read_file.read() + original_message = symmetric_key.decrypt(encrypted_data) + with open(file_to_decrypt, 'wb') as write_file: + write_file.write(original_message) + with open(symmetric_key_source, 'wb') as symmetric_file: symmetric_file.write(symmetric_key_data) \ No newline at end of file diff --git a/Windows/figENC_Windows.py b/Windows/figENC_Windows.py @@ -1,6 +1,8 @@ from initiate_key import rsa_key +from initiate_key import weak_key from encrypt import rsa_enc from decrypt import rsa_dec +from decrypt import weak_dec import tkinter as tk crypto_mode = "" @@ -35,6 +37,7 @@ def setup(mode): save.pack(fill="both") save_label.config(text="Save location for keys") save_label.pack() + save_instructions.config(text="Save the keys to an empty folder, and store them somewhere secure\nIf other key files exist in the same folder, they will be overwritten") save_instructions.pack() save_input.pack(fill="both") submit.config(text="Encrypt file/s") @@ -60,14 +63,43 @@ def setup(mode): file_instructions.pack() file_input.pack(fill='x') save.pack(fill="both") + save_label.config(text="Save location for keys") + save_label.pack() + save_instructions.config(text="Save the keys to an empty folder, and store them somewhere secure\nIf other key files exist in the same folder, they will be overwritten") + save_instructions.pack() + save_input.pack(fill="both") + submit.config(text="Encrypt file/s") + submit.pack(pady="10") + crypto_mode = "weak_key_enc" + elif mode == 2: + file_frame.pack_forget() + file_label.pack_forget() + file_instructions.pack_forget() + file_input.pack_forget() + passcode_frame.pack_forget() + passcode_label.pack_forget() + passcode_instructions.pack_forget() + passcode_input.pack_forget() + save.pack_forget() + save_label.pack_forget() + save_instructions.pack_forget() + save_input.pack_forget() + submit.pack_forget() + file_frame.pack(fill="both") + file_label.config(text="Filepath/s to the file/s to encrypt") + file_label.pack() + file_instructions.pack() + file_input.pack(fill='x') + save.pack(fill="both") save_label.config(text="Key location") save_label.pack() + save_instructions.config(text="Filepath to matching key trio") save_instructions.pack() save_input.pack(fill="both") submit.config(text="Encrypt file/s") submit.pack(pady="10") crypto_mode = "enc" - elif mode == 2: + elif mode == 3: file_frame.pack_forget() file_label.pack_forget() file_instructions.pack_forget() @@ -95,12 +127,41 @@ def setup(mode): save.pack(fill="both") save_label.config(text="Key location") save_label.pack() + save_instructions.config(text="Filepath to matching key trio") save_instructions.pack() save_input.pack(fill="both") submit.config(text="Decrypt file/s") submit.pack(pady="10") crypto_mode = "dec" - elif mode == 3: + elif mode == 4: + file_frame.pack_forget() + file_label.pack_forget() + file_instructions.pack_forget() + file_input.pack_forget() + passcode_frame.pack_forget() + passcode_label.pack_forget() + passcode_instructions.pack_forget() + passcode_input.pack_forget() + save.pack_forget() + save_label.pack_forget() + save_instructions.pack_forget() + save_input.pack_forget() + submit.pack_forget() + file_frame.pack(fill="both") + file_label.config(text="Filepath/s to the file/s to decrypt") + file_label.pack() + file_instructions.pack() + file_input.pack(fill='x') + save.pack(fill="both") + save_label.config(text="Key location") + save_label.pack() + save_instructions.config(text="Filepath to matching key trio") + save_instructions.pack() + save_input.pack(fill="both") + submit.config(text="Decrypt file/s") + submit.pack(pady="10") + crypto_mode = "weak_dec" + elif mode == 5: file_frame.pack_forget() file_label.pack_forget() file_instructions.pack_forget() @@ -123,22 +184,53 @@ def setup(mode): save.pack(fill="both") save_label.config(text="Save location for keys") save_label.pack() + save_instructions.config(text="Save the keys to an empty folder, and store them somewhere secure\nIf other key files exist in the same folder, they will be overwritten") save_instructions.pack() save_input.pack(fill="both") submit.config(text="Create keys") submit.pack(pady="10") crypto_mode = "just_key" + elif mode == 6: + file_frame.pack_forget() + file_label.pack_forget() + file_instructions.pack_forget() + file_input.pack_forget() + passcode_frame.pack_forget() + passcode_label.pack_forget() + passcode_instructions.pack_forget() + passcode_input.pack_forget() + save.pack_forget() + save_label.pack_forget() + save_instructions.pack_forget() + save_input.pack_forget() + submit.pack_forget() + save.pack(fill="both") + save_label.config(text="Save location for keys") + save_label.pack() + save_instructions.config(text="Save the keys to an empty folder, and store them somewhere secure\nIf other key files exist in the same folder, they will be overwritten") + save_instructions.pack() + save_input.pack(fill="both") + submit.config(text="Create keys") + submit.pack(pady="10") + crypto_mode = "weak_key" def go(mode, save_folder, target_file, passkey=None): if mode == "key_enc": rsa_key(passkey, save_folder) rsa_enc(target_file, save_folder) + elif mode == "weak_key_enc": + weak_key(save_folder) + rsa_enc(target_file, save_folder) elif mode == "enc": rsa_enc(target_file, save_folder) elif mode == "dec": rsa_dec(target_file, save_folder, passkey) + elif mode == "weak_dec": + weak_dec(target_file, save_folder) elif mode == "just_key": rsa_key(passkey, save_folder) + elif mode == "weak_key": + weak_key(save_folder) root = tk.Tk() root.wm_title("figENC") @@ -156,16 +248,19 @@ action = tk.Frame(frame, bg="#1A181C", pady="5") action.pack(fill='both') action_label = tk.Label(action, text="Action:", justify='left', font=("Arial", "14"), bg="#1A181C", fg="#ACA0B2") action_label.pack() -action_list = tk.Listbox(action, selectmode="single", font=("Arial", "12"), height=4, bd=1, relief=tk.SUNKEN, bg="#1A181C", fg="#B494C7", selectbackground="#643181") -action_list.insert(1, "Encrypt with fresh keys") -action_list.insert(2, "Encrypt with generated keys") -action_list.insert(3, "Decrypt with generated keys") -action_list.insert(4, "Only create fresh keys") +action_list = tk.Listbox(action, selectmode="single", font=("Arial", "12"), height=7, bd=1, relief=tk.SUNKEN, bg="#1A181C", fg="#B494C7", selectbackground="#643181") +action_list.insert(1, "Encrypt with fresh keys (password locked)") +action_list.insert(2, "Encrypt with fresh keys (no password)") +action_list.insert(3, "Encrypt with generated keys") +action_list.insert(4, "Decrypt with generated keys (password locked)") +action_list.insert(5, "Decrypt with generated keys (no password)") +action_list.insert(6, "Only create fresh keys (password locked)") +action_list.insert(7, "Only create fresh keys (no password)") action_list.pack(fill='both', pady="10") submit_action = tk.Button(action, text="Begin Process", font=("Arial", "12"), command=lambda: setup(action_list.curselection()), bg="#643181", fg="#B494C7") submit_action.pack() -step_two =tk.Frame(frame, bg="#1A181C") +step_two = tk.Frame(frame, bg="#1A181C") step_two.pack(fill="both") file_frame = tk.Frame(step_two, bg="#1A181C", pady="8") diff --git a/Windows/initiate_key.py b/Windows/initiate_key.py @@ -42,4 +42,41 @@ def rsa_key(passkey, savefolder): with open(public_key_file, 'wb') as public_file: public_file.write(public_key_text) with open(symmetric_key_file, 'wb') as symmetric_file: + symmetric_file.write(symmetric_key) + +#weak_key() generates a symmetric key as well as a public and private key +def weak_key(savefolder): + # Generating the symmetric key for use encrypting the file + symmetric_key = Fernet.generate_key() + # Generating the private key object for use encrypting the symmetric key + private_key = rsa.generate_private_key( + public_exponent=65537, + key_size=4096, + backend=default_backend() + ) + # Generating the public key object for use decrypting the symmetric key + public_key = private_key.public_key() + # Turning the private key object to readable text for export + private_key_text = private_key.private_bytes( + encoding=serialization.Encoding.PEM, + format=serialization.PrivateFormat.PKCS8, + encryption_algorithm=serialization.NoEncryption() + ) + # Turning the public key object to readable text for export + public_key_text = public_key.public_bytes( + encoding=serialization.Encoding.PEM, + format=serialization.PublicFormat.SubjectPublicKeyInfo + ) + # Checking the validity of the filepath provided + if savefolder[-1] != '/': + savefolder += '/' + # Writing the keys to their respective files + private_key_file = savefolder + 'private_key.pem' + public_key_file = savefolder + 'public_key.pem' + symmetric_key_file = savefolder + 'symmetric_key.key' + with open(private_key_file, 'wb') as private_file: + private_file.write(private_key_text) + with open(public_key_file, 'wb') as public_file: + public_file.write(public_key_text) + with open(symmetric_key_file, 'wb') as symmetric_file: symmetric_file.write(symmetric_key) \ No newline at end of file