This commit is contained in:
parent
f409aefdc0
commit
a8730ceac3
@ -49,7 +49,8 @@ class NetWrapper:
|
|||||||
nonce = b64encode(cipher.nonce).decode('UTF-8')
|
nonce = b64encode(cipher.nonce).decode('UTF-8')
|
||||||
ct = b64encode(ciphertext).decode('UTF-8')
|
ct = b64encode(ciphertext).decode('UTF-8')
|
||||||
b64tag = b64encode(tag).decode('UTF-8')
|
b64tag = b64encode(tag).decode('UTF-8')
|
||||||
sendjson = json.dumps({'header': b64encode(header).decode('UTF-8'), 'nonce': nonce, 'message': ct, 'tag': b64tag}).encode(
|
sendjson = json.dumps(
|
||||||
|
{'header': b64encode(header).decode('UTF-8'), 'nonce': nonce, 'message': ct, 'tag': b64tag}).encode(
|
||||||
'UTF-8')
|
'UTF-8')
|
||||||
self.network.send_msg(self.clientAddr, sendjson)
|
self.network.send_msg(self.clientAddr, sendjson)
|
||||||
|
|
||||||
@ -94,7 +95,7 @@ class NetWrapper:
|
|||||||
message = "OK".encode('UTF-8')
|
message = "OK".encode('UTF-8')
|
||||||
else:
|
else:
|
||||||
message = "ERROR".encode('UTF-8')
|
message = "ERROR".encode('UTF-8')
|
||||||
header = json.dumps({'source': self.network.own_addr, 'type': 'CMD'}).encode('UTF-8')
|
header = json.dumps({'source': self.network.own_addr, 'type': 'AUT'}).encode('UTF-8')
|
||||||
cipher = ChaCha20_Poly1305.new(key=self.cipherkey)
|
cipher = ChaCha20_Poly1305.new(key=self.cipherkey)
|
||||||
cipher.update(header)
|
cipher.update(header)
|
||||||
ciphertext, tag = cipher.encrypt_and_digest(message)
|
ciphertext, tag = cipher.encrypt_and_digest(message)
|
||||||
|
Loading…
Reference in New Issue
Block a user