This commit is contained in:
parent
8acd49fe09
commit
09c376debf
@ -55,18 +55,16 @@ class NetWrapper:
|
|||||||
self.clientAddr = header['source']
|
self.clientAddr = header['source']
|
||||||
self.currentUser = header['username']
|
self.currentUser = header['username']
|
||||||
self.currentClientPublicKey = self.clientPublicKey[self.currentUser]
|
self.currentClientPublicKey = self.clientPublicKey[self.currentUser]
|
||||||
try:
|
if not self.verifyRSAHeaderSignature(b64decode(incommingJson['header']),
|
||||||
if not self.verifyRSAHeaderSignature(b64decode(incommingJson['header']),
|
b64decode(incommingJson['headersignature'])) or header[
|
||||||
b64decode(incommingJson['headersignature'])) or header[
|
'type'] != 'IDY':
|
||||||
'type'] != 'IDY':
|
|
||||||
raise Exception('Bad initial message')
|
|
||||||
except Exception:
|
|
||||||
raise Exception('Bad initial message')
|
raise Exception('Bad initial message')
|
||||||
retheader, retheadersignature = self.signRSAHeader("IDY", {})
|
retheader, retheadersignature = self.signRSAHeader("IDY", {})
|
||||||
dcryptedmsg = self.decryptRSAMessage(b64decode(incommingJson['message']))
|
dcryptedmsg = self.decryptRSAMessage(b64decode(incommingJson['message']))
|
||||||
retmsg = self.encryptRSAMessage(dcryptedmsg)
|
retmsg = self.encryptRSAMessage(dcryptedmsg)
|
||||||
identMsg = json.dumps(
|
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(
|
'message': b64encode(retmsg).decode('UTF-8')}).encode(
|
||||||
'UTF-8')
|
'UTF-8')
|
||||||
self.network.send_msg(self.clientAddr, identMsg)
|
self.network.send_msg(self.clientAddr, identMsg)
|
||||||
@ -92,7 +90,7 @@ class NetWrapper:
|
|||||||
def keyExchange(self) -> None:
|
def keyExchange(self) -> None:
|
||||||
dh = pyDH.DiffieHellman()
|
dh = pyDH.DiffieHellman()
|
||||||
mypubkey = self.encryptRSAMessage(str(dh.gen_public_key()).encode('UTF-8'))
|
mypubkey = self.encryptRSAMessage(str(dh.gen_public_key()).encode('UTF-8'))
|
||||||
header, headersignature = self.signRSAHeader("DH",{})
|
header, headersignature = self.signRSAHeader("DH", {})
|
||||||
jsonmsg = json.dumps(
|
jsonmsg = json.dumps(
|
||||||
{'header': b64encode(header).decode('UTF-8'), 'headersignature': b64encode(headersignature).decode('UTF-8'),
|
{'header': b64encode(header).decode('UTF-8'), 'headersignature': b64encode(headersignature).decode('UTF-8'),
|
||||||
'message': b64encode(mypubkey).decode('UTF-8')}).encode('UTF-8')
|
'message': b64encode(mypubkey).decode('UTF-8')}).encode('UTF-8')
|
||||||
|
Loading…
Reference in New Issue
Block a user