foggyos vagyok
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Torma Kristóf 2021-04-26 17:19:36 +02:00
parent f409aefdc0
commit a8730ceac3
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047

View File

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