CN117995261A - Smart card power-off test method and device and storage medium - Google Patents

Smart card power-off test method and device and storage medium Download PDF

Info

Publication number
CN117995261A
CN117995261A CN202410331487.5A CN202410331487A CN117995261A CN 117995261 A CN117995261 A CN 117995261A CN 202410331487 A CN202410331487 A CN 202410331487A CN 117995261 A CN117995261 A CN 117995261A
Authority
CN
China
Prior art keywords
data
power
terminal
instruction
smart card
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410331487.5A
Other languages
Chinese (zh)
Inventor
程冉
杨黄林
袁外平
梁雪焕
黄卫文
孙奥
陈宇英
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xinghan Intelligent Technology Co ltd
Original Assignee
Xinghan Intelligent Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xinghan Intelligent Technology Co ltd filed Critical Xinghan Intelligent Technology Co ltd
Priority to CN202410331487.5A priority Critical patent/CN117995261A/en
Publication of CN117995261A publication Critical patent/CN117995261A/en
Pending legal-status Critical Current

Links

Landscapes

  • Power Sources (AREA)

Abstract

The invention discloses a smart card power-off test method, a device and a storage medium, wherein the method comprises the following steps: receiving a first application selection instruction sent by a terminal; selecting an application according to the first application selection instruction, and sending a successful selection response to the terminal; receiving power-off test information sent by a terminal, and performing power-off test processing by applying response power-off test information to obtain test feedback information, wherein the power-off test processing represents power-off test processing performed in the process of transmitting data of a first data area to a second data area; and sending the comparison result information to the terminal so that the terminal determines the power-off test result according to the comparison result information. The power-off test is carried out through the application arranged on the intelligent card, so that the data interaction of the terminal can be reduced, the test speed is high, the test period is short, the power-off test is carried out for a plurality of times, the test precision is high, and the method can be widely applied to the technical field of intelligent cards.

Description

