diff --git a/communication/client.py b/communication/client.py index c2b9c65285d3fe833506d4d9c8e58388e6831e93..ef53a9ed510360982cd35d4dfdb6213ce10fe8e9 100644 --- a/communication/client.py +++ b/communication/client.py @@ -79,7 +79,7 @@ def main(): configure_logging() # server information - host = '192.168.178.51' + host = '192.168.178.63' port = 12345 # Load RSA public key (for encrypting the key) diff --git a/communication/server.py b/communication/server.py index 2523449e6c3e8323b583039bc4204b9174d44049..4348f709670d71e79892f16e5a501fd654d2efbc 100644 --- a/communication/server.py +++ b/communication/server.py @@ -21,7 +21,7 @@ def load_private_key(): def decrypt_key_with_rsa(private_key, encrypted_key): cipher = PKCS1_OAEP.new(private_key) key = cipher.decrypt(encrypted_key) - logging.info(f"Decrypted key: {key.hex()}") + logging.info(f"Decrypted RSA key: {key.hex()}") return key # Decrypt received message using the key, depending on algorithm @@ -75,15 +75,14 @@ def handle_client(conn, addr, private_key): encrypted_key = base64.b64decode(data['encrypted_key']) encrypted_message = data['encrypted_message'] logging.info(f"Algorithm: {algorithm}, Key Length: {key_length}") - user_input(f"Received data from client {addr}: Algorithm: {algorithm}, Key Length: {key_length}, Encrypted message: {encrypted_message}") except json.JSONDecodeError as e: logging.error(f"Error decoding data: {e}") conn.close() return # Decrypt the key using RSA + logging.info(f"Decrypted RSA key from client {addr}.") key = decrypt_key_with_rsa(private_key, encrypted_key) - logging.info(f"Decrypted key from client {addr}.") # Decrypt the message using the key decrypted_message = decrypt_message(algorithm, key, encrypted_message) @@ -103,7 +102,7 @@ def main(): configure_logging() # server information - host = '192.168.178.51' + host = '192.168.178.63' port = 12345 # Load RSA private key (for decrypting the key) @@ -125,6 +124,7 @@ def main(): while True: try: conn, addr = s.accept() + logging.info("\n") logging.info(f"Connection from {addr}") handle_client(conn, addr, private_key) conn.close()