Method and system for testing smart cards
Patent Information
- Application Number
- CN202610988298.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-03
- Publication Date
- 2026-08-21
AI Technical Summary
由于现有技术完全忽略了智能卡执行不同操作时产生的功耗侧信道信息,导致无法捕捉这些隐蔽操作留下的物理特征
[0040]This application provides a testing method and system for smart cards. By acquiring the instantaneous energy consumption trajectory of the smart card under test during the execution of a target instruction, the actual operational characteristics generated at the physical level when the smart card under test executes the target instruction can be obtained. By matching the instantaneous energy consumption trajectory with a pre-established standard operation energy consumption feature library, the complex energy consumption changes during the execution of the target instruction can be analyzed into an internal operation behavior sequence composed of different basic operations, thereby realizing the identification and reconstruction of the actual internal execution behavior of the smart card under test. By comparing the internal operation behavior sequence with the expected behavior sequence corresponding to the target instruction, it can be determined whether the smart card under test has performed an unexpected operation during the execution of the target instruction, thereby breaking through the limitations of traditional black-box testing that only relies on instruction response results, and improving the accuracy, comprehensiveness, and security compliance detection capabilities of smart card operation behavior testing.
Smart Images

Figure CN122615693A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of smart card technology, and in particular to a testing method and testing system for smart cards. Background Technology
[0002] Smart cards (such as SIM cards and financial IC cards) are widely used in core areas such as communications, finance, and identity authentication. They typically run complex chip operating systems and multiple applications. To ensure the information security, functional integrity, and compliance of smart cards, rigorous testing is essential.
[0003] Traditional smart card testing primarily relies on interactive testing of APDU (Application Protocol Data Unit) commands, which involves sending commands to the smart card and checking the correctness of the returned response data and status words. However, this black-box testing method can only verify the surface correctness of the command output and cannot reveal the true internal behavior of the smart card during command execution. For example, some malicious programs or backdoor vulnerabilities may covertly perform unexpected additional operations when executing regular file read commands, and these operations often do not cause command errors. Because current technology completely ignores the power consumption side-channel information generated when the smart card performs different operations, it is impossible to capture the physical characteristics left by these covert operations.
[0004] In summary, existing technologies rely solely on command response results for external verification, making it difficult to effectively monitor and detect unexpected operational behaviors hidden within smart cards during testing. This results in insufficient comprehensiveness and accuracy in security and compliance testing. Summary of the Invention
[0005] In view of this, the purpose of this application is to provide a testing method and system for smart cards. By collecting the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction and matching and analyzing it with a pre-established standard operation energy consumption feature library, the internal operation behavior sequence of the smart card during the execution of the target instruction can be reconstructed, thereby identifying hidden unexpected operation behaviors and improving the security and compliance detection capabilities of smart card testing.
[0006] In a first aspect, the present invention provides a method for testing a smart card, comprising: Obtain the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction.
[0007] The instantaneous energy consumption trajectory is segmented to obtain multiple trajectory segments.
[0008] Multiple trajectory segments are matched with a pre-established standard operation energy consumption feature library to obtain matching results. The matching results are used to characterize the correspondence between trajectory segments and basic operations. The standard operation energy consumption feature library is used to store the energy consumption features corresponding to the smart card when performing different basic operations.
[0009] Based on the matching results, determine the multiple basic operations of the smart card under test during the execution of the target instruction, as well as the execution order of these basic operations.
[0010] Based on multiple basic operations and their execution order, a sequence of internal operation behaviors of the smart card under test during the execution of the target instruction is generated.
[0011] The test results of the smart card under test are determined by comparing the internal operation behavior sequence with the expected behavior sequence corresponding to the target instruction.
[0012] In an optional implementation, the method further includes the step of establishing a standard operating energy consumption characteristic library, specifically: Control the standard smart card to perform several preset basic operations.
[0013] During the execution of each basic operation by the standard smart card, the standard instantaneous energy consumption trajectory for each basic operation is acquired.
[0014] Feature extraction is performed on each standard instantaneous energy consumption trajectory to obtain the energy consumption features corresponding to each basic operation.
[0015] A standard operating energy consumption feature library was constructed based on energy consumption characteristics.
[0016] In an optional implementation, the basic operations include at least one of data processing operations, non-volatile memory write operations, cryptographic algorithm operations, and random number generation operations.
[0017] Energy consumption characteristics include at least one of waveform shape, peak value, duration, and frequency characteristics.
[0018] In an optional implementation, the step of obtaining the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction includes: While sending the target command to the smart card under test, the high-precision energy consumption acquisition unit is started simultaneously.
[0019] During the execution of the target instruction by the smart card under test, the current and / or voltage data of the circuit in the smart card under test are collected in real time through a high-precision energy consumption acquisition unit.
[0020] After the target instruction is executed, an instantaneous energy consumption trajectory is generated based on the collected current and / or voltage data.
[0021] In an optional implementation, the step of determining, based on the matching results, multiple basic operations of the smart card under test during the execution of the target instruction, and the execution order of these basic operations, includes: Based on the matching results for each trajectory segment, determine the basic operation corresponding to each trajectory segment.
[0022] The execution order of multiple basic operations is determined based on the time position of each trajectory segment in the instantaneous energy consumption trajectory.
[0023] In an optional implementation, before segmenting the instantaneous energy consumption trajectory, the method further includes: The instantaneous energy consumption trajectory is filtered to obtain the filtered instantaneous energy consumption trajectory.
[0024] The filtered instantaneous energy consumption trajectory is time-aligned to obtain the time-aligned instantaneous energy consumption trajectory.
[0025] The instantaneous energy consumption trajectory after time alignment is segmented.
[0026] In an optional implementation, the step of comparing the internal operation behavior sequence with the expected behavior of the target instruction, and determining the test result of the smart card under test based on the comparison result, includes: The basic operations and their execution order in the internal operation sequence are compared with the expected basic operations and their execution order in the expected behavior sequence to obtain the comparison results.
[0027] If the comparison results indicate that the basic operations in the internal operational behavior sequence and the execution order of the basic operations are consistent with the expected behavior sequence, the test result is determined to be a pass.
[0028] If the comparison results indicate that the internal operational behavior sequence includes basic operations outside the expected behavior sequence, lacks expected basic operations in the expected behavior sequence, and / or the execution order of the basic operations is inconsistent with the expected execution order, the test result is determined to be a test failure.
[0029] In an optional implementation, after determining that the test result is a test failure, the method further includes: Identify abnormal comparison items that cause the test result to fail.
[0030] When the anomaly comparison item includes basic operations outside the expected behavior sequence, identify the operation type corresponding to the basic operations outside the expected behavior sequence.
[0031] Based on the anomaly comparison items and / or operation type, determine the abnormal behavior of the smart card under test and output the corresponding prompt information for the abnormal behavior.
[0032] In an optional implementation, the target instruction is at least one instruction from a preset test instruction sequence.
[0033] The method also includes: Send a sequence of test commands to the smart card under test in a preset order.
[0034] The instantaneous energy consumption trajectory of each instruction in the test instruction sequence is obtained, and the test result corresponding to each instruction is determined.
[0035] Generate the overall test result corresponding to the sequence of test instructions based on each test result.
[0036] Secondly, the present invention provides a testing system for performing a testing method for a smart card according to any of the foregoing embodiments; the system includes a test control host, a smart card reader / writer interface, a high-precision power consumption acquisition unit, and a data processing and analysis unit.
[0037] The test control host establishes a communication connection with the smart card under test through the smart card reader / writer interface, and is used to send target commands to the smart card under test.
[0038] A high-precision energy consumption acquisition unit is connected in series on the power supply line of the smart card under test to acquire the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction.
[0039] The data processing and analysis unit is communicatively connected to both the test control host and the high-precision energy consumption acquisition unit. It segments the instantaneous energy consumption trajectory to obtain multiple trajectory fragments. These fragments are then matched against a pre-established standard operation energy consumption feature library to obtain matching results. The matching results characterize the correspondence between trajectory fragments and basic operations. The standard operation energy consumption feature library stores the energy consumption characteristics of the smart card when performing different basic operations. Based on the matching results, the unit determines the multiple basic operations and their execution order of the smart card under test during the execution of the target instruction. Based on these basic operations and their execution order, it generates an internal operation behavior sequence for the smart card under test during the execution of the target instruction. Finally, it compares this internal operation behavior sequence with the expected behavior sequence corresponding to the target instruction, and determines the test result of the smart card under test based on the comparison results.
[0040] This application provides a testing method and system for smart cards. By acquiring the instantaneous energy consumption trajectory of the smart card under test during the execution of a target instruction, the actual operational characteristics generated at the physical level when the smart card under test executes the target instruction can be obtained. By matching the instantaneous energy consumption trajectory with a pre-established standard operation energy consumption feature library, the complex energy consumption changes during the execution of the target instruction can be analyzed into an internal operation behavior sequence composed of different basic operations, thereby realizing the identification and reconstruction of the actual internal execution behavior of the smart card under test. By comparing the internal operation behavior sequence with the expected behavior sequence corresponding to the target instruction, it can be determined whether the smart card under test has performed an unexpected operation during the execution of the target instruction, thereby breaking through the limitations of traditional black-box testing that only relies on instruction response results, and improving the accuracy, comprehensiveness, and security compliance detection capabilities of smart card operation behavior testing.
[0041] Other features and advantages of this application will be set forth in the following description and will be apparent in part from the description or may be learned by practicing the application. The objectives and other advantages of this application are realized and obtained through the structures particularly pointed out in the description, claims and drawings.
[0042] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0044] Figure 1 A schematic diagram of the test system provided in the embodiments of this application; Figure 2 A flowchart of a smart card testing method provided in an embodiment of this application; Figure 3 Flowchart of the method for establishing a standard operating energy consumption feature library provided in the embodiments of this application; Figure 4 A flowchart of the instantaneous energy consumption trajectory acquisition method provided in the embodiments of this application; Figure 5 Flowchart of the method for determining the sequence of internal operation behaviors provided in the embodiments of this application; Figure 6 A flowchart illustrating the test result determination method provided in this application embodiment.
[0045] Icons: 1-Test control host; 2-Smart card reader interface; 3-High-precision energy consumption acquisition unit; 4-Data processing and analysis unit. Detailed Implementation
[0046] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0047] To help those skilled in the art better understand this application, a brief introduction to its application scenarios and design concepts is provided.
[0048] Existing smart card testing solutions primarily rely on Application Protocol Data Unit (APDU) command interaction. This involves sending a target command to the smart card and determining success based on the response data and status word returned by the card. This type of testing is essentially a black-box approach, only verifying whether the smart card's external output matches expectations, but failing to capture the actual internal execution behavior of the smart card during the execution of the target command. Therefore, when hidden logic, abnormal calls, malicious backdoors, or unexpected operations exist within the smart card, even if the smart card ultimately returns a correct response, current technology cannot identify whether the smart card has performed unauthorized write operations, accessed sensitive data, invoked abnormal cryptographic algorithms, or engaged in other violations in the background. This results in significant blind spots in smart card security testing, functional integrity testing, and compliance verification.
[0049] Furthermore, existing technologies typically overlook the power consumption side-channel characteristics generated by smart cards during different internal operations. In reality, different types of basic operations produce different current and voltage variation characteristics during execution. For example, data read operations, non-volatile memory write operations, cryptographic algorithm operations, and random number generation operations all exhibit significant differences in power consumption waveforms, peak values, durations, and frequency characteristics. Because existing testing schemes do not collect and analyze power consumption side-channel information during smart card operations, this physical layer information cannot be used to identify and verify the true internal behavior of smart cards, thus limiting the comprehensiveness and accuracy of test results.
[0050] Based on this, embodiments of this application provide a testing method and system for smart cards. By collecting instantaneous energy consumption trajectories in real time during the execution of target instructions by the smart card under test, and constructing a standard operation energy consumption feature library, the collected instantaneous energy consumption trajectories are matched and analyzed with the standard operation energy consumption feature library to obtain the internal operation behavior sequence of the smart card under test during the execution of the target instructions. Subsequently, the internal operation behavior sequence is compared with the expected behavior sequence corresponding to the target instructions to determine the test results of the smart card under test. Through this method, the actual internal execution behavior of the smart card can be reconstructed and identified at the physical level, thereby effectively discovering hidden operation behaviors, illegal call behaviors, and abnormal write behaviors that traditional black-box testing cannot detect, improving the security detection capability, behavior compliance verification capability, and testing accuracy during the smart card testing process. Simultaneously, this application can also achieve refined identification of different basic smart card operation behaviors, enhancing the transparency of the smart card testing process and providing more reliable technical support for smart card security assessment, functional verification, and abnormal behavior detection.
[0051] To facilitate understanding of this embodiment, the embodiments of this application will be described in detail below.
[0052] This application provides a testing system for executing a smart card testing method; see reference... Figure 1 The test system provided in this application includes a test control host 1, a smart card reader interface 2, a high-precision energy consumption acquisition unit 3, and a data processing and analysis unit 4.
[0053] The test control host 1 establishes a communication connection with the smart card under test through the smart card reader / writer interface 2, and is used to send target instructions to the smart card under test.
[0054] The high-precision energy consumption acquisition unit 3 is connected in series on the power supply line of the smart card under test to acquire the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction.
[0055] The data processing and analysis unit 4 is communicatively connected to the test control host 1 and the high-precision energy consumption acquisition unit 3, respectively. It is used to segment the instantaneous energy consumption trajectory to obtain multiple trajectory segments; match these multiple trajectory segments with a pre-established standard operation energy consumption feature library to obtain matching results; the matching results characterize the correspondence between trajectory segments and basic operations; the standard operation energy consumption feature library stores the energy consumption characteristics corresponding to different basic operations performed by the smart card; based on the matching results, it determines multiple basic operations and their execution order during the execution of the target instruction by the smart card under test; based on these basic operations and their execution order, it generates an internal operation behavior sequence of the smart card under test during the execution of the target instruction; and compares this internal operation behavior sequence with the expected behavior sequence corresponding to the target instruction, determining the test result of the smart card under test based on the comparison results.
[0056] Here, the testing system is used to test and analyze the internal operational behavior of the smart card under test during the execution of target instructions. The smart card under test can be a SIM card, USIM card, financial IC card, Java Card, Native Card, or other embedded security chip. The testing system includes a test control host 1, a smart card reader / writer interface 2, a high-precision power consumption acquisition unit 3, and a data processing and analysis unit 4.
[0057] The test control host 1 establishes a communication connection with the smart card under test (SDB) through the smart card reader / writer interface 2. The test control host 1 runs test scripts, sends target instructions to the SDB according to the test scripts, and receives test results output by the data processing and analysis unit 4. The target instructions can be application protocol data unit instructions, or other test instructions used to trigger the SDB to perform operations such as reading, writing, algorithm calls, random number generation, or application selection. The test control host 1 can send target instructions to the SDB as a single instruction, or send a sequence of test instructions consisting of multiple target instructions in a preset order.
[0058] The smart card reader / writer interface 2 is located between the test control host 1 and the smart card under test. The smart card reader / writer interface 2 establishes a communication link between the test control host 1 and the smart card under test, forwards the target instructions sent by the test control host 1 to the smart card under test, and simultaneously feeds back the response data, status word, or execution completion information returned by the smart card under test to the test control host 1. The smart card reader / writer interface 2 can be a contact smart card reader / writer interface, a contactless smart card reader / writer interface, or a composite interface supporting both contact and contactless communication. The smart card reader / writer interface 2 can be integrated with the test control host 1 or connected to the test control host 1 as a standalone device.
[0059] A high-precision energy consumption acquisition unit 3 is connected in series in the power supply line of the smart card under test. The high-precision energy consumption acquisition unit 3 is used to collect current and / or voltage data in the power supply line of the smart card under test in real time during the execution of the target instruction, and to generate an instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction based on the collected current and / or voltage data. The high-precision energy consumption acquisition unit 3 can be set on the power supply branch between the smart card reader / writer interface 2 and the smart card under test, or it can be set on the main power supply line from the test system to the smart card under test, as long as the high-precision energy consumption acquisition unit 3 can acquire the instantaneous current and / or instantaneous voltage changes of the smart card under test during the execution of the target instruction. The high-precision energy consumption acquisition unit 3 may include one or more of the following: current sampling circuit, voltage sampling circuit, analog-to-digital conversion circuit, sampling control circuit, and data buffer circuit. The high-precision energy consumption acquisition unit 3 can collect data at a sampling frequency higher than the frequency of changes in the basic operations within the smart card under test, in order to retain the waveform shape, peak value, duration, and frequency characteristics corresponding to different basic operations.
[0060] The data processing and analysis unit 4 is communicatively connected to both the test control host 1 and the high-precision energy consumption acquisition unit 3. The data processing and analysis unit 4 receives the instantaneous energy consumption trajectory output by the high-precision energy consumption acquisition unit 3 and processes and analyzes the instantaneous energy consumption trajectory. The data processing and analysis unit 4 can filter the instantaneous energy consumption trajectory to reduce noise interference; it can perform time alignment processing on the filtered instantaneous energy consumption trajectory to ensure that the instantaneous energy consumption trajectory corresponds to the execution time period of the target instruction; and it can segment the time-aligned instantaneous energy consumption trajectory to obtain multiple trajectory segments.
[0061] The data processing and analysis unit 4 can pre-store a standard operation energy consumption feature library, or it can retrieve the library from the test control host 1, external storage devices, or a server. The standard operation energy consumption feature library stores the energy consumption characteristics of the smart card when performing different basic operations. Basic operations may include at least one of data processing operations, non-volatile memory write operations, cryptographic algorithm operations, and random number generation operations. Energy consumption characteristics may include at least one of waveform shape, peak value, duration, and frequency characteristics. The standard operation energy consumption feature library can be obtained by collecting standard instantaneous energy consumption trajectories and extracting energy consumption characteristics after a standard smart card has pre-executed multiple basic operations, or it can be constructed from historical test data, standard sample data, or statistical data from multiple standard smart cards.
[0062] The data processing and analysis unit 4 matches the instantaneous energy consumption trajectory generated during the execution of the target instruction by the smart card under test with the standard operation energy consumption feature library. Specifically, the data processing and analysis unit 4 segments the instantaneous energy consumption trajectory to obtain multiple trajectory segments; it then matches these multiple trajectory segments with the standard operation energy consumption feature library to obtain matching results. The matching results are used to characterize the correspondence between trajectory segments and basic operations. Based on the matching results for each trajectory segment, the data processing and analysis unit 4 can determine the basic operation corresponding to each trajectory segment; and based on the time position of each trajectory segment in the instantaneous energy consumption trajectory, it can determine the execution order of multiple basic operations.
[0063] Subsequently, the data processing and analysis unit 4 generates an internal operation behavior sequence of the smart card under test during the execution of the target instruction, based on multiple basic operations and their execution order. This internal operation behavior sequence represents the actual combination of basic operations performed by the smart card under test during the execution of the target instruction, as well as the execution order of these basic operations. Through this internal operation behavior sequence, the testing system can convert the continuous energy consumption changes of the smart card under test during the execution of the target instruction into identifiable and comparable operation behavior information.
[0064] The data processing and analysis unit 4 is also used to compare the internal operation behavior sequence with the expected behavior sequence corresponding to the target instruction, and determine the test result of the smart card under test based on the comparison result. Specifically, the data processing and analysis unit 4 can compare the basic operations and the execution order of the basic operations in the internal operation behavior sequence with the expected basic operations and the expected execution order in the expected behavior sequence to obtain the comparison result.
[0065] When the comparison results indicate that the basic operations in the internal operation sequence and the execution order of the basic operations are consistent with the expected operation sequence, the data processing and analysis unit 4 determines that the test result of the smart card under test for the target instruction is a pass. When the comparison results indicate that the internal operation sequence includes basic operations outside the expected operation sequence, lacks the expected basic operations in the expected operation sequence, and / or the execution order of the basic operations is inconsistent with the expected execution order, the data processing and analysis unit 4 determines that the test result of the smart card under test for the target instruction is a fail.
[0066] If the test result is a failure, the data processing and analysis unit 4 can also identify the abnormal comparison items that caused the test failure. When the abnormal comparison item includes a basic operation outside the expected behavior sequence, the data processing and analysis unit 4 can identify the operation type corresponding to the basic operation outside the expected behavior sequence, and determine the abnormal behavior of the smart card under test based on the abnormal comparison item and / or operation type, and output the corresponding prompt information for the abnormal behavior. For example, when the target instruction is a read instruction, but there is a non-volatile memory write operation in the internal operation behavior sequence, the data processing and analysis unit 4 can identify the non-volatile memory write operation as a basic operation outside the expected behavior sequence and output a prompt information indicating the existence of unexpected write behavior. As another example, when the internal operation behavior sequence lacks the expected basic operation in the expected behavior sequence, the data processing and analysis unit 4 can output a prompt information indicating the lack of expected operation; when the execution order of the basic operations is inconsistent with the expected execution order, the data processing and analysis unit 4 can output a prompt information indicating an abnormal execution order.
[0067] In one optional embodiment, the test control host 1, smart card reader / writer interface 2, high-precision energy consumption acquisition unit 3, and data processing and analysis unit 4 can be configured as independent hardware modules and connected via wired communication. In another optional embodiment, the smart card reader / writer interface 2 and high-precision energy consumption acquisition unit 3 can be integrated into the same test fixture or test reading / writing device. In yet another optional embodiment, the data processing and analysis unit 4 can be integrated into the test control host 1, whereby the test control host 1 performs instantaneous energy consumption trajectory processing, standard operation energy consumption feature library matching, internal operation behavior sequence generation, and test result determination. In yet another optional embodiment, the data processing and analysis unit 4 can be deployed in an independent computing device or server. The test control host 1 sends the instantaneous energy consumption trajectory to the data processing and analysis unit 4, which then performs analysis and returns the test results to the test control host 1.
[0068] The testing system provided in this application embodiment includes a test control host 1 that controls the smart card under test to execute target instructions, a high-precision energy consumption acquisition unit 3 that acquires the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instructions, and a data processing and analysis unit 4 that segments the instantaneous energy consumption trajectory into multiple trajectory segments. Based on a standard operation energy consumption feature library, the system determines multiple basic operations of the smart card under test during the execution of the target instructions and the execution order of these basic operations, thereby generating an internal operation behavior sequence. The system then determines the test result based on the comparison between the internal operation behavior sequence and the expected behavior sequence. Therefore, the testing system can not only determine whether the results returned by the smart card under test are correct, but also identify from the perspective of physical energy consumption characteristics whether the smart card under test has executed basic operations outside the expected behavior sequence, whether the expected basic operations are missing, and whether the execution order of the basic operations is abnormal, thereby improving the accuracy, security, and compliance detection capabilities of smart card testing.
[0069] In an optional implementation, the smart card testing system further includes: Test control host 1 is also used to control the standard smart card to perform several preset basic operations.
[0070] The high-precision energy consumption acquisition unit 3 is also used to acquire the standard instantaneous energy consumption trajectory when each basic operation is performed during the execution of each basic operation by the standard smart card.
[0071] The data processing and analysis unit 4 is also used to extract features from each standard instantaneous energy consumption trajectory to obtain the energy consumption features corresponding to each basic operation.
[0072] Data processing and analysis unit 4 is also used to build a standard operating energy consumption feature library based on energy consumption characteristics.
[0073] In an optional implementation, the basic operations include at least one of data processing operations, non-volatile memory write operations, cryptographic algorithm operations, and random number generation operations.
[0074] Energy consumption characteristics include at least one of waveform shape, peak value, duration, and frequency characteristics.
[0075] In an optional implementation, the smart card testing system further includes: The test control host 1 is also used to simultaneously start the high-precision energy consumption acquisition unit 3 while sending the target command to the smart card under test.
[0076] The high-precision energy consumption acquisition unit 3 is also used to collect current and / or voltage data of the circuits in the smart card under test in real time during the execution of the target instruction by the smart card under test.
[0077] The data processing and analysis unit 4 is also used to generate an instantaneous energy consumption trajectory based on the collected current data and / or voltage data after the target instruction is executed.
[0078] In an optional implementation, the data processing and analysis unit 4 is further configured to: Based on the matching results for each trajectory segment, determine the basic operation corresponding to each trajectory segment.
[0079] The execution order of multiple basic operations is determined based on the time position of each trajectory segment in the instantaneous energy consumption trajectory.
[0080] In an optional implementation, the data processing and analysis unit 4 is further configured to: The instantaneous energy consumption trajectory is filtered to obtain the filtered instantaneous energy consumption trajectory.
[0081] The filtered instantaneous energy consumption trajectory is time-aligned to obtain the time-aligned instantaneous energy consumption trajectory.
[0082] The instantaneous energy consumption trajectory after time alignment is segmented.
[0083] In an optional implementation, the data processing and analysis unit 4 is further configured to: The basic operations and their execution order in the internal operation sequence are compared with the expected basic operations and their execution order in the expected behavior sequence to obtain the comparison results.
[0084] If the comparison results indicate that the basic operations in the internal operational behavior sequence and the execution order of the basic operations are consistent with the expected behavior sequence, the test result is determined to be a pass.
[0085] If the comparison results indicate that the internal operational behavior sequence contains basic operations outside the expected behavior sequence, lacks expected basic operations in the expected behavior sequence, and / or the execution order of the basic operations is inconsistent with the expected execution order, the test result is determined to be a test failure.
[0086] In an optional implementation, the data processing and analysis unit 4 is further configured to: Identify abnormal comparison items that cause the test result to fail.
[0087] When the anomaly comparison item includes basic operations outside the expected behavior sequence, identify the operation type corresponding to the basic operations outside the expected behavior sequence.
[0088] Based on the anomaly comparison items and / or operation type, determine the abnormal behavior of the smart card under test and output the corresponding prompt information for the abnormal behavior.
[0089] In an optional implementation, the target instruction is at least one instruction from a preset test instruction sequence. The smart card testing system further includes: The test control host 1 is also used to send a sequence of test instructions to the smart card under test in a preset order.
[0090] The high-precision energy consumption acquisition unit 3 is also used to acquire the instantaneous energy consumption trajectory of each instruction in the test instruction sequence during execution, and to determine the test result corresponding to each instruction.
[0091] The data processing and analysis unit 4 is also used to generate the overall test result corresponding to the test instruction sequence based on each test result.
[0092] Based on this, embodiments of this application provide a testing method for smart cards, referring to... Figure 2 The smart card testing method provided in this application includes: Step S101: Obtain the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction.
[0093] Here, the target instruction can be an application protocol data unit instruction, or a test instruction used to trigger the smart card under test to perform data reading, data writing, file selection, cryptographic algorithm operation, random number generation operation, application selection operation, or permission verification operation.
[0094] The test control host sends target instructions to the smart card under test (SDK) via the smart card reader / writer interface. Upon receiving the target instruction, the SDK begins executing the internal processing procedure corresponding to that instruction. This internal processing procedure may include a single basic operation or a combination of multiple basic operations. For example, read instructions typically involve data processing operations, update instructions typically involve data processing operations and non-volatile memory write operations, authentication instructions typically involve cryptographic algorithm operations, and random number generation instructions typically involve random number generation operations.
[0095] During the execution of the target instruction by the smart card under test (SDT), the high-precision energy consumption acquisition unit collects the current and / or voltage data of the power supply lines in the SDT in real time, and generates an instantaneous energy consumption trajectory based on the collected current and / or voltage data. The instantaneous energy consumption trajectory represents the change in energy consumption of the SDT over time during the execution of the target instruction. The instantaneous energy consumption trajectory can be a trajectory formed by the change in current over time, a trajectory formed by the change in voltage over time, or a trajectory formed by the change in instantaneous power over time calculated based on the current and voltage data. As long as the data reflects the instantaneous energy consumption changes of the SDT during the execution of the target instruction, it can be used as an instantaneous energy consumption trajectory.
[0096] In actual data acquisition, the high-precision energy consumption acquisition unit can start acquisition synchronously when the target command is sent, or it can start acquisition a preset time before the target command is sent, or it can start acquisition when the smart card under test begins to respond to the target command. The high-precision energy consumption acquisition unit can stop acquisition after the smart card under test returns response data or status words, or it can stop acquisition after the preset execution time corresponding to the target command has ended. By reserving acquisition time before and after the execution of the target command, the energy consumption changes at the beginning or end of the target command can be avoided.
[0097] Step S102: The instantaneous energy consumption trajectory is segmented to obtain multiple trajectory segments.
[0098] Here, the data processing and analysis unit segments the instantaneous energy consumption trajectory. Since the execution of the target instruction may involve multiple basic operations, the complete instantaneous energy consumption trajectory typically consists of multiple energy consumption variation intervals. The data processing and analysis unit divides the complete instantaneous energy consumption trajectory into multiple trajectory segments, allowing each segment to serve as the basic unit for subsequent matching analysis.
[0099] In one optional implementation, the data processing and analysis unit can segment the instantaneous energy consumption trajectory according to a preset time window. For example, the data processing and analysis unit can continuously divide the instantaneous energy consumption trajectory into multiple trajectory segments using a fixed-length time window. The data processing and analysis unit can also use a sliding window method for segmentation, so that there is partial overlap between adjacent trajectory segments, thereby reducing the recognition error caused by the basic operation boundary falling between two trajectory segments.
[0100] In another optional implementation, the data processing and analysis unit can segment the instantaneous energy consumption trajectory based on the energy consumption change characteristics. For example, when a sudden change in current peak, voltage fluctuation, power change, rising edge, falling edge, or energy change rate exceeds a preset threshold occurs in the instantaneous energy consumption trajectory, the data processing and analysis unit determines the above-mentioned position as the segmentation boundary and obtains multiple trajectory segments based on the segmentation boundary.
[0101] In another optional implementation, the data processing and analysis unit can segment the data based on the execution time information of the target instruction. The execution time information of the target instruction may include the target instruction sending time, the start time of the smart card under test, the response data return time, the status word return time, or a time stamp of a preset execution stage. Based on the above time information, the data processing and analysis unit determines the effective analysis interval in the instantaneous energy consumption trajectory and further divides the effective analysis interval into multiple trajectory segments.
[0102] Step S103: Match multiple trajectory segments with a pre-established standard operation energy consumption feature library to obtain matching results; wherein, the matching results are used to characterize the correspondence between trajectory segments and basic operations; the standard operation energy consumption feature library is used to store the energy consumption features corresponding to the smart card when performing different basic operations.
[0103] Here, the data processing and analysis unit matches multiple trajectory segments with a standard operation energy consumption feature library. This library stores the energy consumption characteristics of the smart card when performing different basic operations. Basic operations can include data processing operations, non-volatile memory write operations, cryptographic algorithm operations, and random number generation operations. Energy consumption characteristics can include waveform shape, peak value, duration, and frequency characteristics. The standard operation energy consumption feature library is essentially a set of energy consumption characteristics corresponding to basic operations. The data processing and analysis unit can use this library to determine which type of basic operation the trajectory segment most closely resembles.
[0104] During matching, the data processing and analysis unit can extract features to be matched for each trajectory segment. These features may include the waveform shape, peak value, duration, frequency distribution, energy integral value, rising edge slope, falling edge slope, mean, variance, or local peak distribution of the trajectory segment. The data processing and analysis unit compares these features with energy consumption features in the standard operating energy consumption feature library to obtain the matching result.
[0105] The matching method can be set according to actual testing needs. In one optional implementation, the data processing and analysis unit can use waveform similarity matching to calculate the similarity between the waveform shape of the trajectory segment and the reference waveform in the standard operating energy consumption feature library. In another optional implementation, the data processing and analysis unit can use feature range matching to compare the peak value, duration, and frequency characteristics of the trajectory segment with the feature ranges in the standard operating energy consumption feature library, respectively. In yet another optional implementation, the data processing and analysis unit can use dynamic time warping matching to calculate the matching degree after aligning the trajectory segment with the reference trajectory through time scaling. The data processing and analysis unit can also use a classification model to identify the trajectory segment, and the classification model can be trained based on sample features in the standard operating energy consumption feature library.
[0106] The matching results can include candidate basic operations corresponding to the trajectory segment, matching scores for the candidate basic operations, matching confidence levels, matching threshold judgment results, or ranking results of candidate basic operations. Through the matching results, the data processing and analysis unit can obtain the correspondence between trajectory segments and basic operations, providing a basis for determining the multiple basic operations actually performed by the smart card under test.
[0107] Step S104: Based on the matching results, determine the multiple basic operations of the smart card under test during the execution of the target instruction and the execution order of the multiple basic operations.
[0108] Here, the data processing and analysis unit determines multiple basic operations involved in the execution of the target instruction by the smart card under test based on the matching results obtained in step S103. For each trajectory segment, the data processing and analysis unit can determine the basic operation corresponding to that trajectory segment based on the matching results. When the matching score between a trajectory segment and the energy consumption characteristic corresponding to a basic operation meets a preset matching threshold, the data processing and analysis unit determines that basic operation as the basic operation corresponding to that trajectory segment. When a trajectory segment meets the preset matching threshold with multiple basic operations, the data processing and analysis unit can determine the basic operation corresponding to that trajectory segment by combining the matching results of adjacent trajectory segments and the business logic corresponding to the target instruction.
[0109] In one optional implementation, when a trajectory segment does not meet a preset matching threshold with any basic operation in the standard operation energy consumption feature library, the data processing and analysis unit can mark the trajectory segment as an unknown operation segment or as a segment to be reviewed. Unknown operation segments or segments to be reviewed can indicate to the tester that the standard operation energy consumption feature library may need updating, or that the smart card under test may have performed an abnormal operation not recorded in the standard operation energy consumption feature library.
[0110] After identifying multiple basic operations, the data processing and analysis unit determines the execution order of these operations based on the temporal positions of multiple trajectory segments within the instantaneous energy consumption trajectory. Generally, the earlier the temporal position of a trajectory segment within the instantaneous energy consumption trajectory, the earlier the corresponding basic operation is executed; conversely, the later the temporal position of a trajectory segment, the later the corresponding basic operation is executed. By sorting the multiple basic operations according to their temporal positions, the data processing and analysis unit obtains the execution order of the operations.
[0111] Step S105: Based on multiple basic operations and their execution order, generate the internal operation behavior sequence of the smart card under test during the execution of the target instruction.
[0112] Here, the data processing and analysis unit generates an internal operation behavior sequence of the smart card under test during the execution of the target instruction, based on several defined basic operations and their execution order. This internal operation behavior sequence represents the actual combination of basic operations performed by the smart card under test during the execution of the target instruction, as well as the execution order of these basic operations.
[0113] The internal operation sequence can include only the operation type and execution order of basic operations, or it can further include the start time, end time, duration, corresponding trajectory segment identifier, matching score, or matching confidence level for each basic operation. By retaining the above information, the data processing and analysis unit can determine not only whether the basic operation type and execution order meet expectations during subsequent comparisons, but also whether the duration of the basic operation is abnormal, whether the matching confidence level is too low, and whether there are unknown operation segments.
[0114] For example, when the target instruction is a read instruction, the internal operation sequence may normally only include data processing operations. However, if the data processing and analysis unit determines, based on the matching results, that the smart card under test first performs a data processing operation and then a non-volatile memory write operation, then the internal operation sequence generated by the data processing and analysis unit will include both the data processing operation and the non-volatile memory write operation. This internal operation sequence reflects that the smart card under test performed an additional write operation during the execution of the read instruction, providing a basis for determining the test results.
[0115] Step S106: Compare the internal operation behavior sequence with the expected behavior sequence corresponding to the target instruction, and determine the test result of the smart card under test based on the comparison result.
[0116] Here, the data processing and analysis unit obtains the expected behavior sequence corresponding to the target instruction. The expected behavior sequence represents the basic operations that the target instruction should trigger under normal execution conditions, as well as the expected execution order of these basic operations. The expected behavior sequence can be pre-configured by testers or determined based on test scripts, smart card application specifications, standard smart card execution results, or historical qualified sample execution results. The expected behavior sequence may include expected basic operations, expected execution order, allowed basic operations, prohibited basic operations, the allowed number of basic operations, or the allowed duration range of basic operations.
[0117] The data processing and analysis unit compares the basic operations and their execution order in the internal operational behavior sequence with the expected basic operations and their expected execution order in the expected behavior sequence to obtain the comparison results. The comparison may include whether the basic operation types are consistent, whether the basic operation execution order is consistent, whether the number of basic operations is consistent, whether basic operations outside the expected behavior sequence are included, whether any expected basic operations in the expected behavior sequence are missing, and whether the duration of the basic operations is within the allowable range.
[0118] When the comparison results indicate that the basic operations in the internal operational behavior sequence and the execution order of the basic operations are consistent with the expected behavior sequence, the data processing and analysis unit determines that the test result of the smart card under test is a pass. When the comparison results indicate that the internal operational behavior sequence includes basic operations outside the expected behavior sequence, lacks expected basic operations in the expected behavior sequence, and / or the execution order of the basic operations is inconsistent with the expected execution order, the data processing and analysis unit determines that the test result of the smart card under test is a fail.
[0119] Specifically, the target instruction is a binary file read instruction. The expected behavior sequence includes data processing operations but does not include non-volatile memory write operations. After the test system sends the binary file read instruction to the smart card under test, the data processing and analysis unit obtains the instantaneous power consumption trajectory of the smart card under test during the execution of the binary file read instruction, and performs segmented processing and matching analysis on the instantaneous power consumption trajectory. If the internal operation behavior sequence only includes data processing operations, the data processing and analysis unit determines the test result as a pass. If the internal operation behavior sequence includes data processing operations and non-volatile memory write operations, the data processing and analysis unit determines that the internal operation behavior sequence contains basic operations outside the expected behavior sequence and determines the test result as a fail.
[0120] Based on this, the embodiments of this application can convert the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction into multiple trajectory segments, and determine multiple basic operations and their execution order based on a standard operation energy consumption feature library, thereby generating an internal operation behavior sequence. Subsequently, the embodiments of this application compare the internal operation behavior sequence with the expected behavior sequence to determine whether the smart card under test has executed basic operations outside the expected behavior sequence, whether the expected basic operations are missing, and whether the execution order of the basic operations is abnormal. Thus, the embodiments of this application can not only determine whether the results returned by the smart card under test are correct, but also detect the actual internal execution behavior of the smart card under test from the perspective of physical energy consumption characteristics, improving the accuracy, security, and compliance detection capabilities of smart card testing.
[0121] In an optional implementation, the method further includes the step of establishing a standard operating energy consumption characteristic library, referring to... Figure 3 Specifically, the steps are as follows: S201-S204.
[0122] Step S201: Control the standard smart card to perform multiple preset basic operations.
[0123] Here, the standard smart card can be a sample of a smart card that is functional, conforms to the test specifications, and has no known abnormal behavior. The standard smart card can be a single smart card or multiple smart cards of the same model or from different batches. Building a standard operating energy consumption feature library using multiple standard smart cards can reduce the impact of differences in a single sample on energy consumption characteristics, thus improving the applicability of the standard operating energy consumption feature library in subsequent tests.
[0124] Basic operations refer to the fundamental operational units that a smart card may invoke when executing target instructions. These basic operations include at least one of the following: data processing operations, non-volatile memory write operations, cryptographic algorithm operations, and random number generation operations. Data processing operations may include data transfer, data reading, cache writing, memory access, and file system reading. Non-volatile memory write operations may include writing, erasing, updating, or writing status flags to EEPROM (Electrically Erasable Programmable Read-Only Memory) or Flash memory. Cryptographic algorithm operations may include operations where algorithms such as AES (Advanced Encryption Standard), RSA (Asymmetric Encryption), and DES (Data Encryption Standard) are run independently, or operations related to security calculations such as digest calculation, signature verification, and key derivation. Random number generation operations may include hardware random number generation, pseudo-random number generation, or random challenge number generation for security protocols.
[0125] When controlling a standard smart card to perform basic operations, the test control host can send preset instructions to the standard smart card through the smart card reader / writer interface, or call preset application interfaces in the standard smart card through test scripts, so that the standard smart card can execute a certain type of basic operation as independently as possible. To improve the accuracy of the energy consumption characteristics corresponding to the basic operations, each type of basic operation can be executed repeatedly, keeping the power supply conditions, communication parameters, and sampling conditions relatively consistent each time. For basic operations that cannot be triggered completely independently, instructions containing the target basic operation and with few interfering operations can be selected as training instructions, and the trajectory interval corresponding to the target basic operation can be determined by combining subsequent segmented processing or manual annotation.
[0126] Step S202: During the execution of each basic operation by the standard smart card, the standard instantaneous energy consumption trajectory during the execution of each basic operation is obtained.
[0127] Here, during each basic operation performed by the standard smart card, the high-precision energy consumption acquisition unit can simultaneously collect current and / or voltage data from the power supply line of the standard smart card, and generate a standard instantaneous energy consumption trajectory based on the collected current and / or voltage data. The standard instantaneous energy consumption trajectory can be a trajectory showing current changes over time, a trajectory showing voltage changes over time, or a trajectory showing power changes over time calculated from the current and voltage data. The standard instantaneous energy consumption trajectory is used to reflect the changes in physical energy consumption during the corresponding basic operation performed by the standard smart card.
[0128] When collecting standard instantaneous energy consumption trajectories, the start time can be the moment the basic operation is triggered, the moment the test control host sends a preset command, or the moment the standard smart card begins to show energy consumption changes. The end time can be the moment the basic operation completes, the moment the standard smart card returns response data or a status word, or the moment the preset collection duration ends. To avoid missing energy consumption changes during the start or end phases of the basic operation, a pre-collection time can be reserved before the basic operation is triggered, and a post-collection time can be reserved after the basic operation ends.
[0129] For each basic operation, multiple standard instantaneous energy consumption trajectories can be acquired. These trajectories can originate from repeated executions of the same standard smart card or from the execution of the same basic operation across multiple standard smart cards. The data processing and analysis unit can perform uniform sampling rate processing, time alignment processing, and abnormal trajectory removal on the multiple standard instantaneous energy consumption trajectories to reduce the impact of acquisition noise, individual differences, and occasional interference on subsequent feature extraction.
[0130] Step S203: Extract features from each standard instantaneous energy consumption trajectory to obtain the energy consumption features corresponding to each basic operation.
[0131] Before feature extraction, the standard instantaneous energy consumption trajectory can be processed by filtering, baseline correction, normalization, time alignment, and segmentation. Filtering reduces sampling noise and power supply fluctuations. Baseline correction reduces static power consumption offset at different acquisition times. Normalization reduces amplitude differences caused by different standard smart cards, different power supply conditions, or different acquisition devices. Time alignment ensures that multiple standard instantaneous energy consumption trajectories for the same basic operation maintain consistency at the start time or key waveform positions.
[0132] In an optional implementation, the energy consumption characteristics include at least one of waveform shape, peak value, duration, and frequency characteristics.
[0133] The waveform shape represents the overall energy consumption profile corresponding to the basic operation. The peak value represents the maximum current value, maximum voltage change value, or maximum power value during the execution of the basic operation. The duration represents the length of time from the start to the end of the basic operation. The frequency characteristics are obtained by frequency domain analysis of the standard instantaneous energy consumption trajectory and are used to represent the periodic changes, spectral distribution, or main frequency components of the basic operation during execution.
[0134] For multiple standard instantaneous energy consumption trajectories corresponding to the same basic operation, the data processing and analysis unit can extract candidate energy consumption features corresponding to each standard instantaneous energy consumption trajectory, and perform statistical processing on multiple candidate energy consumption features to obtain the energy consumption features corresponding to the basic operation. Statistical processing may include averaging, medianing, determining feature ranges, determining confidence intervals, determining template features, or training a classification model. Through statistical processing, the energy consumption features stored in the standard operation energy consumption feature library can better represent the stable features of the same basic operation, reducing the impact of occasional acquisition errors on the matching results.
[0135] Step S204: Construct a standard operating energy consumption feature library based on energy consumption characteristics.
[0136] Here, the data processing and analysis unit establishes a correspondence between the energy consumption characteristics of each basic operation and the operation type of the basic operation, and constructs a standard operation energy consumption characteristic library based on this correspondence. The standard operation energy consumption characteristic library may include one or more of the following: basic operation identifier, basic operation name, energy consumption characteristic, characteristic range, reference trajectory, sampling conditions, applicable card type, matching threshold, and update time. The basic operation identifier is used to distinguish different basic operations. The energy consumption characteristic is used for subsequent matching with the instantaneous energy consumption trajectory of the smart card under test. The characteristic range and matching threshold are used to determine whether the trajectory segment of the smart card under test corresponds to a certain basic operation.
[0137] The standard operating energy consumption characteristic library can be stored in the data processing and analysis unit, or in the test control host, external storage device, or server. During test analysis, the data processing and analysis unit can directly access the locally stored standard operating energy consumption characteristic library, or obtain it from external devices via a communication link. The standard operating energy consumption characteristic library can be categorized and stored according to smart card type, chip platform, application type, basic operation type, or sampling conditions, so that the corresponding energy consumption characteristics can be selected for matching when testing different smart cards under test.
[0138] In one alternative implementation, the standard operating energy consumption feature library can be a static feature library. The static feature library is established before formal testing and is directly used for matching analysis during the testing process. In another alternative implementation, the standard operating energy consumption feature library can be an updatable feature library. The updatable feature library can be updated based on new standard smart card samples, new basic operations, new sampling conditions, or manually verified test results. The update process may include adding energy consumption features corresponding to new basic operations, correcting existing energy consumption features corresponding to basic operations, adjusting matching thresholds, or deleting feature data corresponding to abnormal samples.
[0139] This application embodiment can pre-establish a standard operating energy consumption feature library that can characterize the energy consumption features of different basic operations. When the smart card under test is subsequently tested, the data processing and analysis unit can match the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction with the standard operating energy consumption feature library to identify the basic operations actually performed by the smart card under test and generate an internal operation behavior sequence. Based on this, the operation process that cannot be directly observed within the smart card under test can be converted into an identifiable operation behavior sequence, thereby providing a data basis for determining whether the smart card under test has any unexpected operations.
[0140] In an optional implementation, refer to Figure 4 Step S101 includes the following steps S301-S303.
[0141] In step S301, while sending the target command to the smart card under test, the high-precision energy consumption acquisition unit is started simultaneously.
[0142] Here, the test control host sends target instructions to the smart card under test (SDT) via the smart card reader / writer interface. The target instructions can be APDU instructions or other test instructions used to trigger the SDT to perform data reading, data writing, file selection, cryptographic algorithm operations, random number generation, or application invocation operations. To ensure that the subsequently acquired instantaneous energy consumption trajectory covers the complete execution process of the target instructions, the test control host can send a data acquisition start signal to the high-precision energy consumption acquisition unit simultaneously with sending the target instructions to the SDT, causing the high-precision energy consumption acquisition unit to start synchronously with the target instruction sending action.
[0143] Synchronous startup is not limited to starting at the exact same moment. Synchronous startup can be understood as the acquisition time window of the high-precision energy consumption acquisition unit corresponding to the execution time window of the target instruction. In practice, the high-precision energy consumption acquisition unit can start acquisition at a preset advance time before the target instruction is sent, or it can start acquisition when the target instruction is sent, or it can start acquisition when the test control host detects that the smart card under test has begun to respond to the target instruction. By reserving a certain acquisition time before and after the execution of the target instruction, the energy consumption changes at the beginning or end of the target instruction can be avoided.
[0144] Step S302: During the execution of the target instruction by the smart card under test, the current data and / or voltage data of the circuit in the smart card under test are collected in real time through the high-precision power consumption acquisition unit.
[0145] Here, the high-precision power consumption acquisition unit can be connected in series on the power supply line of the smart card under test, or it can be set on the power supply branch between the smart card reader / writer interface and the smart card under test, or it can be set on the main power supply line from the test system to the smart card under test. The specific location of the high-precision power consumption acquisition unit is not limited, as long as the high-precision power consumption acquisition unit can acquire the current data and / or voltage data of the smart card under test during the execution of the target instruction.
[0146] The high-precision energy consumption acquisition unit may include one or more of the following: a current sampling circuit, a voltage sampling circuit, an analog-to-digital converter (ADC), a sampling control circuit, and a data buffer circuit. The current sampling circuit can be used to acquire instantaneous current changes in the power supply line. The voltage sampling circuit can be used to acquire instantaneous voltage changes at the power supply terminal of the smart card under test. The ADC can convert analog current signals and / or analog voltage signals into digital sampled data. The sampling control circuit can control the acquisition process according to the sampling frequency, sampling time window, and trigger signal. The data buffer circuit can buffer the acquired current and / or voltage data and send the current and / or voltage data to the data processing and analysis unit.
[0147] Real-time data acquisition can be continuous or high-frequency sampling at a preset sampling frequency. The sampling frequency can be set according to the duration of the basic operations within the smart card under test, the execution speed of the target instruction, and the energy consumption characteristics to be identified. To facilitate the differentiation of basic operations such as data processing operations, non-volatile memory write operations, cryptographic algorithm operations, and random number generation operations, the high-precision energy consumption acquisition unit can use a sampling frequency higher than the frequency of energy consumption changes in basic operations to retain information such as waveform shape, peak value, duration, and frequency characteristics.
[0148] Step S303: After the target instruction is executed, an instantaneous energy consumption trajectory is generated based on the collected current data and / or voltage data.
[0149] Here, the completion of the target instruction execution can be determined by the smart card under test returning response data, returning a status word, the test control host receiving execution completion information, or reaching the preset acquisition duration. After the target instruction is executed, the high-precision energy consumption acquisition unit can stop acquisition and send the acquired current and / or voltage data to the data processing and analysis unit. The data processing and analysis unit can organize the current and / or voltage data according to the sampling time sequence to generate the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction.
[0150] Instantaneous energy consumption trajectories can be formed by changes in current over time, changes in voltage over time, or changes in instantaneous power over time calculated based on current and voltage data. For example, the data processing and analysis unit can calculate instantaneous power based on current and voltage data at the same sampling moment, and arrange multiple instantaneous power values in chronological order to obtain an instantaneous power trajectory. The data processing and analysis unit can also perform integration processing on the instantaneous power trajectory to obtain an energy change trajectory. Any trajectory that reflects the energy consumption changes of the smart card under test during the execution of the target instruction can be considered an instantaneous energy consumption trajectory.
[0151] When generating the instantaneous energy consumption trajectory, the data processing and analysis unit can also record one or more of the following information: target instruction sending time, data acquisition start time, data acquisition end time, response data return time, status word return time, sampling frequency, power supply voltage, smart card identifier under test, and target instruction identifier. This information can be stored in association with the instantaneous energy consumption trajectory for subsequent time alignment, trajectory segmentation, feature matching, and test result traceability.
[0152] This application embodiment can simultaneously acquire current and / or voltage data during the execution of a target instruction by the smart card under test, and convert the current and / or voltage data into an instantaneous energy consumption trajectory that reflects the energy consumption changes during the execution of the target instruction by the smart card under test. Since different basic operations have different energy consumption change characteristics during execution, the instantaneous energy consumption trajectory can provide a reliable data foundation for subsequent identification of internal operation behavior sequences, thereby facilitating the discovery of unexpected operations that are difficult to identify by relying solely on response data and status words.
[0153] In an optional implementation, refer to Figure 5 Step S104 includes the following steps S401-S402.
[0154] Step S401: Determine the basic operation corresponding to each trajectory segment based on the matching result corresponding to each trajectory segment.
[0155] Here, the data processing and analysis unit obtains the matching results corresponding to each trajectory segment. The matching results may include candidate basic operations corresponding to the trajectory segment, matching scores for the candidate basic operations, matching confidence levels, matching threshold judgment results, or ranking results of the candidate basic operations. Based on the matching results, the data processing and analysis unit determines the basic operation corresponding to the trajectory segment from multiple basic operations corresponding to the standard operation energy consumption feature library.
[0156] In one optional implementation, the data processing and analysis unit determines the candidate basic operation with the highest matching score as the basic operation corresponding to the trajectory segment. This method is suitable for situations where the energy consumption characteristics of different basic operations differ significantly. For example, when there are significant differences in the peak value, duration, or waveform shape between data processing operations and non-volatile memory write operations, the data processing and analysis unit can directly determine the basic operation based on the highest matching score.
[0157] In another optional implementation, the data processing and analysis unit first determines whether the matching score corresponding to the candidate basic operation reaches a preset matching threshold; when the matching score corresponding to the candidate basic operation reaches the preset matching threshold, the data processing and analysis unit determines the candidate basic operation as the basic operation corresponding to the trajectory segment; when the matching scores corresponding to multiple candidate basic operations all reach the preset matching threshold, the data processing and analysis unit can combine the matching scores of the candidate basic operations, the matching results of adjacent trajectory segments, and the expected behavior sequence corresponding to the target instruction to determine the basic operation corresponding to the trajectory segment.
[0158] In another optional implementation, when the trajectory segment does not meet the preset matching threshold with any of the basic operations in the standard operation energy consumption feature library, the data processing and analysis unit can mark the trajectory segment as an unknown operation segment or as a segment to be reviewed. Unknown operation segments or segments to be reviewed are used to prompt the tester that the smart card under test may have performed an operation not recorded in the standard operation energy consumption feature library, or that the current standard operation energy consumption feature library needs to be updated.
[0159] In another optional implementation, when multiple consecutive trajectory segments correspond to the same basic operation, the data processing and analysis unit can merge the multiple consecutive trajectory segments into an execution interval corresponding to the same basic operation, and record the basic operation corresponding to that execution interval as a single basic operation. This process avoids the repeated recording of the same basic operation due to fine-grained segmentation, thus improving the accuracy of the internal operation sequence.
[0160] In another alternative implementation, when the matching result of a trajectory segment indicates that the trajectory segment may correspond to multiple consecutive basic operations, the data processing and analysis unit can further divide the trajectory segment based on local peaks, energy mutation points, or reference durations within the trajectory segment, and determine the basic operations corresponding to the sub-segments after the further division. This reduces the identification error caused by a trajectory segment containing multiple basic operations.
[0161] Step S402: Determine the execution order of multiple basic operations based on the time position of each trajectory segment in the instantaneous energy consumption trajectory.
[0162] Here, the data processing and analysis unit sorts multiple basic operations based on the temporal position of each trajectory segment within the instantaneous energy consumption trajectory. The temporal position of a trajectory segment within the instantaneous energy consumption trajectory can include the start time, end time, center time, or corresponding sampling point number of the trajectory segment. The data processing and analysis unit can arrange the corresponding basic operations from earliest to latest based on the start time of the trajectory segments, thereby determining the execution order of multiple basic operations.
[0163] In one alternative implementation, the data processing and analysis unit sorts multiple basic operations according to the start time of each trajectory segment. Basic operations corresponding to trajectory segments with earlier start times are arranged first, and basic operations corresponding to trajectory segments with later start times are arranged last. This method is suitable for situations where there is no significant overlap between trajectory segments.
[0164] In another alternative implementation, when there is overlap between adjacent trajectory segments, the data processing and analysis unit can determine the execution order of basic operations based on the center time of the trajectory segment, or based on the time position of the main energy consumption characteristics appearing in the trajectory segment. This approach can reduce the overlap effect caused by sliding window segmentation.
[0165] In another alternative implementation, when the trajectory segments corresponding to two basic operations overlap in time or have unclear boundaries, the data processing and analysis unit can determine the execution order of the two basic operations by combining the matching confidence, the reference duration of the basic operations, and the logical relationship between adjacent basic operations. For example, in the normal processing flow corresponding to the target instruction, when the data processing operation usually occurs before the non-volatile memory write operation, the data processing and analysis unit can modify the execution order by combining this logical relationship.
[0166] After determining the execution order of multiple basic operations, the data processing and analysis unit can associate and save the operation type, execution order, start time, end time, duration, corresponding trajectory segment identifier, and matching confidence level of each basic operation. This information can be used to subsequently generate internal operation behavior sequences, or to locate the time interval and trajectory segment corresponding to abnormal basic operations when test results fail.
[0167] In an optional implementation, before segmenting the instantaneous energy consumption trajectory in step S102, the method further includes the following steps S501-S503.
[0168] Step S501: Filter the instantaneous energy consumption trajectory to obtain the filtered instantaneous energy consumption trajectory.
[0169] Here, the data processing and analysis unit can filter the instantaneous energy consumption trajectory. During the acquisition process, the instantaneous energy consumption trajectory may be affected by factors such as environmental noise, power supply fluctuations, sampling circuit interference, changes in the reader interface's operating status, or changes in the idle power consumption of the smart card under test. This can result in spike noise, high-frequency interference, or low-frequency drift in the instantaneous energy consumption trajectory. Filtering can reduce these interferences, allowing the instantaneous energy consumption trajectory to more accurately reflect the actual energy consumption changes during the execution of the target instruction by the smart card under test.
[0170] Filtering can employ one or more of the following: low-pass filtering, high-pass filtering, band-pass filtering, median filtering, moving average filtering, wavelet denoising, or adaptive filtering. Low-pass filtering can remove high-frequency noise generated during sampling. High-pass filtering can remove slowly changing baseline drift. Band-pass filtering can preserve the main frequency components relevant to the basic operation. Median filtering can remove occasional spikes. Moving average filtering can smooth local fluctuations. Wavelet denoising can reduce noise while preserving waveform abrupt changes. Adaptive filtering can dynamically adjust filtering parameters based on noise intensity or the sampling environment.
[0171] Filtering can be performed on current data, voltage data, or the instantaneous power trajectory calculated from current and voltage data. If the instantaneous energy consumption trajectory includes data from multiple acquisition channels, the data processing and analysis unit can perform filtering on the data from different acquisition channels separately, or it can perform filtering after fusing multi-channel data. After filtering, the data processing and analysis unit can obtain the filtered instantaneous energy consumption trajectory. The filtered instantaneous energy consumption trajectory retains the waveform shape, peak value, duration, and frequency characteristics related to the basic operation, while reducing the impact of irrelevant noise on subsequent time alignment and segmentation processing.
[0172] Step S502: Perform time alignment processing on the filtered instantaneous energy consumption trajectory to obtain the time-aligned instantaneous energy consumption trajectory.
[0173] Here, the data processing and analysis unit can perform time alignment processing on the filtered instantaneous energy consumption trajectory. Because there may be slight time deviations between the target command sending time, the high-precision energy consumption acquisition unit startup time, the time the smart card under test begins executing the target command, and the time the smart card under test returns response data, the filtered instantaneous energy consumption trajectory may have a start-point or end-point offset from the actual execution stage of the target command. Time alignment processing can be used to correct these offsets, ensuring that the filtered instantaneous energy consumption trajectory corresponds temporally to the execution process of the target command.
[0174] In one optional implementation, the data processing and analysis unit can use the time when the target instruction is sent as the time zero point and align the filtered instantaneous energy consumption trajectory according to the collected timestamp. In another optional implementation, the data processing and analysis unit can use the time when the smart card under test returns response data or a status word as the end reference point to extract and align the filtered instantaneous energy consumption trajectory. In yet another optional implementation, the data processing and analysis unit can use a sudden energy consumption change point as the alignment reference point, such as the moment when the current rises rapidly, the moment when the power peak occurs, or the moment when the energy change rate exceeds a preset threshold as the reference point for the start of execution of the target instruction. In yet another optional implementation, the data processing and analysis unit can calculate the similarity between the filtered instantaneous energy consumption trajectory and the reference trajectory in the standard operating energy consumption feature library, and complete the time alignment based on the position with the highest similarity.
[0175] Time alignment processing can also include effective trajectory interval extraction. The data processing and analysis unit can remove idle trajectory segments before the execution of the target instruction, and irrelevant trajectory segments after the execution of the target instruction, retaining only the effective trajectory intervals corresponding to the execution process of the target instruction. For data length differences caused by inconsistent sampling frequencies or different acquisition devices, the data processing and analysis unit can also resample the filtered instantaneous energy consumption trajectory to make the time-aligned instantaneous energy consumption trajectory comparable to the energy consumption characteristics in the standard operation energy consumption feature library. Through time alignment processing, subsequent segmentation processing can more accurately locate the trajectory intervals corresponding to different basic operations.
[0176] Step S503: The instantaneous energy consumption trajectory after time alignment is segmented.
[0177] Here, the data processing and analysis unit can segment the time-aligned instantaneous energy consumption trajectory to obtain multiple trajectory segments. Since the target instruction may continuously call multiple basic operations during execution, the time-aligned instantaneous energy consumption trajectory usually includes energy consumption change intervals corresponding to multiple basic operations. Segmentation processing can divide the continuous trajectory into multiple analysis units, making it easier to match each trajectory segment with the energy consumption features in the standard operation energy consumption feature library.
[0178] Segmentation can be performed according to a preset time window or according to energy consumption variation characteristics. When segmenting according to a preset time window, the data processing and analysis unit can use a fixed-length window or a sliding window to divide the instantaneous energy consumption trajectory after time alignment. When segmenting according to energy consumption variation characteristics, the data processing and analysis unit can determine the segment boundaries based on current peak value, voltage fluctuation, power surge, rising edge, falling edge, local extrema, energy change rate, or frequency characteristic changes. The segment boundaries can represent the switching positions of the basic operations within the smart card under test.
[0179] In one optional implementation, the data processing and analysis unit can segment the time-aligned instantaneous energy consumption trajectory by combining reference durations from a standard operation energy consumption characteristic library. Different basic operations typically have relatively stable duration ranges; for example, non-volatile memory write operations usually have duration and peak characteristics that differ from ordinary data processing operations. The data processing and analysis unit can search for intervals that may correspond to different basic operations in the time-aligned instantaneous energy consumption trajectory based on the reference duration ranges of different basic operations, and use these intervals as trajectory segments.
[0180] In another alternative implementation, the data processing and analysis unit can first perform coarse segmentation, and then perform sub-segmentation. Coarse segmentation can be used to determine the approximate operation phases during the execution of the target instruction. Sub-segmentation can be used to further distinguish multiple basic operations within each operation phase. For example, when a long trajectory segment contains both data processing operations and non-volatile memory write operations, the data processing and analysis unit can split the long trajectory segment into two or more shorter trajectory segments based on local peak changes or duration differences. By combining coarse and sub-segmentation, the identification error caused by unclear boundaries of basic operations can be reduced.
[0181] The data processing and analysis unit in this embodiment can first filter the instantaneous energy consumption trajectory, then perform time alignment processing, and finally segment the time-aligned instantaneous energy consumption trajectory. Based on this, the effective energy consumption characteristics in the instantaneous energy consumption trajectory are more prominent, and the correspondence between the trajectory segments and the basic internal operations of the smart card under test is clearer. This helps to improve the accuracy of matching the standard operation energy consumption feature library and improve the reliability of the internal operation behavior sequence generation results.
[0182] In an optional implementation, refer to Figure 6 Step S106 includes the following steps S601-S603.
[0183] Step S601: Compare the basic operations and their execution order in the internal operation behavior sequence with the expected basic operations and their expected execution order in the expected behavior sequence to obtain the comparison result.
[0184] Here, the internal operation behavior sequence represents the basic operations actually performed by the smart card under test during the execution of the target instruction, as well as the execution order of these basic operations. The expected behavior sequence represents the expected basic operations that should be triggered under normal execution of the target instruction, as well as the expected execution order. By comparing the internal operation behavior sequence with the expected behavior sequence, the data processing and analysis unit can determine whether the smart card under test completes the corresponding operations in the expected manner during the execution of the target instruction.
[0185] During the comparison, the data processing and analysis unit can determine whether the basic operation types in the internal operation behavior sequence are consistent with the expected basic operation types in the expected behavior sequence, whether the number of basic operations in the internal operation behavior sequence is consistent with the expected number of basic operations in the expected behavior sequence, and whether the execution order of the basic operations in the internal operation behavior sequence is consistent with the expected execution order in the expected behavior sequence. The data processing and analysis unit can further determine whether the internal operation behavior sequence contains basic operations outside the expected behavior sequence, whether it lacks expected basic operations from the expected behavior sequence, whether the duration of basic operations is within the allowable range, whether the matching confidence level meets preset requirements, or whether it contains prohibited basic operations.
[0186] For example, when the target instruction is a read instruction, the expected behavior sequence may include data processing operations, but may not include non-volatile memory write operations. If the internal operation behavior sequence only includes data processing operations, and the execution order of the data processing operations is consistent with the expected behavior sequence, then the alignment result indicates that the internal operation behavior sequence is consistent with the expected behavior sequence. If the internal operation behavior sequence also includes non-volatile memory write operations, anomalous cryptographic algorithm operations, random number generation operations, or other basic operations outside the expected behavior sequence, then the alignment result indicates that the internal operation behavior sequence contains basic operations outside the expected behavior sequence. If the internal operation behavior sequence does not contain the expected basic operations required in the expected behavior sequence, then the alignment result indicates that the internal operation behavior sequence lacks the expected basic operations in the expected behavior sequence. If the execution order of each basic operation in the internal operation behavior sequence is different from the expected execution order in the expected behavior sequence, then the alignment result indicates that the execution order of the basic operations is inconsistent with the expected execution order.
[0187] In one optional implementation, the data processing and analysis unit can employ a completely consistent comparison method, meaning that the comparison result is determined to indicate that the internal operation behavior sequence is consistent with the expected behavior sequence only if the basic operation type, number of basic operations, and execution order of the basic operations in the internal operation behavior sequence are all consistent with the expected behavior sequence. In another optional implementation, the data processing and analysis unit can employ a rule-matching comparison method, meaning that the comparison result is determined to indicate that the internal operation behavior sequence is consistent with the expected behavior sequence as long as the internal operation behavior sequence meets the necessary operation rules corresponding to the expected behavior sequence and does not contain prohibited basic operations. In yet another optional implementation, the data processing and analysis unit can employ a tolerance-based comparison method, meaning that the comparison result is still determined to indicate that the internal operation behavior sequence is consistent with the expected behavior sequence even when the basic operation duration, matching confidence level, or energy consumption characteristic deviation is within an allowable range.
[0188] Step S602: If the comparison result indicates that the basic operations in the internal operation behavior sequence and the execution order of the basic operations are consistent with the expected behavior sequence, the test result is determined to be a successful test.
[0189] Here, when the comparison results indicate that the basic operations in the internal operational behavior sequence and the execution order of the basic operations are consistent with the expected behavior sequence, the data processing and analysis unit determines that the test result of the smart card under test for the target instruction is a pass. A pass indicates that the basic operations actually executed by the smart card under test during the execution of the target instruction conform to the expected behavior sequence corresponding to the target instruction, no basic operations outside the expected behavior sequence are detected, no expected basic operations in the expected behavior sequence are missing, and no abnormal execution order of basic operations occurs.
[0190] Test results may include a test pass indicator, or information such as the target instruction identifier, internal operation sequence, expected behavior sequence, comparison result, matching confidence level, trajectory segment information, test time, and the identifier of the smart card under test. The data processing and analysis unit can send the test pass result to the test control host, or store the test pass result in a local database or test report. By retaining the internal operation sequence, expected behavior sequence, and comparison result, testers can not only know whether the target instruction passed the test, but also trace the specific operation behavior of the smart card under test during the execution of the target instruction.
[0191] Step S603: If the comparison result indicates that the internal operation behavior sequence contains basic operations outside the expected behavior sequence, lacks expected basic operations in the expected behavior sequence, and / or the execution order of the basic operations is inconsistent with the expected execution order, the test result is determined to be a test failure.
[0192] Here, when the comparison result indicates that the internal operation sequence includes basic operations beyond the expected sequence, the data processing and analysis unit determines that the smart card under test has executed additional operations that should not be triggered by the target instruction. When the comparison result indicates that the internal operation sequence lacks the expected basic operations from the expected sequence, the data processing and analysis unit determines that the smart card under test has not fully executed the expected operations corresponding to the target instruction. When the comparison result indicates that the execution order of basic operations is inconsistent with the expected execution order, the data processing and analysis unit determines that there is an anomaly in the operation order during the execution of the target instruction by the smart card under test.
[0193] Basic operations outside the expected sequence of actions may include non-volatile memory write operations, aberrant cryptographic algorithm operations, random number generation operations, sensitive data access operations, state update operations, or other basic operations not permitted by the expected sequence of actions that the target instruction should not trigger. Missing expected basic operations may include data processing operations, authorization verification operations, cryptographic algorithm operations, or state update operations that must occur during the normal execution of the target instruction. Abnormal execution order of basic operations may include data processing operations that should be executed first being postponed, or operations that should be executed after authentication being executed prematurely.
[0194] A test failure indicates that the smart card under test exhibits abnormal internal operational behavior during the execution of the target instruction. This abnormal internal operational behavior may not cause the smart card to return incorrect response data or an incorrect status word, but it will show energy consumption characteristics in the instantaneous energy consumption trajectory that match the corresponding basic operation. Therefore, by comparing the sequence of internal operational behaviors with the expected sequence of behaviors, the data processing and analysis unit can discover hidden operational behaviors, missing operational behaviors, or abnormal operational sequences that are difficult to detect using traditional black-box testing based on response data and status words.
[0195] Specifically, the target instruction is a binary file read instruction, and the expected behavior sequence only includes data processing operations. When the internal operation behavior sequence includes data processing operations and non-volatile memory write operations, the data processing and analysis unit determines that the internal operation behavior sequence contains non-volatile memory write operations outside the expected behavior sequence, and determines the test result as a test failure. This test result can indicate that the smart card under test may have hidden write behavior when executing read-type instructions, thus providing a basis for security assessment and compliance analysis.
[0196] Specifically, the target instruction is an authentication instruction, and the expected sequence of actions includes an authorization verification operation and a cryptographic algorithm operation. When the internal sequence of actions only includes the authorization verification operation and omits the cryptographic algorithm operation, the data processing and analysis unit determines that the internal sequence of actions is missing the cryptographic algorithm operation from the expected sequence and determines the test result as a failure. For example, if the target instruction requires the authorization verification operation to be performed before the data reading operation, but the internal sequence of actions indicates that the smart card under test performs the data reading operation before the authorization verification operation, the data processing and analysis unit determines that the execution order of the basic operations is inconsistent with the expected execution order and determines the test result as a failure.
[0197] In an optional implementation, after step S603 determines that the test result is a test failure, the method further includes the following steps S701-S703.
[0198] Step S701: Identify abnormal comparison items that cause the test result to fail.
[0199] Here, the data processing and analysis unit identifies anomalous comparison items that cause the test to fail, based on the comparison results. Anomalous comparison items represent specific inconsistencies between the internal operational sequence and the expected sequence.
[0200] Anomalies may include: the internal operation sequence containing basic operations outside the expected operation sequence; the internal operation sequence lacking the expected basic operations in the expected operation sequence; the execution order of basic operations being inconsistent with the expected execution order; the duration of basic operations not meeting the preset time range; the matching confidence of the basic operations not meeting the preset confidence requirements; or the existence of unknown operation segments in the internal operation sequence.
[0201] For example, when the target instruction is a read instruction, the expected behavior sequence does not include non-volatile memory write operations. If the internal operation behavior sequence includes non-volatile memory write operations, the data processing and analysis unit will identify "the existence of non-volatile memory write operations outside the expected behavior sequence" as an abnormal comparison item. As another example, when the target instruction is an authentication instruction, the expected behavior sequence includes cryptographic algorithm operations. If the internal operation behavior sequence does not include cryptographic algorithm operations, the data processing and analysis unit will identify "the absence of cryptographic algorithm operations in the expected behavior sequence" as an abnormal comparison item. Furthermore, if the expected behavior sequence requires the execution of an authorization verification operation before the data read operation, and the internal operation behavior sequence shows that the smart card under test performs a data read operation before the authorization verification operation, the data processing and analysis unit will identify "the execution order of the basic operations is inconsistent with the expected execution order" as an abnormal comparison item.
[0202] In one optional implementation, when multiple inconsistencies exist in the comparison results, the data processing and analysis unit can simultaneously identify multiple abnormal comparison items. For example, if the internal operation behavior sequence includes both basic operations outside the expected behavior sequence and lacks the expected basic operations in the expected behavior sequence, the data processing and analysis unit can output both of these inconsistencies as abnormal comparison items to improve the completeness of the test results.
[0203] Step S702: When the anomaly comparison item includes basic operations outside the expected behavior sequence, identify the operation type corresponding to the basic operations outside the expected behavior sequence.
[0204] Here, when the identified anomaly comparison item includes a basic operation outside the expected behavior sequence, the data processing and analysis unit further identifies the operation type corresponding to that basic operation. The operation type can be determined based on the matching results between the trajectory segment and the standard operation energy consumption feature library, or it can be determined based on the basic operation identifier, matching score, matching confidence level, and the energy consumption features corresponding to the trajectory segment.
[0205] The operation types corresponding to basic operations outside the expected behavior sequence can include non-volatile memory write operations, cryptographic algorithm operations, random number generation operations, data processing operations, sensitive data access operations, state update operations, or unknown operation types. For example, when the trajectory segment corresponding to an anomaly comparison item matches the energy consumption feature corresponding to a non-volatile memory write operation in the standard operation energy consumption feature library, the data processing and analysis unit identifies the operation type corresponding to the basic operation outside the expected behavior sequence as a non-volatile memory write operation. When the trajectory segment corresponding to an anomaly comparison item matches the energy consumption feature corresponding to a cryptographic algorithm operation in the standard operation energy consumption feature library, the data processing and analysis unit identifies the operation type corresponding to the basic operation outside the expected behavior sequence as a cryptographic algorithm operation.
[0206] In one optional implementation, when a basic operation outside the expected behavior sequence corresponds to multiple candidate operation types, the data processing and analysis unit can determine the candidate operation type with the highest matching confidence as the final operation type. In another optional implementation, when the matching confidence levels corresponding to multiple candidate operation types all meet preset confidence requirements and the differences are small, the data processing and analysis unit can output multiple candidate operation types and mark the basic operation as an operation to be reviewed. In this way, testers can manually review abnormal basic operations with similar confidence levels, avoiding misjudgments.
[0207] Step S703: Determine the abnormal behavior of the smart card under test based on the abnormal comparison items and / or operation type, and output the corresponding prompt information for the abnormal behavior.
[0208] Here, the data processing and analysis unit determines the abnormal behavior of the smart card under test based on the identified anomaly comparison items and / or the identified operation type. Abnormal behavior refers to the abnormal execution situation of the smart card under test relative to the expected sequence of behavior during the execution of the target instruction.
[0209] When the anomaly comparison item includes a basic operation outside the expected behavior sequence, and the operation type corresponding to this basic operation is a non-volatile memory write operation, the data processing and analysis unit can determine that the smart card under test exhibits unexpected write behavior. When the anomaly comparison item includes a basic operation outside the expected behavior sequence, and the operation type corresponding to this basic operation is a cryptographic algorithm operation, the data processing and analysis unit can determine that the smart card under test exhibits abnormal algorithm call behavior. When the anomaly comparison item includes a basic operation outside the expected behavior sequence, and the operation type corresponding to this basic operation is a random number generation operation, the data processing and analysis unit can determine that the smart card under test exhibits unexpected random number generation behavior.
[0210] When the anomaly comparison item is a missing expected basic operation in the expected behavior sequence, the data processing and analysis unit can determine that the smart card under test has a missing expected operation behavior. When the execution order of the basic operation in the anomaly comparison item is inconsistent with the expected execution order, the data processing and analysis unit can determine that the smart card under test has an abnormal operation sequence behavior. When the anomaly comparison item is an unknown operation segment in the internal operation behavior sequence, the data processing and analysis unit can determine that the smart card under test has an unknown operation behavior and prompt the tester to further analyze the unknown operation behavior.
[0211] The prompts for abnormal behavior may include one or more of the following: target instruction identifier, test result, abnormal comparison item, abnormal behavior type, expected behavior sequence, internal operation behavior sequence, operation type corresponding to basic operations outside the expected behavior sequence, trajectory segment corresponding to the abnormal basic operation, start and end time corresponding to the abnormal basic operation, matching confidence level, smart card identifier under test, and processing suggestions. The data processing and analysis unit can send the prompts to the test control host, or write them to a test report, log file, or database. The test control host can display the prompts on the interface or output them as alarm information.
[0212] For example, the target instruction is a binary file read instruction, and the expected behavior sequence only includes data processing operations. If the internal operation behavior sequence includes data processing operations and non-volatile memory write operations, the anomaly comparison item identified by the data processing and analysis unit is that the internal operation behavior sequence contains a basic operation outside the expected behavior sequence, and further identifies the operation type of this basic operation as a non-volatile memory write operation. Based on this anomaly comparison item and the operation type, the data processing and analysis unit determines that the smart card under test has unexpected write behavior and outputs a prompt message indicating "Unexpected write behavior exists during the execution of the binary file read instruction".
[0213] In an optional implementation, the target instruction is at least one instruction from a preset test instruction sequence.
[0214] Here, the target instruction can be at least one instruction from a preset test instruction sequence. The test instruction sequence can be used to perform continuous function testing, combined behavior testing, security testing, or application process testing on the smart card under test.
[0215] The method also includes the following steps S801-S803.
[0216] Step S801: Send a sequence of test commands to the smart card under test in a preset order.
[0217] Here, the test control host can send multiple instructions from a test instruction sequence to the smart card under test in a preset order. The instructions in the test instruction sequence can include one or more of the following: file selection instructions, binary file read instructions, file update instructions, authentication instructions, random number generation instructions, application switching instructions, or security algorithm call instructions. Different instructions in the test instruction sequence can correspond to different test purposes. For example, some instructions can be used to verify the data reading behavior of the smart card under test, some instructions can be used to verify the security authentication behavior of the smart card under test, and some instructions can be used to verify the state switching behavior of the smart card under test during continuous operation.
[0218] The preset order can be pre-configured based on the test script or dynamically generated according to smart card application specifications, business processes, or test tasks. The test control host can send each instruction in the test instruction sequence in a fixed order, or dynamically determine the next instruction to be sent based on the execution result of the previous instruction. For example, when the smart card under test returns a successful authentication status after executing an authentication instruction, the test control host can continue to send subsequent data reading instructions; when the smart card under test returns a failed authentication status, the test control host can terminate the current test instruction sequence or switch to an abnormal test process.
[0219] In one optional implementation, the test control host can set a preset time interval between sending two adjacent commands, allowing the smart card under test to complete the internal processing corresponding to the previous command. In another optional implementation, the test control host can dynamically adjust the sending interval based on the response data, status word, or execution completion signal returned by the smart card under test. The test control host then sends the next command only after the smart card under test returns execution completion information. This approach avoids overlapping execution processes of multiple commands, which could affect the instantaneous energy consumption trajectory analysis results.
[0220] Step S802: Obtain the instantaneous energy consumption trajectory during the execution of each instruction in the test instruction sequence, and determine the test result corresponding to each instruction.
[0221] Here, for each instruction sent by the test control host, the high-precision energy consumption acquisition unit can simultaneously acquire the instantaneous energy consumption trajectory of the smart card under test during the execution of the current instruction. The data processing and analysis unit can perform the aforementioned instantaneous energy consumption trajectory processing, trajectory segmentation, feature matching, internal operation behavior sequence generation, and test result determination processes for each instruction in the test instruction sequence.
[0222] Specifically, the data processing and analysis unit can first perform filtering, time alignment, and segmentation on the instantaneous energy consumption trajectory corresponding to each instruction. Then, it matches each trajectory segment with the energy consumption features in the standard operation energy consumption feature library to obtain the internal operation behavior sequence corresponding to the current instruction. Subsequently, the data processing and analysis unit can compare the internal operation behavior sequence with the expected behavior corresponding to the current instruction and determine the test result corresponding to the current instruction based on the comparison result.
[0223] Test results can include types such as test passed, test failed, pending review, or abnormal termination. Test results may also include additional information such as the internal operation sequence, matching confidence level, abnormal operation type, abnormal trajectory segment location, and prompt messages. For example, when the internal operation sequence corresponding to the binary file read instruction in the test instruction sequence only includes data processing operations, the data processing and analysis unit can determine that the test result for the current instruction is a test passed. When the internal operation sequence corresponding to the binary file read instruction includes a non-volatile memory write operation, the data processing and analysis unit can determine that the test result for the current instruction is a test failed and output a prompt message indicating the existence of unexpected write behavior.
[0224] In one optional implementation, the data processing and analysis unit can independently store the instantaneous energy consumption trajectory corresponding to each instruction in the test instruction sequence for subsequent individual analysis and problem tracing. In another optional implementation, the data processing and analysis unit can also concatenate the instantaneous energy consumption trajectories corresponding to multiple instructions in chronological order to form a combined trajectory, and analyze the state change behavior of the smart card under test during instruction execution within the combined trajectory. For example, the smart card under test may enter a specific state after the execution of the previous instruction, and this state may affect the internal operational behavior during the execution of subsequent instructions. Through combined trajectory analysis, hidden behaviors that only appear in continuous instruction scenarios can be further identified.
[0225] Step S803: Generate the overall test result corresponding to the test instruction sequence based on each test result.
[0226] Here, the data processing and analysis unit can generate an overall test result for the entire test instruction sequence based on the test results corresponding to each instruction in the sequence. The overall test result reflects the comprehensive behavior of the smart card under test throughout the execution of the entire test instruction sequence.
[0227] In one optional implementation, when all instructions in the test instruction sequence correspond to a pass result, the data processing and analysis unit can determine the overall test result as "overall test pass". In another optional implementation, when any instruction in the test instruction sequence corresponds to a fail result, the data processing and analysis unit can determine the overall test result as "overall test fail". In yet another optional implementation, the data processing and analysis unit can set different weights according to the importance of different instructions and generate the overall test result based on the weighted result. For example, instructions related to security authentication can correspond to higher weights, while instructions related to ordinary data reading can correspond to lower weights. When a high-weight instruction corresponds to a fail result, even if all other instructions pass, the data processing and analysis unit can still determine the overall test result as "overall test fail".
[0228] The overall test results can include information such as the overall test status, test pass rate, number of abnormal commands, statistics on abnormal behavior types, frequency of abnormal operations, risk level, and test recommendations. The data processing and analysis unit can output the overall test results to the test control host or generate a corresponding test report. The test report can include the test command sequence, the internal operation behavior sequence corresponding to each command, the test results corresponding to each command, and the overall test results. Through the overall test results, testers can not only understand the behavior of the smart card under test during the execution of a single command, but also conduct a comprehensive analysis of the security, stability, and behavioral compliance of the smart card under test from an overall perspective.
[0229] This application's embodiments can analyze the internal operational behavior of the smart card under test in scenarios involving the execution of multiple consecutive instructions, and generate an overall test result based on multiple test results. Compared to testing a single target instruction, the overall test process corresponding to the test instruction sequence can more comprehensively cover the state changes and operation combinations of the smart card under test in actual business operations, thereby improving the detection capability of hidden abnormal behavior, cross-instruction abnormal call behavior, and complex violation behavior.
[0230] In a specific embodiment, the testing method for the smart card provided in this application is described in detail.
[0231] The smart card under test is a USIM card. The test system includes a test control host, a smart card reader / writer interface, a high-precision energy consumption acquisition unit, and a data processing and analysis unit. The test control host establishes a communication connection with the smart card under test through the smart card reader / writer interface. The high-precision energy consumption acquisition unit is connected in series with the power supply line of the smart card under test to collect current data in real time during the execution of instructions. The data processing and analysis unit generates an instantaneous energy consumption trajectory based on the current data, segments the instantaneous energy consumption trajectory, matches the obtained multiple trajectory segments with a standard operation energy consumption feature library, and determines multiple basic operations and their execution order during the execution of instructions by the smart card under test based on the matching results.
[0232] The testing system first establishes a standard operating energy consumption characteristic library.
[0233] The test control host controls the standard smart card to perform data processing operations, non-volatile memory write operations, cryptographic algorithm operations, and random number generation operations. Taking the non-volatile memory write operation as an example, the test control host sends an update file command to the standard smart card, causing the standard smart card to perform an EEPROM write operation. The high-precision energy consumption acquisition unit synchronously acquires the current data during the standard smart card's EEPROM write operation and generates the corresponding standard instantaneous energy consumption trajectory. The data processing and analysis unit performs filtering, time alignment, and feature extraction processing on the standard instantaneous energy consumption trajectory to obtain the energy consumption characteristics corresponding to the non-volatile memory write operation. These energy consumption characteristics may be characterized by a relatively long duration, a relatively high peak value, obvious write pulse changes in the waveform, and / or frequency characteristics that differ from ordinary data processing operations.
[0234] The testing system uses the same method to establish energy consumption characteristics for other basic operations. For example, the energy consumption characteristics for data processing operations can be characterized by relatively short duration, relatively stable waveform changes, and energy peaks lower than those for non-volatile memory write operations; the energy consumption characteristics for cryptographic algorithm operations can be characterized by periodic waveform changes; and the energy consumption characteristics for random number generation operations can be characterized by sudden waveform changes within a short period. The data processing and analysis unit stores the correspondence between the above basic operations and their corresponding energy consumption characteristics in the standard operation energy consumption characteristic library. After the standard operation energy consumption characteristic library is established, it stores reference energy consumption characteristics for various basic operations, which are used for matching and analyzing trajectory segments during the execution of target instructions by the smart card under test.
[0235] Subsequently, the testing system tested the smart card under test.
[0236] The test control host sends a read binary file command to the smart card under test (SDB). This command is used to read the user data file from the USIM card. Logically, when executing the read binary file command, the SDB should read the target data from the file system and write it to the output buffer. Therefore, the expected sequence of actions for the read binary file command is a data processing operation, excluding non-volatile memory write operations, cryptographic algorithm operations, or random number generation operations.
[0237] Simultaneously with the test control host sending the binary file read command, the high-precision energy consumption acquisition unit starts up and collects current data in the power supply line of the smart card under test in real time. After the smart card under test completes the binary file read command, the high-precision energy consumption acquisition unit stops acquiring data and sends the acquired current data to the data processing and analysis unit.
[0238] The data processing and analysis unit generates an instantaneous energy consumption trajectory based on the collected current data. Subsequently, the unit filters the instantaneous energy consumption trajectory to remove acquisition noise; then, it performs time alignment processing on the filtered trajectory to correct the start position of the binary file read instruction execution; finally, it segments the time-aligned trajectory to obtain multiple trajectory segments. In this embodiment, the data processing and analysis unit divides the instantaneous energy consumption trajectory into a first trajectory segment and a second trajectory segment. The first trajectory segment corresponds to the preceding time interval in the binary file read instruction execution process, and the second trajectory segment corresponds to the following time interval.
[0239] The data processing and analysis unit matches the first and second trajectory segments with the standard operation energy consumption characteristic library to obtain matching results. The waveform of the first trajectory segment is relatively stable, with a short duration, and its peak value is within the energy consumption characteristic range corresponding to the data processing operation. Therefore, the first trajectory segment matches the data processing operation in the standard operation energy consumption characteristic library. The duration of the second trajectory segment is longer than that of the first trajectory segment. The second trajectory segment shows a significantly higher energy consumption peak value than the data processing operation, and its waveform contains pulse changes similar to those of the EEPROM write process. Therefore, the second trajectory segment matches the non-volatile memory write operation in the standard operation energy consumption characteristic library.
[0240] Based on the matching results corresponding to the first trajectory segment, the data processing and analysis unit determines that the basic operation corresponding to the first trajectory segment is a data processing operation; based on the matching results corresponding to the second trajectory segment, the data processing and analysis unit determines that the basic operation corresponding to the second trajectory segment is a non-volatile memory write operation. Since the time position of the first trajectory segment in the instantaneous energy consumption trajectory is earlier than the time position of the second trajectory segment in the instantaneous energy consumption trajectory, the data processing and analysis unit determines that the execution order of the data processing operation is earlier than the execution order of the non-volatile memory write operation.
[0241] The data processing and analysis unit generates a sequence of internal operation behaviors of the smart card under test during the execution of a binary file read instruction, based on data processing operations, non-volatile memory write operations, and the execution order of the two basic operations mentioned above. This sequence of internal operation behaviors includes, in sequence: data processing operations and non-volatile memory write operations.
[0242] The data processing and analysis unit further compares the basic operations and their execution order in the internal operation sequence with the expected basic operations and their execution order in the expected operation sequence corresponding to the binary file read instruction. Since the expected operation sequence corresponding to the binary file read instruction only includes data processing operations, while the internal operation sequence includes non-volatile memory write operations in addition to data processing operations, the comparison result indicates that the internal operation sequence contains basic operations beyond the expected operation sequence. Based on this comparison result, the data processing and analysis unit determines that the test result for the smart card under test for the binary file read instruction is a failure.
[0243] After determining that the test result is a failure, the data processing and analysis unit identifies the abnormal comparison item that caused the test failure. In this embodiment, the abnormal comparison item is a basic operation outside the expected behavior sequence contained in the internal operation behavior sequence. Since the basic operation outside the expected behavior sequence matches the energy consumption characteristics corresponding to non-volatile memory write operations in the standard operation energy consumption characteristic library, the data processing and analysis unit further identifies the operation type corresponding to this basic operation as a non-volatile memory write operation. Based on the abnormal comparison item and the operation type, the data processing and analysis unit determines that the smart card under test has unexpected write behavior.
[0244] The data processing and analysis unit outputs prompts corresponding to abnormal behavior. These prompts include the target instruction identifier, test result, anomaly comparison item, abnormal operation type, trajectory segment corresponding to the abnormal basic operation, and matching confidence level. For example, the prompts might include: the target instruction is a binary file read instruction; the test result is test failed; the anomaly comparison item is a basic operation outside the expected behavior sequence; the abnormal operation type is a non-volatile memory write operation; and the trajectory segment corresponding to the abnormal basic operation is the second trajectory segment. After receiving the test results and prompts from the data processing and analysis unit, the test control host displays the prompt indicating unexpected write behavior in the binary file read instruction on the display interface and writes the corresponding test results and prompts into the test report.
[0245] In another implementation scenario, if the data processing and analysis unit divides the instantaneous energy consumption trajectory of the smart card under test during the execution of the binary file read instruction into one or more trajectory segments, and each trajectory segment matches a data processing operation but does not match a non-volatile memory write operation, cryptographic algorithm operation, random number generation operation, or other basic operations outside the expected behavior sequence, then the internal operation behavior sequence generated by the data processing and analysis unit only includes data processing operations. Since the basic operations in this internal operation behavior sequence and the execution order of the basic operations are consistent with the expected behavior sequence, the data processing and analysis unit determines the test result as passed.
[0246] In another implementation scenario, the target instruction is an authentication instruction, and the expected behavior sequence corresponding to the authentication instruction includes an authorization verification operation and a cryptographic algorithm operation. If the data processing and analysis unit determines, based on the instantaneous energy consumption trajectory, that the internal operation behavior sequence only includes the authorization verification operation and not the cryptographic algorithm operation, then the data processing and analysis unit determines that the internal operation behavior sequence lacks the cryptographic algorithm operation from the expected behavior sequence, and determines the test result as a test failure. The data processing and analysis unit can use the lack of expected basic operations as an anomaly comparison item and output a prompt message indicating the missing expected operation.
[0247] In another implementation scenario, the expected sequence of actions corresponding to the target instruction requires the execution of a permission verification operation before the data reading operation. If the data processing and analysis unit determines, based on the instantaneous energy consumption trajectory, that the internal operation sequence includes a data reading operation and a permission verification operation in sequence, then the data processing and analysis unit determines that the execution order of the basic operations is inconsistent with the expected execution order and determines the test result as a test failure. The data processing and analysis unit can use the abnormal execution order as an anomaly comparison item and output a prompt message indicating an abnormal operation order.
[0248] This application embodiment can not only determine whether the target instruction has been successfully executed based on the response data returned by the smart card under test, but also analyze the actual basic operations and execution order of the basic operations inside the smart card under test through instantaneous energy consumption trajectory analysis. This allows for the identification of hidden write behavior, expected operation missing behavior, abnormal operation order behavior, or other illegal operation behavior that are difficult to detect by traditional black-box testing, thereby improving the accuracy, security, and behavior compliance detection capabilities of smart card testing.
[0249] The computer program product provided in this application includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation details, please refer to the method embodiments, which will not be repeated here.
[0250] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0251] Furthermore, in the description of the embodiments of this application, unless otherwise expressly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in this application based on the specific circumstances.
[0252] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0253] In the description of this application, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this application. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.
[0254] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The scope of protection of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application. Such modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of protection of the claims.
Claims
1. A testing method for a smart card, characterized in that, include: Acquire the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction; The instantaneous energy consumption trajectory is segmented to obtain multiple trajectory segments; Multiple trajectory segments are matched with a pre-established standard operation energy consumption feature library to obtain matching results; wherein, the matching results are used to characterize the correspondence between the trajectory segments and basic operations; the standard operation energy consumption feature library is used to store the energy consumption features corresponding to the smart card when performing different basic operations; Based on the matching results, determine the multiple basic operations of the smart card under test during the execution of the target instruction and the execution order of the multiple basic operations; Based on the multiple basic operations and their execution order, an internal operation sequence of the smart card under test is generated during the execution of the target instruction. The test result of the smart card under test is determined based on the comparison between the internal operation behavior sequence and the expected behavior sequence corresponding to the target instruction.
2. The testing method for a smart card according to claim 1, characterized in that, The method further includes the step of establishing the standard operating energy consumption characteristic library, specifically: Control the standard smart card to perform several preset basic operations; During the execution of each of the basic operations by the standard smart card, the standard instantaneous energy consumption trajectory during the execution of each of the basic operations is acquired respectively; Feature extraction is performed on each of the standard instantaneous energy consumption trajectories to obtain the energy consumption features corresponding to each of the basic operations; The standard operating energy consumption feature library is constructed based on the energy consumption features.
3. The testing method for a smart card according to claim 2, characterized in that, The basic operations include at least one of data processing operations, non-volatile memory write operations, cryptographic algorithm operations, and random number generation operations; The energy consumption characteristics include at least one of waveform shape, peak value, duration, and frequency characteristics.
4. The testing method for a smart card according to claim 1, characterized in that, The step of obtaining the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction includes: While sending the target command to the smart card under test, the high-precision energy consumption acquisition unit is simultaneously activated; During the execution of the target instruction by the smart card under test, the current data and / or voltage data of the power supply line in the smart card under test are collected in real time by the high-precision energy consumption acquisition unit. After the target instruction is executed, the instantaneous energy consumption trajectory is generated based on the collected current data and / or voltage data.
5. The testing method for a smart card according to claim 1, characterized in that, The step of determining, based on the matching result, multiple basic operations of the smart card under test during the execution of the target instruction and the execution order of the multiple basic operations includes: Based on the matching results corresponding to each trajectory segment, determine the basic operation corresponding to each trajectory segment; The execution order of the multiple basic operations is determined based on the time position of each trajectory segment in the instantaneous energy consumption trajectory.
6. The testing method for a smart card according to claim 1, characterized in that, Before segmenting the instantaneous energy consumption trajectory, the method further includes: The instantaneous energy consumption trajectory is filtered to obtain the filtered instantaneous energy consumption trajectory; The filtered instantaneous energy consumption trajectory is time-aligned to obtain the time-aligned instantaneous energy consumption trajectory. The instantaneous energy consumption trajectory after time alignment is segmented.
7. The testing method for a smart card according to claim 1, characterized in that, The step of comparing the internal operation behavior sequence with the expected behavior of the target instruction, and determining the test result of the smart card under test based on the comparison result, includes: The basic operations and their execution order in the internal operation behavior sequence are compared with the expected basic operations and their expected execution order in the expected behavior sequence to obtain the comparison result. If the comparison results indicate that the basic operations in the internal operation behavior sequence and the execution order of the basic operations are consistent with the expected behavior sequence, the test result is determined to be a pass. If the comparison result indicates that the internal operation behavior sequence includes basic operations outside the expected behavior sequence, lacks expected basic operations in the expected behavior sequence, and / or the execution order of the basic operations is inconsistent with the expected execution order, the test result is determined to be a test failure.
8. The testing method for a smart card according to claim 7, characterized in that, After determining that the test result is a test failure, the method further includes: Identify the abnormal comparison items that cause the test result to fail; When the anomaly comparison item includes a basic operation outside the expected behavior sequence, identify the operation type corresponding to the basic operation outside the expected behavior sequence; Based on the anomaly comparison item and / or the operation type, determine the abnormal behavior of the smart card under test, and output the corresponding prompt information for the abnormal behavior.
9. The testing method for a smart card according to claim 1, characterized in that, The target instruction is at least one instruction in a preset test instruction sequence; The method further includes: The test instruction sequence is sent to the smart card under test in a preset order; The instantaneous energy consumption trajectory during the execution of each instruction in the test instruction sequence is obtained respectively, and the test result corresponding to each instruction is determined respectively; The overall test result corresponding to the test instruction sequence is generated based on each of the test results.
10. A testing system, characterized in that, The testing system is used to perform the testing method for the smart card according to any one of claims 1-9; the system includes a test control host, a smart card reader / writer interface, a high-precision power consumption acquisition unit, and a data processing and analysis unit; The test control host establishes a communication connection with the smart card under test through the smart card reader / writer interface, and is used to send target instructions to the smart card under test; The high-precision energy consumption acquisition unit is connected in series on the power supply line of the smart card under test, and is used to acquire the instantaneous energy consumption trajectory of the smart card under test during the execution of the target instruction; The data processing and analysis unit is communicatively connected to the test control host and the high-precision energy consumption acquisition unit, respectively, and is used to segment the instantaneous energy consumption trajectory to obtain multiple trajectory segments; match the multiple trajectory segments with a pre-established standard operation energy consumption feature library to obtain matching results; wherein, the matching results are used to characterize the correspondence between the trajectory segments and basic operations; the standard operation energy consumption feature library is used to store the energy consumption characteristics corresponding to the smart card when performing different basic operations; based on the matching results, determine the multiple basic operations of the smart card under test in the process of executing the target instruction and the execution order of the multiple basic operations; based on the multiple basic operations and the execution order of the multiple basic operations, generate the internal operation behavior sequence of the smart card under test in the process of executing the target instruction; compare the internal operation behavior sequence with the expected behavior sequence corresponding to the target instruction, and determine the test result of the smart card under test based on the comparison result.