Smart card power-off test method and device and storage medium
Technical Field
The present invention relates to the field of smart cards, and in particular, to a smart card power failure test method, device and storage medium.
Background
The smart card is always inevitably powered off in the use process, and if the condition of improper processing occurs in the COS (Chip Operating System, on-chip operating system) for the erasing of the EEPROM (ELECTRICALLY ERASABLE PROGRAMMABLE READ-Only Memory), the condition of bad card or disordered data in the card can occur. The power-off test of the smart card, such as the anti-plug test, aims to detect the protection of data integrity and the automatic rollback capability when unexpected power-off occurs in the interaction process of an on-chip operating system of the smart card and a terminal.
The traditional power-off test writes different test cases according to different test platforms, the smart card is powered on and reset again, then the terminal reads the data of the smart card one by one, the test period is long, the test speed is too slow, and the test efficiency is too low.
Disclosure of Invention
Therefore, an object of the embodiments of the present invention is to provide a smart card power-off testing method, device and storage medium, which improve the efficiency and speed of power-off testing and reduce the testing period.
In a first aspect, an embodiment of the present invention provides a method for testing power failure of a smart card, where the smart card is provided with an application, the application includes a first data area and a second data area, the first data area stores first data, the second data area stores second data, and the smart card is communicatively connected to a terminal, and the method includes:
receiving a first application selection instruction sent by the terminal;
Selecting the application according to the first application selection instruction;
receiving power-off test information sent by the terminal;
Responding to the power-off test information by the application to perform power-off test processing, so as to obtain test feedback information, wherein the power-off test processing represents the power-off test processing performed in the process of transmitting the data of the first data area to the second data area to replace the second data;
And sending the test feedback information to the terminal so that the terminal determines a power-off test result according to the test feedback information.
In a second aspect, an embodiment of the present invention provides a method for testing power failure of a smart card, where the smart card is applied to a terminal, and the smart card is provided with an application, and includes a first data area, a backup area, and a second data area, where the first data area stores first data, the second data area stores second data, the backup area caches the second data, and the smart card is communicatively connected to the terminal, and the method includes:
acquiring reset success information sent by the smart card;
Sending a first application selection instruction to the smart card so that the smart card selects the application according to the first application selection instruction;
Receiving a selection success response sent by the intelligent card;
Transmitting power-off test information to the smart card according to the selection success response, so that after the smart card receives the power-off test information, the power-off test information is responded by the application to perform power-off test processing, test feedback information is obtained, and the power-off test processing represents power-off test processing performed in the process of transmitting data of the first data area to the second data area through the backup area to replace the second data;
Receiving the test feedback information sent by the smart card;
And determining a power-off test result according to the test feedback information.
In a third aspect, an embodiment of the present invention provides a method for testing power failure of a smart card, which is applied to a terminal, where the smart card is provided with an application, and the smart card includes a first data area and a second data area, where the first data area stores first data, and the second data area stores second data, and the smart card is communicatively connected to the terminal, and the method includes:
acquiring reset success information sent by the smart card;
Sending a first application selection instruction to the smart card so that the smart card selects the application according to the first application selection instruction;
Receiving a selection success response sent by the intelligent card;
transmitting power-off test information to the smart card according to the selection success response, so that after the smart card receives the power-off test information, responding the power-off test information by the application to perform power-off test processing to obtain test feedback information, wherein the power-off test processing represents power-off test processing performed in the process of transmitting the first data of the first data area to the second data area to replace the second data;
Receiving the test feedback information sent by the smart card;
And determining a power-off test result according to the test feedback information.
In a fourth aspect, an embodiment of the present invention provides a smart card power-off test device, applied to a smart card, where the device includes:
At least one processor;
At least one memory for storing at least one program;
the at least one program, when executed by the at least one processor, causes the at least one processor to implement the smart card power down test method as described above.
In a fifth aspect, an embodiment of the present invention provides a smart card power-off testing device, applied to a terminal, where the device includes:
At least one processor;
At least one memory for storing at least one program;
the at least one program, when executed by the at least one processor, causes the at least one processor to implement the smart card power down test method as described above.
In a sixth aspect, embodiments of the present invention provide a computer readable storage medium having stored therein a processor executable program which when executed by a processor is for performing a smart card power down test method as described above.
The embodiment of the invention has the following beneficial effects: the embodiment of the invention provides a smart card power-off test method, which comprises the following steps: receiving a first application selection instruction sent by a terminal; selecting an application according to the first application selection instruction; receiving power-off test information sent by a terminal, and performing power-off test processing by applying response power-off test information to obtain test feedback information, wherein the power-off test processing represents power-off test processing performed in the process of transmitting data of a first data area to a second data area to replace the second data; and sending the test feedback information to the terminal so that the terminal determines a power-off test result according to the test feedback information. In the technical scheme of the embodiment, the smart card is subjected to power-off test by selecting the application, so that the data interaction of the terminal is reduced, the test speed is high, and the test period is short.
Drawings
FIG. 1 is a schematic flow chart of steps of a smart card power-off test method according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating steps of a first power down test according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating steps of another first power down test according to an embodiment of the present invention;
FIG. 4 is a flow chart of data reduction provided by an embodiment of the present invention;
FIG. 5 is a flowchart illustrating steps of a second power down test provided by an embodiment of the present invention;
FIG. 6 is a flowchart illustrating steps of another first power down test according to an embodiment of the present invention;
FIG. 7 is a flowchart illustrating steps of another first power down test according to an embodiment of the present invention;
FIG. 8 is a flowchart illustrating steps of another smart card power-down testing method according to an embodiment of the present invention;
FIG. 9 is a flowchart illustrating steps of another smart card power-down testing method according to an embodiment of the present invention;
FIG. 10 is a block diagram of a smart card power down test system according to an embodiment of the present invention;
FIG. 11 is a block diagram of another smart card power down test system provided by an embodiment of the present invention;
Fig. 12 is a block diagram of a smart card power-off testing device according to an embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present invention more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the invention.
It should be noted that although functional block division is performed in a device diagram and a logic sequence is shown in a flowchart, in some cases, the steps shown or described may be performed in a different order than the block division in the device, or in the flowchart. The terms first, second and the like in the description, in the claims and in the above-described figures, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
The related technical noun instruction concretely comprises the following steps:
The smart card (SMART CARD) includes a financial card, a non-financial card, an IC card, and the like. The financial card is also called a bank card, and can be divided into a credit card and a cash card, wherein the credit card and the cash card can be used for paying according to a preset limit when the financial card is used for consuming payment, and the cash card can be used as an electronic purse or an electronic bankbook, but cannot be used for paying. Instead of the financial card, also called a non-banking card, the scope of the related art is very wide, and practically encompasses all fields other than the financial card, such as telecommunications, travel, education, public transportation, and the like.
Embodiments of the present invention will be further described below with reference to the accompanying drawings.
As shown in fig. 1, an embodiment of the present invention provides a smart card power-off test method, which includes the following steps.
Step S100, a first selection application instruction sent by a terminal is received.
Referring to fig. 1, specifically, after the smart card is powered on and reset, an application for testing is selected and connected to the terminal in a communication manner, which includes a wireless connection or a wired connection, and specifically, the connection is not limited herein. It should be noted that, the terminal may be different according to different application scenarios, may be a cabinet machine of a bank storage type, may be an access control card swiping machine, may be a mobile phone terminal, or may be other devices with authentication functions, and the implementation is not limited specifically.
Step S200, selecting an application according to the first application selection instruction.
Specifically, after the smart card acquires the first application selection instruction, the smart card selects an application to perform the power-off test of the smart card, after the application selection, the smart card sends a selection success response to the terminal, and after the terminal receives the selection success response, the smart card sends power-off test information, so that step S300 is executed again.
In some alternative embodiments, after the smart card acquires the first application selection instruction, the smart card selects an application to perform the power-off test of the smart card, and after the application selection, the smart card may not send a selection success response to the terminal, and after a preset time elapses, the terminal side does not receive the selection unsuccessful response sent by the smart card, so that the terminal side may default to the smart card selection application success, and at this time, the terminal may send power-off test information to the smart card, thereby executing step S300.
Step S300, receiving power-off test information sent by a terminal; and performing power-off test processing by applying response power-off test information to obtain test feedback information, wherein the power-off test processing represents the power-off test processing performed in the process of transmitting the data of the first data area to the second data area to replace the second data.
Specifically, after the application is successfully selected, the smart card sends a success response to the terminal, then the terminal starts to send power-off test information to the smart card, the power-off test information comprises a first writing instruction, and the smart card receives the first writing instruction sent by the terminal. The application of the smart card writes the first data into the second data area according to the first writing instruction, and the terminal is powered off at the first power-off time, wherein the power-off time of the smart card is the first power-off time.
In some alternative embodiments, first, a first writing instruction sent by a terminal is acquired; then, first data of the first data area are written into the second data area according to the first writing instruction, wherein the data of the second data area before writing is the second data; then, if the first writing instruction is executed, a first writing response instruction is sent to the terminal; receiving a second comparison instruction sent by the terminal, wherein the first writing instruction and the second comparison instruction are executed in the application; and then comparing the data of the second data area with the first data and the second data respectively according to the second comparison instruction to obtain second comparison result information.
In some alternative embodiments, first, a first writing instruction sent by a terminal is acquired; then, first data of the first data area are written into the second data area according to the first writing instruction, wherein the data of the second data area before writing is the second data; then, if the first writing instruction is executed, a first writing response instruction is sent to the terminal; and receiving a second reading instruction sent by the terminal, wherein the first writing instruction and the second reading instruction are executed in the application, reading the data of the second data area according to the second reading instruction, and generating second reading instruction response information according to the data of the second data area. And the terminal compares the data of the second data area with the first data and the second data respectively according to the second read instruction response information to obtain second comparison result information.
In some alternative embodiments, the comparison instruction may perform a comparison within the smart card, where the comparison of the data is compared by the smart card COS when there is no backup of the first and second data by the backup area; after the backup area backs up the first data and the second data, the written data is compared with the backed-up first data and the backed-up second data after the data is written in the second data area, and at the moment, a comparison instruction executes comparison in the application; after the terminal stores the first data and the second data, the data written in the second data area is read for comparison, and at the moment, the comparison instruction executes comparison in the terminal.
In some alternative embodiments, the test purpose is to detect whether an abnormal problem (i.e. non-first data or non-second data) occurs in the data in the second data area in the scenario that the first data is copied from the first data area to the second data area in the case of power failure, when the smart card receives the first writing instruction written from the first data area to the second data area, the first data in the first data area may be directly written to the second data area, or the first data in the first data area may be written to the backup area first, and then after the writing of the first data in the backup area is completed, the first data is written from the backup area to the second data area. And the power is cut off at a first power-off time in the whole writing process, wherein the first power-off time comprises a plurality of power-off time points, and the smart card is powered off at the power-off time points. After the first writing instruction is executed, the intelligent card receives a second comparison instruction sent by the terminal, and the data of the second data area are respectively compared with the first data and the second data according to the second comparison instruction to obtain second comparison result information. That is, in case of successful power-off, the first data is already written into the second data area after the first writing instruction is executed.
In some alternative embodiments, the backup area is backed up with first data and second data, the first data in the first data area is written into the second data area, after the writing is finished, the smart card receives a second comparison instruction sent by the terminal, the smart card reads the first data and the second data from the applied backup area, and the data in the second data area is compared with the first data and the second data respectively to obtain second comparison result information.
It should be noted that, the first power-off time is determined according to the first power-off cycle number, where the first power-off cycle number is obtained by adding one to the first power-off cycle number by the terminal when the first power-off time is reached and the smart card does not complete the first write command, and the first power-off time is equal to the product of the first initial time plus the first power-off cycle number and the first time step.
In some alternative embodiments, the application includes a first data area, a backup area, and a second data area, the first data area storing first data, the second data area storing second data, the backup area storing second data, the smart card communicatively coupled to the terminal, the method further comprising: the power-off test process is performed during the transmission of the data of the first data area to the second data area through the backup area to replace the second data.
Specifically, the first data area writes first data into the backup area for caching, and then writes the first data cached in the backup area into the second data area to replace the second data; and the power-off test processing is performed in the process that the data in the first data area is written into the backup area, and the first data is transmitted from the backup area to the second data area to replace the second data.
In some alternative embodiments, in order to shorten the power-off test time, the smart card is pre-tested by the first power-off test before the power-off test is performed, so as to find the time point when the first data is written into the backup area by the first power-off test, when the terminal receives the comparison result information fed back by the smart card for the first time in the process of the first power-off test (the situation that the data in the second data area is the first data is represented by the comparison result information here), it is proved that the first data in the first data area is already written into the second data area, then based on the writing principle of the two data areas of the smart card, the first data is already written into the second data area on the premise that the first data is already written into the backup area, so that the power-off cycle number corresponding to the comparison result information fed back by the smart card is obtained, then the first power-off cycle number is obtained by a certain cycle number according to the power-off cycle number, and the first power-off cycle number is close to the backup area or the power-off cycle number corresponding to the first data is obtained as the time point when the power-off cycle number corresponding to the first data is actually written into the backup area, and the power-off cycle number is actually obtained, and the time is recorded as the time of the power-off test is actually completed. The power-off test is performed only after the time point is finished when the power is off, so that the power-off time is greatly reduced, and the power-off test time is less.
In some alternative embodiments, if the data in the second data area is the same as the first data, the first comparison result information is sent to the terminal; acquiring a data restoration instruction sent by a terminal; and restoring the data of the second data area into second data according to the data restoring instruction.
In some alternative embodiments, the smart card is powered off during the first data writing process, and after each power off, a synchronization comparison of the data is performed, that is, whether the data of the N pages is updated simultaneously is checked, and the updating steps are as follows: firstly judging whether the data of the second data area is the same as the first data, if so, responding to 0x01 by the data comparison instruction, otherwise judging whether the data of the second data area is the same as the second data, if so, responding to 0x02 by the data comparison instruction and caching different page index numbers, otherwise, responding to 0x00, and ending the data comparison process. If the data comparison instruction responds to 0x01, then the power is cut off in the data recovery process, the intelligent card receives the data recovery instruction sent by the terminal, and the data in the second data area is recovered to the second data, and the data comparison is still carried out according to the steps after the power cut off is finished. The second data area is a new value writing area, the backup area is a self-defined backup area, and the first data is written into the backup area every time the first data is written. Meanwhile, all data operations (data updating and data comparison) are performed in the application, and the terminal only needs to send an operating instruction and transmit a page index number, so that speed acceleration in the power-off test process can be ensured, and log data of the terminal can be reduced.
In some alternative embodiments, after restoring the data of the second data area to the second data according to the data restoration instruction, the method includes: sending a restore response message to the terminal so that the terminal sets a first power-off time; acquiring a first writing instruction; under the condition that the first power-off time is reached and the smart card does not complete the first writing instruction, the terminal sets a second power-off time; after power-on reset, acquiring a second selection application instruction sent by the terminal; selecting an application according to the second selection application instruction, writing the first data of the backup area into a second data area, and powering off at a second power-off time; if the second application selection instruction is executed, a second writing response instruction is sent to the terminal; receiving a third comparison instruction sent by the terminal; respectively comparing the data of the second data area with the first data and the second data according to the third comparison instruction to obtain third comparison result information, or receiving a third reading instruction sent by the terminal, reading the data of the second data area according to the third reading instruction, and generating third reading instruction response information according to the data of the second data area; and the terminal compares the data of the second data area with the first data and the second data respectively according to the third read instruction response information to obtain third comparison result information, wherein the outage test information comprises a first write instruction, a second comparison instruction, a second selection application instruction, a data restoration instruction and a third comparison instruction, and the test feedback information comprises the second comparison result information and the third comparison result information.
Specifically, in the technical solution of this embodiment, the power-off test includes two-stage power-off tests, where the two-stage power-off tests are all power-off test processes of loop iteration, and first power-off test is performed on the smart card based on the first power-off time number, that is, power-off is performed by a first power-off time (the first power-off time is equal to a product of a first initial time plus a power-off cycle number and a first time step, and the first initial time and the first time step are both preset values), where the first power-off time is a power-off time when writing into the backup area is nearly completed or when writing into the backup area is completed for the first data, and then a stage of writing the first data of the first data area into the backup area can be quickly reached when performing the first power-off test. And when the first writing instruction is executed and the first writing response instruction is not received, the smart card finishes writing the first data into the second data area, restores the data of the second data area into the second data, and enters a stage of a second power-off test after finishing the writing. The method comprises the steps that in a second power-off test, writing operation of a second selection application instruction sent to a smart card is different from a first writing instruction sent by a first power-off test, the second selection application instruction characterizes selection application and writes data of a backup area into a second data area, then according to second power-off time and under the condition that the smart card does not finish the second selection application instruction, the second power-off time is continuously added with a second time step and a flow of the second power-off test is conducted again until the second selection application instruction is reached, at the moment, a terminal receives second writing response information sent by the smart card, then sends a third comparison instruction to the smart card, so that the smart card can compare the data of the second data area with the first data and the second data respectively to obtain third comparison result information, then the terminal determines a second power-off test result according to the third comparison result information, if the second power-off test result is successful, the terminal adds a first time step to the first power-off time and conducts power-off test on the smart card based on the first time step after the processing, and the first power-off test is conducted until the first power-off time is not completed, and the first power-off test is conducted according to the first power-off time is conducted; if the power failure occurs in the test result in the power failure test process, the power failure test is stopped immediately, and the power failure test can be repeated after the relevant parameters of the terminal or the intelligent card are adjusted.
In some alternative embodiments, after restoring the data of the second data area to the second data according to the data restoration instruction, the method includes: sending a restore response message to the terminal so that the terminal sets a first power-off time; acquiring a first writing instruction; under the condition that the first power-off time is reached and the smart card does not complete the first writing instruction, the terminal sets a second power-off time; after power-on reset, acquiring a second selection application instruction sent by the terminal; selecting an application according to the second selection application instruction, writing first data of the first data area into the second data area, and powering off at a second power-off time; if the second application selection instruction is executed, a second writing response instruction is sent to the terminal; receiving a third comparison instruction sent by the terminal; and comparing the data of the second data area with the first data and the second data respectively according to the third comparison instruction to obtain third comparison result information, wherein the outage test information comprises a first writing instruction, a second comparison instruction, a second selection application instruction, a data restoration instruction and a third comparison instruction, and the test feedback information comprises the second comparison result information and the third comparison result information.
Specifically, in the technical solution of this embodiment, the power-off test includes two-stage power-off tests, where the two-stage power-off tests are all power-off test processes of loop iteration, and first power-off test is performed on the smart card based on the first power-off time number, that is, power-off is performed by a first power-off time (the first power-off time is equal to a product of a first initial time plus a power-off cycle number and a first time step, and the first initial time and the first time step are both preset values), where the first power-off time is a power-off time near completion of writing first data into the second data area. And when the first writing instruction is executed and the first writing response instruction is not received, restoring the data of the second data area into second data, so that a stage of a second power-off test is entered. The method comprises the steps that in a second power-off test, writing operation of a second selection application instruction sent to a smart card is different from a first writing instruction sent by a first power-off test, the second selection application instruction characterizes selection application and writes first data into a second data area, then according to second power-off time and under the condition that the smart card does not complete the second selection application instruction, the second power-off time is continuously added with a second time step to process and re-process a flow of the second power-off test until the second selection application instruction is reached, at the moment, a terminal receives second writing response information sent by the smart card, then sends a third comparison instruction to the smart card, so that the smart card can compare the data of the second data area with the first data and the second data respectively to obtain third comparison result information, then the terminal determines a second power-off test result according to the third comparison result information, if the second power-off test result is successful, the terminal adds a first time step to process the first power-off time and processes the first power-off time step to the smart card until the first power-off time is equal to the first power-off time after the processing is completed, and the first power-off test is continuously performed on the smart card according to the first power-off time to the first power-off test flow is completed; if the power failure occurs in the test result in the power failure test process, the power failure test is stopped immediately, and the power failure test can be repeated after the relevant parameters of the terminal or the intelligent card are adjusted.
In some alternative embodiments, writing first data of the first data area to the second data area according to the first write instruction includes: determining a first target page number of the first data area and a second target page number of the second data area according to the first writing instruction; and writing the first data of the first target page number into the second target page number, wherein the first target page number is the same as and corresponds to the second target page number, and the smart card is also used for caching the second data of the second target page number.
In some alternative embodiments, after the smart card obtains the first write command, the smart card obtains the page number of the data to be replaced according to the first write command to form a first target page number, stores the first data corresponding to the input first target page number in the backup area for backup and caching, where the page number of the data to be replaced is the page number in the first data area, so that the number of the first target page number can be set to be smaller than the number of all page numbers in the first data area according to the need, so as to avoid errors and prolong the test time. The first data is data in the first data area, the first data is directly written into a data list corresponding to a second target page number of the second data area after being acquired, or is written into a backup area for backup caching, then the first data is written into the data list corresponding to the second target page number of the second data area, and one data list is data of one page; and powering off the first data in the process of writing the first data into the data list corresponding to the second target page number, wherein the power-off time is the first power-off time.
In some alternative embodiments, the first data is powered off during the process of writing the first data into the second target page number of the second data area, after the second data area is powered on again, another selection instruction sent by the terminal is obtained, and the application of the power-off test is selected according to the another selection instruction and the first data is written into the second target page number of the second data area.
In some alternative embodiments, the flag area is responsive to corresponding data after the first data is written to the backup area, and the flag area is a flag that marks whether the writing of data to the backup area is completed. The first data is then written to the second target page number of the second data area and power down is started at the time of writing. After the terminal is powered on again, the terminal sends a selection instruction to the intelligent card, and the intelligent card selects the application according to the received selection instruction and writes the first data into a second target page number of the second data area.
In some alternative embodiments, writing the first data of the first target page number into the second target page number includes: writing first data of the first target page number into a third target page number of the backup area; and writing the first data in the third target page number into the second target page number, wherein the first target page number is the same as and corresponds to the second target page number.
Specifically, the first target page number of the first data area and the second target page number of the second data area may be set to be the same and correspond to each other, and then the first write instruction characterizes writing the first data of the first target page number of the first data area into the first target page number of the second data area. In the case of the setting of the present embodiment, writing the first data of the first data area to the second data area includes: first, first data of a first target page number of a first data area is written into a third target page number of a backup area; and copying and pasting the first data of the third target page number of the backup area into the second target page number of the second data area.
In some alternative embodiments, before acquiring the first writing instruction sent by the terminal, the method includes: acquiring a reset request sent by a terminal; resetting according to the resetting request, and sending resetting success response information to the terminal after resetting is completed; acquiring a first application selection instruction sent by a terminal, selecting an application, and sending a selection success response to the terminal after the selection is completed; acquiring a first comparison instruction sent by a terminal; respectively comparing the data of the second data area with the first data and the second data according to the first comparison instruction to obtain first comparison result information; and sending the first comparison result information to the terminal so that the terminal sets a first power-off time to power off or generates power-off failure information.
In some alternative embodiments, before acquiring the first writing instruction sent by the terminal, the method includes: acquiring a reset request sent by a terminal; resetting according to the resetting request, and sending resetting success response information to the terminal after resetting is completed; acquiring a first application selection instruction sent by a terminal, selecting an application, and sending a selection success response to the terminal after the selection is completed; acquiring a first reading instruction sent by a terminal; reading data of the second data area according to the first reading instruction; and generating first read instruction response information according to the data of the second data area and sending the first read instruction response information to the terminal so that the terminal can set the first power-off time to power off or generate power-off failure information according to the first read instruction response information.
Specifically, the terminal sends a reset request to the smart card, after receiving a reset success response returned by the smart card, sends a first selection application instruction to the smart card, so that the smart card runs and selects an application program suitable for a first power-off test, after the smart card selects the application program, the terminal sends a selection success response, after receiving the selection success response returned by the smart card, the terminal sends a first comparison instruction to the smart card, and the smart card compares data currently stored in a second data area with first data and second data respectively according to the first comparison instruction, generates first comparison result information, and the terminal receives the first comparison result information sent by the smart card; and under the condition that the first comparison result information represents that the data of the second data area is the second data, setting the power-off time according to the first power-off time, and sending a first writing instruction to the intelligent card. And under the condition that the data of the first comparison result information representing the second data area is the first data, the terminal sends a data restoration instruction to the intelligent card. And under the condition that the data of the first comparison result information representing the second data area is not the second data and the first data, the terminal generates outage failure information and ends the outage test.
In some alternative embodiments, before acquiring the first writing instruction sent by the terminal, the method includes: acquiring a reset request sent by a terminal; resetting according to the resetting request, and sending a resetting success response to the terminal after resetting is completed; acquiring a first selection application instruction sent by a terminal; and selecting the application according to the first selection application instruction, and sending a selection success response to the terminal after the selection is completed.
Specifically, after the smart card is powered on, the terminal sends a reset request to the smart card, so that the smart card is reset, and after the smart card is reset, a reset success response is sent to the terminal; after receiving the reset success response, the terminal sends a first application selection instruction to the intelligent card, so that the intelligent card selects an application to perform the power-off test of the intelligent card after receiving the first application selection instruction, and after the application selection is successful, the intelligent card sends a selection success response to the terminal. Thereby enabling the terminal to send a first write command to the smart card and to start the power down test.
In some alternative embodiments, after the power-on reset, comparing the data of the backup area with the data of the second data area, if the data of the second data area is equal to the data of the backup area, performing data recovery, that is, finding a time point when the data of the backup area starts to be written into the second data area, and setting the power-off start time according to the time point. The terminal sends a data restoration instruction to the smart card during data restoration, the smart card restores the data of the second data area into the second data according to the data restoration instruction, namely, restores the data of the second data area into the data when the (N-X) -th power failure occurs, the first data is just written into the second data area from the backup area at the moment, the Nth power failure times are the power failure times when the data restoration starts, the (N-X) -th power failure times are the power failure times when the first data is started to be written into the second data area from the backup area, and the Flag bit Flag after the data restoration is set to 1, so that a data restoration time point is obtained. In the following power-off test (namely the next backward cycle power-off test), the power-off starting time is the found data recovery time point, so that the power-off time of writing the data of the first data area into the backup area is avoided, namely the power-off is started from the found time point, and the power-off is not performed before the time point, thereby greatly shortening the overall power-off time and enabling the power-off test period to be shorter.
In some alternative embodiments, writing the first data into the second target page number of the second data region includes: inputting a first target page number into an application, and starting a transaction; writing the page number of the first target page number of the backup area into a second data area, and writing the first data into the second target page number for updating; judging whether the page numbers of the first target page numbers are written into the second data area; ending the transaction if all the writing is performed;
Specifically, inputting a page number required to update data into an application for performing power-off test of the smart card, and then starting a power-off test transaction; writing the page number of the first target page number cached in the backup area into a second data area for data updating, wherein the data of a corresponding data list of the second target page number is updated into first data; the data of the data list corresponding to the page number of the first target page number is updated into first data, and the page number of the first target page number needs to be copied to a second data area for data updating; and after the page numbers of the first target page number are all copied to the second data area to complete data updating, ending the data updating transaction.
In some optional embodiments, the terminal generates power failure information or power success information according to the second comparison result information, including: if the data of the second data area is different from the first data and the data of the second data area is different from the second data, the terminal generates outage failure information; if the data of the second data area is the same as the first data or the data of the second data area is the same as the second data, the terminal generates power-off success information.
Specifically, if the data corresponding to the updated page number (01, 03, 05) in the second data area is the same as the data corresponding to the page number (01, 03, 05) in the first data area, and the data corresponding to the non-updated page number is not changed, or the data of all page numbers in the second data area is not changed, it represents that the EEPROM (ELECTRICALLY ERA step Sable Programmable read only memory, electrically erasable programmable read only memory) is successfully written. At the moment, a first comparison result generated by the intelligent card is transmitted to the terminal, and the terminal generates power failure success information.
If the data corresponding to the updated page number (01, 03, 05) in the second data area is different from the data corresponding to the page number (01, 03, 05) in the first data area and is not the second data of the second data area, or the data corresponding to the non-updated page number is changed, the writing of the EEPROM is failed. At the moment, a first comparison result generated by the intelligent card is transmitted to the terminal, and the terminal generates outage failure information.
In some alternative embodiments, the application is selected according to the second selection application instruction, and the first data of the backup area is written into the second data area, and the power is turned off at the second power-off time.
Specifically, after receiving the second selection application instruction, the smart card receives the second selection application instruction, selects an application to execute the second power-off test, and writes the data of the backup area into the second data area while selecting the application, wherein the data of the backup area is the first data written into the first data area, that is, the first data area writes the first data which needs to be written into the second data area into the backup area first, and then writes the first data into the second data area from the backup area. And (3) performing power-off in the process of writing the first data cached in the backup area into the second data area, wherein the power-off time is second power-off time, the second power-off time comprises multiple power-off times, the power-off is performed in one power-off period, the power-off period is a second time step, and the power-on reset is continued to perform power-off after the power-off is finished until the second power-off time is more than or equal to the preset second execution time.
In some alternative embodiments, writing the first data of the backup area to the second data area, powering down at a second power-down time, includes: the terminal sets a second execution time; selecting an application and writing the first data of the backup area into a second data area in a second execution time; if the second power-off time is smaller than the second execution time, a second time step is acquired, a second time step is added to the second power-off time to obtain a new second power-off time, and power is off at the new second power-off time.
Specifically, after power-on reset after power-off, the test application is reselected according to a second application selection instruction, a preset second execution time is obtained, the application is selected in the second execution time, and the first data written in the cached first data area of the backup area is written in the second data area. And performing power-off test in the writing process, setting a second power-off starting time and a second time step, and automatically setting the second power-off starting time and the second time step according to the second execution time, wherein the power-off is performed after the second time step is finished after the second power-off starting time is started, and the second time step is the time interval of power-off, and the power-off is performed once every second time step. After the execution of the selection instruction is finished, the intelligent card sends instruction response information or correct status words to the terminal.
In some alternative embodiments, the first power-off time is equal to the first initial time plus a product of the first number of power-off cycles and the first time step; the second power-off time is equal to a second initial time plus a product of a second number of power-off cycles and a second time step, the second time step being less than the first time step.
Specifically, the terminal sends a power-off instruction, that is, a first instruction to the application, where the execution time Tmax1 of the first instruction is set to be equal to the power-off start time T1, a first time step T1, and the power-off number n (first power-off cycle number), and if (t1+t1×n) is greater than Tmax1, the power-off is ended, and the data update condition is detected. If (t1+t1×n) is smaller than Tmax1, powering off is performed at (t1+t1×n), powering up is reset after powering off, application of a power-off test is selected, and whether data updating is synchronous or not is checked, that is, data of the first data area and data of the second data area are compared.
Specifically, the next power-off is performed after the power-off is finished, and the next power-off is performed in the next second time step. Obtaining a preset execution time tmax2=100 microseconds, setting a power-off start time t2=2 microseconds, setting a second time step t2=2 microseconds, and ending the power-off with a power-off number n2=49 (a second power-off cycle number), if (t2+t2×n2) is smaller than Tmax2, powering off the smart card at (t2+t2×n2), and judging whether the execution of the second selected application instruction is ended by the terminal, i.e. whether the terminal successfully receives the data or the correct status word returned by the instruction response, for example 9000, if the terminal successfully receives the correct response value and/or the status word, ending the power-off, otherwise continuing the power-off test until the terminal receives the data or the correct status word returned by the instruction response.
In some alternative embodiments, if the second selection application instruction is executed, a second writing response instruction is sent to the terminal, and a third comparison instruction sent by the terminal is received; and respectively comparing the data of the second data area with the first data and the second data according to the third comparison instruction to obtain third comparison result information.
Specifically, after the second selection application instruction is executed, a response signal after the second selection application instruction is executed is sent to the terminal, and the terminal further sends a third comparison instruction to the smart card end. The application of the smart card end then compares the data of the second data area with the second data and the first data to obtain third comparison result information, and the compared second data and first data can be cached in the backup area. The next power down after the power down reset requires resending the second select application instruction to the smart card.
It should be noted that the first selection application instruction and the second selection application instruction may be the same instruction, and have different functions in the first power-off time of the first power-off test and the second power-off time of the second power-off test, where the functions of the first selection application instruction include requiring the smart card selection application, and the functions of the second selection application instruction include requiring the smart card selection application and writing the first data from the backup area to the second data area, and it is understood that the second writing response information may characterize the requirement of writing the first data from the backup area to the second data area in response to the second selection application instruction. After the second writing response information is sent to the terminal, the terminal sends a second comparison instruction to the smart card.
In some alternative embodiments, the step of the first power down test may comprise: firstly, under the condition that the first power-off time is smaller than the first execution time, the terminal sends a reset request to the intelligent card; then, after receiving a reset success response returned by the intelligent card, the terminal sends a first application selection instruction to the intelligent card; then, after receiving a selection success response returned by the intelligent card, the terminal sends a first comparison instruction to the intelligent card; receiving a first comparison result sent by the smart card; then, under the condition that the first comparison result is characterized in that the data of the second data area is the second data (namely, the original data of the second data area is not changed), setting the power-off time according to the first power-off time, and sending a first writing instruction to the intelligent card; and finally, under the condition that the first writing response information fed back by the intelligent card is received, sending a second comparison instruction to the intelligent card, receiving second comparison result information sent by the intelligent card, and determining a first power-off test result according to the second comparison result information.
In some alternative embodiments, the terminal generates a data reduction instruction before the second power-off time is set, that is, before the terminal sends the second selection application instruction; transmitting a data restoring instruction to the intelligent card, and rolling back the data of the second data area by the intelligent card so as to restore the data of the second data area into second data; after the smart card rolls back, the reset response information is generated, after the terminal receives the reset response information sent by the smart card, the flag bit is set to be a second flag from the first flag according to the reset response information, the first flag represents that the data of the second data area is second data, the second flag represents that the data of the second data area is first data, and at the moment, the smart card needs to roll back the data of the second data area, so that the data of the second data area is reduced to be second data. Therefore, before the power-off test is started, the data of the second data area is ensured to be the second data.
And step S400, the test feedback information is sent to the terminal, so that the terminal determines a power-off test result according to the test feedback information.
Specifically, the first data and the data of the second data area are the same, namely the first data is successfully written into the second data area, at the moment, the intelligent card end sends comparison result information to the terminal, and the terminal generates power failure success information according to the comparison result information. And if the data of the second data area is the same as the second data, the first data is not written into the second data area or the first data is subjected to data rollback processing after being written into the second data area, at the moment, the intelligent card end sends comparison result information to the terminal, and the terminal generates power failure success information according to the comparison result information. And if the power failure succeeds, continuing to perform the power failure test until the first execution time is finished. If the first data and the second data in the second data area are different, the smart card end sends comparison result information to the terminal, and the terminal generates outage failure information, so that outage test is ended. I.e., the power failure ends the power down test.
In some alternative embodiments, the smart card extracts data in a second target page number of the second data area and first data cached in the backup area according to the second comparison instruction, and compares the data in the second target page number of the second data area with the first data cached in the backup area to obtain a first result; then comparing the data in the page numbers except the second target page number in the second data area with the data except the second target page number in the second data to obtain a second result; and combining the first result and the second result to obtain second comparison result information, and sending the second comparison result information to the terminal so that the terminal generates power-off success information and re-executes the steps to perform power-off test, or generates power-off failure information and ends the power-off test. That is, when the data in the second target page number of the second data area is not changed or the data in the first target page number is not changed, and the data outside the second target page number in the second data area is not changed, the power-off is successful, otherwise, the power-off fails.
In some alternative embodiments, after comparing the data of the second data area with the first data and the second data according to the third comparison instruction to obtain third comparison result information, the method includes: if the data of the backup area is the same as the data of the second data area or the data of the second data area is the same as the second data area, a first time step is added to the first power-off time after power-on reset to obtain a new first power-off time, the first time step represents a power-off time interval when the first writing instruction is executed, and if the new first power-off time is smaller than the first execution time, power-off test processing is repeatedly executed; otherwise, ending the power-off test processing.
In some alternative embodiments, the first power-off time is automatically increased by a first time step after the power-on reset to obtain a new first power-off time, if the new first power-off time is smaller than the first execution time, continuing to power off the first write command, and after the first time step is finished, performing power off; and if the new first power-off time is greater than or equal to the first execution time, ending the power-off test.
In some alternative embodiments, after comparing the data of the second data area with the first data and the second data according to the second comparison instruction to obtain second comparison result information, the method includes: if the first data of the first data area is the same as the data of the second data area, or the data of the second data area is the same as the second data area, adding a first time step to the first power-off time after power-on reset to obtain a new first power-off time, wherein the first time step represents a power-off time interval when the first writing instruction is executed, and if the new first power-off time is smaller than the first execution time, repeating the power-off test processing; otherwise, ending the power-off test processing.
In some optional embodiments, before acquiring the first selection application instruction sent by the terminal, the method further includes: creating a first data area and a second data area, and initializing first data of the first data area to be random numbers; and initializing second data of the second data area to preset data. The preset data are regular data.
In some alternative embodiments, the smart card is connected to the JAVA application after power-up, and then performs a power-down test: before that, the smart card creates a first data area and a second data area of 256 x n bytes according to the page index number, i.e. the data number that can be indexed to the corresponding page number. Initializing the created first data area and second data area, namely giving an initial value, and internally storing 256 x N bytes of initial values, namely N pages of data lists, wherein the N pages of data lists form a data area, the data of each page of data list consists of 256 bytes, and the specific byte number can be selected according to requirements; the data exceeding 256 bytes (one page) can be read according to the input page index number, the data exceeding 256 bytes (one page) can be written according to the page index number, and the data comparison can be carried out according to the page index number; and updating the data of the first data area into the corresponding page number of the second data area with 256 x N bytes when the data is required to be updated.
Specifically, when data initialization is performed, two steps of initialization are performed, wherein in the first step, data of all page numbers in a first data area are initialized to be random numbers; and secondly, initializing the data of all page numbers of the second data area into custom data, wherein the custom data is preset data.
In some alternative embodiments, the data settings and data updates of the smart card application may be specifically as follows:
Specific data settings refer to charts 1 and 2:
Chart 1 data set of first data region
Page index number Data
1 … … 0000 (256 Bytes)
2 1111 … … 1111 (256 Bytes)
3 2222 … … 2222 (256 Bytes)
…… ……
N Nnn … … nnn (256 bytes)
It can be seen that the application initializes the page data in the different page index numbers to different data when the data setting is performed on the first data area.
Chart 2 data set of second data area
Page index number Data
1 ABCD … … ADA 1 (256 bytes random number)
2 BFCD … … CBDA (256 bytes random number)
3 2DD2 … … FD (256 bytes random number)
…… ……
N CDAA … … 589D (256 bytes random number)
It can be seen that the application initializes the page data in the different page index numbers to random data when performing the data setting on the second data area.
The updating of the data of the first data area to the second data area is specifically as follows:
Chart 3 second data area after successful update of data
Page index number Data
1 … … 0000 (256 Bytes)
2 1111 … … 1111 (256 Bytes)
3 2222 … … 2222 (256 Bytes)
…… ……
N Nnn … … nnn (256 bytes)
It can be seen that the second data area at this time has been successfully updated to the data of the first data area.
Chart 4 second data area after successful update of data
Page index number Data
1 ABCD … … ADA 1 (256 bytes random number)
2 BFCD … … CBDA (256 bytes random number)
3 2DD2 … … FD (256 bytes random number)
…… ……
N CDAA … … 589D (256 bytes random number)
It can be seen that, in the graph 4, the data in the first data area is not written into the second data area, and then the data may be before the data in the first data area is written into the second data area, or the data in the first data area is interrupted in the process of writing into the second data area, so that the data is not written.
Chart 5 second data area after data update failure
It can be seen that one page of data of the second data area in the chart 5 includes both the data of the first data area and the data of the second data area, which indicates that the update fails. When the power-off test is performed, the data of the first data area can be directly written into the second data area without being written into the backup area, or the data of the first data area can be written into the backup area first and then the data of the backup area can be written into the B area.
Chart 6 backup area after data writing
Page index number Data
1 ABCD … … DF12 (256 bytes)
2 … … 0000 (256 Bytes)
3 1111 … … 1111 (256 Bytes)
4 2222 … … 2222 (256 Bytes)
…… ……
N Nnn … … nnn (256 bytes)
It can be seen that the backup area in fig. 6 is written with data of the second data area, and the backup area may contain other data (not necessarily, data unrelated to the present scheme). The data of the first data area is continuously stored in the backup area.
Writing data of the backup area to the second data area:
chart 7 second data area after successful update of data
Page index number Data
1 … … 0000 (256 Bytes)
2 1111 … … 1111 (256 Bytes)
3 2222 … … 2222 (256 Bytes)
…… ……
N Nnn … … nnn (256 bytes)
It can be seen that the chart 7 is a case where the data of the backup area is successfully written into the second data area, and the second data area is the data of the first data area.
Chart 8 second data area after successful update of data
Page index number Data
1 ABCD … … ADA 1 (256 bytes random number)
2 BFCD … … CBDA (256 bytes random number)
3 2DD2 … … FD (256 bytes random number)
…… ……
N CDAA … … 589D (256 bytes random number)
The chart 8 is a case that the data of the backup area is not written into the second data area yet, and may be before the data of the backup area is written into the second data area at this time or the data of the backup area is interrupted in the process of writing into the second data area, so that the data is not written.
Chart 9 second data area after data update failure
Page index number Data
1 ABCD … … ADA 1 (256 bytes random number)
2 1111 … … 1111 (256 Bytes random number)
3 2DD2 … … 2222 (256 bytes random number)
…… ……
N Nnnn … … 589D (256 bytes random number)
It can be seen that the page data of the corresponding pages of the first data area and the second data area are simultaneously contained in the page data of the second data area in the chart 9, and this indicates that the update fails. At this time, it may be that the writing of the data in the first data area fails during the writing of the data in the backup area and/or the writing of the data in the second data area fails during the writing of the data in the backup area.
In some alternative implementations, as shown in fig. 2, fig. 2 is a flowchart of a first power-off test of the smart card power-off test method applied to the power-off test scenario of fig. 10, where the first power-off test includes, but is not limited to, steps S201 to S225.
Step S201, initializing the terminal, n1=0, flag=0;
Wherein n1 is the first power-off cycle number, and flag is a flag bit for indicating whether the second data area is subjected to data recovery, if not, flag is 0, and if yes, flag is 1.
Step S202, the terminal judges whether the flag is 0, if yes, step S203 is executed, and if not, a second power-off test is executed.
In step S203, the terminal executes n1=n1+1.
Step S204, the terminal determines whether T1 is less than Tmax1, where t1=t01+t1×n1, if yes, step S205 is executed, if no, ending;
step S205, the terminal sends a reset request to the smart card;
Step S206, the intelligent card performs power-on reset operation according to the reset request and sends a reset success response to the terminal;
Step S207, the terminal sends a first application selection instruction to the smart card;
step S208, the intelligent card selects the application according to the first selection application instruction and sends a selection success response to the terminal;
step S209, the terminal sends a first comparison instruction to the smart card;
Step S210, the smart card compares the data of the second data area with the first data and the second data respectively according to the first comparison instruction to generate first comparison result information, and sends the first comparison result information to the terminal;
Step S211, the terminal judges whether the first comparison result information is first data, if so, the step S212 is executed, and if not, the step S215 is executed;
step S212, the terminal sends a data restoration instruction to the smart card;
Step S213, the smart card restores the current data into second data of T1 time of n1-x1 times according to the data restoration instruction, and sends restoration response information to the terminal; wherein x1 is a preset cycle power-off number;
Step S214, the terminal sets flag to 1, n1=n1-x 1 according to the reduction response information;
Step S215, the terminal judges whether the first comparison result information is the second data, if so, step S216 is executed, and if not, step S225 is executed;
step S216, the terminal sets a first power-off time;
step S217, the terminal sends a first writing instruction to the smart card;
Step S218, the smart card writes first data of the first data area into the second data area according to the first writing instruction;
step S219, under the condition that the smart card completes the first writing instruction, a first writing response instruction is sent to the terminal;
step S220, the terminal judges whether a first writing response instruction sent by the smart card is received, if yes, step S221 is executed, and if not, step S202 is executed;
step S221, the terminal sends a second comparison instruction to the smart card;
step S222, the smart card compares the data of the second data area with the first data and the second data respectively according to the second comparison instruction, generates second comparison result information, and sends the second comparison result information to the terminal;
Step S223, the terminal judges whether the first data or the second data according to the second comparison result information, if yes, the step S224 is executed, and if not, the step S225 is executed;
Step S224, the first power-off test result is that the power-off is successful;
in step S225, the first power-off test result is a power-off failure.
The technical problems that can be solved by each step or the combination of a plurality of steps in steps S201 to S225 in the present embodiment can be solved, and the obtained technical effects are referred to the above embodiments, and are not described in detail herein.
In some alternative implementations, as shown in fig. 3, fig. 3 is a flowchart of a first power-off test of a smart card power-off test method applied to the power-off test scenario of fig. 11 according to another embodiment of the present invention, where the first power-off test includes, but is not limited to, steps S301 to S326.
Step S301, initializing a terminal, wherein n1=0 and flag=0;
Wherein n1 is the first power-off cycle number, and flag is a flag bit for indicating whether the second data area is subjected to data recovery, if not, flag is 0, and if yes, flag is 1.
In step S302, the terminal determines whether the flag is 0, if yes, step S303 is executed, and if not, step S of the second power-off test is executed.
In step S303, the terminal executes n1=n1+1.
Step S304, the terminal determines whether T1 is less than Tmax1, where t1=t01+t1×n1, if yes, step S305 is executed, if no, ending;
step S305, the terminal sends a reset request to the smart card;
step S306, the intelligent card performs power-on reset operation according to the reset request and sends a reset success response to the terminal;
step S307, the terminal sends a first application selection instruction to the smart card;
step S308, the intelligent card selects application according to the first selection application instruction and sends a selection success response to the terminal;
Step S309, the terminal sends a first comparison instruction to the smart card;
Step S310, the smart card compares the data of the second data area with the first data and the second data respectively according to the first comparison instruction to generate first comparison result information, and sends the first comparison result information to the terminal;
step S311, the terminal judges whether the first comparison result information is the first data, if so, the step S312 is executed, and if not, the step S316 is executed;
step S312, the terminal judges whether the flag is 1, if yes, step S325 is executed, and if not, step S313 is executed;
step S313, the terminal sends a data restoring instruction to the intelligent card;
Step S314, the smart card restores the current data into second data of T1 time of n1-x1 times according to the data restoration instruction, and sends restoration response information to the terminal; wherein x1 is a preset cycle power-off number;
Step S315, the terminal sets flag to 1, n1=n1-x 1 according to the reduction response information;
Step S316, the terminal judges whether the first comparison result information is the second data, if yes, the step S317 is executed, if not, the step S326 is executed;
step S317, the terminal sets a first power-off time;
Step S318, the terminal sends a first writing instruction to the smart card;
Step S319, the smart card writes first data of the first data area into the second data area according to the first writing instruction;
step S320, under the condition that the smart card completes the first writing instruction, a first writing response instruction is sent to the terminal;
Step S321, the terminal judges whether a first writing response instruction sent by the smart card is received, if yes, step S322 is executed, and if not, step S302 is executed;
step S322, the terminal sends a second comparison instruction to the smart card;
Step S323, the smart card compares the data of the second data area with the first data and the second data respectively according to the second comparison instruction to generate second comparison result information, and sends the second comparison result information to the terminal;
step S324, the terminal judges whether the first data or the second data according to the second comparison result information, if yes, the step S325 is executed, and if not, the step S326 is executed;
Step S325, the first power-off test result is that the power-off is successful;
in step S326, the first power-off test result is a power-off failure.
The technical problems that can be solved by each step or the combination of a plurality of steps in steps S301 to S326 in the present embodiment can be solved, and the obtained technical effects are referred to the above embodiments, and are not described in detail herein.
In some alternative implementations, as shown in fig. 4, another embodiment of the present invention provides a flowchart of data restoration, where the data restoration includes, but is not limited to, steps S401 to S405.
Step S401, a terminal sends a data reduction instruction;
step S402, the smart card restores the current data into initial data of T1 time of N-X times according to the data restoration instruction;
step S403, the smart card returns a response value;
Step S404, the terminal judges whether the data restoring instruction is completed, if yes, step S405 is executed, and if not, step S401 is executed.
The technical problems that can be solved by each step or the combination of a plurality of steps in steps S401 to S405 in this embodiment can be solved, and the obtained technical effects are referred to the above embodiments, and are not described in detail herein.
In some alternative implementations, as shown in fig. 5, another embodiment of the present invention provides a flowchart of a second power-off test of the smart card power-off test method applied to the power-off test scenario of fig. 10, where the second power-off test may be combined with the first power-off test, and the second power-off test includes, but is not limited to, steps S501 to S515.
Step S501, the terminal executes n2=n2+1, and n2=0 in the initial state;
Step S502, the terminal determines whether T2 is less than Tmax2, where t2=t02+t2×n2, if yes, step S503 is executed, and if no, step S514 is executed;
step S503, the terminal sends a reset request to the smart card;
step S504, the intelligent card performs power-on reset operation according to the reset request and sends a reset success response to the terminal;
step S505, the terminal sets a second power-off time;
step S506, the terminal sends a second application selection instruction to the smart card;
Step S507, the smart card selects application according to the second selection application instruction, and writes the data of the backup area into the second data area;
Step S508, under the condition that the smart card completes the second selection application instruction, a second writing response instruction is sent to the terminal;
step S509, the terminal judges whether a second writing response instruction sent by the smart card is received, if yes, step S511 is executed, and if not, step S501 is executed;
step S511, the terminal sends a third comparison instruction to the smart card;
step S512, the smart card compares the data of the second data area with the first data and the second data respectively according to the third comparison instruction to generate third comparison result information, and sends the third comparison result information to the terminal;
Step S513, the terminal judges whether the first data or the second data according to the third comparison result information, if yes, step S514 is executed, and if not, step S515 is executed;
step S514, the second power-off test result is that the power-off is successful;
in step S515, the second power-off test result is a power-off failure.
The technical problems that can be solved by each step or the combination of a plurality of steps in steps S501 to S515 in this embodiment can be solved, and the obtained technical effects are referred to the above embodiments, and are not described in detail herein.
In some alternative implementations, as shown in fig. 6, fig. 6 is a flowchart of a first power-off test of a smart card power-off test method applied to the power-off test scenario of fig. 11, where the first power-off test includes, but is not limited to, steps S601 to S625.
Step S601, terminal initialization, n1=0, flag=0;
Wherein n1 is the first power-off cycle number, and flag is a flag bit for indicating whether the second data area is subjected to data recovery, if not, flag is 0, and if yes, flag is 1.
In step S602, the terminal determines whether the flag is 0, if yes, step S603 is executed, and if not, step S of the second power-off test is executed.
In step S603, the terminal executes n1=n1+1.
Step S604, the terminal determines whether T1 is less than Tmax1, where t1=t01+t1×n1, if yes, step S605 is executed, if no, ending;
Step S605, the terminal sends a reset request to the smart card;
step S606, the smart card performs power-on reset operation according to the reset request and sends a reset success response to the terminal;
step S607, the terminal sends a first selection application instruction to the smart card;
step S608, the intelligent card selects the application according to the first selection application instruction and sends a selection success response to the terminal;
step S609, the terminal sends a first comparison instruction to the smart card;
Step S610, the smart card compares the data of the second data area with the first data and the second data respectively according to the first comparison instruction, generates first comparison result information, and sends the first comparison result information to the terminal;
Step S611, the terminal judges whether the first comparison result information is the first data, if so, step S612 is executed, and if not, step S615 is executed;
step S612, the terminal sends a data restoration instruction to the smart card;
Step S613, the smart card restores the current data into second data of T1 time of n1-x1 times according to the data restoration instruction, and sends restoration response information to the terminal; wherein x1 is a preset cycle power-off number;
Step S614, the terminal sets flag to 1, n1=n1-x 1 according to the reduction response information;
step S615, the terminal judges whether the first comparison result information is the second data, if so, step S616 is executed, and if not, step S625 is executed;
Step S616, the terminal sets a first power-off time;
Step S617, the terminal sends a first writing instruction to the smart card;
Step S618, the smart card writes the first data of the first data area into the second data area according to the first writing instruction;
step S619, under the condition that the smart card completes the first writing instruction, a first writing response instruction is sent to the terminal;
Step S620, the terminal judges whether a first writing response instruction sent by the smart card is received, if yes, step S621 is executed, and if not, step S602 is executed;
step S621, the terminal sends a second comparison instruction to the smart card;
Step S622, the smart card compares the data of the second data area with the first data and the second data respectively according to the second comparison instruction, generates second comparison result information, and sends the second comparison result information to the terminal;
step S623, the terminal judges whether the first data or the second data according to the second comparison result information, if yes, the step S624 is executed, and if not, the step S625 is executed;
step S624, the first power-off test result is that the power-off is successful;
in step S625, the first power-off test result is a power-off failure.
The technical problems that can be solved in each step or the combination of a plurality of steps in steps S601 to S625 in the present embodiment can be solved, and the obtained technical effects are referred to the above embodiments, and are not described in detail herein.
In some alternative implementations, as shown in fig. 7, fig. 7 is a flowchart of a first power-off test of a smart card power-off test method applied to the power-off test scenario of fig. 11 according to another embodiment of the present invention, where the first power-off test includes, but is not limited to, steps S701 to S726.
Step S701, initializing the terminal, n1=0, flag=0;
Wherein n1 is the first power-off cycle number, and flag is a flag bit for indicating whether the second data area is subjected to data recovery, if not, flag is 0, and if yes, flag is 1.
In step S702, the terminal determines whether the flag is 0, if yes, step S703 is executed, and if not, step S of the second power-off test is executed.
In step S703, the terminal executes n1=n1+1.
Step S704, the terminal determines whether T1 is less than Tmax1, where t1=t01+t1×n1, if yes, step S705 is executed, if no, ending;
step S705, the terminal sends a reset request to the smart card;
step S706, the smart card performs power-on reset operation according to the reset request and sends a reset success response to the terminal;
Step S707, the terminal sends a first application selection instruction to the smart card;
Step S708, the smart card selects the application according to the first selection application instruction and sends a selection success response to the terminal;
step S709, the terminal sends a first comparison instruction to the smart card;
Step S710, the smart card compares the data of the second data area with the first data and the second data respectively according to the first comparison instruction, generates first comparison result information, and sends the first comparison result information to the terminal;
Step S711, the terminal determines whether the first comparison result information is the first data, if so, step S712 is executed, and if not, step S716 is executed;
Step S712, the terminal determines whether flag is 1, if yes, step S725 is executed, and if no, step S713 is executed;
step S713, the terminal sends a data restoration instruction to the smart card;
step S714, the smart card restores the current data into second data of the time T1 of n1-x1 times according to the data restoration instruction, and sends restoration response information to the terminal; wherein x1 is a preset cycle power-off number;
step S715, the terminal sets flag to 1, n1=n1-x 1 according to the reduction response information;
Step S716, the terminal judges whether the first comparison result information is the second data, if so, step S717 is executed, and if not, step S726 is executed;
Step S717, the terminal sets a first power-off time;
step S718, the terminal sends a first writing instruction to the smart card;
step S719, the smart card writes the first data of the first data area into the second data area according to the first writing instruction;
step S720, under the condition that the smart card completes the first writing instruction, a first writing response instruction is sent to the terminal;
step S721, the terminal judges whether a first writing response instruction sent by the smart card is received, if yes, step S722 is executed, and if not, step S702 is executed;
Step S722, the terminal sends a second comparison instruction to the smart card;
step 723, the smart card compares the data of the second data area with the first data and the second data respectively according to the second comparison instruction to generate second comparison result information, and sends the second comparison result information to the terminal;
Step S724, the terminal judges whether the first data or the second data according to the second comparison result information, if yes, step S725 is executed, and if not, step S726 is executed;
step S725, the first power-off test result is that the power-off is successful;
in step S726, the first power-off test result is a power-off failure.
The technical problems that can be solved by each step or the combination of a plurality of steps in steps S701 to S726 in the present embodiment can be obtained by referring to the above embodiments, and detailed descriptions thereof are omitted herein.
The embodiment of the invention has the following beneficial effects: the embodiment of the invention provides a smart card power-off test method, which comprises the following steps: acquiring a first selection application instruction sent by a terminal; selecting an application according to the first application selection instruction; acquiring a first writing instruction sent by a terminal; writing first data of the first data area into the second data area according to the first writing instruction, and powering off at a first power-off time; if the first writing instruction is executed, a first writing response instruction is sent to the terminal, a second comparison instruction sent by the terminal is received, and the first writing instruction and the second comparison instruction are executed in the application; respectively comparing the data of the second data area with the first data and the second data according to the second comparison instruction to obtain second comparison result information; sending power failure information or power failure success information to the terminal according to the second comparison result information; after power-on reset, acquiring a second selection application instruction sent by the terminal; selecting an application according to the second selection application instruction, writing the first data into a second data area, and powering off at a second power-off time; if the second selection application instruction is executed, a second writing response instruction is sent to the terminal, and a third comparison instruction sent by the terminal is received; respectively comparing the data of the second data area with the first data and the second data according to a third comparison instruction to obtain third comparison result information; and re-executing the steps or sending power failure information to the terminal according to the third comparison result information. The smart card is subjected to power-off test by selecting the application, so that data interaction of the terminal is reduced, the test speed is high, the test period is short, and the test precision is improved by multiple power-off tests.
In a second aspect, referring to fig. 8, an embodiment of the present invention provides another smart card power-off test method applied to a terminal, where the smart card is provided with an application, and the smart card includes a first data area, a backup area, and a second data area, where the first data area stores first data, the second data area stores second data, the backup area caches second data, and the smart card is communicatively connected to the terminal, and the method includes:
Step S800, acquiring reset success information sent by the smart card;
Step 810, a first application selection instruction is sent to the smart card, so that the smart card selects an application according to the first application selection instruction;
step S820, receiving a selection success response sent by the smart card;
Step S830, sending power-off test information to the smart card according to the selection success response, so that after the smart card receives the power-off test information, performing power-off test processing by applying the response power-off test information to obtain test feedback information, wherein the power-off test processing represents power-off test processing performed in the process of transmitting data of a first data area to a second data area through a backup area to replace the second data;
step S840, receiving test feedback information sent by the smart card;
and step S850, determining a power-off test result according to the test feedback information.
In some alternative embodiments, the power-off test information is sent to the smart card according to the selection success response, so that after the smart card receives the power-off test information, the power-off test processing is performed by applying the response power-off test information, and test feedback information is obtained, including: setting a first power-off time after receiving a successful selection response, wherein the first power-off time represents that the smart card is powered off when the first power-off time is reached; transmitting a first writing instruction to the smart card so that the smart card writes first data of the first data area into the backup area according to the first writing instruction, and writes the first data in the backup area into the second data area, wherein the data of the second data area before writing is the second data; receiving a first writing response instruction sent by the smart card, wherein the first writing response instruction characterizes that the execution of the first writing instruction is completed; sending a second comparison instruction to the smart card; and the smart card receives the second comparison instruction, and respectively compares the data of the second data area with the first data and the second data according to the second comparison instruction to obtain second comparison result information.
In some alternative embodiments, before setting the first power-off time after receiving the selection success response, the method includes: the first comparison instruction is sent to the intelligent card, so that the intelligent card can respectively compare the data of the second data area with the first data and the second data according to the first comparison instruction to obtain first comparison result information; receiving first comparison result information; and setting a first power-off time according to the first comparison result information to power off or generate power-off failure information.
In some alternative embodiments, the first power down time is determined from a first number of power down cycles, the method further comprising: under the condition that the first comparison result information is first data, a data restoration instruction is sent to the intelligent card, so that the intelligent card restores the data of the second data area into second data according to the data restoration instruction, and restoration response information is sent to the terminal; receiving restoration response information sent by the smart card; setting a first power-off time according to the restoration response information, and sending a first writing instruction to the smart card; and under the condition that the first power-off time is reached and the first writing response information fed back by the smart card is not received, adding one to the first power-off cycle times.
In some alternative embodiments, after sending the first write instruction to the smart card, the method further includes: under the condition that the first power-off time is reached and the smart card does not complete the first writing instruction, the terminal sets a second power-off time; after power-on reset, a second selection application instruction is sent to the intelligent card, so that the intelligent card selects application according to the second selection application instruction, and first data of the backup area are written into a second data area, wherein the first data area firstly writes the first data into the backup area, and then the first data is written into the second data area from the backup area; receiving a second writing response instruction sent by the intelligent card, wherein the second writing response instruction represents that the intelligent card finishes executing a second selection application instruction; and the third comparison instruction is sent to the intelligent card, so that the intelligent card respectively compares the data of the second data area with the first data and the second data according to the third comparison instruction to obtain third comparison result information.
It can be seen that the content in the above method embodiment is applicable to the method embodiment, and the functions specifically implemented by the method embodiment are the same as those of the method embodiment, and the beneficial effects achieved by the method embodiment are the same as those achieved by the method embodiment.
In a third aspect, referring to fig. 9, an embodiment of the present invention provides a further smart card power-off test method applied to a terminal, where the smart card is provided with an application, and the smart card includes a first data area and a second data area, where the first data area stores first data, and the second data area stores second data, and the smart card is communicatively connected to the terminal, and the method includes:
Step S900, acquiring reset success information sent by the smart card;
Step S910, a first application selection instruction is sent to the smart card, so that the smart card selects an application according to the first application selection instruction;
Step S920, receiving a selection success response sent by the smart card;
step S930, sending power-off test information to the smart card according to the selection success response, so that after the smart card receives the power-off test information, performing power-off test processing by applying the response power-off test information to obtain test feedback information, wherein the power-off test processing represents power-off test processing performed in the process of transmitting the data of the first data area to the second data area to replace the second data;
step S940, receiving test feedback information sent by the smart card;
step S950, determining the power-off test result according to the test feedback information.
In some alternative embodiments, the power-off test information is sent to the smart card according to the selection success response, so that after the smart card receives the power-off test information, the power-off test processing is performed by applying the response power-off test information, and test feedback information is obtained, including: setting a first power-off time after receiving a successful selection response, wherein the first power-off time represents that the smart card is powered off when the first power-off time is reached; transmitting a first writing instruction to the smart card so that the smart card writes first data of the first data area into the second data area according to the first writing instruction, wherein the data of the second data area before writing is second data; receiving a first writing response instruction sent by the smart card, wherein the first writing response instruction characterizes that the execution of the first writing instruction is completed; sending a second comparison instruction to the smart card; and the smart card receives the second comparison instruction, and respectively compares the data of the second data area with the first data and the second data according to the second comparison instruction to obtain second comparison result information.
In some alternative embodiments, before setting the first power-off time after receiving the selection success response, the method includes: the first comparison instruction is sent to the intelligent card, so that the intelligent card can respectively compare the data of the second data area with the first data and the second data according to the first comparison instruction to obtain first comparison result information; receiving first comparison result information; and setting a first power-off time according to the first comparison result information to power off or generate power-off failure information.
In some alternative embodiments, the first power down time is determined from a first number of power down cycles, the method further comprising: under the condition that the first comparison result information is first data, a data restoration instruction is sent to the intelligent card, so that the intelligent card restores the data of the second data area into second data according to the data restoration instruction, and restoration response information is sent to the terminal; receiving restoration response information sent by the smart card; setting a first power-off time according to the restoration response information, and sending a first writing instruction to the smart card; and under the condition that the first power-off time is reached and the first writing response information fed back by the smart card is not received, adding one to the first power-off cycle times.
In some alternative embodiments, after sending the first write instruction to the smart card, the method further includes: under the condition that the first power-off time is reached and the smart card does not complete the first writing instruction, the terminal sets a second power-off time; after power-on reset, a second selection application instruction is sent to the intelligent card, so that the intelligent card selects application according to the second selection application instruction, and first data of the first data area are written into the second data area; receiving a second writing response instruction sent by the intelligent card, wherein the second writing response instruction represents that the intelligent card finishes executing a second selection application instruction; and the third comparison instruction is sent to the intelligent card, so that the intelligent card respectively compares the data of the second data area with the first data and the second data according to the third comparison instruction to obtain third comparison result information.
It can be seen that the content in the above method embodiment is applicable to the method embodiment, and the functions specifically implemented by the method embodiment are the same as those of the method embodiment, and the beneficial effects achieved by the method embodiment are the same as those achieved by the method embodiment.
It should be noted that fig. 10 is a schematic diagram of an application scenario of the smart card power-off test method according to an embodiment of the present invention. The application scene is a smart card authentication identification scene, and comprises a terminal and a smart card. The terminal is provided with a unit for information interaction with the smart card, and the terminal and the smart card may be physically connected (a unit provided with a card slot and for reading and writing information of the smart card), or may be wireless connection, which is not particularly limited in this embodiment. The intelligent card is divided into a first data area, a backup area and a second data area, wherein the first data area stores first data, the second data area stores second data, the information transmission direction of the intelligent card is that the data in the first data area is written into the backup area, and after the data is pasted in the backup area, the backup area can write the data into the second data area.
It should be noted that fig. 11 is a schematic diagram of an application scenario of a smart card power-off test method according to another embodiment of the present invention. The application scene is a smart card authentication identification scene, and comprises a terminal and a smart card. The terminal is provided with a unit for information interaction with the smart card, and the terminal and the smart card may be physically connected (a unit provided with a card slot and for reading and writing information of the smart card), or may be wireless connection, which is not particularly limited in this embodiment. The intelligent card is divided into a first data area, a backup area and a second data area, wherein the first data area stores first data, the second data area stores second data, the information transmission direction of the intelligent card is that the data in the first data area is written into the second data area, the backup area can store the first data and the second data, and the first data and the second data stored in the backup area are data which are called in the process of comparing the data in the second data area.
In a fourth aspect, as shown in fig. 12, an embodiment of the present invention provides a smart card power-off testing device, which is applied to a smart card, and the device includes: at least one processor; at least one memory for storing at least one program; the at least one program, when executed by the at least one processor, causes the at least one processor to implement the method as described above.
It can be seen that the content in the above method embodiment is applicable to the embodiment of the present device, and the functions specifically implemented by the embodiment of the present device are the same as those of the embodiment of the above method, and the beneficial effects achieved by the embodiment of the above method are the same as those achieved by the embodiment of the above method.
In a fifth aspect, as shown in fig. 12, an embodiment of the present invention further provides a smart card power-off testing device, which is applied to a terminal, where the device includes: at least one processor; at least one memory for storing at least one program; the at least one program, when executed by the at least one processor, causes the at least one processor to implement the method steps of the method embodiments described above or the system described above.
It can be seen that the content in the above method embodiment is applicable to the embodiment of the present device, and the functions specifically implemented by the embodiment of the present device are the same as those of the embodiment of the above method, and the beneficial effects achieved by the embodiment of the above method are the same as those achieved by the embodiment of the above method.
In a sixth aspect, furthermore, the embodiments of the present application disclose a computer program product or a computer program, which is stored in a computer readable storage medium. The computer program may be read from a computer readable storage medium by a processor of a computer device, the processor executing the computer program to cause the computer device to perform the method or the system described above. Similarly, the content in the above method embodiment is applicable to the present storage medium embodiment, and the specific functions of the present storage medium embodiment are the same as those of the above method embodiment, and the achieved beneficial effects are the same as those of the above method embodiment.
It is to be understood that all or some of the steps, systems, and methods disclosed above may be implemented in software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, a digital information processor, or a microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes both volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as known to those skilled in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can be accessed by a computer. Furthermore, as is well known to those of ordinary skill in the art, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data message such as a carrier wave or other transport mechanism and includes any information delivery media.
The embodiments of the present invention have been described in detail with reference to the accompanying drawings, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge of one of ordinary skill in the art without departing from the spirit of the present invention.

