This commit is contained in:
parent
f1220dd49e
commit
904c01db47
@ -37,14 +37,14 @@ class NetWrapper:
|
||||
identMsg = json.dumps(
|
||||
{'type': 'IDY', 'source': self.network.own_addr,
|
||||
'message': b64encode(cipher.encrypt(retmsg.encode('UTF-8')))}).encode(
|
||||
'UTF-8')
|
||||
'ASCII')
|
||||
self.network.send_msg(self.clientAddr, identMsg)
|
||||
|
||||
def sendMessage(self, message: bytes) -> None:
|
||||
cipher = ChaCha20.new(self.cipherkey, get_random_bytes(12))
|
||||
ciphertext = cipher.encrypt(message)
|
||||
nonce = b64encode(cipher.nonce).decode('UTF-8')
|
||||
ct = b64encode(ciphertext).decode('UTF-8')
|
||||
nonce = b64encode(cipher.nonce).decode('ASCII')
|
||||
ct = b64encode(ciphertext).decode('ASCII')
|
||||
sendjson = json.dumps({'type': 'CMD', 'source': self.network.own_addr, 'nonce': nonce, 'message': ct}).encode(
|
||||
'UTF-8')
|
||||
self.network.send_msg(self.clientAddr, sendjson)
|
||||
@ -52,7 +52,7 @@ class NetWrapper:
|
||||
def keyExchange(self) -> None:
|
||||
dh = pyDH.DiffieHellman()
|
||||
cipher = PKCS1_OAEP.new(self.currentClientPublicKey)
|
||||
mypubkey = b64encode(cipher.encrypt(str(dh.gen_public_key()).encode('UTF-8')))
|
||||
mypubkey = b64encode(cipher.encrypt(str(dh.gen_public_key()).encode('UTF-8'))).decode('ASCII')
|
||||
jsonmsg = json.dumps({'type': 'DH', 'source': self.network.own_addr, 'message': mypubkey}).encode('UTF-8')
|
||||
self.network.send_msg(self.clientAddr, jsonmsg)
|
||||
decodedmsg = {'source': '', 'type': ''}
|
||||
@ -85,8 +85,8 @@ class NetWrapper:
|
||||
message = "ERROR".encode('UTF-8')
|
||||
cipher = ChaCha20.new(self.cipherkey, get_random_bytes(12))
|
||||
ciphertext = cipher.encrypt(message)
|
||||
nonce = b64encode(cipher.nonce).decode('UTF-8')
|
||||
ct = b64encode(ciphertext).decode('UTF-8')
|
||||
nonce = b64encode(cipher.nonce).decode('ASCII')
|
||||
ct = b64encode(ciphertext).decode('ASCII')
|
||||
sendjson = json.dumps(
|
||||
{'type': 'AUT', 'source': self.network.own_addr, 'nonce': nonce, 'message': ct}).encode(
|
||||
'UTF-8')
|
||||
|
Loading…
Reference in New Issue
Block a user