Hardware Trojan horse detection method based on automatic semantic feature extraction
By converting the integrated circuit design code into an abstract syntax tree and a control-data flow graph, extracting the statement sequence and inputting it into the natural language processing model, it solves the problems of low automation of hardware Trojan detection and neglected semantic features in the existing technology, and achieves Highly accurate and automated register-transfer-level hardware Trojan detection.
Patent Information
- Application Number
- CN202410807828.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-21
- Publication Date
- 2024-10-18
AI Technical Summary
Existing hardware Trojan detection methods based on machine learning technology rely on feature engineering and expert knowledge, have a low degree of automation, and ignore the semantic features of integrated circuit design, resulting in insufficient accuracy and automation of hardware Trojan detection in the pre-silicon stage. .
By converting the integrated circuit design code under test into an abstract syntax tree, a control-data flow graph is generated, the sentence sequence from the input signal to the output signal is extracted, word segmentation is performed and input to the natural language processing classification model, and binary word segmentation is automatically extracted Features to implement register transfer level hardware Trojan detection.
It improves the accuracy and automation of hardware Trojan detection, and can directly analyze the register transfer level code, providing a more direct means to achieve fully automated hardware Trojan detection without manual feature extraction and manual inspection.
Smart Images

Figure CN118797640A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of integrated circuit hardware security, and in particular relates to a hardware Trojan detection method based on automatic extraction of semantic features. Background Art
[0002] The globalization of integrated circuit design and manufacturing has raised concerns about chip security, with one of the main concerns being hardware Trojans. Hardware Trojans are malicious modifications to integrated circuit designs made by attackers. Hardware Trojans mainly consist of two parts: trigger logic and load function. The trigger logic is activated under rare conditions set by the attacker and generates a trigger signal. Once a hardware Trojan is triggered, it may lead to sensitive information leakage, performance degradation, or even cause the chip to deny service, posing a serious threat to the security and reliability of integrated circuit hardware.
[0003] Since the functions of integrated circuit chips are difficult to modify after they are manufactured, hardware Trojan detection in the early stages of integrated circuit design is an important means to address the security threats of hardware Trojans. Recently, machine learning and deep learning technologies have attracted widespread attention in the field of hardware Trojan detection and have shown great potential. Related models and algorithms have been used for hardware Trojan detection in the pre-silicon stage, including random forest algorithms, recurrent neural networks, and graph neural network models.
[0004] However, existing hardware Trojan detection methods based on machine learning technology rely on feature engineering and expert knowledge for feature extraction, and have a low degree of automation. Hardware Trojan detection methods based on deep learning technology currently focus on the structural and behavioral characteristics of circuits, while the semantic characteristics of the register transfer level code of integrated circuit design are ignored. The register transfer level code of integrated circuit design has rich semantic features. By converting the target code into an intermediate representation, hardware Trojan detection can be achieved based on semantic features, thus providing a more direct means for hardware Trojan detection in the design stage. Summary of the invention
[0005] In order to overcome the shortcomings of the prior art, the present invention provides a hardware Trojan detection method based on automatic extraction of semantic features. The method comprises the following steps: inputting the design code of the integrated circuit to be tested; converting the design code of the integrated circuit to be tested into an abstract syntax tree; converting the circuit to be tested into a control-data flow graph based on the abstract syntax tree; extracting the sequence of statements from the input signal to the output signal in the control-data flow graph; segmenting the extracted statement sequence; segmenting the segmented statement sequence, and extracting the binary segmentation features and inputting them into the trained natural language processing classification model to obtain the predicted probability of being a hardware Trojan or a normal circuit. The present invention can realize hardware Trojan detection at the register transfer level statement granularity.
[0006] A hardware Trojan detection method based on automatic extraction of semantic features, characterized by the following steps:
[0007] Step 1: Input the IC design code to be tested;
[0008] Step 2: Convert the IC design code to be tested into an abstract syntax tree;
[0009] Step 3: Convert the circuit under test into a control-data flow graph based on the abstract syntax tree;
[0010] Step 4: Extract the statement sequence from input signal to output signal in the control-data flow graph;
[0011] Step 5: Segment the extracted sentence sequence;
[0012] Step 6: Segment the sentence sequence obtained by segmentation, extract the binary segmentation features and input them into the trained natural language processing classification model to obtain the predicted probability of it being a hardware Trojan or a normal circuit, thereby realizing hardware Trojan detection at the register transfer level statement granularity.
[0013] Furthermore, the integrated circuit design to be tested described in step 1 is input in the form of register transfer level code.
[0014] Furthermore, the specific process of step 2 is: first, the sub-module calls in the integrated circuit design code to be tested are flattened and described by one module; then, the flattened circuit design code is syntactically analyzed, and the register transfer level code is converted into an abstract syntax tree description form, wherein the nodes in the abstract syntax tree correspond to the basic operations in the circuit design code, and the basic operations include arithmetic operations and logical operations.
[0015] Furthermore, the specific process of step 3 is: perform control flow and data flow analysis on the integrated circuit design code to be tested, add the control dependency and data dependency relationship between statements to the abstract syntax tree, and obtain the control-data flow graph of the integrated circuit design to be tested; wherein the control flow represents the control dependency relationship between register transfer level code statements, and the data flow represents the data flow between signals in the register transfer level code.
[0016] Furthermore, in step 4, a depth-first search algorithm is used to extract a statement sequence from the control-data flow graph, and each element in the sequence corresponds to a node in the abstract syntax tree.
[0017] Furthermore, in step 5, a sliding window algorithm is used to segment the extracted sentence sequence to obtain a segmented sentence sequence.
[0018] Furthermore, the natural language processing classification model described in step 6 adopts the FastText text classification model, which mainly includes an embedding layer, a hidden layer and an output layer, wherein the embedding layer includes a lookup table, which maps the words in the segmented sentence sequence into vectors, and extracts the binary word segmentation features at the same time, and maps them together with the words to a vector of a fixed length to obtain the syntactic features and semantic features of the circuit design; the model output is a two-dimensional vector, which represents the predicted probability of each sentence sequence being a hardware Trojan or a normal circuit.
[0019] The beneficial effects of the present invention are:
[0020] 1. The hardware Trojan detection method proposed in the present invention directly analyzes the register transfer level integrated circuit design code, and can automatically extract the grammatical and semantic features of the code, providing a more direct means for hardware Trojan detection in the pre-silicon stage.
[0021] 2. The sentence sequence extraction and segmentation strategy used in the present invention can help the natural language processing model learn more accurate Trojan features and improve the accuracy of hardware Trojan detection by segmenting the sentence sequence from the integrated circuit design input signal to the output signal.
[0022] 3. The hardware Trojan detection method proposed in the present invention is fully automated, without the need for manual feature extraction and additional manual inspection, thereby improving the automation level of hardware Trojan detection in the design phase. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 It is a flow chart of a hardware Trojan detection method based on automatic extraction of semantic features of the present invention;
[0024] Figure 2 It is a flowchart of an example of the sentence sequence extraction process of the present invention. DETAILED DESCRIPTION
[0025] The present invention is further described below in conjunction with the accompanying drawings and embodiments. The present invention includes but is not limited to the following embodiments.
[0026] like Figure 1 As shown, a hardware Trojan detection method based on automatic extraction of semantic features realizes automatic extraction and detection of hardware Trojan features at the register transfer level, including the following steps:
[0027] Step 1: Input the IC design code to be tested;
[0028] Step 2: Convert the IC design code to be tested into an abstract syntax tree;
[0029] Step 3: Convert the circuit under test into a control-data flow graph based on the abstract syntax tree;
[0030] Step 4: Extract the statement sequence from input signal to output signal in the control-data flow graph;
[0031] Step 5: Segment the extracted sentence sequence;
[0032] Step 6: Segment the sentence sequence obtained by segmentation, extract the binary word segmentation features and input them into the trained natural language processing classification model to achieve hardware Trojan detection at the register transfer level statement granularity.
[0033] Furthermore, in step 1, the design of the integrated circuit to be tested is input in the form of register transfer level code, such as Verilog HDL.
[0034] Furthermore, in step 2, the submodule calls in the IC design code to be tested are first flattened and described by one module, and then the flattened IC to be tested is subjected to syntax analysis, and the register transfer level code is converted into an abstract syntax tree description form, wherein the nodes in the abstract syntax tree correspond to basic operations in circuit design, such as arithmetic operations, logical operations, etc. Specifically, the Pyverilog parsing tool can be used to perform syntax analysis and generate an abstract syntax tree.
[0035] Furthermore, the step 3 performs control flow and data flow analysis on the circuit design to be tested, adds the control dependency and data dependency relationship between statements to the abstract syntax tree, and obtains a control-data flow graph of the circuit design to be tested, which represents the nodes and their connection relationships. Specifically, the control flow represents the control dependency relationship between register transfer level code statements, such as conditional and branch statements, etc.; the data flow represents the data flow between signals in the register transfer level code, such as assignment statements, etc. Figure 1 The dashed arrows in the figure represent control dependencies, and the solid arrows represent data dependencies.
[0036] Furthermore, the step 4 adopts a depth-first search algorithm for the control-data flow graph to extract all statement sequences from the input signal to the output signal in the circuit to be tested, and each element in the sequence corresponds to a node in the abstract syntax tree.
[0037] Furthermore, in step 5, the extracted statement sequence is segmented using a sliding window algorithm to obtain a segmented statement sequence, wherein the parameters of the sliding window algorithm include a window size and a step size, such as a window size of 6 statements and a step size of 4 statements.
[0038] Furthermore, the natural language processing classification model in step 6 uses the FastText text classification model, which specifically includes three modules: an embedding layer, a hidden layer, and an output layer. The FastText model has completed model training based on a training data set, in which the hardware Trojan sentence sequence is a positive class with a label of 1, and the normal circuit sentence sequence is a negative class with a label of 0.
[0039] Furthermore, in step 6, the embedding layer of the FastText model includes a lookup table, which maps the words in the segmented sentence sequence into vectors, extracts the binary word segmentation features, and maps them together with the words to a vector of fixed length to extract the syntactic and semantic features of the circuit design; the hidden layer takes the average of the input vector by dimension to obtain a vector with the same dimension to represent the input sentence sequence; the output layer includes a full connection operation and a softmax activation function. The FastText model outputs a two-dimensional vector, which represents the predicted probability of each sentence sequence being a hardware Trojan or a normal circuit, thereby realizing hardware Trojan detection. Specific embodiment:
[0041] The following takes the Trust-Hub hardware Trojan test set as an example to illustrate the hardware Trojan detection method proposed in the present invention.
[0042] 1) Construct a dataset. The dataset includes 29 hardware Trojan circuits from Trust-Hub. The hardware Trojans are conditionally triggered and implanted into AES, RS232 and PIC16F84 benchmark circuits described in Verilog code.
[0043] 2) Convert the integrated circuit designs in the data set into an abstract syntax tree. First, flatten each integrated circuit design in the data set. Specifically, flatten the sub-module calls in the circuit design, and describe the circuit design by one module; then, perform syntactic analysis on each flattened circuit design. Specifically, use the Pyverilog parsing tool to convert each circuit into its corresponding abstract syntax tree representation, where the nodes in the abstract syntax tree correspond to the basic operations of the circuit design, such as arithmetic operations, logical operations, etc.
[0044] 3) Each circuit to be tested is converted into a control-data flow graph based on an abstract syntax tree. The abstract syntax tree of the register transfer level circuit represents all the statements containing the circuit. Therefore, the control flow and data flow analysis can be directly performed on the abstract syntax tree. By analyzing the control flow and data flow dependencies between statements, a control-data flow graph of the register transfer level code is constructed. The specific control flow represents the control dependency between the register transfer level code statements, such as conditional and branch statements, etc.; the data flow represents the data flow between signals in the register transfer level code, such as assignment statements, etc.
[0045] 4) A depth-first search algorithm is used for the control-data flow graph of each circuit design to extract all statement sequences from the input signal to the output signal in the circuit. Each element in the sequence corresponds to a node in the abstract syntax tree, and the statement sequence is saved in the form of a string text. These sequences represent the paths between the main input signals and output signals of the hardware design, contain rich semantic information and retain the logical structure characteristics of the circuit. As outlined in lines 1-5 of Algorithm 1 below, a depth-first search algorithm is used to extract the statement sequence in the control-data flow graph.
[0046]
[0047]
[0048] 5) Using the sliding window algorithm to segment the extracted sentence sequence helps to improve the granularity of hardware Trojan detection. The sentence sequence segmentation process is described in lines 6-20 of Algorithm 1. Specifically, the sentence sequence is segmented according to the set window size and step size. Figure 2 The process of extracting the statement sequence of the trigger module of the AES-T700 hardware Trojan circuit is given, and the Verilog code of the circuit, the converted control-data flow graph and a statement sequence extracted from the state signal are shown respectively. Figure 2 (a) is the Verilog code of the AES-T700 hardware Trojan benchmark circuit trigger module. When the state signal is a 128-bit special value, the signal Tj_Trjg becomes 1 and the hardware Trojan is triggered; Figure 2 (b) is the control-data flow graph corresponding to the hardware Trojan trigger module; Figure 2 (c) is the sentence sequence from the state input signal to the Tj_Trig output signal extracted based on Algorithm 1. Hardware Trojan detection is a supervised machine learning process. In order to train the model and evaluate the prediction performance, it is necessary to assign category labels to the data. Specifically, according to the specific description of the hardware Trojan in the Trust-Hub dataset, the category label is assigned according to whether the segmented sentence sequence contains Trojan logic. The hardware Trojan sentence sequence is a positive class with a label of 1, and the normal circuit sentence sequence is a negative class with a label of 0.
[0049] 6) Segment the segmented sentence sequence and extract the binary segmentation features and input them into the FastText hardware Trojan detection model for training. Specifically, grid search and leave-one-out cross-validation are used to train the FastText model. True positive rate (TPR), true negative rate (TNR), accuracy, precision, and F1 value are used as evaluation indicators in training. Among them, the TPR score reflects the FastText model's ability to detect hardware Trojans; the F1 value can provide a comprehensive performance evaluation of the system. Therefore, when selecting FastText hyperparameters, maximizing the F1 value is used as the evaluation indicator.
[0050] The FastText text classification model specifically includes three modules: embedding layer, hidden layer and output layer. The embedding layer includes a lookup table, which maps the words in the segmented sentence sequence into vectors, extracts the binary word segmentation features, and maps them together with the words to a vector of fixed length to extract the syntactic and semantic features of the circuit design; the hidden layer takes the average of the input vector by dimension to obtain a vector with the same dimension to represent the input sentence sequence; the output layer includes a full connection operation and a softmax activation function. The FastText model outputs a two-dimensional vector, which represents the predicted probability of each sentence sequence being a hardware Trojan or a normal circuit. The hyperparameter selection range and optimal value during the training of the FastText hardware Trojan detection model are shown in Table 1.
[0051] Table 1
[0052]
[0053]
[0054] Based on the trained FastText model, hardware Trojan detection is performed on the test set data. The FastText hardware Trojan detection model outputs a two-dimensional vector, which represents the predicted probability of the sentence sequence as two categories: hardware Trojan and normal circuit, thereby realizing hardware Trojan detection. The hardware Trojan detection results are shown in Table 2. The results show that the proposed method can successfully realize hardware Trojan detection. The average values of TPR and TNR are 98.43% and 99.92% respectively, indicating that hardware Trojan and normal circuit can be successfully detected; under the comprehensive performance evaluation, the average value of F1 is 96.87%. This shows that the hardware Trojan detection method provided by the present invention can effectively realize register transfer level hardware Trojan detection and achieve high detection accuracy through automatic extraction of semantic features and natural language processing classification model.
[0055] Table 2
[0056] Test Circuit TPR TNR Accuracy Precision F1-score Trojans / Total AES-T500 100.0% 100.0% 100.0% 100.0% 100.0% 52 / 446 AES-T600 87.5% 100.0% 93.8% 100.0% 92.9% 4 / 641 AES-T1300 100.0% 100.0% 100.0% 100.0% 100.0% 11 / 787 AES-T1600 100.0% 100.0% 100.0% 100.0% 100.0% 39 / 635 AES-T1700 100.0% 100.0% 100.0% 100.0% 100.0% 54 / 215 RS232-T100 100.0% 99.6% 99.8% 95.1% 97.5% 97 / 1243 RS232-T200 100.0% 99.9% 100.0% 97.9% 98.9% 46 / 1250 RS232-T300 100.0% 100.0% 100.0% 100.0% 100.0% 17 / 1266 RS232-T500 95.2% 99.8% 97.5% 90.9% 93.0% 21 / 1320 PIC16F84-T200 100.0% 99.8% 99.9% 71.4% 83.3% 5 / 1156 PIC16F84-T300 100.0% 100.0% 100.0% 100.0% 100.0% 5 / 1154 average value 98.43% 99.92% 99.18% 95.94% 96.87%
[0057] The above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit the same. A person skilled in the art may modify or make equivalent substitutions for the technical solutions of the present invention without departing from the spirit and scope of the present invention. The protection scope of the present invention shall be subject to the claims.
Claims
1. A hardware Trojan detection method based on automatic extraction of semantic features, characterized in that Here are the steps: Step 1: Input the IC design code to be tested; Step 2: Convert the IC design code to an abstract syntax tree; Step 3: Convert the circuit under test into a control-data flow graph based on the abstract syntax tree; Step 4: Extract the statement sequence from input signal to output signal in the control-data flow graph; Step 5: Segment the extracted sentence sequence; Step 6: Segment the sentence sequence obtained by segmentation, extract the binary segmentation features and input them into the trained natural language processing classification model to obtain the predicted probability of it being a hardware Trojan or a normal circuit, thereby realizing hardware Trojan detection at the register transfer level statement granularity.
2. A method for detecting hardware Trojans based on automatic extraction of semantic features as claimed in claim 1, characterized in that: The integrated circuit design under test described in step 1 is input in the form of register transfer level code.
3. The method for detecting hardware Trojans based on automatic extraction of semantic features according to claim 1, characterized in that: The specific process of step 2 is: first, the sub-module calls in the integrated circuit design code to be tested are flattened and described by one module; then, the flattened circuit design code is syntactically analyzed, and the register transfer level code is converted into an abstract syntax tree description form, wherein the nodes in the abstract syntax tree correspond to the basic operations in the circuit design code, and the basic operations include arithmetic operations and logical operations.
4. The method for detecting hardware Trojans based on automatic extraction of semantic features according to claim 1, characterized in that: The specific process of step 3 is: perform control flow and data flow analysis on the integrated circuit design code to be tested, add the control dependency and data dependency between statements to the abstract syntax tree, and obtain the control-data flow graph of the integrated circuit design to be tested; wherein the control flow represents the control dependency between register transfer level code statements, and the data flow represents the data flow between signals in the register transfer level code.
5. The method for detecting hardware Trojans based on automatic extraction of semantic features as claimed in claim 1, characterized in that: In step 4, a depth-first search algorithm is used to extract a statement sequence from the control-data flow graph, and each element in the sequence corresponds to a node in the abstract syntax tree.
6. A method for detecting hardware Trojans based on automatic extraction of semantic features as claimed in claim 1, characterized in that: In step 5, a sliding window algorithm is used to segment the extracted sentence sequence to obtain a segmented sentence sequence.
7. The method for detecting hardware Trojans based on automatic extraction of semantic features according to claim 1, characterized in that: The natural language processing classification model described in step 6 adopts the FastText text classification model, which mainly includes an embedding layer, a hidden layer and an output layer. The embedding layer includes a lookup table, which maps the words in the segmented sentence sequence into vectors, extracts the binary word segmentation features, and maps them together with the words to a vector of a fixed length to obtain the syntactic features and semantic features of the circuit design; the model output is a two-dimensional vector, which represents the predicted probability of each sentence sequence being a hardware Trojan or a normal circuit.
Citation Information
Cited By
Chip Trojan horse detection method and device, program product, medium and electronic equipment
CN120277671A