Claims (16)

1. The utility model provides a smart card outage test method, characterized by being applied to the smart card, the smart card is provided with the application, the application includes first data area and second data area, first data area stores first data, second data area stores second data, the smart card is connected with terminal communication, the method includes:
receiving a first application selection instruction sent by the terminal;
Selecting the application according to the first application selection instruction;
receiving power-off test information sent by the terminal;
Responding to the power-off test information by the application to perform power-off test processing, so as to obtain test feedback information, wherein the power-off test processing represents the power-off test processing performed in the process of transmitting the data of the first data area to the second data area to replace the second data;
And sending the test feedback information to the terminal so that the terminal determines a power-off test result according to the test feedback information.
2. The smart card power down test method of claim 1, wherein the application includes a first data area, a backup area, and a second data area, the first data area storing first data, the second data area storing second data, the backup area buffering the second data, the smart card being communicatively coupled to a terminal, the method further comprising:
And the power-off test processing is performed in the process that the data of the first data area is transmitted to the second data area through the backup area to replace the second data.
3. The smart card power-off test method according to claim 2, wherein, in the case that the power-off time set by the terminal is the first power-off time, receiving the power-off test information sent by the terminal, and receiving the power-off test information sent by the terminal, responding to the power-off test information by the application to perform power-off test processing, obtaining test feedback information includes:
Acquiring a first writing instruction sent by the terminal;
writing first data of the first data area into the second data area through the backup area according to the first writing instruction, wherein the data of the second data area before writing is second data;
if the first writing instruction is executed, a first writing response instruction is sent to the terminal;
Receiving a second comparison instruction sent by the terminal, wherein the first writing instruction and the second comparison instruction are executed in the application, respectively comparing the data of the second data area with the first data and the second data according to the second comparison instruction to obtain second comparison result information, or receiving a second reading instruction sent by the terminal, wherein the first writing instruction and the second reading instruction are executed in the application, reading the data of the second data area according to the second reading instruction, and generating second reading instruction response information according to the data of the second data area.
4. The smart card power-off test method according to claim 1, wherein, in the case that the power-off time set by the terminal is the first power-off time, receiving the power-off test information sent by the terminal, and receiving the power-off test information sent by the terminal, responding to the power-off test information by the application to perform power-off test processing, obtaining test feedback information includes:
Acquiring a first writing instruction sent by the terminal;
Writing first data of the first data area into the second data area according to the first writing instruction, wherein the data of the second data area before writing is second data;
if the first writing instruction is executed, a first writing response instruction is sent to the terminal;
Receiving a second comparison instruction sent by the terminal, wherein the first writing instruction and the second comparison instruction are executed in the application;
And comparing the data of the second data area with the first data and the second data respectively according to the second comparison instruction to obtain second comparison result information, or receiving a second reading instruction sent by the terminal, wherein the first writing instruction and the second reading instruction are executed in the application, the data of the second data area is read according to the second reading instruction, and second reading instruction response information is generated according to the data of the second data area.
5. The smart card power-off test method according to claim 3 or 4, wherein the first power-off time is determined according to a first power-off cycle number, the first power-off cycle number is obtained by adding the first power-off cycle number by the terminal when the first power-off time is reached and the smart card does not complete the first write command, and the first power-off time is equal to a product of a first initial time plus the first power-off cycle number and a first time step.
6. The smart card power-down test method according to claim 3 or 4, wherein before the first write command sent by the terminal is obtained, the method comprises:
A first comparison instruction sent by the terminal is obtained,
Comparing the data of the second data area with the first data and the second data respectively according to the first comparison instruction to obtain first comparison result information,
The first comparison result information is sent to the terminal, so that the terminal sets the first power-off time to power off or generates power-off failure information; or alternatively
Acquiring a first reading instruction sent by the terminal;
reading data of the second data area according to the first reading instruction;
And generating first read instruction response information according to the data of the second data area and sending the first read instruction response information to the terminal so that the terminal can set the first power-off time to power off or generate power-off failure information according to the first read instruction response information.
7. The smart card power-down test method according to claim 6, wherein before the first write command sent by the terminal is obtained, the method comprises:
acquiring a reset request sent by the terminal;
resetting according to the resetting request, and sending a resetting success response to the terminal after resetting is completed;
Acquiring the first selection application instruction sent by the terminal;
And selecting an application according to the first application selection instruction, and sending a selection success response to the terminal after the selection is completed.
8. A smart card power down test method as recited in claim 3, further comprising:
If the first comparison result information is that the data of the second data area is the same as the first data;
acquiring a data reduction instruction sent by the terminal;
And restoring the data of the second data area into the second data according to the data restoring instruction.
9. The smart card power-down test method according to claim 8, wherein after the data of the second data area is restored to the second data according to the data restoration instruction, the method comprises:
Sending a restore response message to the terminal so that the terminal sets a first power-off time;
Acquiring the first writing instruction;
Under the condition that the first power-off time is reached and the smart card does not complete the first writing instruction, the terminal sets a second power-off time;
after power-on reset, acquiring a second selection application instruction sent by the terminal;
Selecting an application according to the second selection application instruction, and writing the first data of the backup area into the second data area, wherein the first data area firstly writes the first data into the backup area, and then writes the first data into the second data area from the backup area;
if the second application selection instruction is executed, a second writing response instruction is sent to the terminal;
And receiving a third comparison instruction sent by the terminal, respectively comparing the data of the second data area with the first data and the second data according to the third comparison instruction to obtain third comparison result information, or receiving a third reading instruction sent by the terminal, reading the data of the second data area according to the third reading instruction, and generating third reading instruction response information according to the data of the second data area.
10. A smart card power down test method as defined in claim 3, wherein the writing the first data of the first data area to the second data area according to the first write instruction comprises:
determining a first target page number of the first data area and a second target page number of the second data area according to the first writing instruction;
writing first data of the first target page number into a third target page number of the backup area;
and writing the first data in the third target page number into the second target page number, wherein the first target page number is identical to and corresponds to the second target page number.
11. The smart card power down test method of claim 4, wherein the writing the first data of the first data area to the second data area according to the first write command comprises:
determining a first target page number of the first data area and a second target page number of the second data area according to the first writing instruction;
And writing the first data of the first target page number into the second target page number, wherein the first target page number is the same as and corresponds to the second target page number, and the smart card is also used for caching the second data of the second target page number.
12. The utility model provides a smart card outage test method which is characterized in that is applied to the terminal, the smart card is provided with the application, the smart card includes first data area, backup area and second data area, first data area stores first data, second data area stores second data, backup area caches second data, smart card and terminal communication connection, the method includes:
acquiring reset success information sent by the smart card;
Sending a first application selection instruction to the smart card so that the smart card selects the application according to the first application selection instruction;
Receiving a selection success response sent by the intelligent card;
Transmitting power-off test information to the smart card according to the selection success response, so that after the smart card receives the power-off test information, the power-off test information is responded by the application to perform power-off test processing, test feedback information is obtained, and the power-off test processing represents power-off test processing performed in the process of transmitting data of the first data area to the second data area through the backup area to replace the second data;
Receiving the test feedback information sent by the smart card;
And determining a power-off test result according to the test feedback information.
13. The utility model provides a smart card outage test method, characterized by being applied to the terminal, the smart card is provided with the application, the smart card includes first data area and second data area, first data area stores first data, second data area stores second data, the smart card is connected with the terminal communication, the method includes:
acquiring reset success information sent by the smart card;
Sending a first application selection instruction to the smart card so that the smart card selects the application according to the first application selection instruction;
Receiving a selection success response sent by the intelligent card;
transmitting power-off test information to the smart card according to the selection success response, so that after the smart card receives the power-off test information, responding the power-off test information by the application to perform power-off test processing to obtain test feedback information, wherein the power-off test processing represents power-off test processing performed in the process of transmitting the first data of the first data area to the second data area to replace the second data;
Receiving the test feedback information sent by the smart card;
And determining a power-off test result according to the test feedback information.
14. A smart card power down test apparatus, for use with a smart card, the apparatus comprising:
At least one processor;
At least one memory for storing at least one program;
The at least one program, when executed by the at least one processor, causes the at least one processor to implement the smart card power down test method of any one of claims 1-11.
15. A smart card power down test apparatus, for use with a terminal, the apparatus comprising:
At least one processor;
At least one memory for storing at least one program;
The at least one program, when executed by the at least one processor, causes the at least one processor to implement the smart card power down test method of claim 12 or the smart card power down test method of claim 13.
16. A computer readable storage medium, in which a processor executable program is stored, characterized in that the processor executable program is for performing the smart card power down test method according to any one of claims 1-11 and/or for performing the smart card power down test method according to claim 12 and/or for performing the smart card power down test method according to claim 13 when executed by a processor.
CN202410331487.5A 2024-03-21 2024-03-21 Smart card power-off test method and device and storage medium Pending CN117995261A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410331487.5A CN117995261A (en) 2024-03-21 2024-03-21 Smart card power-off test method and device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410331487.5A CN117995261A (en) 2024-03-21 2024-03-21 Smart card power-off test method and device and storage medium

