A bit replacement method, replacement circuit and system
By simplifying the bit permutation method and circuit structure, combining bit decimation and insertion operations, the problems of large resource occupation and low operation efficiency are solved, efficient bit permutation operations are achieved, and the operation speed and frequency of the cryptographic algorithm chip are improved.
Patent Information
- Application Number
- CN202411238240.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-05
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-09-05
AI Technical Summary
The existing bit permutation operation has problems such as large resource occupation, complex structure and low operating efficiency in the cryptographic algorithm chip, especially the inability to effectively combine bit decimation and insertion operations, and the multi-stage permutation parameter generation circuit leads to a long critical path.
By using a bit permutation method, by obtaining control permutation sequence and operation type, using 2-select 1 MUX circuit and feedback network to directly select valid data, simplifying the circuit structure, removing multi-level MUX selectors, reducing resource usage, and automatically through feedback network Adjust cycle time and optimize circuit operation efficiency.
It realizes efficient operation of bit substitution, reduces circuit area and resource consumption, improves the working frequency and operation speed of the cryptographic algorithm chip, and reduces the memory storage requirements for exchange parameters.
Smart Images

Figure CN118764176B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of information security technology, and in particular to a bit replacement method, replacement circuit and system. Background Art
[0002] At present, with the development of modern artificial intelligence and social informatization, people have a growing consensus on the need to ensure information security for important data. The application scenarios of information security technology have also gradually expanded from traditional military and political fields to the civilian field of society. In the information security system, the use of cryptographic algorithms such as sequence ciphers to encrypt data is an important means to ensure information security. Among them, permutation operations such as bit extraction and insertion provide functions such as bit diffusion and confusion of data bit strings, becoming an indispensable supporting technology. In addition, in the process of implementing cryptographic algorithm chips, the low-area implementation and fast operation of bit permutation operations are of great significance to improving the resource utilization and performance of chips.
[0003] At present, different types of permutation networks are often used to implement bit permutation operations. The main permutation networks include Butterfly networks for bit insertion operations, Inverse-Butterfly networks for bit extraction operations, GRP networks and BENES networks that combine the two operations, etc. For Butterfly networks and Inverse-Butterfly networks, they are only applicable to a single permutation operation, and it is impossible to combine bit extraction and insertion operations into the same hardware. Different operations require different networks to be designed; for GRP networks and BENES networks, bit extraction operations can be combined with bit insertion operations, but the implementation is complex in structure, large in circuit area, and consumes a lot of resources. At the same time, the various existing optimization methods still need to generate parameter generation circuits for different multi-level permutation parameters for different networks. The critical path is long, which will inevitably restrict the operation efficiency of the circuit. Summary of the invention
[0004] In order to reduce the occupation of on-chip resources and improve the operating efficiency of the circuit, the present application provides a bit replacement method, replacement circuit and system.
[0005] In a first aspect, the present application provides a bit replacement method, which adopts the following technical solution:
[0006] A bit replacement method comprises the following steps:
[0007] Get: determine the substitution rule, get the control substitution sequence PARAM and substitution operation type TYPE;
[0008] Data input: input the data to be operated DATA, control substitution sequence PARAM and substitution operation type TYPE into the substitution circuit;
[0009] Replacement execution: start the replacement circuit and perform periodic replacement circuit feedback action;
[0010] Operation type judgment: judge the replacement operation type TYPE and activate the response result output enable;
[0011] Result output: After the replacement action is completed, according to the input replacement operation type TYPE type, through the 2-to-1 MUX circuit, the replacement result PEX_DATA is extracted or the replacement result PDEP_DATA is inserted for output.
[0012] By adopting the above technical solution, according to the substitution rule, the control substitution sequence and the substitution operation type are obtained, and then the control substitution sequence, the substitution operation type and the data to be operated are input into the substitution circuit, and the periodic circuit feedback action is performed according to the control substitution sequence, and the corresponding result output enable is activated according to the operation type, and then the extraction substitution result or the insertion substitution result is output; through the above settings, the traditional large-scale substitution network is abandoned, and the multi-level and large number of MUX selectors are removed, which greatly reduces the circuit area and reduces the occupation of on-chip resources; there is no need to add a substitution parameter generation circuit, and the effective data selection is directly performed according to the feedback network and the corresponding data in the input data is locked through the register through the selector, shortening the critical path, which can increase the operating frequency of the cryptographic algorithm chip and make the chip run faster; reduce the large consumption of hardware resources, reduce the storage of a large number of exchange parameters in the memory, and optimize and improve the operation efficiency of the circuit.
[0013] Optionally, in the replacement execution step, a feedback circuit action of M cycles is performed according to the number M of valid information in the control replacement sequence PARAM.
[0014] By adopting the above technical solution, by obtaining the effective information quantity in the control replacement sequence, performing the circuit action of the effective information quantity cycle, and automatically adjusting the completion cycle time, the shortcomings of the traditional replacement circuit such as the waste of circuit area resources and the aggravation of circuit delay caused by the use of invalid information are optimized.
[0015] Optionally, it also includes obtaining the replacement data bit width and selecting the operation data bit width N; a circuit generation step is also provided between the obtaining step and the data input step;
[0016] Circuit generation: Generate a new permutation circuit based on the operation data bit width N.
[0017] By adopting the above technical solution, the replacement circuit is optimized according to different data bit widths, so as to adapt to the processing of data with different bit widths and improve applicability. Moreover, the replacement circuits with different bit widths occupy a certain on-chip area, which can reduce resource occupation.
[0018] In a second aspect, the present application provides a replacement circuit, which adopts the following technical solution:
[0019] A replacement circuit comprises: a main circuit and a first output circuit, wherein the main circuit comprises:
[0020] The first data selector, the input end is used to input the control replacement sequence PARAM data signal and the feedback signal ;
[0021] a trigger, electrically connected to the output terminal of the first data selector, and configured to receive a data signal output by the first data selector;
[0022] The first NOT gate has an input end connected to the output end of the trigger, and is used to receive the data signal output by the trigger and control the permutation sequence. The data signal is inverted to obtain Data signal;
[0023] The adder has an input terminal electrically connected to the output terminal of the first NOT gate, and is used to receive the output of the first NOT gate. Data signal, and perform +1 operation to obtain Data signal, then find 1 from low bit to high bit to obtain selection information;
[0024] The first output circuit is electrically connected to the output terminal of the adder and is used to receive the selection information output by the adder and then output the selection information to the input terminal according to the selection information. Extract data at corresponding positions in the data to obtain output data ;
[0025] A second NOT gate is connected to the output end of the adder, and is used to receive the selection information output by the adder, identify the selection information, and filter out invalid information;
[0026] An AND gate is connected to the output end of the second NOT gate and the output end of the trigger, and the output end is connected to the input end of the first data selector, and is used to perform AND operation on the selection information filtered by the second NOT gate and the data signal output by the trigger, and output a feedback signal , used to input a feedback signal to the first data selector .
[0027] By adopting the above technical solution, the control permutation sequence data is input into the first data selector, and the output data signal enters the trigger after selection. The data signal passing through the trigger enters the first NOT gate and the AND gate. After the permutation sequence data is inverted through the first NOT gate, it enters the adder, and the adder adds 1 to output data. According to the position of 1, it enters the first output circuit for extraction. The data passing through the trigger and the data passing through the adder output feedback data through the AND gate and enters the first data selector. After periodic execution, the first 1 is found in sequence from low bit to high bit, and the extraction and permutation or insertion and permutation of a single data is completed. Through the above circuit structure, bit permutation is realized, and the above circuit structure is simple. According to the feedback network, effective data selection is directly performed, and the corresponding data in the input data is locked through the register through the selector, and the critical path is shortened, so that the working frequency of the cryptographic algorithm chip can be increased, and the chip runs faster; the large consumption of hardware resources is reduced, the storage of a large number of exchange parameters in the memory is reduced, and the operation speed of the circuit is optimized and improved; and compared with the traditional network, the circuit occupies less on-chip resources, so that the chip operation efficiency is improved.
[0028] Optionally, the second output circuit is electrically connected to the output terminal of the adder, and is used to receive the selection information, and then output the selection information to the input Insert the data at the corresponding position in the data to obtain the output data .
[0029] By adopting the above technical scheme, the control replacement sequence data is input into the first data selector, and the output data signal enters the trigger after selection. The data signal passing through the trigger enters the first NOT gate and the AND gate. After the replacement sequence data is inverted through the first NOT gate, it enters the adder, and the adder adds 1 to output data. According to the position of 1, it enters the second output end circuit for insertion. The data passing through the trigger and the data passing through the adder are fed back through the AND gate output data and enter the first data selector. After periodic execution, the first 1 is found in sequence from low bit to high bit, and the extraction replacement or insertion replacement of a single data is completed. Through the above circuit, the method can complete the two replacement actions of extraction and insertion, and there is no need to set up two replacement networks separately, so that the circuit can realize extraction and insertion at the same time, reduce the large consumption of hardware resources, reduce the storage of a large number of exchange parameters in the memory, and optimize and improve the operation speed of the circuit.
[0030] Optionally, the first data selector is a 2-to-1 data selector.
[0031] By adopting the above technical solution, through a 2-to-1 data selector, the increase in data selection parameters is reduced, the number of operations is reduced, the circuit area is reduced, and resource consumption is reduced.
[0032] In a third aspect, the present application provides a replacement system, which adopts the following technical solution:
[0033] A replacement system, comprising the following modules:
[0034] Acquisition module: According to the cryptographic algorithm, obtain the determined substitution rules and obtain the control substitution sequence and permutation operation types ;
[0035] Data input module: The input end is connected to the output end of the acquisition module, which is used to obtain the control permutation sequence , permutation operation type And the data to be operated Input to the permutation circuit;
[0036] Permutation execution module: The input end is connected to the output end of the data input module and is used to control the permutation sequence The effective information in the circuit is used to perform periodic feedback circuit actions;
[0037] Operation type judgment module: The input end is connected to the output end of the acquisition module to judge the type of replacement operation , activate the corresponding result output enable;
[0038] Result output module: The input end is connected to the output end of the replacement execution module and the output end of the operation type judgment module, and is used to output the corresponding insertion or extraction result according to the replacement operation type.
[0039] By adopting the above technical solution, the acquisition module determines the replacement rule according to the cryptographic algorithm, obtains the control replacement sequence and the replacement operation type, and then starts the replacement circuit through the data input module and the replacement execution module to perform the replacement, and then the operation type judgment module judges the output type, and the control result output module outputs the corresponding result; through the processing of the above multiple modules, the replacement within multiple cycles is completed, the data replacement operation is completed, and the replacement rate is improved.
[0040] Optionally, a circuit generation module is also included;
[0041] Circuit generation module: The input end is connected to the output end of the acquisition module and is used to generate a new replacement circuit according to the data bit width.
[0042] By adopting the above technical solution, the replacement circuit is optimized to generate a row replacement circuit according to the data bit width obtained by the acquisition module, which is suitable for replacement of various data bit widths.
[0043] In summary, the present application includes at least one of the following beneficial technical effects:
[0044] 1. Abandon the traditional large-scale permutation network, remove the multi-level and large number of MUX selectors, greatly reduce the circuit area, and reduce the occupation of on-chip resources; there is no need to add a permutation parameter generation circuit, directly select effective data according to the feedback network and lock the corresponding data in the input data through the register through the selector, shorten the critical path, and increase the operating frequency of the cryptographic algorithm chip, so that the chip runs faster; reduce the large consumption of hardware resources, reduce the storage of a large number of exchange parameters in the memory, and optimize and improve the operation speed of the circuit;
[0045] 2. The circuit structure is simple. It directly selects valid data according to the feedback network and locks the corresponding data in the input data through the register through the selector, shortening the critical path, which can increase the working frequency of the cryptographic algorithm chip and make the chip run faster; it reduces the consumption of hardware resources, reduces the storage of a large number of exchange parameters in the memory, and optimizes and improves the running speed of the circuit;
[0046] 3. The acquisition module determines the replacement rule according to the cryptographic algorithm, obtains the control replacement sequence and replacement operation type, and then starts the replacement circuit through the data input module and the replacement execution module to perform the replacement, and then determines the output type through the operation type judgment module, and controls the result output module to output the corresponding result; through the processing of the above multiple modules, the replacement within multiple cycles is completed, and the data replacement operation is completed. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 is a flowchart of a bit replacement method in an embodiment of the present application;
[0048] Figure 2 is a schematic diagram of a replacement circuit in an embodiment of the present application;
[0049] Figure 3 This is a schematic diagram of the operation of extraction and replacement in an embodiment of the present application;
[0050] Figure 4 is a circuit diagram of an extraction replacement circuit in an embodiment of the present application;
[0051] Figure 5 is a schematic diagram of the operation of inserting and replacing in an embodiment of the present application;
[0052] Figure 6 is a circuit diagram of an insertion replacement circuit in an embodiment of the present application;
[0053] Figure 7 is a system diagram of the replacement system in an embodiment of the present application.
[0054] Reference numerals: 110, first data selector; 120, flip-flop; 130, first NOT gate; 140, adder; 150, second NOT gate; 160, AND gate. DETAILED DESCRIPTION
[0055] The following combination Figures 1 to 7 This application is described in further detail.
[0056] This embodiment discloses a bit replacement method.
[0057] Reference Figure 1 , a bit replacement method, comprising the following steps:
[0058] Get: Determine the substitution rules and obtain the control substitution sequence and permutation operation types , obtain the replacement data bit width, and select the operation data bit width N;
[0059] Specifically, according to the substitution rule of the cryptographic algorithm, a control substitution sequence and a substitution operation type are obtained, and then the operation data bit width is selected according to the data bit width;
[0060] Circuit generation: Generate a new permutation circuit based on the operation data bit width N;
[0061] Specifically, according to the operating data bit width N, the main circuit is updated to form a new replacement circuit. The operating bit width of the new replacement circuit is adapted to the operating data bit width, reducing the calculation complexity and improving the circuit operation speed. The hardware part of the circuit relies on the original hardware, and each circuit element remains original. The operation accuracy is updated to enable it to process data with a larger bit width, and the number of operation cycles of the replacement circuit is updated.
[0062] Data input: The data to be operated , control the permutation sequence and permutation operation types Input permutation circuit;
[0063] Replacement execution: Start the replacement circuit and control the replacement sequence The effective information quantity M in the circuit is M cycles of feedback circuit operation;
[0064] Specifically, according to the control substitution sequence The effective information number M in the permutation sequence is used to make the circuit perform periodic actions and provide signal feedback. By identifying the effective information number in the control permutation sequence, periodic actions are performed to reduce the occupation of invalid information on the circuit operation, improve the circuit operation efficiency, and reduce unnecessary circuit operation.
[0065] Operation type judgment: judge the replacement operation type , activate the response result output enable;
[0066] Result output: After the replacement action is completed, according to the input replacement operation type TYPE type, through the 2-to-1 MUX circuit, select the replacement result Or insert the permutation result Output.
[0067] The implementation principle of a bit replacement method in the embodiment of the present application is: by obtaining a replacement rule, obtaining a control replacement sequence and permutation operation types , obtain the replacement data bit width, select the operation data bit width N, and then generate the replacement circuit according to the operation data bit width N, and then replace the data to be operated , control the permutation sequence and permutation operation types Input replacement circuit, start replacement circuit, according to the control replacement sequence The number of valid information in M is M, and the permutation circuit feedback action of M cycles is performed to control the permutation sequence Search for "1" from low bit to high bit to form selection information, and then treat the operation data according to the operation type and selection information. Perform replacement actions and output the corresponding results.
[0068] This embodiment also discloses a replacement circuit.
[0069] Reference Figure 2 , a replacement circuit, comprising: a main circuit, a first output circuit and a second output circuit, wherein the main circuit comprises:
[0070] The first data selector 110, the input terminal is used to input the control permutation sequence Data signal and feedback signal ;
[0071] Specifically, the first data selector 110 may be an N-to-1 data selector, and in this example, a 2-to-1 data selector is preferred.
[0072] A trigger 120, electrically connected to an output terminal of the first data selector 110, for receiving a data signal output by the first data selector 110;
[0073] The first NOT gate 130 has an input terminal connected to the output terminal of the trigger 120, and is used to receive the data signal output by the trigger 120 and control the permutation sequence. The data signal is inverted to obtain Data signal;
[0074] The adder 140 has an input terminal electrically connected to the output terminal of the first NOT gate 130, and is used to receive the output of the first NOT gate 130. Data signal, and perform +1 operation to obtain Data signal, then find 1 from low bit to high bit to obtain selection information;
[0075] The first output circuit is a PEX output circuit, which is electrically connected to the output terminal of the adder 140 and is used to receive the selection information output by the adder 140 and then output the selection information to the input terminal according to the selection information. Extract data at corresponding positions in the data to obtain output data ;
[0076] The second output circuit is The output circuit is electrically connected to the output terminal of the adder 140 and is used to receive the selection information and then output the selection information to the input Insert the data at the corresponding position in the data to obtain the output data ;
[0077] Specifically, the first output circuit includes a second data selector, the input end of the second data selector receives the input signal of the data to be operated and is connected to the output end of the adder 140, extracts the data to be operated according to the extraction position of the control sequence output by the adder 140, and the output end is connected to a register for outputting the selection result to the corresponding register to form the output data. ;
[0078] The second output circuit includes a third data selector, the input end of the third data selector receives the input signal of the data to be operated and is connected to the output end of the adder 140, and performs an insertion operation on the data to be operated according to the insertion position of the control sequence output by the adder 140. The output end is connected to and exists, and is used to output the selection result to the corresponding register to form the output data .
[0079] The second NOT gate 150 is connected to the output end of the adder 140, and is used to receive the selection information output by the adder 140, identify the selection information, and filter out invalid information;
[0080] The AND gate 160 is connected to the output end of the second NOT gate 150 and the output end of the trigger 120, and the output end is connected to the input end of the first data selector 110, and is used to perform AND operation on the selection information filtered by the second NOT gate 150 and the data signal output by the trigger 120, and output a feedback signal , used to input a feedback signal to the first data selector 110 .
[0081] Specifically, when the adder 140 is connected only to the first output circuit, the extraction replacement circuit is referred to as Figure 3 and Figure 4, the extraction and replacement operation is to control the sequence The original data corresponding to the valid bits in the output data are extracted one by one and placed in order from low bit to high bit ( Figure 3 (from left to right) position.
[0082] Traditional extraction and replacement circuits use a large Inverse-Butterfly network, in which the idea is to exchange data at different positions in sequence, divide them into different exchange layers, and generate exchange parameters for different exchange layers according to the control sequence PARAM.
[0083] Reference Figure 4 , the actual operation idea of the extraction replacement circuit is given as an example: the idea of this method is to control the sequence The valid information in the data, that is, the bit that is "1", is searched from the low bit to the high bit in turn for the first "1". In the process of searching for "1", a feedback data signal is generated. , return to the first data selector again, and then find "1" again, according to The number of valid information in the signal, complete the circuit action of the corresponding cycle, and then according to the position of "1", the corresponding data to be replaced Extract and get the final output data.
[0084] For the key core problem of finding "1", the following theoretical analysis is given:
[0085] Assume that the input control sequence data is:
[0086] ;
[0087] If you want to get the lowest bit "1", you need to mask out the invalid bits in other positions and only highlight the lowest bit "1" position, so the control sequence data After negation, we get the negation for:
[0088] ;
[0089] Will To perform the operation, you can traverse from the low bit to the high bit until you invert the permutation data. When "0" is encountered in the transmission, the transmission stops, that is, the control sequence data The "1" bit in the FET stops the conduction.
[0090] at this time, The lowest bit is "1" in The lowest bit "1" in the part, and the two can only output the expected result, ;
[0091] After getting the result, you can invert the "1" result and add it to the control sequence data. AND, remove the lowest bit "1", and then repeat the above operation to get the second lowest bit "1", ..., until the All "1"s are found, and after each 1 is found, the operation data is treated Perform corresponding extraction and complete the extraction operation.
[0092] Since the extraction and replacement operation is to replace the data The bit is output according to the valid bit in the control information, so a many-to-one selection circuit is used to select the sequence data to be controlled. Each bit is used as input, and the "1" result is taken as selection information, and then the operation data is treated according to the selection information. Make a selection and output the selection result to the corresponding register.
[0093] when After the "1" is extracted, the final extraction and replacement operation result is obtained. .
[0094] When the adder 140 is connected only to the second output circuit, in order to insert the replacement circuit, refer to Figure 5 and Figure 6 The insertion replacement operation is to put the original data from low bit to high bit in turn into the control parameter In the position corresponding to the valid bit.
[0095] This method is the same as the extraction and replacement PEX, and the control parameters are obtained The method of setting each lowest bit "1" in the .
[0096] Since the insertion replacement operation is to place the data from low bit to high bit in the data to be replaced DATA in the control parameter The position corresponding to the valid bit in The lowest bit data in is taken as input, the "1" result is taken as the position output information, and the low bit data is output in sequence to the register corresponding to the position output information.
[0097] when After the position of "1" is inserted, the final insertion and replacement operation result is obtained. .
[0098] The embodiment of the present application also discloses a replacement system.
[0099] Reference Figure 7 , the replacement system includes the following modules:
[0100] Acquisition module: according to the cryptographic algorithm, obtains the determined substitution rule, obtains the control substitution sequence PARAM, the substitution operation type TYPE and the bit width N of the data to be operated;
[0101] Circuit generation module: the input end is connected to the output end of the acquisition module, and is used to generate a new replacement circuit according to the data bit width;
[0102] Data input module: The input end is connected to the output end of the acquisition module, which is used to obtain the control permutation sequence , permutation operation type And the data to be operated Input to the permutation circuit;
[0103] Permutation execution module: The input end is connected to the output end of the data input module and is used to control the permutation sequence The effective information in the circuit is used to perform periodic feedback circuit actions;
[0104] Operation type judgment module: The input end is connected to the output end of the acquisition module to judge the type of replacement operation , activate the corresponding result output enable;
[0105] Result output module: The input end is connected to the output end of the replacement execution module and the output end of the operation type judgment module, and is used to output the corresponding insertion or extraction result according to the replacement operation type.
[0106] The implementation principle of a replacement system in an embodiment of the present application is as follows: the control replacement sequence PARAM, the replacement operation type TYPE and the bit width of the data to be operated are obtained through the acquisition module, and the replacement circuit is generated according to the bit width, and then the control replacement sequence PARAM and the replacement operation type TYPE are input into the data input module, and then the replacement execution module is executed to start the replacement circuit, and a periodic circuit feedback operation is performed according to the valid information in the control replacement sequence PARAM, and 1 is found one by one from the low bit to the high bit to form the selection information, and then the operation data is treated according to the selection information and the replacement operation type TYPE. Perform substitution, and then execute the result output module to output the corresponding result.
[0107] The above are all preferred embodiments of the present application, and the protection scope of the present application is not limited thereto. Therefore, any equivalent changes made according to the structure, shape, and principle of the present application should be included in the protection scope of the present application.
Claims
1. A bit replacement method, characterized in that: The following steps are involved: Get: determine the substitution rule, get the control substitution sequence PARAM and substitution operation type TYPE; Data input: input the data to be operated DATA, control substitution sequence PARAM and substitution operation type TYPE into the substitution circuit; Replacement execution: start the replacement circuit and perform periodic replacement circuit feedback action; Operation type judgment: judge the replacement operation type TYPE and activate the response result output enable; Result output: After the replacement action is completed, according to the input replacement operation type TYPE type, through the 2-to-1 MUX circuit, the replacement result PEX_DATA is extracted or the replacement result PDEP_DATA is inserted for output.
2. The bit replacement method according to claim 1, characterized in that: In the replacement execution step, according to the effective information quantity M in the control replacement sequence PARAM, the feedback circuit action of M cycles is performed.
3. The bit replacement method according to claim 1 or 2, characterized in that: The acquisition step further includes acquiring the replacement data bit width and selecting the operation data bit width N; a circuit generation step is also provided between the acquisition step and the data input step; Circuit generation: Generate a new permutation circuit based on the operation data bit width N.
4. A replacement circuit for the bit replacement method according to any one of claims 1 to 3, characterized in that: include: A main circuit and a first output circuit, wherein the main circuit comprises: The first data selector (110) has an input terminal for inputting a control permutation sequence Data signal and feedback signal ; A trigger (120), electrically connected to an output terminal of the first data selector (110), and configured to receive a data signal output by the first data selector (110); The first NOT gate (130) has an input end connected to the output end of the trigger (120) and is used to receive a data signal output by the trigger (120) and to control the permutation sequence. The data signal is inverted to obtain Data signal; The adder (140) has an input end electrically connected to the output end of the first NOT gate (130) and is used to receive the output of the first NOT gate (130). Data signal, and perform +1 operation to obtain Data signal, then find 1 from low bit to high bit to obtain selection information; The first output circuit is electrically connected to the output terminal of the adder (140) and is used to receive the selection information output by the adder (140) and then output the selection information to the input terminal according to the selection information. Extract data at corresponding positions in the data to obtain output data ; A second NOT gate (150) is connected to the output end of the adder (140), and is used to receive the selection information output by the adder (140), identify the selection information, and filter out invalid information; An AND gate (160) is connected to the output end of the second NOT gate (150) and the output end of the trigger (120), and the output end is connected to the input end of the first data selector (110), and is used to receive the selection information filtered by the second NOT gate (150) and the data signal output by the trigger (120), and perform AND operation to output a feedback signal , used to input a feedback signal to the first data selector (110) .
5. The replacement circuit according to claim 4, characterized in that: Also includes: The second output circuit is electrically connected to the output terminal of the adder (140) and is used to receive the selection information and then output the selected information to the input Insert the data at the corresponding position in the data to obtain the output data .
6. The replacement circuit according to claim 4, characterized in that: The first data selector (110) is a 2-to-1 data selector.
7. A system for implementing the bit replacement method according to any one of claims 1 to 3, characterized in that: Includes the following modules: Acquisition module: According to the cryptographic algorithm, obtain the determined substitution rules and obtain the control substitution sequence and permutation operation types ; Data input module: The input end is connected to the output end of the acquisition module, which is used to obtain the control permutation sequence , permutation operation type And the data to be operated Input to the permutation circuit; Permutation execution module: The input end is connected to the output end of the data input module and is used to control the permutation sequence The effective information in the circuit is used to perform periodic feedback circuit actions; Operation type judgment module: The input end is connected to the output end of the acquisition module to judge the type of replacement operation , activate the corresponding result output enable; Result output module: The input end is connected to the output end of the replacement execution module and the output end of the operation type judgment module, and is used to output the corresponding insertion or extraction result according to the replacement operation type.
8. The system according to claim 7, characterized in that: Also included is a circuit generation module; Circuit generation module: The input end is connected to the output end of the acquisition module and is used to generate a new replacement circuit according to the data bit width.
