From 23925d4b3942cb39c4ded30aab0b4a4427b82cee Mon Sep 17 00:00:00 2001 From: "DESKTOP-DPA61F8\\Benedek" Date: Sun, 18 Apr 2021 19:15:54 +0200 Subject: [PATCH] generatePrivateKeyForUser now accept the server's public key for easier testing (the output file will contain the keyphrase, client_private_key, server_public_key) --- server/authentication.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/server/authentication.py b/server/authentication.py index 7ea5125..a02e067 100644 --- a/server/authentication.py +++ b/server/authentication.py @@ -11,7 +11,6 @@ from Crypto.Protocol.KDF import bcrypt, bcrypt_check auth_logger = logging.getLogger('AUTH APPLICATION ') auth_logger.root.setLevel(logging.INFO) - class Authetication: ABSOLUTE_PATH = os.path.abspath(os.path.dirname(sys.argv[0])) HOME_DIRECTORY_LOCATION = ABSOLUTE_PATH + "\\home" @@ -71,7 +70,7 @@ class Authetication: os.mkdir(self.PRIVATE_KEY_DIRECTORY_LOCATION) - def generatePrivateKeyForUser(self, username:str, user_passphrase:str) -> bool: + def generatePrivateKeyForUser(self, username:str, user_passphrase:str, public_server_key='') -> bool: if self.checkUserExists(username): with open(self.CONFIG_DIRECTORY_LOCATION + '\\config.txt') as json_file: data = json.load(json_file) @@ -82,7 +81,7 @@ class Authetication: public_key_value = str(public_key.export_key('DER', pkcs=8)) ##Save private key in separate file - user_privatekey = {'passphrase': user_passphrase, 'privateKey': private_key_value} + user_privatekey = {'passphrase': user_passphrase, 'privateClientKey': private_key_value, 'publicServerKey': public_server_key} with open(self.PRIVATE_KEY_DIRECTORY_LOCATION + '\\' + str(data['index']) + '.txt', 'w+') as outfile: json.dump(user_privatekey, outfile) @@ -93,7 +92,6 @@ class Authetication: with open(self.CONFIG_DIRECTORY_LOCATION + '\\config.txt', 'w') as outfile: json.dump(data, outfile) break - return True else: return False