This commit is contained in:
		@@ -40,7 +40,7 @@ class NetWrapper:
 | 
				
			|||||||
        self.network.send_msg(self.clientAddr, identMsg)
 | 
					        self.network.send_msg(self.clientAddr, identMsg)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def sendMessage(self, message: bytes) -> None:
 | 
					    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)
 | 
					        ciphertext = cipher.encrypt(message)
 | 
				
			||||||
        nonce = b64encode(cipher.nonce).decode('ASCII')
 | 
					        nonce = b64encode(cipher.nonce).decode('ASCII')
 | 
				
			||||||
        ct = b64encode(ciphertext).decode('ASCII')
 | 
					        ct = b64encode(ciphertext).decode('ASCII')
 | 
				
			||||||
@@ -75,7 +75,7 @@ class NetWrapper:
 | 
				
			|||||||
        try:
 | 
					        try:
 | 
				
			||||||
            retnonce = b64decode(b64['nonce'])
 | 
					            retnonce = b64decode(b64['nonce'])
 | 
				
			||||||
            retciphertext = b64decode(b64['message'])
 | 
					            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(' ')
 | 
					            plaintext = retcipher.decrypt(retciphertext).decode('UTF-8').split(' ')
 | 
				
			||||||
            linsuccess = (not (len(plaintext) != 3 or plaintext[0] != "LIN" or plaintext[
 | 
					            linsuccess = (not (len(plaintext) != 3 or plaintext[0] != "LIN" or plaintext[
 | 
				
			||||||
                1] != self.currentUser)) and self.authenticationInstance.login(plaintext[1], plaintext[2])
 | 
					                1] != self.currentUser)) and self.authenticationInstance.login(plaintext[1], plaintext[2])
 | 
				
			||||||
@@ -83,7 +83,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')
 | 
				
			||||||
            cipher = ChaCha20.new(self.cipherkey, get_random_bytes(12))
 | 
					            cipher = ChaCha20.new(key=self.cipherkey, nonce=get_random_bytes(12))
 | 
				
			||||||
            ciphertext = cipher.encrypt(message)
 | 
					            ciphertext = cipher.encrypt(message)
 | 
				
			||||||
            nonce = b64encode(cipher.nonce).decode('ASCII')
 | 
					            nonce = b64encode(cipher.nonce).decode('ASCII')
 | 
				
			||||||
            ct = b64encode(ciphertext).decode('ASCII')
 | 
					            ct = b64encode(ciphertext).decode('ASCII')
 | 
				
			||||||
@@ -139,7 +139,7 @@ class NetWrapper:
 | 
				
			|||||||
                b64 = json.loads(msg.decode('UTF-8'))
 | 
					                b64 = json.loads(msg.decode('UTF-8'))
 | 
				
			||||||
            retnonce = b64decode(b64['nonce'])
 | 
					            retnonce = b64decode(b64['nonce'])
 | 
				
			||||||
            retciphertext = b64decode(b64['message'])
 | 
					            retciphertext = b64decode(b64['message'])
 | 
				
			||||||
            retcipher = ChaCha20.new(self.cipherkey, nonce=retnonce)
 | 
					            retcipher = ChaCha20.new(key=self.cipherkey, nonce=retnonce)
 | 
				
			||||||
            plaintext = retcipher.decrypt(retciphertext)
 | 
					            plaintext = retcipher.decrypt(retciphertext)
 | 
				
			||||||
            return plaintext
 | 
					            return plaintext
 | 
				
			||||||
        except Exception:
 | 
					        except Exception:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user