def test_set_ctr_mode(): packet.SafePacket.encryption_mode = None packet.set_ctr_mode() assert packet.SafePacket.encryption_mode == packet.CTR_MODE packet.SafePacket.encryption_mode = None packet.set_packet_encryption_mode(packet.CTR_MODE) assert packet.SafePacket.encryption_mode == packet.CTR_MODE
def test_safe_packet(): packet.set_packet_encryption_key("key") for mode in [packet.CBC_MODE, packet.CTR_MODE]: packet.set_packet_encryption_mode(mode) packet1 = ASTTestSafePacket() packet2 = ASTTestSafePacket() # Modify values modify_ast_test_packet(packet1) dump = packet1.dumps() for key in packet1.__dict__.keys(): assert key.encode() not in dump assert is_encrypted(dump) packet2.loads(dump) check_ast_test_packet(packet1, packet2)