Intelligent card problem monitoring method
By constructing the DEBUG management module inside the smart card and sending printing information in real time, the problem of inaccurate error information acquisition and inaccurate positioning during the smart card information transmission is solved, real-time monitoring and precise positioning of smart card problems is realized, and the development and testing are improved Convenience.
Patent Information
- Application Number
- CN202411395099.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-08
- Publication Date
- 2025-02-14
AI Technical Summary
In the process of information transmission between smart cards and PC/card readers, error information is not acquired in real time, positioning is not accurate, and error information inside the card cannot be controlled, resulting in inconvenience in development and testing.
The DEBUG management module is constructed inside the smart card, and the printed information is generated and sent to the adapter through this module. The adapter saves and parses this information in real time to realize real-time monitoring and positioning of smart card problems.
Real-time monitoring and precise positioning of smart card problems is realized, the convenience of development and testing is improved, and error information is promptly obtained and managed.
Smart Images

Figure CN119443124A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of smart card monitoring, and in particular to a method for monitoring smart card problems. Background Art
[0002] At present, information is transmitted between smart cards and PC / card readers through APDU instructions, and various types of problems may be encountered during the information transmission process. The existing technology monitors and analyzes these problems by reading the system log after the information interaction is completed, but this monitoring method has some problems: 1. The acquisition of error information is not real-time, and the cause of the error can only be analyzed after the interaction is completed. 2. The positioning of the error information is not accurate, and the problem node where the error occurred cannot be quickly confirmed. 3. The error information is uncontrollable, and there is a lack of control and management procedures for the error information inside the card, which causes many inconveniences for developers during testing and development. Therefore, a method for monitoring smart card problems is urgently needed to solve this problem. Summary of the invention
[0003] In view of the above problems, the present invention is proposed to provide a method for monitoring smart card problems that overcomes the above problems or at least partially solves the above problems.
[0004] In order to solve the above technical problems, the embodiments of the present application disclose the following technical solutions:
[0005] In a first aspect, an embodiment of the present invention discloses a method for monitoring smart card problems, comprising:
[0006] The card reader sends an APDU command to the adapter, and the adapter saves the APDU command and forwards it to the IC card;
[0007] The IC card calls the internal DEBUG management module, generates printing information through the DEBUG management module, and sends the printing information to the adapter through a private protocol;
[0008] The information management module inside the adapter saves the printing information, and after the saving is completed, sends the printing information saving result to the IC card, and the IC card continues to process the APDU instruction to obtain APDU response data;
[0009] The IC card returns the APDU response data to the adapter, and the adapter parses the APDU response data to obtain APDU parsed data, stores the APDU parsed data in the information management module, and forwards the APDU response data to the card reader;
[0010] Connect the PC to the adapter, receive user instructions through the PC, obtain printing information and APDU parsing data from the adapter's internal information management module in real time, and monitor smart card problems.
[0011] Furthermore, the adapter saves the APDU instruction and forwards it to the IC card. The specific method includes: when the adapter receives the APDU instruction sent by the card reader, the adapter working mode is converted to the simulated card receiving mode, the APDU instruction sent by the card reader is received, and the timestamp of the APDU instruction sending is recorded, the adapter simulated card working mode is converted to the sending mode, the APDU instruction is sent to the IC card, and after successful sending, it is converted to the receiving data mode.
[0012] Furthermore, the IC card calls the internal DEBUG management module, generates printing information through the DEBUG management module, and sends the printing information to the adapter through a private protocol. The printing information is obtained through the printing information interface provided by the DEBUG management module inside the IC card. The printing information includes the status information of the IC card operation. The printing interface first assembles the printing information according to the private protocol, and then sends it to the adapter according to the private protocol. The printing information will be returned from the printing interface only after it is sent. After the printing information is returned from the printing interface, the IC card continues with subsequent processing.
[0013] Furthermore, the printing interface first assembles the printing information according to the private protocol, and the method of private protocol assembly specifically includes: first, adding the printing information judgment character pre-agreed by the adapter and the IC card to the first position of the information after the private protocol assembly, and then adding the empty character pre-agreed by the adapter and the IC card to the middle position of the information after the private protocol assembly, and finally adding the printing information to the unaffected position of the information after the private protocol assembly.
[0014] Furthermore, the IC card returns the APDU response data to the adapter, and the adapter parses the APDU response data to obtain APDU parsed data; the specific method includes: the adapter judges the first byte of the received APDU response data, if the first byte of the APDU response data is INS, it indicates that the subsequent data of the current APDU response data is response data, and continues to receive all data according to the standard process.
[0015] Furthermore, the IC card returns the APDU response data to the adapter, and the adapter parses the APDU response data to obtain APDU parsed data; the specific method includes: the adapter judges the first byte of the received APDU response data, if the first byte of the APDU response data is 60, it indicates that the subsequent data of the current APDU response data is a process byte, the adapter first sends 1 byte 60 to the card reader, and then continues to wait for receiving the APDU response data; if the first byte of the APDU response data is 6X or 9X, it indicates that the subsequent data of the current APDU response data is a process byte or a status byte, and continues to receive the status word according to the standard process.
[0016] Furthermore, the PC is connected to the adapter, receives user instructions through the PC, and obtains printing information and APDU parsing data in real time from the internal information management module of the adapter. The specific method includes: the PC receives user instructions, and notifies the adapter whether to record the printing information sent by the IC card according to the user instructions. When the adapter receives the printing information sent by the IC card, it displays the APDU instruction data, printing information and APDU parsing data to the user in the order of timestamps.
[0017] In a second aspect, an embodiment of the present invention discloses an electronic device, including:
[0018] one or more processors;
[0019] A memory for storing one or more programs;
[0020] When the one or more programs are executed by the one or more processors, the one or more processors implement the smart card problem monitoring method.
[0021] The beneficial effects of the above technical solution provided by the embodiment of the present invention include at least:
[0022] The present invention discloses a method for monitoring smart card problems, including: a card reader sends an APDU instruction to an adapter, the adapter saves the APDU instruction and forwards it to an IC card; the IC card calls an internal DEBUG management module to generate print information, and sends the print information to the adapter; the adapter internal information management module saves the print information, and sends the print information saving result to the IC card; the IC card continues to process the APDU instruction to obtain APDU response data; the IC card returns the APDU response data to the adapter, the adapter parses the APDU response data to obtain APDU parsing data, and forwards the APDU response data to the card reader; the PC end is connected to the adapter, and the print information and APDU parsing data are obtained from the adapter internal information management module in real time, so as to realize monitoring of smart card problems. The present invention adopts a method of constructing a DEBUG module to monitor inside the smart card to obtain error information in real time, and can accurately locate and monitor according to the real-time instructions of an external PC, and the convenience is greatly improved.
[0023] The technical solution of the present invention is further described in detail below through the accompanying drawings and embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings are used to provide a further understanding of the present invention and constitute a part of the specification. Together with the embodiments of the present invention, they are used to explain the present invention and do not constitute a limitation of the present invention. In the accompanying drawings:
[0025] Figure 1 This is a flow chart of a method for monitoring smart card problems in Embodiment 1 of the present invention;
[0026] Figure 2 This is a schematic diagram of the structure of an electronic device in Embodiment 2 of the present invention. DETAILED DESCRIPTION
[0027] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0028] In order to solve the problems existing in the prior art, an embodiment of the present invention provides a method for monitoring smart card problems.
[0029] Example 1
[0030] The present invention discloses a method for monitoring smart card problems. Figure 1 ,include:
[0031] S100. The card reader sends an APDU instruction to the adapter, and the adapter saves the APDU instruction and forwards it to the IC card; wherein the card reader sends the APDU (Application Protocol Data Unit) instruction according to the standard specification, which is an important way for the smart card and the smart card reader to communicate. The APDU instruction follows the ISO7816-4 specification, which is used to define the data format exchanged between the smart card and the card reader.
[0032] The sending process of APDU instruction specifically includes:
[0033] Construct APDU instructions: According to the communication requirements, the card reader constructs APDU instructions according to the above structure.
[0034] Send APDU command: The card reader sends the constructed APDU command to the smart card through a physical interface (such as a contact or contactless interface).
[0035] Receive response: The smart card processes the received APDU instruction and performs the corresponding operation according to the instruction. Then, the smart card returns the execution result to the card reader in the form of response APDU.
[0036] Parse response: The card reader receives and parses the response APDU to obtain the execution result of the smart card.
[0037] In S100 of this embodiment, the adapter saves the APDU instruction and forwards it to the IC card. The specific method includes: when the adapter receives the APDU instruction sent by the card reader, the adapter working mode is converted to the simulated card receiving mode, the APDU instruction sent by the card reader is received, and the timestamp of the APDU instruction sending is recorded, the adapter simulated card working mode is converted to the sending mode, the APDU instruction is sent to the IC card, and after successful sending, it is converted to the receiving data mode.
[0038] S200. The IC card calls the internal DEBUG management module, generates print information through the DEBUG management module, and sends the print information to the adapter through a private protocol; wherein, the print information is obtained through the print information interface provided by the DEBUG management module inside the IC card, and the print information includes the status information of the IC card operation. The print interface first assembles the print information according to the private protocol, and then sends it to the adapter according to the private protocol. The print information will be returned from the print interface only after it is sent. After the print information is returned from the print interface, the IC card continues the subsequent processing. By adding a DEBUG management module inside the smart card, the module is used to monitor and obtain DEBUG information inside the smart card, and the smart card is connected to the PC / card reader externally through the adapter as a transit, and DEBUG information, configuration information, control information, etc. are exchanged through the communication interface between the adapter and the smart card.
[0039] In S200 of this embodiment, the printing interface first assembles the printing information according to the private protocol, and the method of private protocol assembly specifically includes: first, adding the printing information judgment character pre-agreed by the adapter and the IC card to the first position of the information assembled by the private protocol, then adding the empty position character pre-agreed by the adapter and the IC card to the middle position of the information assembled by the private protocol, and finally adding the printing information to the unassigned position of the information assembled by the private protocol. Specifically, in some preferred embodiments, the printing interface first assembles the printing information according to the private protocol, such as "FF+LEN (2 bytes)+print data", and then sends it to the adapter according to the standard protocol. The printing information will be returned from the interface only after it is sent, and the card can continue with subsequent processing.
[0040] S300. The adapter internal information management module saves the print information, and after saving, sends the print information to the IC card to save the result, and the IC card continues to process the APDU command to obtain the APDU response data;
[0041] Specifically, the process of the IC card processing the APDU (Application Protocol Data Unit) instruction and generating APDU response data is the core link of the communication between the smart card and the card reader. First, the IC card receives the APDU instruction sent by the card reader through its built-in interface (such as a contact or contactless interface). This instruction contains the operation that the card reader wants the IC card to perform and related parameters. The processing unit inside the IC card will parse the received APDU instruction, identify the instruction category (CLA), instruction code (INS), parameters (P1, P2) and possible data fields (Data) and the expected response data length (Le). According to the parsed instructions and parameters, the IC card will perform the corresponding operation. This may include reading or writing data, executing specific application functions, verifying passwords, etc. After executing the instruction, the IC card will generate APDU response data based on the result of the operation. This response data contains the status code (SW1 and SW2) of the execution result and possible data fields (Data). The status code is used to indicate whether the instruction is executed successfully and whether further processing is required. If the instruction is executed successfully and data is returned, then the data will be included in the Data field of the response data. Finally, the IC card sends the generated APDU response data to the card reader through its interface. The card reader receives and parses this data to obtain the result of the instruction execution.
[0042] S400. The IC card returns the APDU response data to the adapter, the adapter parses the APDU response data to obtain APDU parsed data, and saves the APDU parsed data in the information management module, and forwards the APDU response data to the card reader;
[0043] In S400 of the present embodiment, the IC card returns the APDU response data to the adapter, and the adapter parses the APDU response data to obtain the APDU parsed data; the specific method includes: the adapter judges the first byte of the received APDU response data, and if the first byte of the APDU response data is INS, it indicates that the subsequent data of the current APDU response data is the response data, and all data are continued to be received according to the standard process. If the first byte of the APDU response data is 60, it indicates that the subsequent data of the current APDU response data is the process byte, and the adapter first sends 1 byte 60 to the card reader, and then continues to wait for the reception of the APDU response data; if the first byte of the APDU response data is 6X or 9X, it indicates that the subsequent data of the current APDU response data is the process byte or the status byte, and continues to receive the status word according to the standard process. If the first byte of the APDU response data is FF, it indicates that the current APDU response data is a private protocol, and the subsequent data are all print information, then continue to receive the 2-byte subsequent data length, and then receive the print information according to the length. The adapter saves the timestamp and print information in the information management module.
[0044] S500. The PC is connected to the adapter, receives user instructions through the PC, obtains printing information and APDU response data from the internal information management module of the adapter in real time, and monitors smart card problems.
[0045] In S500 of this embodiment, the PC is connected to the adapter, user instructions are received through the PC, and printing information and APDU parsing data are obtained in real time from the internal information management module of the adapter. The specific method includes: the PC receives user instructions, and notifies the adapter whether to record the printing information sent by the IC card according to the user instructions. When the adapter receives the printing information sent by the IC card, it displays the APDU instruction data, printing information and APDU parsing data to the user in the order of timestamps.
[0046] Specifically, the PC sends control information to the DEBUG management module inside the smart card through the adapter. The control information is used to indicate the problem monitoring trend of the DEBUG module. The control process mainly includes: 1. Start indication, indicating the DEBUG management module to start running. 2. Monitoring method. The monitoring method provided in this application includes two situations. Monitoring method 1: fixed-point monitoring, according to the node indicated by the control information to obtain information in a targeted manner. Monitoring method 2: periodic full coverage monitoring, periodically obtain the DEBUG information of the target node. 3. Information feedback control, obtain the DEBUG information that the DEBUG management module has obtained at this time, and clear the information according to the next step instruction and carry out the next round of monitoring. 4. End indication, instructing the DEBUG management module to stop working. In the specific monitoring method 1, according to the monitoring node indicated by the PC, the DEBUG module will go to the node to listen and obtain all the information of the node. This method is suitable for targeted single-point positioning analysis. In monitoring method 2, the nodes to be monitored and the monitoring period are pre-set in the control information, and then the DEBUG module periodically monitors and obtains the information until the cycle ends. This method is suitable for long-term overall profile analysis.
[0047] The present embodiment discloses a method for monitoring smart card problems, comprising: a card reader sends an APDU instruction to an adapter, the adapter saves the APDU instruction and forwards it to an IC card; the IC card calls an internal DEBUG management module, obtains printing information through the DEBUG management module, and sends the printing information to the adapter through a private protocol; the internal information management module of the adapter saves the printing information, and after saving, sends an APDU instruction processing signal to the IC card, the IC card processes the APDU instruction to obtain APDU response data; the IC card returns the APDU response data to the adapter, the adapter parses the APDU response data to obtain APDU parsed data, and stores the APDU parsed data in the information management module, and forwards the APDU parsed data to the card reader; a PC is connected to the adapter, receives user instructions through the PC, and obtains printing information and APDU response data from the internal information management module of the adapter in real time, so as to monitor smart card problems. The present invention adopts a method of constructing a DEBUG module monitoring inside the smart card to obtain error information in real time, which does not affect the normal APDU communication of the smart card. At the same time, it can accurately locate and monitor according to the real-time indication of the external PC, and the convenience is greatly improved.
[0048] Example 2
[0049] Based on the same inventive concept, an embodiment of the present disclosure also provides an electronic device. Figure 2 FIG. 1 is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. Figure 2As shown, an embodiment of the present disclosure provides an electronic device including: one or more processors 101, a memory 102, and one or more I / O interfaces 103. The memory 102 stores one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement any optimization method in the above embodiments; the one or more I / O interfaces 103 are connected between the processor and the memory, and are configured to implement information interaction between the processor and the memory.
[0050] Among them, the processor 101 is a device with data processing capabilities, including but not limited to a central processing unit (CPU), etc.; the memory 102 is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); the I / O interface (read-write interface) 103 is connected between the processor 101 and the memory 102, and can realize information interaction between the processor 101 and the memory 102, including but not limited to a data bus (Bus), etc.
[0051] In some embodiments, the processor 101 , the memory 102 , and the I / O interface 103 are connected to each other via a bus 104 , and further connected to other components of the computing device.
[0052] In some embodiments, the one or more processors 101 include a field programmable gate array.
[0053] According to an embodiment of the present disclosure, a computer-readable medium is further provided, wherein a computer program is stored on the computer-readable medium, wherein when the program is executed by a processor, the steps in any optimization method in the above-mentioned embodiment are implemented.
[0054] It should be understood that the specific order or hierarchy of steps in the disclosed process is an example of an exemplary method. Based on design preferences, it should be understood that the specific order or hierarchy of steps in the process can be rearranged without departing from the scope of protection of the present disclosure. The attached method claims present the elements of the various steps in an exemplary order and are not intended to be limited to the specific order or hierarchy described.
[0055] In the above detailed description, various features are grouped together in a single embodiment to simplify the disclosure. This method of disclosure should not be interpreted as reflecting an intention that the embodiments of the claimed subject matter require more features than are clearly stated in each claim. On the contrary, as reflected in the appended claims, the invention is in a state of having less than all the features of the disclosed individual embodiments. Therefore, the appended claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.
[0056] Those skilled in the art will also appreciate that the various illustrative logic blocks, modules, circuits, and algorithmic steps described in conjunction with the embodiments herein can all be implemented as electronic hardware, computer software, or a combination thereof. In order to clearly illustrate the interchangeability between hardware and software, various illustrative components, blocks, modules, circuits, and steps are generally described above around their functions. Whether such functions are implemented as hardware or software depends on specific applications and the design constraints imposed on the entire system. A skilled person can implement the described functions in an alternative manner for each specific application, but such implementation decisions should not be interpreted as departing from the scope of protection of the present disclosure.
[0057] The steps of the method or algorithm described in conjunction with the embodiments herein may be directly embodied as hardware, a software module executed by a processor, or a combination thereof. The software module may be located in a RAM memory, a flash memory, a ROM memory, an EPROM memory, an EEPROM memory, a register, a hard disk, a mobile disk, a CD-ROM, or any other form of storage medium well known in the art. An exemplary storage medium is connected to the processor so that the processor can read information from the storage medium and can write information to the storage medium. Of course, the storage medium may also be an integral part of the processor. The processor and the storage medium may be located in an ASIC. The ASIC may be located in a user terminal. Of course, the processor and the storage medium may also be present in a user terminal as discrete components.
[0058] For software implementation, the techniques described in this application can be implemented with modules (e.g., procedures, functions, etc.) that perform the functions described in this application. These software codes can be stored in a memory unit and executed by a processor. The memory unit can be implemented within the processor or outside the processor. In the latter case, it is coupled to the processor in a communication manner via various means, which are well known in the art.
[0059] The above description includes examples of one or more embodiments. Of course, it is impossible to describe all possible combinations of components or methods for the purpose of describing the above embodiments, but it should be recognized by those skilled in the art that the various embodiments may be further combined and arranged. Therefore, the embodiments described herein are intended to cover all such changes, modifications and variations that fall within the scope of protection of the appended claims. In addition, with respect to the term "comprising" used in the specification or claims, the word is covered in a manner similar to the term "including", just as "including," is explained as a transitional word in the claims. In addition, any term "or" used in the specification of the claims is intended to mean "non-exclusive or".
Claims
1. A method for monitoring smart card problems, characterized in that: include: The card reader sends an APDU command to the adapter, and the adapter saves the APDU command and forwards it to the IC card; The IC card calls the internal DEBUG management module, generates printing information through the DEBUG management module, and sends the printing information to the adapter through a private protocol; The information management module inside the adapter saves the printing information, and after the saving is completed, sends the printing information saving result to the IC card, and the IC card continues to process the APDU instruction to obtain APDU response data; The IC card returns the APDU response data to the adapter, and the adapter parses the APDU response data to obtain APDU parsed data, stores the APDU parsed data in the information management module, and forwards the APDU response data to the card reader; The PC is connected to the adapter, receives user instructions through the PC, obtains printing information and APDU parsing data from the internal information management module of the adapter in real time, and monitors smart card problems.
2. The method for monitoring smart card problems as claimed in claim 1, characterized in that: The adapter saves the APDU instruction and forwards it to the IC card. The specific method includes: when the adapter receives the APDU instruction sent by the card reader, the adapter working mode is converted to the simulated card receiving mode, the APDU instruction sent by the card reader is received, and the timestamp of the APDU instruction sending is recorded, the adapter simulated card working mode is converted to the sending mode, the APDU instruction is sent to the IC card, and after successful sending, it is converted to the receiving data mode.
3. The method for monitoring smart card problems as claimed in claim 1, characterized in that: The IC card calls the internal DEBUG management module, generates printing information through the DEBUG management module, and sends the printing information to the adapter through a private protocol. The printing information is obtained through the printing information interface provided by the DEBUG management module inside the IC card. The printing information includes the status information of the IC card operation. The printing interface first assembles the printing information according to the private protocol, and then sends it to the adapter according to the private protocol. The printing information will be returned from the printing interface only after it is sent. After the printing information is returned from the printing interface, the IC card continues with subsequent processing.
4. The method for monitoring smart card problems as claimed in claim 3, characterized in that: The printing interface first assembles the printing information according to the private protocol. The method of private protocol assembly specifically includes: first, adding the printing information judgment character pre-agreed by the adapter and the IC card to the first position of the information after private protocol assembly, then adding the empty position character pre-agreed by the adapter and the IC card to the middle position of the information after private protocol assembly, and finally adding the printing information to the unaffected position of the information after private protocol assembly.
5. The method for monitoring smart card problems as claimed in claim 1, characterized in that: The IC card returns the APDU response data to the adapter, and the adapter parses the APDU response data to obtain APDU parsed data; the specific method includes: the adapter judges the first byte of the received APDU response data, if the first byte of the APDU response data is INS, it indicates that the subsequent data of the current APDU response data is response data, and continues to receive all data according to the standard process.
6. The method for monitoring smart card problems as claimed in claim 1, characterized in that: The IC card returns the APDU response data to the adapter, and the adapter parses the APDU response data to obtain APDU parsed data; the specific method includes: the adapter judges the first byte of the received APDU response data, if the first byte of the APDU response data is 60, it indicates that the subsequent data of the current APDU response data is a process byte, the adapter first sends 1 byte 60 to the card reader, and then continues to wait for receiving the APDU response data; if the first byte of the APDU response data is 6X or 9X, it indicates that the subsequent data of the current APDU response data is a status byte, and continues to receive the status word according to the standard process.
7. A method for monitoring smart card problems as claimed in claim 1, characterized in that: The PC is connected to the adapter, user instructions are received through the PC, and printing information and APDU parsing data are obtained from the internal information management module of the adapter in real time. The specific method includes: the PC receives the user instructions, and notifies the adapter whether to record the printing information sent by the IC card according to the user instructions. When the adapter receives the printing information sent by the IC card, it displays the APDU instruction data, printing information and APDU parsing data to the user in the order of timestamps.
8. An electronic device, characterized in that: include: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the problem monitoring method.
Citation Information
Cited By
Smart card reading method, system and device and terminal equipment
CN120822529A