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

This commit is contained in:
Torma Kristóf 2021-04-25 19:24:52 +02:00
parent 6107ffe99d
commit a15d3e4dc7
Signed by: tormakris
GPG Key ID: DC83C4F2C41B1047

View File

@ -66,7 +66,7 @@ class NetWrapper:
def authenticate(self, password: str):
message = f"LIN {self.username} {password}".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')
@ -101,7 +101,7 @@ class NetWrapper:
def sendMessage(self, message: bytes):
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')
@ -120,7 +120,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)
return plaintext
except Exception: