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')