Method for locating sm4 side channel leakage and soft evidence extraction based on chi-square test

CN122533731APending Publication Date: 2026-08-07CHINA AUTOMOTIVE ENG RES INST
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA AUTOMOTIVE ENG RES INST
Filing Date
2026-05-29
Publication Date
2026-08-07

AI Technical Summary

Technical Problem

[0007]本发明意在提供基于卡方检验的SM4侧信道泄露定位与软证据提取方法,以解决传统侧信道分析泄露定位精度低、证据输出形式单一的问题

Benefits of technology

(1)本方案采用“双态采样+卡方检验热图”的方式进行无模型粗定位,能够在不依赖功耗模型和强先验的条件下快速筛出信息泄露区域,显著减少后续分析的搜索空间。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122533731A_ABST
    Figure CN122533731A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of side channel security analysis of national secret algorithm, and discloses a kind of SM4 side channel leakage positioning and soft evidence extraction method based on chi-square test, comprising: collecting equipment idle state and S-box operation state two kinds of side channel trajectory and completing timing alignment;Carry out chi-square test for each sampling point, compare the difference between the two kinds of signal distribution, and rely on chi-square heat map to screen the leakage candidate area;Perform linear regression analysis, use the 8-bit intermediate value of SM4 algorithm S-box as label calculation to determine the coefficient, lock the high correlation signal segment, and generate fixed ROI;The fixed ROI trajectory is input into 256 neural template classifiers to learn, and finally output the posterior probability distribution corresponding to the byte value as soft evidence.The present application realizes coarse and fine double positioning of leakage position in layers, discards single determination mode, probabilistic evidence output, improves positioning accuracy, can be compatible with multiple side channel signals, and is suitable for security vulnerability detection and risk assessment of SM4 encryption chip.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of side-channel security analysis technology of Chinese cryptographic algorithms, specifically to a method for SM4 side-channel leakage location and soft evidence extraction based on chi-square test. Background Technology

[0002] SM4 is a block cipher algorithm widely deployed in embedded and security-critical scenarios such as security chips, IoT terminals, and industrial control equipment. Its software and firmware implementations typically use a lookup-based S-box as the core non-linear operation unit, which can lead to significant leaks during operation. On one hand, the input and output bytes of the S-box are directly reflected in the electromagnetic or power consumption changes of registers, buses, and memory; on the other hand, the lookup operation itself generates memory access leaks related to the index, making the S-box the most concentrated point of leakage in the entire encryption process. Therefore, side-channel security assessments of SM4 typically focus on locating S-box leaks and extracting intermediate value evidence. Existing SM4 side-channel analysis and assessment methods generally suffer from the following shortcomings: High cost of leak location: The actual collected trajectory window is long and the non-leaking interval accounts for a large proportion. Traditional methods rely on manually selecting time windows or directly training the model in the full window, which is not only time-consuming and labor-intensive with high computational overhead, but also depends on the experience of operators, has poor reproducibility, and is difficult to form a standardized evaluation process.

[0003] ROI extraction is unstable, and dimensionality reduction is prone to losing key information: Existing technologies only screen sampling points through simple correlation coefficients, which cannot distinguish between linear correlation and distribution differences, and are prone to introducing noise or losing weak but stable leakage points; when shortening the signal dimension, it often leads to a significant decrease in key recovery capability, and cannot balance dimensionality reduction efficiency and analysis accuracy.

[0004] The output format is hard decision, which is difficult to support multi-evidence fusion and structured inference: Traditional template attacks and correlation energy analysis usually output hard decision results or single correlation coefficients. In single-trace and few-trace scenarios, they do not support soft evidence fusion of multiple ROIs and multiple trajectories, and are also difficult to combine with structured inference methods, thus limiting overall robustness and scalability.

[0005] Lack of an end-to-end evaluation pipeline tailored to the characteristics of SM4: Existing technologies do not fully utilize the structural characteristics of SM4, such as a single S-box, centralized leakage, and clear execution steps. They lack versatility in multimodal side channels such as electromagnetic and photonic imaging. The signal characterization and processing logic of different acquisition modes are independent of each other, making it impossible to form a unified and transferable evaluation process.

[0006] Therefore, there is an urgent need for an SM4 side-channel analysis method that can quickly locate, accurately extract ROIs, and output soft evidence in order to achieve efficient SM4 side-channel security assessment. Summary of the Invention

[0007] The present invention aims to provide a method for SM4 side-channel leakage location and soft evidence extraction based on chi-square test, so as to solve the problems of low leakage location accuracy and single evidence output form in traditional side-channel analysis.