Publications (1)

Publication Number Publication Date
CN117995261A true CN117995261A (en) 2024-05-07

Family

ID=90889052

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410331487.5A Pending CN117995261A (en) 2024-03-21 2024-03-21 Smart card power-off test method and device and storage medium

Country Status (1)

Country Link
CN (1) CN117995261A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102486719A (en) * 2010-12-06 2012-06-06 普天信息技术研究院有限公司 Intelligent memory card and transaction-writing method thereof
CN108364670A (en) * 2018-02-06 2018-08-03 珠海全志科技股份有限公司 Read and write method for testing pressure, device, equipment and storage medium
CN111007336A (en) * 2019-11-29 2020-04-14 四川爱联科技有限公司 Module production test power-on and power-off automatic detection system and method based on serial port communication
CN113849388A (en) * 2021-09-30 2021-12-28 北京金山云网络技术有限公司 Test method and device, electronic equipment and storage medium
WO2022142544A1 (en) * 2020-12-29 2022-07-07 深圳大普微电子科技有限公司 Method for preventing data loss from flash memory, solid state drive controller, solid state drive
CN114780041A (en) * 2022-05-06 2022-07-22 佛山市顺德区卓晶电子科技有限公司 Power failure memory storage method and device

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102486719A (en) * 2010-12-06 2012-06-06 普天信息技术研究院有限公司 Intelligent memory card and transaction-writing method thereof
CN108364670A (en) * 2018-02-06 2018-08-03 珠海全志科技股份有限公司 Read and write method for testing pressure, device, equipment and storage medium
CN111007336A (en) * 2019-11-29 2020-04-14 四川爱联科技有限公司 Module production test power-on and power-off automatic detection system and method based on serial port communication
WO2022142544A1 (en) * 2020-12-29 2022-07-07 深圳大普微电子科技有限公司 Method for preventing data loss from flash memory, solid state drive controller, solid state drive
CN113849388A (en) * 2021-09-30 2021-12-28 北京金山云网络技术有限公司 Test method and device, electronic equipment and storage medium
CN114780041A (en) * 2022-05-06 2022-07-22 佛山市顺德区卓晶电子科技有限公司 Power failure memory storage method and device

