File data importing method and device, electronic equipment and medium
By adding anti-playback count field to the APDU instruction data and comparing it with the local count value, the problem of repeated import of file data is solved, and the effect of importing file data is achieved only once.
Patent Information
- Application Number
- CN202410984465.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2025-02-14
AI Technical Summary
In the prior art, when importing file data through APDU instructions, the user misoperated or network reasons lead to repeated import of file data, resulting in repeated import of data.
The anti-playback count field is added to the APDU instruction data generated by the imported file data, and the local anti-playback count field is stored when initialized in the SE device application. File data import is allowed to be performed only when the count value in the anti-playback count field corresponding to the APDU instruction is 1 larger than the count value in the local anti-playback count field.
Make sure that the file data is imported successfully only once, and avoid the occurrence of repeated import of file data in abnormal scenarios.
Smart Images

Figure CN119441140A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data import, and in particular to a method, device, electronic device and medium for importing file data. Background Art
[0002] When the device is used in an online or offline scenario, file data is imported through APDU instructions. Users may mistakenly click repeatedly or retry due to network reasons. The APDU instruction script will be executed repeatedly, causing the file data to be repeatedly imported into the device. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a method, device, electronic device and medium for importing file data, so as to solve the above-mentioned problems existing in the prior art and avoid repeated import of file data into the device.
[0004] In a first aspect, a method for importing file data is provided, and the method may include:
[0005] Obtaining import instruction information; the import instruction information includes the file data to be imported and the file data identifier;
[0006] Determine the count value of the import instruction information data field according to the file data identifier;
[0007] Compare the count value with the local count value corresponding to the file data to obtain a comparison result;
[0008] If the comparison result is that the difference between the count value and the local count value is 1, the import instruction information is executed.
[0009] In a possible implementation, after executing the import instruction information, the method further includes:
[0010] The local count value is updated to obtain a current local count value, so that the current local count value is the same as the count value.
[0011] In a possible implementation, the method further includes:
[0012] If the comparison result is that the count value is not greater than the local count value, a response result including a count value error is generated.
[0013] In one possible implementation, the structure of the import instruction corresponding to the import instruction information includes: instruction category, instruction code, first instruction parameter, second instruction parameter, the number of bytes in the instruction data field, the data bit string sent by the instruction, and the maximum number of data bytes expected in the response data field.
[0014] In a possible implementation, the method further includes:
[0015] If multiple import instruction information is obtained within a preset interval, a data import queue is generated according to the acquisition time of the import instruction information;
[0016] Removing duplicate file data from the data import queue to obtain one or more import instructions including non-duplicate file data and count values corresponding to the non-duplicate file data;
[0017] According to the acquisition time sequence of each piece of import instruction information, the count value in the import instruction information is compared with the corresponding local count value to obtain a comparison result.
[0018] In a possible implementation, the method further includes:
[0019] If the number of repeated file data within the preset interval reaches a preset number, a response result including the number of repeated file data is issued.
[0020] In a second aspect, a device for importing file data is provided, which may include:
[0021] An acquisition unit, used for acquiring import instruction information; the import instruction information includes the file data to be imported and the file data identifier;
[0022] and, determining a count value of the import instruction information data field according to the file data identifier;
[0023] A comparison unit compares the count value with a local count value corresponding to the file data to obtain a comparison result;
[0024] If the comparison result is that the difference between the count value and the local count value is 1, the import instruction information is executed.
[0025] In a possible implementation, an updating unit is also included;
[0026] The updating unit is used to update the local count value to obtain a current local count value, so that the current local count value is the same as the count value.
[0027] In a third aspect, an electronic device is provided, the electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0028] Memory, used to store computer programs;
[0029] The processor is used to implement any method step described in the first aspect when executing the program stored in the memory.
[0030] In a fourth aspect, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any method step described in the first aspect is implemented.
[0031] The present application provides a method for importing file data, which includes adding an anti-replay count field to the APDU instruction data generated by the imported file data, and storing a local anti-replay count field for comparison and judgment when initializing in the SE device application. Only when the count value in the anti-replay count field corresponding to the APDU instruction is greater than the count value in the local anti-replay count field by 1, the file data import is allowed to execute, otherwise the instruction reports an error. The present application can ensure that the file data imported by the correct import instruction information can only be successfully imported once, avoiding the situation where the file data is repeatedly imported in abnormal scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0033] Figure 1 A system architecture diagram for a file data import method provided in an embodiment of the present application;
[0034] Figure 2 A flowchart of a method for importing file data provided in an embodiment of the present application;
[0035] Figure 3 A schematic diagram of the structure of a device for importing file data provided in an embodiment of the present application;
[0036] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments of the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0038] A file data importing method provided in an embodiment of the present application can be applied to Figure 1 In the system architecture shown in Figure 1As shown, the system may include: a server and a terminal. The server may be a physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal may be a user equipment (UE) such as a mobile phone, smart phone, laptop, digital broadcast receiver, personal digital assistant (PDA), tablet computer (PAD), handheld device, vehicle-mounted device, wearable device, computing device or other processing device connected to a wireless modem, mobile station (MS), mobile terminal, etc. The terminal and the server may be directly or indirectly connected via wired or wireless communication, which is not limited in this application.
[0039] The terminal (device) is used to receive the import instruction information and send the import instruction information to the server.
[0040] The server is used to obtain import instruction information to execute a file data import method provided by the present application.
[0041] Generally, in actual application, the application of SE device (terminal device carrying smart card) imports file data through APDU instruction in online or offline scenarios. The user may mistakenly click repeatedly or retry due to network reasons. The APDU instruction script will be executed repeatedly, resulting in repeated import of file data into the terminal (hereinafter referred to as device).
[0042] Therefore, the present application provides a method for importing file data to solve the above-mentioned problems existing in the prior art and avoid repeated import of file data into a device.
[0043] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.
[0044] Figure 2 A flowchart of a method for importing file data provided in an embodiment of the present application is shown below. Figure 2 As shown, the method may include:
[0045] Step S210: Obtain import instruction information.
[0046] The import instruction information includes the file data to be imported and the file data identifier.
[0047] Scenarios for obtaining import instruction information include:
[0048] After the card reader receives the signal including the initial file data sent by the device carrying the smart card, the card reader processes the initial file data to obtain processed file data, generates APDU instructions (import instruction information) for the processed file data, and sends the APDU instructions to the device that needs to carry the smart card.
[0049] Afterwards, the interface of the device receives the APDU instruction, searches the data field of the locally imported APDU instruction, and determines the position of the counter according to business rules; for example, the first 4 bytes of the data field of the first APDU in the APDU instruction searched for this business import, thereby determining the count value of the imported instruction information.
[0050] Furthermore, the structure of the import instruction corresponding to the import instruction information is: instruction category, instruction code, first instruction parameter (instruction parameter 1), second instruction parameter (instruction parameter 2), the number of bytes in the instruction data field, the data bit string sent by the instruction, and the maximum number of data bytes expected in the response data field.
[0051] The APDU instruction structure is shown in Table 1:
[0052] Table 1
[0053]
[0054]
[0055] Step S220: compare the count value corresponding to the import instruction information with the local count value corresponding to the file data to obtain a comparison result; and determine whether to execute the import instruction information based on the comparison result.
[0056] Before executing step S220, during the process of initializing the application of the device, a local count field is configured in the application smart card data, and the local count value is reflected in the field; the local count field is 4 bytes, and the initial value of the local count value is 00000000.
[0057] It should be noted that, when the file data in the import instruction information is imported into the device for the first time, the count value of the local count field corresponding to the file data is the initial value.
[0058] According to the file data identifier, the count value of the data field of the import instruction information is determined. It should be noted that the count field has a byte data structure in the data field corresponding to the import instruction, and the count value is reflected in the count field.
[0059] Step S220 specifically includes:
[0060] If the comparison result is that the difference between the count value and the local count value is 1, the import instruction information is executed. That is to say, when the count value is greater than the local count value and the difference between the two is 1, it indicates that the import instruction information can be executed. After executing the import instruction information, the local count value is updated to obtain the current local count value so that the current local count value is the same as the count value. In short, the local count value changes with each successful execution of the import instruction information.
[0061] For example, the count value of the local anti-replay count field is 00000000, and the count value of the count field corresponding to the import instruction information is 00000001, indicating that the import instruction information can be successfully executed.
[0062] If the comparison result is that the count value is not greater than the local count value, a response result including a count value error is generated or a response result including a repeated import is returned. In other words, when the count value is less than or equal to the local count value, the import instruction information cannot be successfully executed, and an error response result is returned. The application scenario at this time may be the repeated execution of the import instruction information caused by power outage or network disconnection. Therefore, the import instruction information cannot be successfully executed. This method can avoid the situation where the file data is repeatedly imported in abnormal scenarios, or the situation where the import cannot be normally imported due to errors.
[0063] For example, if the count value of the local count field is 00000002 and the count value of the count field in the import instruction information is 00000001 or 00000002, the import instruction information fails to be executed.
[0064] In some embodiments, if multiple import instruction information is obtained within a preset interval, a data import queue is generated according to the acquisition time of the import instruction information;
[0065] Repetitive file data in the data import queue are eliminated to obtain one or more import instruction information including non-repetitive file data and count values corresponding to the non-repetitive file data;
[0066] According to the acquisition time of each import instruction information, the count value in the import instruction information is compared with the corresponding local count value to obtain a comparison result.
[0067] This method can perform initial screening on the subsequent waiting import instruction information when a large amount of import instruction information appears within a certain time interval, while comparing the count value with the corresponding local count value, so as to delete duplicate files. This can reduce the backlog of import instruction information and the processing time, thereby reducing the waiting time for subsequent import instruction information and improving processing efficiency.
[0068] Furthermore, if the number of repeated file data reaches a preset number within a preset interval, a response result including the number of repeated file data is issued. This method can avoid the increase in the number of repeated files caused by intermittent network, so as to prompt the relevant staff that a fault has occurred.
[0069] In some embodiments, when executing the import instruction information, the integrity of the file data in the import instruction information is checked. If the file data is incomplete data, the import instruction information is returned to the set cache middleware so that the cache middleware resends the import instruction information to the device. The message middleware records this step as a retry operation; this process can be understood as a network failure that may occur during the process of sending the import instruction information, resulting in incomplete file data in the import instruction information. The configured cache middleware does not require the card reader to resend the import instruction information. In another embodiment, if the number of retry operations reaches a preset number, the file data in the import instruction information is incomplete data, and the cache middleware sends a get message so that the card reader resends the import instruction information to the cache middleware. When the cache middleware re-receives the corresponding import instruction information, it sends the import instruction information at this time to the device.
[0070] In some embodiments, the method may further include: under normal circumstances, the import instruction information is used to instruct the smart card to execute the corresponding application, wherein the count field in the data field indicates the count value of the import instruction information, the CLA field indicates the category of the import instruction information, and the INS indicates the instruction code to be executed. In order to use the import instruction information to instruct the execution engine to enter the execution mode, the values of the fields at the corresponding positions of the count field, the CLA field, and the INS field can be specially set, and set to special values agreed with the smart card, that is, the first agreed value, the second agreed value, and the third agreed value.
[0071] For example, in a specific embodiment, the first agreed value, the second agreed value and the third agreed value may all be 01. In other examples, the first agreed value, the second agreed value and the third agreed value are, for example, 00, 01 and 02, respectively. In more embodiments, the first agreed value, the second agreed value and the third agreed value may also be other specific values, and there may be multiple first agreed values and / or second agreed values and / or third agreed values, for example, the first agreed value includes 00 and 01; the second agreed value includes 01 and 02, the third agreed value includes 01 and 02, and so on, and the setting of the agreed values may be set according to the file data to be imported. It should be noted that the field position of the special value in the count field is different from the field position of the specific numerical value of the count value.
[0072] Accordingly, after receiving the import instruction information, the count field, the CLA field value and the INS field value are compared with the preset first agreed value, the second agreed value and the third agreed value respectively. If the field value of the count field is the first agreed value, the field value of the CLA field is the second agreed value, and the field value of the INS field is the third agreed value, it means that the import instruction information can be executed.
[0073] In one embodiment, there is a software tool on a PC. When a user clicks a service button, the server generates file data for a specific service and divides the file data into blocks to form APDU instructions. Since the data field of an APDU is at most 255 bytes, if the file data is greater than 255, it needs to be divided into multiple instructions. After the server organizes the APDU instructions, it will send them to the device (SE device). The application in the SE device receives the APDU instructions of the imported file data and caches them until all APDU instructions are received. At this time, the counter field in the data field corresponding to the APDU instructions is retrieved to compare whether the counter is greater than the local counter stored in the SE device application. The server generates file import data, sends APDU instructions, and the SE device application receives and processes them in sequence after the user clicks the service button.
[0074] The present application provides a method for importing file data, which includes adding an anti-replay count field to the APDU instruction data generated by the imported file data, and storing a local anti-replay count field for comparison and judgment when initializing in the SE device application. Only when the count value in the anti-replay count field corresponding to the APDU instruction is greater than the count value in the local anti-replay count field by 1, the file data import is allowed to execute, otherwise the instruction reports an error. The present application can ensure that the file data imported by the correct import instruction information can only be successfully imported once, avoiding the situation where the file data is repeatedly imported in abnormal scenarios.
[0075] Corresponding to the above method, the present application embodiment also provides a device for importing file data, such as Figure 3 As shown, the device comprises:
[0076] The acquisition unit 310 is used to acquire the import instruction information; the import instruction information includes the file data to be imported and the file data identifier;
[0077] and, determining a count value of the import instruction information data field according to the file data identifier;
[0078] A comparison unit 320 compares the count value with a local count value corresponding to the file data to obtain a comparison result;
[0079] If the comparison result is that the difference between the count value and the local count value is 1, the import instruction information is executed.
[0080] The functions of each functional unit of a file data importing device provided in the above embodiment of the present application can be realized through the above method steps. Therefore, the specific working process and beneficial effects of each unit in a file data importing device provided in the embodiment of the present application are not repeated here.
[0081] The present application also provides an electronic device, such as Figure 4 As shown, it includes a processor 410 , a communication interface 420 , a memory 430 and a communication bus 440 , wherein the processor 410 , the communication interface 420 , and the memory 430 communicate with each other via the communication bus 440 .
[0082] Memory 430, for storing computer programs;
[0083] The processor 410 is used to execute the program stored in the memory 430 to implement the following steps:
[0084] Obtaining import instruction information; the import instruction information includes the file data to be imported and the file data identifier;
[0085] Determine the count value of the import instruction information data field according to the file data identifier;
[0086] Compare the count value with the local count value corresponding to the file data to obtain a comparison result;
[0087] If the comparison result is that the difference between the count value and the local count value is 1, the import instruction information is executed.
[0088] The communication bus mentioned above can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0089] The communication interface is used for communication between the above electronic device and other devices.
[0090] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0091] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0092] The implementation methods and beneficial effects of the components of the electronic device in the above embodiments to solve the problems can be seen in Figure 2 The various steps in the illustrated embodiment are implemented, therefore, the specific working process and beneficial effects of the electronic device provided by the embodiment of the present application are not repeated here.
[0093] In another embodiment provided in the present application, a computer-readable storage medium is provided, in which instructions are stored. When the computer-readable storage medium is executed on a computer, the computer executes a method for importing file data described in any one of the above embodiments.
[0094] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute a method for importing file data described in any one of the above embodiments.
[0095] Those skilled in the art will appreciate that the embodiments in the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt a complete hardware embodiment, a complete software embodiment, or a form of an embodiment combining software and hardware. Moreover, the present application may adopt a form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0096] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0097] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0098] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0099] Unless otherwise defined, the technical terms or scientific terms used in this application should be understood by people with ordinary skills in the field to which the present invention belongs. "First", "second" and similar words used in this application do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements or objects appearing before the word cover the elements or objects listed after the word and their equivalents, without excluding other elements or objects. "Connect", "couple" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0100] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they are aware of the basic creative concepts. Therefore, the present application embodiments are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application embodiments.
[0101] Obviously, those skilled in the art can make various changes and modifications to the embodiments in the present application without departing from the spirit and scope of the embodiments in the present application. Thus, if these modifications and variations of the embodiments in the present application are within the scope of the embodiments in the present application and their equivalents, the embodiments in the present application are also intended to include these modifications and variations.
Claims
1. A method for importing file data, characterized in that: The method comprises: Obtaining import instruction information; the import instruction information includes the file data to be imported and the file data identifier; Determine the count value of the import instruction information data field according to the file data identifier; Compare the count value with the local count value corresponding to the file data to obtain a comparison result; If the comparison result is that the difference between the count value and the local count value is 1, the import instruction information is executed.
2. The method according to claim 1, characterized in that After executing the import instruction information, the method further includes: The local count value is updated to obtain a current local count value, so that the current local count value is the same as the count value.
3. The method according to claim 1, characterized in that The method further comprises: If the comparison result is that the count value is not greater than the local count value, a response result including a count value error is generated.
4. The method according to claim 1, characterized in that The structure of the import instruction corresponding to the import instruction information includes: instruction category, instruction code, first instruction parameter, second instruction parameter, number of bytes in the instruction data field, data bit string sent by the instruction and maximum number of data bytes expected in the response data field.
5. The method according to claim 1, characterized in that The method further comprises: If multiple import instruction information is obtained within a preset interval, a data import queue is generated according to the acquisition time of the import instruction information; Repetitive file data in the data import queue are eliminated to obtain one or more import instructions including non-repetitive file data and count values corresponding to the non-repetitive file data; According to the acquisition time sequence of each piece of import instruction information, the count value in the import instruction information is compared with the corresponding local count value to obtain a comparison result.
6. The method according to claim 5, characterized in that The method further comprises: If the number of repeated file data within the preset interval reaches a preset number, a response result including the number of repeated file data is issued.
7. A device for importing file data, characterized in that: The device comprises: An acquisition unit, used for acquiring import instruction information; the import instruction information includes the file data to be imported and the file data identifier; and, determining a count value of the import instruction information data field according to the file data identifier; A comparison unit compares the count value with a local count value corresponding to the file data to obtain a comparison result; If the comparison result is that the difference between the count value and the local count value is 1, the import instruction information is executed.
8. The device according to claim 7, characterized in that Also includes update unit; The updating unit is used to update the local count value to obtain a current local count value, so that the current local count value is the same as the count value.
9. An electronic device, characterized in that: The electronic device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 6 when executing a program stored in a memory.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 6 are implemented.