Photonic firewall which can conduct the data identification and intrusion detection directly at the optical layer is a high-speed and low-energy network security equipment. For the photonic firewall, the all-optical matching system is the core part. This paper focuses on designing all-optical matching systems for high-order phase modulated optical signals. Based on the squarer, two all-optical matching systems are designed for Quadrature Phase Shift Keying (QPSK) and 8 Phase Shift Keying (8PSK) optical signals respectively. The systems mainly consist of squarers, multiplexers, AND gates and regenerators. The squarer is implemented based on the four-wave mixing (FWM) effect of highly nonlinear fiber (HNLF). The theoretical analysis and simulation verification are conducted for the proposed system. The performances of feasibility and noise impact are evaluated for the proposed system with the data rate of 100 Gbaud. The results show that the system can correctly identify and localize the target sequence with the length of 4 and 8 symbols in the data sequence with the length of 16 symbols. The impact of noise is evaluated by the extinction ratio (ER) and contrast ratio (CR). The ER of two all-optical matching systems reaches 0 dB when the optical signal-to-noise ratio (OSNR) of input optical signal is about 5.59 dB and 9.24 dB respectively. The CR of two all-optical matching systems reaches 0 dB when the OSNR of input optical signal is about 4 dB and 8.62 dB respectively.