[0008] To achieve the above objectives, the present invention adopts the following technical solution: a method for SM4 side-channel leakage localization and soft evidence extraction based on chi-square test, comprising: The dual-state trajectory acquisition process involves controlling the device under test to be in both a non-critical state and a critical state, acquiring the corresponding trajectory sets, and aligning the time axis. The chi-square test coarse localization step performs a chi-square test on each sampling point on the time axis, calculates the difference in electromagnetic leakage distribution between non-critical and critical states, generates a chi-square heat map, and extracts candidate leakage areas. The linear regression fine localization step involves performing linear regression analysis within the candidate leakage region, calculating the coefficient of determination using the S-box median or its encoded form as the label, and completing the fine localization based on the coefficient of determination to generate a fixed ROI. The neural template training and soft evidence extraction steps take a fixed ROI trajectory as input to train a neural template classifier and output the posterior probability distribution of the target byte as soft evidence.

[0009] The principle and advantages of this scheme are as follows: In practical applications, it relies on dual-state comparison sampling to distinguish between computational and noise signals, obtains the effective leakage interval through chi-square test and linear regression to converge layer by layer, and mines the correlation between waveform and cryptographic data through neural network, replacing fixed judgment results with probabilistic soft evidence.

[0010] Beneficial effects: (1) This scheme uses the "dual-state sampling + chi-square test heatmap" method for model-free coarse localization, which can quickly screen out information leakage areas without relying on power consumption models and strong priors, and significantly reduce the search space for subsequent analysis.

[0011] (2) After the chi-square coarse localization, this scheme further uses the determination coefficient of linear regression analysis to fine localize the candidate region, forming a fixed (reproducible) ROI; it supports splicing / fusion of multiple ROI segments, retaining recoverable information while significantly reducing dimensionality, making the single-trace / few-trace recovery capability close to the full acquisition window.

[0012] (3) The posterior probability distribution output by the neural template model is adapted to feature-level / evidence-level fusion of multiple ROIs and can also be used as input for subsequent structured inference, thus improving the overall recovery effect and scalability.

[0013] (4) This scheme is not limited to a single side channel form. In addition to electromagnetic trajectories, it can also be extended to pixel-type side channels. It only requires replacing the sampling points with pixels, and has channel compatibility.

[0014] Preferably, as an improvement, the non-critical state is when the device under test performs a no-operation, an idle loop, or a non-SM4 operation; the critical state is when the device under test repeatedly executes an S-box or a round function segment containing an S-box.

[0015] Technical effect: It accurately distinguishes between two types of signal sources, namely baseline noise and cryptographic operations, ensuring that subsequent difference comparisons have a reliable reference benchmark and highlighting the feature leakage corresponding to S-box operations.

[0016] Preferably, as an improvement, the dual-state trajectory acquisition step uses a GPIO tag unit or an external trigger circuit to provide a unified time reference for side-channel acquisition.

[0017] Technical effect: It enables time alignment of multiple trajectories, eliminates acquisition offset errors, and lays a data foundation for subsequent statistical analysis.

[0018] Preferably, as an improvement, the chi-square test coarse localization step includes: extracting the amplitude sets of non-critical states and critical states according to time sampling points, constructing a contingency table after discretization and binning, calculating the Pearson chi-square statistic for each sampling point to characterize the distribution difference; generating a chi-square heatmap and selecting points with high significant differences, and obtaining one or more candidate leakage regions through connected component merging and interval dilation processing.

[0019] Technical effects: Screening signals across the entire time domain, quickly eliminating invalid noise areas, significantly reducing the analysis scope, and efficiently identifying intervals suspected of password leakage.

[0020] Preferably, as an improvement, the linear regression fine localization step includes: within the candidate leakage region, using the input byte, output byte, Hamming weight, bit expansion encoding or one-hot encoding of the SM4 algorithm S-box as regression labels, performing linear regression analysis on each sampling point and calculating the coefficient of determination, selecting sampling points with a coefficient of determination higher than a preset threshold as strong leakage points, and performing connected component merging and interval regularization on the strong leakage points to obtain a fixed ROI.

[0021] Technical effect: It evaluates the correlation between the signal and the intermediate value of the password, further filters out weak interference points, extracts the fixed fragment with the most significant leakage characteristics, and reduces the data dimension of subsequent model processing.

[0022] Preferably, as an improvement, the neural template classifier is a 256-class classification model, employing a one-dimensional residual network structure; the posterior probability distribution is π(z|t), z∈{0,1,…,255}, where z is the intermediate value of the target password and t is the input trajectory.

[0023] Technical effect: One-dimensional network is adapted for temporal trajectory feature extraction, and the probability distribution form completely preserves the possibility of various values, avoiding irreversible judgment errors caused by hard decision.

[0024] Preferably, as an improvement, it also includes a soft evidence fusion step, which performs single-trace, few-trace fusion recovery or structured inference based on soft evidence.

[0025] Technical benefits: It can flexibly adapt to different test scenarios such as single trajectory and a small number of trajectories, and can connect with professional cryptographic inference systems, enrich the implementation forms of key recovery, and improve the practicality and scalability of analysis solutions. Attached Figure Description

[0026] Figure 1 A schematic diagram of the framework for the SM4 side-channel leakage localization and soft evidence extraction method based on the chi-square test. Detailed Implementation

[0027] The following detailed description illustrates the specific implementation method: The basic implementation examples are as follows: Figure 1 As shown, the method for SM4 side-channel leakage localization and soft evidence extraction based on chi-square test includes the following steps: The dual-state trajectory acquisition process involves controlling the device under test to be in both a non-critical state and a critical state, acquiring the corresponding trajectory sets, and aligning the time axis.

[0028] Firmware configuration is performed on the device under test (DUT), such as MCUs, SoCs, and security chips, to enable it to stably switch between and execute two controllable operating states: In the non-critical state, the device executes no-operation loops, idle waits, or instructions unrelated to the SM4 encryption logic, without performing any core cryptographic operations such as S-box lookups or round function calculations, to collect baseline traces free of cryptographic leaks. In the critical state, the device cyclically executes separately encapsulated S-box lookup routines or round function fragments containing S-boxes within the SM4 encryption algorithm, using variable input data to ensure sufficient coverage of leakage features.

[0029] During the data acquisition process, a near-field electromagnetic probe is used to obtain the electromagnetic radiation leakage signal of the device under test, and an oscilloscope is used to digitize the signal and record the trajectory.

[0030] A unified time reference is provided for side-channel acquisition using GPIO marker units or external trigger circuits. Before the device under test (DUT) enters the SM4 algorithm S-box lookup or round function operation, a synchronization pulse is output through a GPIO pin, or a synchronization signal is generated by an external trigger circuit to control the oscilloscope to start acquisition. Using this synchronization signal as a timing reference, all acquired trajectories are time-axis aligned and window-normalized to ensure that the sampling points of different trajectories and states correspond strictly in time, ensuring the consistency, stability, and reproducibility of leak localization, ROI extraction, and model training. Two sets of trajectories with sufficient quantity and equal number are acquired in both non-critical and critical states, denoted as N1 trajectories acquired in the non-critical state and N2 trajectories acquired in the critical state, forming the non-critical state trajectory set and the critical state trajectory set.

[0031] The chi-square test is a coarse localization step. For each sampling point on the time axis, a chi-square test (χ² test) is performed to calculate the difference in electromagnetic leakage distribution between non-critical and critical states, generating a chi-square heatmap and extracting candidate leakage regions. The specific process is as follows: Split the bi-state trajectory data by sampling point: Combine the non-critical state trajectory set and the critical state trajectory set that have been time-aligned with the original data, and assign them the same time index. Take out two sets of signal amplitude values ​​respectively: the non-critical state in the first... All trajectory amplitudes at each sampling point: A = {a1, a2, …, a_N1}; the critical state is in the first... All trajectory amplitudes at each sampling point: B = {b1,b2, …, b_N2}; The two sets of data are strictly aligned on the time axis, and the same index corresponds to the same time.

[0032] Discretize and bin the amplitude of the sampling points: Divide A With B The continuous amplitude is divided into K discrete intervals (bins) at equal intervals according to the amplitude range. The number of samples in each interval is counted to form a frequency distribution, which is used to construct the contingency table required for the chi-square test.

[0033] Construct a contingency table and calculate the Pearson chi-square statistic χ². ]: Based on sampling points Using the frequency of non-critical and critical states in each bin as the unit, construct a 2×K contingency table, and calculate the difference statistic χ² for that point according to Pearson's chi-square formula. ]. χ²[ The magnitude of χ² directly reflects the degree of difference between the two state distributions. The larger the χ², the more significant the distribution difference, and the more likely the point is to contain password-related leaks, making it more suitable for quickly screening candidate ROIs containing information leaks; The smaller the value, the closer the distribution, and the closer the point is to the background noise.

