Method and apparatus for detecting software and / or hardware similarities
By acquiring and analyzing the power consumption data of the benchmark target and the target to be compared under the same detection environment, and using the correlation of the power consumption curves to determine the similarity between the software and the hardware, the problem of difficulty in judging similarity due to lack of materials in the prior art is solved, and accurate similarity detection and control of detection granularity are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHENZHEN STATE MICRO TECH CO LTD
- Filing Date
- 2022-07-05
- Publication Date
- 2026-04-14
AI Technical Summary
In existing technologies, software and hardware similarity detection is difficult to perform, mainly due to the lack of source code or hardware design documents, which makes it difficult to effectively judge similarity.
By inputting the same test stimulus to the benchmark target and the target to be compared under the same detection environment, power consumption data is obtained. By analyzing the power consumption data, the similarity between the two is judged by the correlation of the power consumption curves, including calculating the correlation coefficient matrix and standard deviation, and dividing the module for fine-grained judgment.
Even in the absence of source code or hardware design documents, it can accurately determine the similarity between software and hardware, without relying on software output, closely approximating the actual working state, and providing fine-grained detection and control.
Smart Images

Figure CN115185837B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of software and / or hardware testing, and more particularly to a method for detecting software and / or hardware similarity, as well as a corresponding testing device. Background Technology
[0002] Currently, software similarity detection mostly relies on analyzing source code or disassembling the final binary file. Hardware IP core similarity detection also relies on analyzing the original VDHL language, netlist, layout, or final hardware.
[0003] However, in practical applications, it is often difficult to obtain the materials mentioned above due to various reasons, making it difficult to judge the similarity of software and / or hardware.
[0004] Therefore, how to provide a detection method that can detect software and / or hardware similarity is a technical problem that the industry urgently needs to solve. Summary of the Invention
[0005] To address the technical problem that software and / or hardware similarity is difficult to determine due to the difficulty in obtaining corresponding materials in existing technologies, this invention proposes a method and apparatus for detecting software and / or hardware similarity.
[0006] The software and / or hardware similarity detection method proposed in this invention includes:
[0007] Step 1: Prepare the same testing environment for the software and / or hardware used as the benchmark and the software and / or hardware used as the target to be compared.
[0008] Step 2: Input at least one set of identical test stimuli into the benchmark target and the target to be compared, respectively, to trigger the detection environment and acquire power consumption data;
[0009] Step 3: Compare and analyze the power consumption data corresponding to the benchmark target and the target to be compared, and determine the similarity of the power consumption data between the benchmark target and the target to be compared. If the similarity of the power consumption data between the benchmark target and the target to be compared meets the preset range, then the benchmark target and the target to be compared are determined to be similar.
[0010] Furthermore, in step 2, a set of test stimuli is input multiple times into the benchmark target or the target to be compared, and the average power consumption curve of the set of test stimuli is calculated. The power consumption data corresponding to the average power consumption curve is used as the power consumption data of the basic target or the target to be compared under the set of test stimuli.
[0011] Furthermore, when there are multiple sets of test stimuli, the multiple sets of power consumption data corresponding to the benchmark target are represented as a two-dimensional matrix M1, and the multiple sets of power consumption data corresponding to the comparison target are represented as a two-dimensional matrix M2. Each row of the two-dimensional matrices M1 and M2 represents the power consumption data of a set of test stimuli at different time points.
[0012] Furthermore, step 3 includes:
[0013] Calculate the standard deviation of the i-th column of a two-dimensional matrix M1. And calculate the standard deviation of the two-dimensional matrix M2. The M1 ki The element in the k-th row and i-th column of the two-dimensional matrix M1 is... M2 is the average value of the i-th column of the two-dimensional matrix M1. kj The element in the k-th row and j-th column of the two-dimensional matrix M2 is... The average value of the j-th column of the two-dimensional matrix M2, where i or j takes the value 1, 2, ..., n, k takes the value 1, 2, ..., m, n is the number of columns of the two-dimensional matrix M1 or M2, and m is the number of rows of the two-dimensional matrix M1 or M2.
[0014] Calculate the covariance of the i-th column of two-dimensional matrix M1 and the j-th column of two-dimensional matrix M2.
[0015] And according to the formula The elements P of the correlation coefficient matrix P between two-dimensional matrices M1 and M2 are calculated. ij ;
[0016] Determine whether the absolute values of the elements on the diagonal of the correlation coefficient matrix meet the preset range;
[0017] If this condition is met, then the benchmark target and the target to be compared are similar.
[0018] Furthermore, the absolute values of the elements on the diagonal of the correlation coefficient matrix are analyzed, and the benchmark target and the target to be compared are divided into multiple corresponding modules. Then, it is determined whether each module of the benchmark target and the target to be compared is similar.
[0019] Furthermore, when the benchmark target is software, a current probe and an oscilloscope are used to acquire power consumption data of the detection environment.
[0020] Furthermore, when the benchmark target includes hardware, a current probe and an oscilloscope are used to acquire the power consumption data of the hardware.
[0021] The software and / or hardware similarity detection device proposed in this invention includes a controller, which uses the software and / or hardware similarity detection method described in the above technical solution to determine the similarity between the benchmark target and the target to be compared.
[0022] This invention analyzes the power consumption data of software and / or hardware to determine their similarity. It enables similarity assessment of software and / or hardware even without source code, and the detection is performed under normal hardware and / or software operating conditions, thus more closely resembling real-world scenarios. Furthermore, it allows control over the granularity of the detection, especially for software similarity assessment, requiring no additional software engineering knowledge and not relying on the software's own output. Attached Figure Description
[0023] The present invention will now be described in detail with reference to the embodiments and accompanying drawings, wherein:
[0024] Figure 1 This is an overall flowchart of an embodiment of the present invention. Detailed Implementation
[0025] To make the technical problems to be solved, the technical solutions, and the beneficial effects of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0026] Therefore, a feature pointed out in this specification is used to describe one feature of one embodiment of the invention, and does not imply that every embodiment of the invention must have the described feature. Furthermore, it should be noted that this specification describes many features. Although certain features may be combined to illustrate possible system designs, these features may also be used in other combinations not explicitly stated. Therefore, unless otherwise stated, the described combinations are not intended to be limiting.
[0027] like Figure 1 As shown, the software and / or hardware similarity detection method proposed in this invention can detect pure software, pure hardware with circuitry, or a combination of software and hardware.
[0028] This invention designates two objects to be compared for similarity as the baseline target and the target to be compared, aiming to determine the similarity between the target and the baseline target. The principle behind this invention is that ordinary software or hardware leaks certain information during operation, which can be considered a characteristic of the software or hardware. The operation process is essentially the switching of logic states of gate circuits; different switches result in different power consumptions, and the power consumption caused by gate circuit switching at different time points forms a curve. Software or hardware with similar designs have roughly the same operating steps, and their corresponding gate circuit switching states are also largely consistent on the time axis. Collecting the power consumption curves formed by the software or hardware during operation and analyzing their correlation can serve as a method for determining similarity.
[0029] To detect the similarity between a benchmark and a target for comparison, both the benchmark software and / or hardware and the target software and / or hardware need to be provided with identical testing environments. Taking software as an example, to detect the similarity between two software components, the hardware required for the software's operation needs to be prepared. Different functionalities of the software require different hardware facilities, with CPUs and other hardware devices being essential. Depending on the specific situation, other hardware facilities may also be required; for example, if the software runs on an embedded platform, an STM32 development board or a Raspberry Pi may be necessary. During software operation, the gate circuits of these hardware components generate corresponding power consumption. By capturing whether the power consumption generated by the hardware gate circuits is the same, the similarity of the software can be determined. Taking hardware as an example, the chip platform where the hardware module to be tested and the benchmark hardware module reside, as well as test code that can run on that chip platform, are needed (the test code for the hardware module to be tested and the benchmark hardware module must be identical to ensure the accuracy of the test results). By starting the hardware and monitoring the power consumption changes of the relevant gate circuits, the similarity of the two hardware modules can be determined.
[0030] After preparing the testing environment, at least one identical set of test stimuli is input to both the benchmark and the target to be compared, triggering the testing environment and acquiring power consumption data. When either the benchmark or the target to be compared stops operating, power consumption data acquisition stops, and this process is repeated until the data from the current set of test stimuli has been processed by either the benchmark or the target to be compared. When the benchmark is software, a current probe and an oscilloscope are used to acquire the power consumption data of the testing environment running the software. When the benchmark includes hardware, a current probe and an oscilloscope are used to acquire the power consumption data of the hardware.
[0031] In a preferred embodiment, there are preferably multiple sets of test stimuli. When there are multiple sets of test stimuli, the multiple sets of power consumption data corresponding to the benchmark target are represented as a two-dimensional matrix M1, and the multiple sets of power consumption data corresponding to the comparison target are represented as a two-dimensional matrix M2. Each row of the two-dimensional matrices M1 and M2 represents the power consumption data of a set of test stimuli at different time points.
[0032] Next, the power consumption data corresponding to the benchmark target and the target to be compared are compared and analyzed, and the similarity of the power consumption data of the benchmark target and the target to be compared is determined. If the similarity of the power consumption data of the benchmark target and the target to be compared meets the preset range, the benchmark target and the target to be compared are determined to be similar.
[0033] In one embodiment, any set of test stimuli can be input multiple times into a benchmark target or a target to be compared, and the average power consumption curve of the set of test stimuli can be calculated. The power consumption data corresponding to the average power consumption curve is used as the power consumption data of the benchmark target or the target to be compared under the set of test stimuli, so that the power consumption data obtained by the set of test stimuli is more accurate.
[0034] In one specific embodiment, when comparing and analyzing the power consumption data of a benchmark target and a target to be compared to determine similarity, the following specific steps can be taken.
[0035] Calculate the standard deviation of the i-th column of a two-dimensional matrix M1. And calculate the standard deviation of the two-dimensional matrix M2. M1 ki Let M1 be the element in the k-th row and i-th column of the two-dimensional matrix. M1 is the average value of the i-th column of the two-dimensional matrix M2. kj Let M2 be the element in the k-th row and j-th column of the two-dimensional matrix M2. Let be the average value of the j-th column of the two-dimensional matrix M2, where i or j takes the value 1, 2, ..., n, k takes the value 1, 2, ..., m, n is the number of columns of the two-dimensional matrix M1 or M2, and m is the number of rows of the two-dimensional matrix M1 or M2.
[0036] Calculate the covariance of the i-th column of two-dimensional matrix M1 and the j-th column of two-dimensional matrix M2.
[0037] According to the formula The elements P of the correlation coefficient matrix P between two-dimensional matrices M1 and M2 are calculated. ij ;
[0038] Determine if the absolute values of the elements on the diagonal of the correlation coefficient matrix meet a preset range. If they do, the benchmark target and the target to be compared are similar. For example, the absolute value |P ii| represents the absolute value of the elements on the diagonal of the correlation coefficient matrix, if 0.0 ≤ |P ii If |P < 0.4, then the target to be detected and the baseline target are considered to be uncorrelated. If 0.4 ≤ |P ii If |P < 0.6, then the target to be detected and the baseline target are considered to have some correlation. If 0.6 ≤ |P ii If |≤1.0, then the target to be detected and the benchmark target are considered to be highly correlated. This example is only to illustrate how to use the correlation coefficient matrix to determine similarity, and does not limit the specific preset range of values. The preset range of values can be adjusted according to the actual situation.
[0039] Since different software and hardware have different scales, the similarity judgment can also be done in modules and stages. The absolute values of the elements on the diagonal of the correlation coefficient matrix can be analyzed, and the benchmark target and the target to be compared can be divided into multiple corresponding modules. Based on the above technical solution, it can be determined whether each module of the benchmark target and the target to be compared is similar.
[0040] Based on the above technical solutions, this invention can also control the granularity of testing. Taking software as an example, some software may need to be tested during a single run, while others may not. When the software's call flow is controllable, testing is only performed during the execution of the software that needs to be tested. For example, when the software is a software library, the library provides various function interfaces. From the call to the function interface to the return of the result, the similarity of specific function interfaces can be detected without testing the similarity of the entire software library, thus achieving control over the granularity of software testing. For hardware similarity detection, the hardware may not operate continuously during a single test. Testing can be controlled to occur only during the hardware's operational period, with the similarity detection software issuing corresponding instructions to control the granularity of hardware testing.
[0041] The present invention also protects a software and / or hardware similarity detection device, including a controller, which uses the software and / or hardware similarity detection method of the above-described technical solution to determine the similarity between a benchmark target and a target to be compared.
[0042] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention. Those skilled in the art will understand that various changes or equivalent substitutions can be made to these features and embodiments without departing from the spirit and scope of the present invention. Furthermore, under the teachings of the present invention, these features and embodiments can be modified to adapt to specific situations and materials without departing from the spirit and scope of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application are within the scope of protection of the present invention.
Claims
1. A method for detecting software and / or hardware similarity, characterized in that, include: Step 1: Prepare the same testing environment for the software and / or hardware used as the benchmark and the software and / or hardware used as the target to be compared. Step 2: Input at least one set of identical test stimuli into the benchmark target and the target to be compared, respectively, to trigger the detection environment and acquire power consumption data; When there are multiple test stimuli, the multiple power consumption data corresponding to the benchmark target are represented as a two-dimensional matrix M1, and the multiple power consumption data corresponding to the comparison target are represented as a two-dimensional matrix M2. Each row of the two-dimensional matrices M1 and M2 represents the power consumption data of a test stimulus at different time points. Step 3: Compare and analyze the power consumption data corresponding to the benchmark target and the target to be compared, and determine the similarity of the power consumption data between the benchmark target and the target to be compared. If the similarity of the power consumption data between the benchmark target and the target to be compared meets the preset range, then the benchmark target and the target to be compared are determined to be similar. Step 3 includes: Calculate the standard deviation of the i-th column of a two-dimensional matrix M1. And calculate the standard deviation of the j-th column of the two-dimensional matrix M2. The Two-dimensional matrix The element in the k-th row and i-th column, the The average value of the i-th column of the two-dimensional matrix M1 is... Two-dimensional matrix The element in the k-th row and j-th column, the The average value of the j-th column of the two-dimensional matrix M2, where i or j takes the value 1, 2, ..., n, k takes the value 1, 2, ..., m, n is the number of columns of the two-dimensional matrix M1 or M2, and m is the number of rows of the two-dimensional matrix M1 or M2. Calculate the covariance of the i-th column of two-dimensional matrix M1 and the j-th column of two-dimensional matrix M2. ; And according to the formula The elements of the correlation coefficient matrix P between two-dimensional matrices M1 and M2 are calculated. ; Determine whether the absolute values of the elements on the diagonal of the correlation coefficient matrix meet the preset range; If this condition is met, then the benchmark target and the target to be compared are similar.
2. The method for detecting software and / or hardware similarity as described in claim 1, characterized in that, In step 2, a set of test stimuli are input multiple times into the benchmark target or the target to be compared, and the average power consumption curve of the set of test stimuli is calculated. The power consumption data corresponding to the average power consumption curve is used as the power consumption data of the basic target or the target to be compared under the set of test stimuli.
3. The method for detecting software and / or hardware similarity as described in claim 1, characterized in that, The absolute values of the elements on the diagonal of the correlation coefficient matrix are analyzed, and the benchmark target and the target to be compared are divided into multiple corresponding modules. Then, it is determined whether each module of the benchmark target and the target to be compared is similar.
4. The method for detecting software and / or hardware similarity as described in claim 1, characterized in that, When the benchmark target is software, a current probe and an oscilloscope are used to acquire power consumption data of the detection environment.
5. The method for detecting software and / or hardware similarity as described in claim 1, characterized in that, When the benchmark target includes hardware, a current probe and an oscilloscope are used to acquire power consumption data of the hardware.
6. A software and / or hardware similarity detection device, comprising a controller, characterized in that, The controller uses the software and / or hardware similarity detection method as described in any one of claims 1 to 5 to determine the similarity between the benchmark target and the target to be compared.
Citation Information
Patent Citations
Method and device for detecting server power consumption
CN103293410A
Chip power consumption detection method and device
CN112083318A