From 4fc32ddeeac1aa355e4f013a530ed489beffbc55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Sun, 25 Apr 2021 19:23:07 +0200 Subject: [PATCH] key --- server/netwrapper.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/netwrapper.py b/server/netwrapper.py index ad68f57..2cf84b8 100644 --- a/server/netwrapper.py +++ b/server/netwrapper.py @@ -40,7 +40,7 @@ class NetWrapper: self.network.send_msg(self.clientAddr, identMsg) def sendMessage(self, message: bytes) -> None: - cipher = ChaCha20.new(self.cipherkey, get_random_bytes(12)) + cipher = ChaCha20.new(key=self.cipherkey, nonce=get_random_bytes(12)) ciphertext = cipher.encrypt(message) nonce = b64encode(cipher.nonce).decode('ASCII') ct = b64encode(ciphertext).decode('ASCII') @@ -75,7 +75,7 @@ class NetWrapper: try: retnonce = b64decode(b64['nonce']) retciphertext = b64decode(b64['message']) - retcipher = ChaCha20.new(self.cipherkey, nonce=retnonce) + retcipher = ChaCha20.new(key=self.cipherkey, nonce=retnonce) plaintext = retcipher.decrypt(retciphertext).decode('UTF-8').split(' ') linsuccess = (not (len(plaintext) != 3 or plaintext[0] != "LIN" or plaintext[ 1] != self.currentUser)) and self.authenticationInstance.login(plaintext[1], plaintext[2]) @@ -83,7 +83,7 @@ class NetWrapper: message = "OK".encode('UTF-8') else: message = "ERROR".encode('UTF-8') - cipher = ChaCha20.new(self.cipherkey, get_random_bytes(12)) + cipher = ChaCha20.new(key=self.cipherkey, nonce=get_random_bytes(12)) ciphertext = cipher.encrypt(message) nonce = b64encode(cipher.nonce).decode('ASCII') ct = b64encode(ciphertext).decode('ASCII') @@ -139,7 +139,7 @@ class NetWrapper: b64 = json.loads(msg.decode('UTF-8')) retnonce = b64decode(b64['nonce']) retciphertext = b64decode(b64['message']) - retcipher = ChaCha20.new(self.cipherkey, nonce=retnonce) + retcipher = ChaCha20.new(key=self.cipherkey, nonce=retnonce) plaintext = retcipher.decrypt(retciphertext) return plaintext except Exception: