IC card, semiconductor chip, internal state recovery method and computer program
A ring-shaped circular memory region in IC cards manages limited memory by recycling data, addressing the challenge of storing and retrieving state data efficiently, thus maintaining the IC card's internal state without memory overflow.
Patent Information
- Application Number
- JP2023120325
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Filing Date
- 2023-07-24
- Publication Date
- 2025-02-05
- Estimated Expiration
- 2043-07-24
Smart Images

Figure 2025017271000001_ABST
Abstract
Description
[Technical field]
[0001] The present application relates to a technique for restoring the internal state of an IC card. [Background technology]
[0002] IC cards are widely used in fields that require high security, and it is becoming increasingly important to check whether the software installed in the IC card operates normally. However, as the functions required of IC cards become more complex, the number of IC card internal states and commands is increasing. For this reason, if you try to execute a command for each IC card internal state and check that the command operates normally, the number of IC card inspections increases, and the burden on the inspector who inspects the operation of the IC card also increases.
[0003] To solve this problem, it is important to consider the ease of testing from the design stage of the IC card.For example, the invention disclosed in Patent Document 1 proposes a method for solving this problem by saving status data representing the internal status of the IC card using a specific command or an automatic saving function, and then restoring the internal status using the saved status data. [Prior art documents] [Patent documents]
[0004] [Patent Document 1] JP 2019-008671 A Summary of the Invention [Problem to be solved by the invention]
[0005] However, compared to a typical personal computer, the memory size of an IC card is small. Therefore, if the IC card has a lot of internal state data, it is not possible to secure an area in the IC card memory that can store all of the state data. Therefore, if there is not enough free space in the area used to store state data, it becomes necessary to delete the oldest data first.
[0006] As mentioned above, it is important to consider ease of testing from the design stage of an IC card, but the invention disclosed in Patent Document 1 is not designed with consideration for prioritizing deletion of older data when there is no free space in the area used to store status data.
[0007] Therefore, this application proposes an IC card that has the function of storing status data representing the internal state of the IC card and restoring the internal state of the IC card using the stored status data, and that has memory management suitable for prioritizing deletion of older data when there is no free space in the area used to store the status data. [Means for solving the problem]
[0008] The first invention for solving the above-mentioned problems is an IC card comprising a ring-shaped annular area logically connected from the beginning to the end and configured to store data by cyclically using the ring-shaped area, a state saving means for storing updated state data representing an internal state in the ring-shaped area of the ring-shaped memory unit, the state data being given state identification information for identifying the state data when the state data is updated by execution of a command, and a state restoration means for reading out the state data given the state identification information specified by an external device from the ring-shaped area of the ring-shaped memory unit, and restoring the internal state corresponding to the state data read from the ring-shaped area of the ring-shaped memory unit.
[0009] The second invention is a semiconductor chip to be implemented in an IC card, comprising: a ring-shaped annular area logically connected from the beginning to the end, and a ring-shaped memory unit configured to store data by cyclically using the ring-shaped area; a state saving means for storing, when state data representing an internal state is updated by execution of a command, the updated state data, with state identification information added for identifying the state data, in the ring-shaped area of the ring-shaped memory unit; and a state restoration means for reading, from the ring-shaped area of the ring-shaped memory unit, the state data with the state identification information specified by an external device, and restoring the internal state corresponding to the state data read from the ring-shaped area of the ring-shaped memory unit.
[0010] The third invention is an internal state restoration method including a step a) of, when status data representing the internal state of the IC card is updated by execution of a command, storing the updated status data, with status identification information for identifying the status data, in a ring-shaped annular area whose beginning and end are logically connected, and a step b) of, by the IC card, reading from the annular area the status data with the status identification information specified by an external device, and restoring the internal state corresponding to the status data read from the annular area.
[0011] A fourth invention is a computer program that causes a processor of a semiconductor chip implemented in an IC card to function as: a ring-shaped annular area having a beginning and an end logically connected, and configured to store data by cyclically using the ring-shaped area; a state saving means that, when state data representing an internal state is updated by execution of a command, stores the updated state data, with state identification information for identifying the state data, in the ring-shaped area of the ring-shaped memory unit; and a state restoration means that reads out the state data, with the state identification information specified by an external device, from the ring-shaped area of the ring-shaped memory unit, and restores the internal state corresponding to the state data read from the ring-shaped area of the ring-shaped memory unit. Effect of the Invention
[0012] In order to solve the problems of this application, the invention disclosed in this application uses a ring-shaped area with the beginning and end logically connected as a storage area for status data, making it possible to store status data in a circular manner in the ring-shaped area. [Brief description of the drawings]
[0013] [Figure 1] A diagram showing the hardware elements of an IC card. [Diagram 2] A diagram showing the software elements of an IC card. [Diagram 3] A diagram showing the hierarchical structure of files. [Figure 4] 4 is a conceptual diagram of an annular region of an annular memory portion. FIG. [Diagram 5] FIG. 4 is a diagram for explaining a series of processes executed by an IC card. [Figure 6] FIG. 4 is a diagram for explaining the operation of a state saving means. [Figure 7] FIG. 1 is a diagram explaining how to write status data. [Figure 8] FIG. 2 is a second diagram for explaining how to write status data. [Figure 9] FIG. 3 is a diagram for explaining how to write status data. [Figure 10] FIG. 4 is a diagram for explaining the operation of a state restoring means. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0014] From here, an embodiment of the present invention disclosed in this application will be described. This embodiment is intended to facilitate understanding of the present invention. The present invention can be modified into various forms other than the present embodiment by utilizing well-known techniques. Furthermore, unless otherwise specified, the drawings are schematic diagrams drawn to facilitate understanding of the present invention.
[0015] First, a description will be given of the IC card 1. Fig. 1 shows hardware elements included in the IC card 1. As shown in Fig. 1, the IC card 1 disclosed in the present application is a card-type device on which a semiconductor chip 2 disclosed in the present application is mounted.
[0016] The IC card 1 illustrated in FIG. 1 has a shape similar to that of a credit card, but the IC card 1 disclosed in the present application also includes a SIM (Subscriber Identity Module) that is attached to a mobile terminal such as a smartphone. Also, the IC card 1 illustrated in FIG. 1 is a contact type having a contact terminal 1a, but the IC card 1 may be a contactless type having an antenna. The semiconductor chip 2 disclosed in the present application can also be mounted on a device other than the IC card 1. For example, the semiconductor chip 2 disclosed in the present application can also be mounted on an IoT device (IoT: Internet of Things).
[0017] From here on, the IC card 1 will be described in detail, but the description of the IC card 1 also includes a description of the semiconductor chip 2 disclosed in the present application. In the description of the semiconductor chip 2 disclosed in the present application, hereafter "IC card 1" should be read as "semiconductor chip 2."
[0018] The processor 20 illustrated in FIG. 1 is a central processing unit for performing processing inside the IC card 1. The ROM 22 is a read-only memory, and is a memory for storing programs and data. The RAM 21 is a volatile memory, and is a working memory for temporarily storing programs and data. The NVM 23 is an electrically rewritable non-volatile memory, and is a memory for storing loaded programs and data. The interface circuit 24 is a circuit for communicating between the IC card 1 and an external device, and has a function of controlling a communication protocol. The specifications of the interface circuit 24 differ depending on the device in which the semiconductor chip 2 is implemented. For example, when the IC card 1 is a contact type, the interface circuit 24 is a circuit that operates in accordance with the communication protocol of the ISO7816 standard. Also, when the IC card 1 is a non-contact type, the interface circuit 24 is a circuit that operates in accordance with the communication protocol of the ISO14443 standard. Furthermore, when the semiconductor chip 2 is implemented in an IoT device, the interface circuit 24 is a circuit that operates in accordance with a wireless communication standard.
[0019] 2 shows software elements provided in the IC card 1. The IC card 1 stores state data 13 that represents the internal state of the IC card 1. The IC card 1 also includes a plurality of commands 14 and a command departure 15 as functions realized by using a program that operates the IC card 1 (more specifically, the processor 20 provided in the semiconductor chip 2). The IC card 1 also includes a circular memory unit 12, a state saving means 10, and a state restoring means 11 as functions realized by using this program.
[0020] The IC card 1 is equipped with a plurality of commands 14 required for the IC card 1. Program codes of the commands 14 are stored in the ROM 22 or NVM 23. The commands 14 provided in the IC card 1 include, for example, a selection command for selecting a file stored in the NVM 23, a verify command for verifying a PIN (Personal Identification Number) or a password, and an authentication command for verifying an encryption key.
[0021] In this embodiment, the function of executing the command 14 corresponding to a command message received from an external device is referred to as the command departure 15. The command message includes an identifier of the command 14 to be processed by the IC card 1, data necessary for executing the command 14, and the like. When the command departure 15 according to this embodiment receives a command message from an external device, it analyzes the command message received from the external device and executes the command 14 corresponding to the command message received from the external device. When the command departure 15 finishes processing the command 14, it calls the state saving means 10, which will be described in detail below, and when the state saving means 10 finishes processing, it transmits a response message indicating the execution result of the command 14 to the external device.
[0022] Status data 13 representing the internal status of IC card 1 is stored in RAM 21 of semiconductor chip 2, and is data that is operated by specific commands 14. In the case of IC card 1, information on a file that is set as a current status in IC card 1 can be used as data representing the internal status of IC card 1.
[0023] FIG. 3 shows the hierarchical structure of files stored in NVM 23. As shown in FIG. 3, the hierarchical structure of files stored in NVM 23 includes MF30 (Master File), DF31 (Dedicated File), and EF32 (Elementary File) as files. MF30 is the core file of the hierarchical structure of files. All files stored in NVM 23 are associated with MF30. DF31 is a file for classifying and organizing EF32. EF32 is a file for storing working data. The current file is the file selected by the selection command. Immediately after starting up the IC card 1, MF30 is automatically selected.
[0024] The information about the file set in the current state in the IC card 1 can include the following information. Identification information of the file (MF30, DF31, EF32) set to the current state -Information regarding the security status of MF30 or DF31 set to the current state The identification information of a file is, for example, an ID assigned to the file. The identification information of a file set to the current state is updated by executing a selection command. The information related to the security status is information indicating the result of a process related to matching or authentication. The security status is updated by executing a verify command that matches a PIN or password, or an authentication command that matches an encryption key. Note that the information related to the file set to the current state may include information other than the above-mentioned information, such as information related to a secure message.
[0025] From here, the annular storage unit 12 will be described in detail. FIG. 4 shows a conceptual diagram of the annular area 120 of the annular storage unit 12. The annular storage unit 12 has an annular area 120 that is in a ring shape with the beginning and end logically connected, and is configured to be able to store data by cyclically using the annular area 120. Such an annular storage unit 12 is realized by an annular area 120 of a predetermined size provided in the NVM 23 or the RAM 21, and a computer program that operates this annular area 120. As shown in FIG. 4, the annular area 120 of the annular storage unit 12 is in a ring shape with the beginning and end logically connected. The annular storage unit 12 stores data in sequence from the beginning of the annular area 120, and when the data stored in the annular area 120 reaches the end of the annular area 120, it returns to the beginning of the annular area 120 and overwrites the data. As a result, although the size of the annular area 120 in the annular memory unit 12 is fixed, data can be stored in the annular area 120 without setting an upper limit by using the annular area 120 in a cyclical manner.
[0026] 4 shows elements 120b of the annular area 120 in the annular memory unit 12 for easy visual understanding. The elements 120b of the annular area 120 are the smallest units of data stored in the annular area 120. The smallest unit of data stored in the annular memory unit 12 may be one byte, but can also be multiple bytes. The annular area 120 has multiple elements 120b, but in FIG. 4 and other figures, only one element 120b is labeled with a symbol.
[0027] The circular storage unit 12 uses a pointer 120a indicating the data write position when writing data to the circular area 120. In this embodiment, the circular storage unit 12 controls the pointer 120a so that it moves clockwise in the circular area 120 shown in FIG. 4. When the circular storage unit 12 writes specified data to the circular area 120, it controls the pointer 120a so that it indicates the element 120a next to the last element 120a to which the specified data was written. When the pointer 120a goes around the circular area 120, the circular storage unit 12 returns the pointer 120a to the first element 120a of the circular area 120, and overwrites the data from the first element 120a of the circular area 120.
[0028] From here, the state saving means 10 and state restoring means 11 realized by a program that operates the IC card 1 will be described. FIG. 5 is a diagram explaining a series of processes executed by the IC card 1. FIG. 6 is a diagram explaining the operation of the state saving means 10. FIG. 7 is a first diagram explaining how to write the state data 13. FIG. 8 is a second diagram explaining how to write the state data 13. FIG. 9 is a third diagram explaining how to write the state data 13. FIG. 10 is a diagram explaining the operation of the state restoring means 11.
[0029] First, a series of processes executed by the IC card 1 will be described with reference to FIG. 5. When the command 14 is received from the external device (step S1), the command dispatcher 15 checks whether the command 14 received from the external device is a restoration command (step S2). If the command 14 received from the external device is not a restoration command, the command dispatcher 15 executes the command 14 received from the external device (step S3). When the command 14 received from the external device is executed, the command dispatcher 15 calls the state saving means 10 and executes the processing of the state saving means 10 (step S4). When the processing of the state saving means 10 is completed, the command dispatcher 15 transmits a response message indicating the execution result of the command 14 received from the external device to the external device (step S5), and the procedure of FIG. 5 is completed. In S1 of FIG. 5, if the command 14 received from the external device is a restoration command, the command dispatcher 15 calls the state restoring means 11 and executes the processing of the state restoring means 11 (step S6). When the processing of the state restoration means 11 is completed, the command dispatcher 15 transmits a response indicating the execution result of the state restoration means 11 to the external device (step S7), and the procedure of FIG. 5 is completed.
[0030] The processing of the state saving means 10 will be described with reference to FIG. 6. When the state saving means 10 is called from the command dispatch 15 and started, it judges whether the state data 13 stored in the RAM 21 has been changed by the execution of the command 14 (step S40). This processing is processing for comparing the state data 13 stored in the RAM 21 at this time point with the latest state data 13 in the annular area 120. The position of the pointer 120a can be used to judge the latest state data 13 in the annular area 12. If the state data 13 at this time point differs from the latest state data 13 in the annular area 120, it can be judged that the state data 13 has been updated by the execution of the command 14. If the state saving means 10 judges that the state data 13 has been updated, it requests the annular memory unit 12 to write the updated state data 13, and when the annular memory unit 12 writes the updated state data 13 in the annular area 120 (step S41), the procedure of FIG. 6 is terminated. When the state saving means 10 determines that the state data 13 has not been updated, it ends the procedure of FIG. 6 without requesting the circular memory unit 12 to write the updated state data 13.
[0031] From here, the process of writing the changed state data 13 to the annular area 120 of the annular storage unit 12 will be described in detail with reference to Figs. 7 to 10. In this embodiment, the state storage means 10 assigns state identification information for identifying the state data 13 to the state data 13 to be written to the annular area 120 of the annular storage unit 12. This is to make it possible to identify each of the state data 13 written to the annular area 120 of the annular storage unit 12. In this embodiment, the state identification information is a number. In Fig. 7 and the like, the number serving as the state identification information is indicated with a "#" added thereto. The state storage means 10 executes a process of incrementing the value of the number serving as the state identification information by one each time the updated state data 13 is written to the annular area 120 of the annular storage unit 12.
[0032] 7 shows the annular area 120 of the annular memory 12 after the first piece of status data 13 has been written. In the annular area 120 shown in FIG. 7, status data 13 with status identification information "01" has been written. When the status data 13 with status identification information "01" has been written, the annular memory 12 moves the pointer 120a to the element 120b next to the last element 120b into which the status data 13 has been written. In FIG. 7, the element 120b pointed to by the pointer 120a is the element 120b next to the last element 120b into which the status data 13 with status identification information "01" has been written.
[0033] FIG. 8 shows the annular area 120 of the annular memory unit 12 after the eighth piece of status data 13 has been written. The status identification information of the status data 13 written in the annular area 120 is all different. In the annular area 120 shown in FIG. 8, the latest status data 13 is the status data 13 with status identification information "08". Also, in the annular area 120 shown in FIG. 8, the oldest status data 13 is the status data 13 with status identification information "01". Note that, for the sake of convenience, all eight status data 13 are made the same size in FIG. 8, but the sizes of the respective status data 13 may be different.
[0034] In Fig. 8, a total of eight pieces of status data 13 are written, and the status data 13 is written to all elements 120b in the annular area 120 of the annular memory unit 12. Therefore, the pointer 120a goes around the annular area 120 of the annular memory unit 12, and in Fig. 8, the pointer 120a moves to the first element 120b.
[0035] Fig. 9 shows the circular memory unit 12 after nine pieces of status data 13 have been written. In Fig. 8, the element 120b pointed to by the pointer 120a is the first element 120b, so in Fig. 9, the status data 13 with status identification information "01" has been overwritten and the status data 13 with status identification information "09" has been written in the circular area 120. Also, in Fig. 9, the pointer 120a has moved to the element 120b next to the element 120b into which the status data 13 with status identification information "09" has been written.
[0036] In this way, in the present invention, the status data 13 can be cyclically stored in the annular area 120 of the annular memory unit 12. By cyclically storing the status data 13 in the annular area 120 of the annular memory unit 12, even if the number of internal states that the IC card 1 can take increases, the area for storing the status data 13 is not insufficient.
[0037] Next, the operation of the state restoration means 11 will be described with reference to Fig. 10. The explanation of the operation of the state restoration means 11 also includes an explanation of the internal state restoration method according to the present invention. The state restoration means 11, called by the command departure 15, searches for state data 13 to which state identification information indicated by the command message of the restoration command has been added from within the annular area 120 of the annular memory unit 12 at this time (step S60).
[0038] The state restoration means 11 branches the process according to the search result of the state data 13 (step S61). If the state data 13 to which the state identification information indicated in the command message of the restoration command is added cannot be searched from the annular area 120 of the annular memory unit 12, the state restoration means 11 executes exception processing (step S64) and ends the procedure of Fig. 9. As the exception processing, it is conceivable to return an error message, or the like.
[0039] If state data 13 with state identification information indicated in the command message of the restoration command can be found from the annular area 120 of the annular memory unit 12, the state restoration means 11 reads this state data 13 from the annular area 120 of the annular memory unit 12 (step S62), and then replaces the state data 13 at this point in time with the state data 13 read from the annular area 120 of the annular memory unit 12 (step S63), and the procedure in Figure 10 is terminated.
[0040] By replacing the state data 13 at this time with the state data 13 read from the annular area 120 of the annular memory unit 12, the internal state of the IC card 1 can be restored to an internal state corresponding to the state data 13 read from the annular memory unit 12. Even when the internal state of the IC card 1 is restored, the state restoration means 11 does not erase the state data 13 from the annular area 120 of the annular memory unit 12, so that the state data 13 stored in the annular area 120 of the annular memory unit 12 can be used any number of times for restoration. [Explanation of symbols]
[0041] 1 IC card 10 State saving means 11 State restoration means 12 Circular Memory 120 Annular Region 120a Pointer 120b element 2. Semiconductor chips
Claims
1. a ring-shaped storage unit having a ring-shaped area whose beginning and end are logically connected, the ring-shaped area being cyclically used to store data; a state saving means for, when state data representing an internal state is updated by execution of a command, storing the updated state data, to which state identification information for identifying the state data has been added, in the annular area of the annular storage unit; a state restoration means for reading out the state data, to which the state identification information designated by an external device is assigned, from the annular area of the annular storage unit, and restoring an internal state corresponding to the state data read out from the annular area of the annular storage unit; Equipped with an IC card.
2. A semiconductor chip to be mounted on an IC card, a ring-shaped storage unit having a ring-shaped area whose beginning and end are logically connected, the ring-shaped area being cyclically used to store data; a state saving means for, when state data representing an internal state is updated by execution of a command, storing the updated state data, to which state identification information for identifying the state data has been added, in the annular area of the annular storage unit; a state restoration means for reading out the state data, to which the state identification information designated by an external device is assigned, from the annular area of the annular storage unit, and restoring an internal state corresponding to the state data read out from the annular area of the annular storage unit; Equipped with semiconductor chips.
3. a step a) of storing, when status data representing an internal status of the IC card is updated by execution of a command, the updated status data to which status identification information for identifying the status data has been added in an annular area having a ring shape with a top end logically connected; a step b in which the IC card reads out from the annular area the state data to which the state identification information designated by an external device is added, and restores an internal state corresponding to the state data read out from the annular area; Includes internal state restoration methods.
4. a ring-shaped storage unit having a ring-shaped area whose beginning and end are logically connected, the ring-shaped area being cyclically used to store data; a state saving means for, when state data representing an internal state is updated by execution of a command, storing the updated state data, to which state identification information for identifying the state data has been added, in the annular area of the annular storage unit; a state restoration means for reading out the state data to which the state identification information designated by an external device is assigned from the annular area of the annular storage unit, and restoring an internal state corresponding to the state data read out from the annular area of the annular storage unit; A computer program that causes the processor of the semiconductor chip mounted on the IC card to function.
Citation Information
Patent Citations
Electronic information storage apparatus, IC card, data restoration method, and data restoration program
JP2019008671A