Similar Documents

Publication Publication Date Title
US7873778B2 (en) Apparatus for storing page data
US8286874B2 (en) Card and host device
CN109582507B (en) Data backup and recovery method for NVDIMM, NVDIMM controller and NVDIMM
CN109685190B (en) Power-down protection method and device for IC card
CN117931091B (en) Abnormal power failure processing method, device, equipment, medium and product
WO1998037510A1 (en) Ic card
CN114866404A (en) Intelligent gateway disaster recovery method and device, electronic equipment and storage medium
CN117995261A (en) Smart card power-off test method and device and storage medium
CN106779635B (en) Smart card and method for sharing balance of multiple accounts in smart card
CN109918228B (en) Data power failure maintaining method and system
CN111400248B (en) Method for writing data and recovering data and file system
CN111090539A (en) Dual-flash-memory self-repairing method and device based on CPLD
CN115562593A (en) Abnormal RAID member disk processing method, device and medium
CN110597467A (en) High-availability data zero-loss storage system and method
CN116755925A (en) Memory system and method of operating the same
KR20200022136A (en) Error correction device and electronic device including the same
CN114461441A (en) Power-down retention data loading method and related equipment
CN103220569A (en) Automatic recovery method and device of set top box
CN209746537U (en) NVDIMM-N compatible with NVDIMM-P function
CN111625194A (en) Data reading method of storage medium, storage system and storage device
JP4239754B2 (en) Nonvolatile memory system
CN114625576B (en) Power failure prevention data processing method and device
CN113625855B (en) Power supply control method, system, medium and equipment of server system
CN115858251B (en) Control method and device of substrate control unit, electronic equipment and storage medium
CN115373600A (en) Method, device and equipment for storing configuration data of RAID (redundant array of independent disk) card and readable medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination