assert secure_auth_and_encryption(conn, name="anonymous", key=key, cipher=message.RC4) == None # Test auth failure for wrong key conn = EncryptedConnection(bithorded) secure_auth_and_encryption(conn, name="tester1", key='0'*len(key), cipher=message.RC4, validate_auth=False) try: conn.send(message.Ping(timeout=2000)) conn.expect(message.Ping) assert False, "We really should not have gotten here" except: pass # Test successful AES upstream / RC4 downstream conn = EncryptedConnection(bithorded) assert secure_auth_and_encryption(conn, name="tester1", key=key, cipher=message.AES_CTR) == 'test_server' conn.send(message.Ping(timeout=2000)) conn.expect(message.Ping) conn.close() # Test successful RC4 upstream / AES downstream conn = EncryptedConnection(bithorded) assert secure_auth_and_encryption(conn, name="tester2", key=key, cipher=message.RC4) == 'test_server' conn.send(message.Ping(timeout=2000)) conn.expect(message.Ping) conn.close() assert bithorded.is_alive()
try: conn.send(message.Ping(timeout=2000)) conn.expect(message.Ping) assert False, "We really should not have gotten here" except: pass # Test successful AES upstream / RC4 downstream conn = EncryptedConnection(bithorded) assert secure_auth_and_encryption(conn, name="tester1", key=key, cipher=message.AES_CTR) == 'test_server' conn.send(message.Ping(timeout=2000)) conn.expect(message.Ping) conn.close() # Test successful RC4 upstream / AES downstream conn = EncryptedConnection(bithorded) assert secure_auth_and_encryption(conn, name="tester2", key=key, cipher=message.RC4) == 'test_server' conn.send(message.Ping(timeout=2000)) conn.expect(message.Ping) conn.close() assert bithorded.is_alive()