Non-contact smart card testing method based on NFC smart phone
Technical Field
The invention relates to the technical field of test verification, in particular to compatibility test of a smart card, an NFC smart phone and a non-contact smart card.
Background
Near Field Communication (NFC) is a short-range, high-frequency wireless Communication technology that allows contactless point-to-point data transmission and exchange of data between electronic devices. NFC is widely applied to mobile payment, identity authentication, entrance guard and other scenes. Along with the wide application of the NFC to the mobile phone end, data interaction between different NFC smart phones and contactless smart cards is more and more frequent.
Due to the wide application of the NFC smart phone and the non-contact smart card, the compatibility problem of data communication between different types of NFC smart phones and different types of non-contact smart cards is caused. Most of the existing schemes for the compatibility test in the market have inflexible functions and low automation degree, and are mainly the intelligent card compatibility test realized based on a PC. Currently, an effective automatic test scheme for an NFC smart phone and a contactless smart card is lacking, and particularly, an automatic detection scheme that can complete all test procedures at a phone end and flexibly formulate a test strategy is lacking.
Disclosure of Invention
In order to solve the test problem of the non-contact smart card, the invention provides a non-contact smart card test method based on an NFC smart phone, which can realize a complete automatic test flow at a mobile phone end, realize test schemes under different conditions and improve test efficiency and accuracy.
The invention provides a non-contact smart card testing method based on an NFC smart phone, which comprises the steps of compiling a testing script at a mobile phone end, loading and analyzing the testing script by the mobile phone, sending an APDU testing instruction set to a smart card by the mobile phone, returning response data by the smart card, receiving and analyzing the data by the mobile phone, giving a testing result and achieving the goal of compatibility testing of the smart card.
The invention relates to a smart phone with an NFC function, in particular to a non-contact smart card, which is a smart phone with an NFC function, wherein the communication mode between the smart card and a mobile phone is NFC communication.
The invention compiles and debugs the test script at the mobile phone end, and the test script has a fixed grammar format. And flexibly customizing the required test scheme according to different test targets through APDU instructions, SW expected to be returned, numerical values expected to be returned, data length expected to be returned, script annotation, cycle control and other functions.
The mobile phone sends the test instruction to the smart card in an NFC transmission mode. The mobile phone establishes NFC connection with the smart card by using the system API, and transmits an APDU command to the smart card through the NFC module transmission system API interface. And when the connection is unsuccessful or the data transmission is abnormal, the mobile phone intercepts abnormal information and performs abnormal processing.
The smart card receives the instruction data, transmits the response data to the mobile phone through the NFC transmission channel, and the mobile phone analyzes the response data, separates and extracts different fields of the data according to NFC related protocols for data verification.
According to the verification strategy made in the script, the mobile phone verifies the response data through the state characters, the numerical values and the data length data, and judges whether the response data is in accordance with the expectation, so that whether the data communication between the mobile phone and the intelligent card is correct or not is judged, and the compatibility problem exists.
The invention controls the integrity of the test through the cycle times and the interruption conditions, and ensures that the compatibility communication performance of the mobile phone and the smart card is accurately judged.
In the invention, each link of the test process can record the log text, and all the processes can be displayed on the mobile phone, including the abnormal information. The log name and the display format can be flexibly defined on the mobile phone.
Drawings
Fig. 1 is a schematic diagram of a testing method of a contactless smart card and an NFC handset.
Fig. 2 is a schematic diagram of a cycle test procedure.
Detailed Description
The following description will discuss the present invention with reference to fig. 1 and 2. This embodiment is described in detail to enable those skilled in the art to practice the invention.
In the attached figure 1 of the embodiment of the invention, a test system of a non-contact smart card and an NFC mobile phone communicates through an NFC communication protocol between the mobile phone and the smart card, and an NFC module belongs to a system module of the mobile phone. Before testing, the mobile phone and the smart card are connected, and if the connection failure program is started, the test can display error information.
And (1) writing and loading a script. And writing a test script by the mobile phone terminal, wherein data in the script has a fixed grammar format. The script data contains a loop number instruction, and fields of an APDU instruction, an expected return SW, an expected response value and an expected response data length. The mobile phone loads the script.
And (2) analyzing the instruction. And (4) after the mobile phone is loaded, carrying out format judgment on the data, if the format conforms to the specified grammar, analyzing the data, if the format does not conform to the specified grammar, carrying out exception handling, displaying error information by the mobile phone, and carrying out the step (6). Otherwise, performing step (3).
And (3) sending an instruction. And the mobile phone sends and tests the analyzed APDU instruction sets one by one through the NFC module. The data transmission test procedure is shown in fig. 2.
And (4) responding to data reception. The smart card sends response data information after receiving the instruction information, and the mobile phone end receives the response data information through the NFC module.
And (5) responding to data processing. And the mobile phone judges the received response data. If the returned data information does not match the expected returned data, indicating a check Fail, step (6) is entered, and Pass is checked, followed by step (7).
And (6) exception handling. And recording the abnormal information in detail.
And (7) storing data. In the test process, the test data and the exception handling information are stored through the step, the test information is stored in a test log, and the test data is displayed in real time by the mobile phone terminal.
Step 4-the received data processing of step 7 is as described in fig. 2. After the instruction set test is completed for one time, if the test times are reached, storing the statistical information in the log, and ending the test, otherwise, continuing to perform the test according to the step (8).
And (8) performing cyclic testing. In fig. 2, the test is performed in a loop until the test instruction set is repeatedly tested according to a predetermined number of times. After the script is analyzed by the mobile phone, a test instruction set is obtained, then legal instructions are sent to the smart card one by one, data verification is carried out on each instruction, verification information of the instruction is generated, and a log is stored. When the loop test is completed, the statistical information is stored in the log.