From 09c376debf8c124f824f5bbfe6b04b6fa02c6ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torma=20Krist=C3=B3f?= Date: Mon, 26 Apr 2021 23:16:47 +0200 Subject: [PATCH] remove redundant try --- server/netwrapper.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/server/netwrapper.py b/server/netwrapper.py index 1fc6329..a572e31 100644 --- a/server/netwrapper.py +++ b/server/netwrapper.py @@ -55,18 +55,16 @@ class NetWrapper: self.clientAddr = header['source'] self.currentUser = header['username'] self.currentClientPublicKey = self.clientPublicKey[self.currentUser] - try: - if not self.verifyRSAHeaderSignature(b64decode(incommingJson['header']), - b64decode(incommingJson['headersignature'])) or header[ - 'type'] != 'IDY': - raise Exception('Bad initial message') - except Exception: + if not self.verifyRSAHeaderSignature(b64decode(incommingJson['header']), + b64decode(incommingJson['headersignature'])) or header[ + 'type'] != 'IDY': raise Exception('Bad initial message') retheader, retheadersignature = self.signRSAHeader("IDY", {}) dcryptedmsg = self.decryptRSAMessage(b64decode(incommingJson['message'])) retmsg = self.encryptRSAMessage(dcryptedmsg) identMsg = json.dumps( - {'header': b64encode(retheader).decode('UTF-8'), 'headersignature': b64encode(retheadersignature).decode('UTF-8'), + {'header': b64encode(retheader).decode('UTF-8'), + 'headersignature': b64encode(retheadersignature).decode('UTF-8'), 'message': b64encode(retmsg).decode('UTF-8')}).encode( 'UTF-8') self.network.send_msg(self.clientAddr, identMsg) @@ -92,7 +90,7 @@ class NetWrapper: def keyExchange(self) -> None: dh = pyDH.DiffieHellman() mypubkey = self.encryptRSAMessage(str(dh.gen_public_key()).encode('UTF-8')) - header, headersignature = self.signRSAHeader("DH",{}) + header, headersignature = self.signRSAHeader("DH", {}) jsonmsg = json.dumps( {'header': b64encode(header).decode('UTF-8'), 'headersignature': b64encode(headersignature).decode('UTF-8'), 'message': b64encode(mypubkey).decode('UTF-8')}).encode('UTF-8')