[0034] Generate a full-time-axis chi-square heatmap: sample all time points The corresponding χ²[ Arranged chronologically, a chi-square difference curve (heatmap) is formed, which visually shows which time periods in the entire trajectory are strongly correlated with key operations.

[0035] Selecting highly significant points: Significant points are selected based on a preset threshold or the Top-P% strategy, and the χ² value is used. Sampling points greater than the difference threshold; or select χ²[ The top P% of sampling points were selected as candidate leakage points.

[0036] Connectivity merging and interval expansion to generate candidate ROIs: Connectivity detection is performed on the selected discrete high saliency points, and adjacent or nearby saliency points are merged into continuous intervals; and the intervals are slightly expanded to retain complete leakage-related segments, finally obtaining one or more continuous candidate leakage regions (candidate ROIs) for subsequent LRA fine localization.

[0037] The chi-square test coarse localization step outputs a chi-square heatmap, a set of significantly different points, and a set of candidate ROI start and end indexes, achieving fully automated and rapid coarse localization without relying on prior models or manual window selection, significantly narrowing the scope of subsequent analysis.

[0038] The linear regression fine-mapping step involves performing linear regression analysis within the candidate leak regions, calculating the coefficient of determination using the S-box median or its encoded form as labels, and completing the fine-mapping based on the coefficient of determination to generate a fixed ROI. The specific process includes: Extract trajectory segments within candidate leakage regions: Using the start and end indices of the candidate leakage regions output by the chi-square test coarse localization step as boundaries, extract corresponding segments from the original aligned trajectory, retaining only the sampling points within the candidate leakage regions, and record them as candidate segment trajectories. During the training phase, based on controlled input data and known or controlled keys, calculate the S-box intermediate value label z (input byte or output byte) corresponding to each segment.

[0039] Determine the regression label and its source: Use the 8-bit median value of the S-box, Hamming weight, bit expansion encoding or one-hot encoding as the regression label. The label can be 0 to 255 or the corresponding encoding value. The label is calculated based on the controlled input data and the known key or the controlled key. For the real leakage point, its signal amplitude changes with the label or encoding feature and can be linearly interpreted by the label or encoding feature.

[0040] Perform linear regression point by point: for each sampling point within the candidate leakage region Perform regressions separately: the independent variable X is the S-box median label of the corresponding trajectory or its encoded form, the dependent variable Y is the signal amplitude of multiple trajectories at that point, and fit a linear model: y=k Given x+b, calculate the coefficient of determination R² for that point. The closer R² is to 1, the more linearly the signal amplitude can be interpreted by the intermediate value label or its encoding form, and the stronger and more stable the leakage; the closer R² is to 0, the weaker the correlation between the signal and the intermediate value of the code, and the more likely it is to be noise or a weakly correlated point.

[0041] Filtering strong leakage points by R²: Select sampling points with R² higher than a preset threshold or the most significant points ranked Top-K, retain the interval where the R² peak is located, and remove the valley noise points to obtain a set of high leakage points.

[0042] Connectivity merging and interval regularization generate fixed ROIs: The filtered strong leakage points are merged into connected components in chronological order, and the intervals are slightly expanded / extended to ensure that the leakage is not truncated. They are merged into one or more continuous fixed intervals. The start index, end index, and length of the ROI are recorded to obtain the fixed ROI. The length of the fixed ROI is much smaller than the original window and the candidate leakage region, which greatly reduces the input dimension of the neural template.

[0043] The neural template training and soft evidence extraction steps take a fixed ROI trajectory as input to train a neural template classifier and output the posterior probability distribution of the target byte as soft evidence.

[0044] The neural template classifier employs a 256-class classifier, preferably using a one-dimensional residual network structure. Fixed ROI segments (single or multiple segments concatenated) are used as model input, and the input or output bytes of the S-box in the SM4 algorithm are used as classification labels to train the 256-class classification model. During the model inference phase, the fixed ROI trajectory is used as input, and after forward computation by the network, a normalized probability distribution is output through a Softmax layer, achieving a probabilistic mapping from leaked waveform features to the password median value. The model ultimately outputs a probability vector π(z|t) of length 256, where z∈{0,1,2,…,255}, and π(z|t) represents the posterior probability that the password median value is z given trajectory t. This 256-dimensional normalized probability distribution serves as soft evidence that can be used for multi-trace fusion and structured inference.

[0045] It also includes a soft evidence fusion step, which performs single-trace or few-trace fusion recovery or structured inference based on soft evidence.

[0046] After outputting soft evidence, it supports single-trace key parsing applications, including: obtaining the optimal intermediate value candidate by calculating argmax π(z|t) for the posterior probability distribution corresponding to a single trace, or filtering the Top-N intermediate value set with the highest probability ranking, to realize cryptographic intermediate value inference under single-trace conditions.

[0047] After outputting soft evidence, it supports few-trace key parsing applications, specifically including: extracting the corresponding soft evidence from multiple traces obtained by performing SM4 encryption operations on the device multiple times, performing product fusion operations on the probability distributions of multiple sets of soft evidence, strengthening effective leakage characteristics, suppressing random noise interference, and improving the accuracy and stability of key inference in few-trace scenarios.

[0048] Soft evidence can also serve as input data for structured key inference. By introducing probabilistic soft evidence into the BP or SASCA inference system with SM4 cryptographic structure constraints, and combining it with the inherent structural features of the SM4 algorithm round function and S-box mapping rules, refined and structured key recovery inference can be achieved.

[0049] The above descriptions are merely embodiments of the present invention, and common knowledge such as specific technical solutions and / or characteristics are not described in detail here. It should be noted that those skilled in the art can make various modifications and improvements without departing from the technical solutions of the present invention, and these should also be considered within the scope of protection of the present invention. These modifications and improvements will not affect the effectiveness of the implementation of the present invention or the practicality of the patent. The scope of protection claimed in this application should be determined by the content of its claims, and the specific embodiments described in the specification can be used to interpret the content of the claims.

Claims

1. A method for SM4 side-channel leakage localization and soft evidence extraction based on chi-square test, characterized in that, include: The dual-state trajectory acquisition process involves controlling the device under test to be in both a non-critical state and a critical state, acquiring the corresponding trajectory sets, and aligning the time axis. The chi-square test coarse localization step performs a chi-square test on each sampling point on the time axis, calculates the difference in electromagnetic leakage distribution between non-critical and critical states, generates a chi-square heat map, and extracts candidate leakage areas. The linear regression fine localization step involves performing linear regression analysis within the candidate leakage region, calculating the coefficient of determination using the S-box median or its encoded form as the label, and completing the fine localization based on the coefficient of determination to generate a fixed ROI. The neural template training and soft evidence extraction steps take a fixed ROI trajectory as input to train a neural template classifier and output the posterior probability distribution of the target byte as soft evidence.

2. The method for SM4 side-channel leakage localization and soft evidence extraction based on chi-square test according to claim 1, characterized in that: The non-critical states are when the device under test performs a no-operation, an idle loop, or a non-SM4 operation; the critical states are when the device under test repeatedly executes an S-box or a round function segment containing an S-box.

3. The method for SM4 side-channel leakage localization and soft evidence extraction based on chi-square test according to claim 1, characterized in that: In the dual-state trajectory acquisition step, a GPIO marker unit or an external trigger circuit is used to provide a unified time reference for side-channel acquisition.

4. The method for SM4 side-channel leakage localization and soft evidence extraction based on chi-square test according to claim 1, characterized in that, The coarse localization step of the chi-square test includes: extracting the amplitude sets of non-critical and critical states according to the time sampling points, constructing a contingency table after discretization and binning, calculating the Pearson chi-square statistic of each sampling point to characterize the distribution difference; generating a chi-square heatmap and selecting points with high significant differences, and obtaining one or more candidate leakage regions through connected component merging and interval dilation processing.

5. The method for SM4 side-channel leakage localization and soft evidence extraction based on chi-square test according to claim 1, characterized in that, The linear regression fine localization step includes: within the candidate leakage region, using the input byte, output byte, Hamming weight, bit expansion encoding or one-hot encoding of the SM4 algorithm S-box as regression labels, performing linear regression analysis on each sampling point and calculating the coefficient of determination, selecting sampling points with a coefficient of determination higher than a preset threshold as strong leakage points, and performing connected component merging and interval normalization on the strong leakage points to obtain a fixed ROI.

6. The method for SM4 side-channel leakage localization and soft evidence extraction based on chi-square test according to claim 1, characterized in that: The neural template classifier is a 256-class classification model, using a one-dimensional residual network structure; the posterior probability distribution is π(z|t), z∈{0,1,…,255}, where z is the median value of the target password and t is the input trajectory.

7. The method for SM4 side-channel leakage localization and soft evidence extraction based on chi-square test according to claim 1, characterized in that: It also includes a soft evidence fusion step, which performs single-trace or few-trace fusion recovery or structured inference based on soft evidence.