key
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Torma Kristóf 2021-04-25 19:23:07 +02:00
parent 45bab9c9f3
commit 4fc32ddeea
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047
1 changed files with 4 additions and 4 deletions

View File

@ -40,7 +40,7 @@ class NetWrapper:
self.network.send_msg(self.clientAddr, identMsg)
def sendMessage(self, message: bytes) -> None:
cipher = ChaCha20.new(self.cipherkey, get_random_bytes(12))
cipher = ChaCha20.new(key=self.cipherkey, nonce=get_random_bytes(12))
ciphertext = cipher.encrypt(message)
nonce = b64encode(cipher.nonce).decode('ASCII')
ct = b64encode(ciphertext).decode('ASCII')
@ -75,7 +75,7 @@ class NetWrapper:
try:
retnonce = b64decode(b64['nonce'])
retciphertext = b64decode(b64['message'])
retcipher = ChaCha20.new(self.cipherkey, nonce=retnonce)
retcipher = ChaCha20.new(key=self.cipherkey, nonce=retnonce)
plaintext = retcipher.decrypt(retciphertext).decode('UTF-8').split(' ')
linsuccess = (not (len(plaintext) != 3 or plaintext[0] != "LIN" or plaintext[
1] != self.currentUser)) and self.authenticationInstance.login(plaintext[1], plaintext[2])
@ -83,7 +83,7 @@ class NetWrapper:
message = "OK".encode('UTF-8')
else:
message = "ERROR".encode('UTF-8')
cipher = ChaCha20.new(self.cipherkey, get_random_bytes(12))
cipher = ChaCha20.new(key=self.cipherkey, nonce=get_random_bytes(12))
ciphertext = cipher.encrypt(message)
nonce = b64encode(cipher.nonce).decode('ASCII')
ct = b64encode(ciphertext).decode('ASCII')
@ -139,7 +139,7 @@ class NetWrapper:
b64 = json.loads(msg.decode('UTF-8'))
retnonce = b64decode(b64['nonce'])
retciphertext = b64decode(b64['message'])
retcipher = ChaCha20.new(self.cipherkey, nonce=retnonce)
retcipher = ChaCha20.new(key=self.cipherkey, nonce=retnonce)
plaintext = retcipher.decrypt(retciphertext)
return plaintext
except Exception: