Smart card RTR transient variable creation method and device, equipment and medium

By using a non-volatile linked list to pre-apply memory for RTR transient variables during the system initialization phase of the smart card, the problem of JavaCard applications needing to reallocate memory after reset is solved, improving creation efficiency and user experience.

CN118819815APending Publication Date: 2024-10-22CHINA MOBILE M2M +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410676260.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-29
Publication Date
2024-10-22

AI Technical Summary

Technical Problem

In the smart card industry, the RTR transient variables of JavaCard applications are cleared when a reset event occurs, resulting in the need to reallocate memory every time the application starts, which is inefficient and has a poor user experience.

Method used

By using a non-volatile linked list to store memory-related information of RTR transient variables during the system initialization phase, and pre-application of memory space, it ensures that the allocated memory can be directly used when the application starts, improving creation efficiency.

Benefits of technology

The creation efficiency of RTR transient variables in smart card applications is improved, the memory allocation time at startup is reduced, and the user experience is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118819815A_ABST
    Figure CN118819815A_ABST
Patent Text Reader

Abstract

The invention discloses a smart card RTR transient variable creation method, device and equipment and a medium, when a smart card is in an initialization stage, firstly, according to an application ID, querying address information of an RTR information linked list stored in an application registry corresponding to an application; when the address information of the RTR information linked list exists in the application registry, searching the RTR information linked list according to the address information of the RTR information linked list to obtain RTR memory information; and finally, allocating a memory for the target RTR transient variable in a storage partition of a volatile memory according to the RTR memory information so as to complete creation of the target RTR transient variable. By adopting the method and the device, the creating efficiency of the RTR transient variable in the smart card application program can be improved, and better user experience is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of smart card technology, and in particular to a smart card RTR transient variable creation method, device, equipment and medium. Background Art

[0002] In the smart card industry, the transient variables of the Java platform-based smart card technology (JavaCard) include CLEAR_ON_RESET (clear on reset, abbreviated as RTR), which is one of the data object clearing strategies of the JavaCard application, mainly used to manage the data life cycle of the application.

[0003] However, when a smart card reset event occurs, the relevant information of the RTR transient variables is cleared. Each time the RTR transient variables created after the application is started, memory space needs to be reallocated for them, which makes the creation efficiency of the smart card RTR transient variables low and the user experience is poor. Summary of the invention

[0004] The technical problem to be solved by the present invention is to provide a method, device, equipment and medium for creating RTR transient variables of a smart card, so as to improve the creation efficiency of RTR transient variables of smart card applications and provide a better user experience.

[0005] In order to solve the above technical problems, an embodiment of the present invention provides a method for creating a smart card RTR transient variable, comprising:

[0006] When the smart card is in the initialization phase, responding to a target RTR transient variable creation request of an application on the smart card;

[0007] Querying an application registration table corresponding to the application according to the application ID; wherein the application registration table is used to store address information of the RTR information linked list;

[0008] When the address information of the RTR information linked list exists in the application registration table, searching the RTR information linked list according to the address information of the RTR information linked list to obtain the RTR memory information;

[0009] Memory is allocated in a storage partition of a volatile memory for the target RTR transient variable according to the RTR memory information to complete creation of the target RTR transient variable.

[0010] Further, searching the RTR information linked list according to the address information of the RTR information linked list to obtain the RTR memory information includes:

[0011] Querying the application registration table corresponding to the application according to the application ID; wherein the application registration table is also used to store address information of the non-volatile member variable linked list;

[0012] Searching the non-volatile member variable linked list according to the address information of the non-volatile member variable linked list to obtain the address information of the target RTR transient variable of the application program;

[0013] The RTR information linked list is queried according to the address information of the RTR information linked list to obtain RTR memory information matching the address information of the target RTR transient variable.

[0014] Optionally, the RTR memory information includes a memory address of the target RTR transient variable, a memory size of the target RTR transient variable, and an application ID.

[0015] Optionally, the smart card RTR transient variable creation method further includes:

[0016] When the address information of the RTR information linked list does not exist in the application registration table, memory is allocated in a storage partition of a volatile memory for the target RTR transient variable to complete the creation of the target RTR transient variable;

[0017] Obtaining RTR memory information corresponding to the target RTR transient variable;

[0018] Writing the RTR memory information into the RTR information linked list to obtain address information of the RTR information linked list;

[0019] Returning the memory address of the target RTR transient variable in the RTR memory information to the application program, so that the application program writes the memory address of the target RTR transient variable into the non-volatile member variable linked list to obtain the address information of the non-volatile member variable linked list;

[0020] The address information of the RTR information linked list and the address information of the non-volatile member variable linked list are written into the application registration table.

[0021] Optionally, the smart card RTR transient variable creation method further includes:

[0022] responding to a target RTR transient variable release request of the application;

[0023] Querying the application registration table corresponding to the application according to the application ID to obtain the address information of the non-volatile member variable linked list and the address information of the RTR information linked list;

[0024] Searching the non-volatile member variable linked list according to the address information of the non-volatile member variable linked list to obtain the memory address of the target RTR transient variable;

[0025] Searching the RTR information linked list according to the address information of the RTR information linked list, and releasing the memory space of the RTR memory information in the RTR information linked list that matches the memory address of the target RTR transient variable;

[0026] Modify the address information of the RTR information linked list and the address information of the non-volatile member variable linked list in the application registration table.

[0027] Optionally, the smart card RTR transient variable creation method further includes:

[0028] Responding to a target RTR transient variable update request of the application; the update request includes RTR new memory information of the target RTR transient variable;

[0029] Querying the application registration table corresponding to the application according to the application ID to obtain the address information of the non-volatile member variable linked list and the address information of the RTR information linked list;

[0030] Searching the non-volatile member variable linked list according to the address information of the non-volatile member variable linked list to obtain the memory address of the target RTR transient variable;

[0031] The RTR information linked list is searched according to the address information of the RTR information linked list, and the RTR memory information in the RTR information linked list that matches the memory address of the target RTR transient variable is replaced with the RTR new memory information.

[0032] Preferably, the non-volatile member variable linked list is a non-volatile storage linked list with a fixed node order, used to store non-volatile member variables and a non-volatile memory reference value corresponding to each non-volatile member variable; the address information of the non-volatile member variable linked list is the non-volatile memory reference value corresponding to the header non-volatile member variable of the non-volatile member variable linked list;

[0033] Each of the non-volatile member variables is used to store the memory address of each RTR transient variable;

[0034] The non-volatile memory reference value corresponding to each of the non-volatile member variables is constructed through a C++ class according to the definition order of the non-volatile member variables.

[0035] Preferably, the RTR information linked list is a non-volatile storage linked list, used to store each RTR memory information and the non-volatile memory reference value corresponding to each RTR memory information; the address information of the RTR information linked list is the non-volatile memory reference value corresponding to the header RTR memory information of the RTR information linked list.

[0036] Optionally, the target RTR transient variable is at least one of all RTR transient variables of the application.

[0037] In order to solve the above technical problems, an embodiment of the present invention further provides a smart card RTR transient variable creation device, comprising:

[0038] A response module, used for responding to a target RTR transient variable creation request of an application on the smart card when the smart card is in an initialization phase;

[0039] An address information query module, used to query an application registration table corresponding to the application according to the application ID; wherein the application registration table is used to store address information of the RTR information linked list;

[0040] An RTR memory information reading module, configured to search the RTR information linked list according to the address information of the RTR information linked list to obtain the RTR memory information when the address information of the RTR information linked list exists in the application registration table;

[0041] The RTR transient variable creation module is used to allocate memory in a storage partition of a volatile memory for the target RTR transient variable according to the RTR memory information to complete the creation of the target RTR transient variable.

[0042] In order to solve the above technical problems, an embodiment of the present invention also provides a smart card RTR transient variable creation device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, and when the processor executes the computer program, it implements the smart card RTR transient variable creation method as described in any one of the above.

[0043] In order to solve the above technical problems, an embodiment of the present invention also provides a computer-readable storage medium, which includes a stored computer program, wherein when the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the smart card RTR transient variable creation method as described in any one of the above.

[0044] Compared with the prior art, the embodiment of the present invention provides a smart card RTR transient variable creation method, device, equipment and medium. When the smart card is in the initialization stage, the address information of the RTR information linked list stored in the application registration table corresponding to the application is first queried according to the application ID; when the address information of the RTR information linked list exists in the application registration table, the RTR information linked list is searched according to the address information of the RTR information linked list to obtain the RTR memory information; finally, according to the RTR memory information, memory is allocated for the target RTR transient variable in the storage partition of the volatile memory to complete the creation of the target RTR transient variable. It can be seen that the embodiment of the present invention uses a non-volatile linked list to store the memory-related information of the RTR transient variable, so that the smart card uses this memory information to complete the pre-application of the RTR transient variable memory in the system initialization stage, thereby improving the efficiency of the smart card application RTR transient variable application and creation method, and has a better user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] In order to more clearly illustrate the technical solution of the present invention, the drawings required for use in the implementation mode will be briefly introduced below. Obviously, the drawings described below are only some implementation modes of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0046] Figure 1 is a flow chart of a method for creating a smart card RTR transient variable provided by an embodiment of the present invention;

[0047] Figure 2 It is a structural relationship diagram of a non-volatile member variable linked list provided by an embodiment of the present invention;

[0048] Figure 3 It is a schematic diagram of the structural relationship of an RTR information link table provided by an embodiment of the present invention;

[0049] Figure 4 It is a RTR transient variable and its memory information storage mapping relationship diagram provided by an embodiment of the present invention;

[0050] Figure 5 is another flow chart of a method for creating a smart card RTR transient variable provided by one embodiment of the present invention;

[0051] Figure 6 It is a RTR transient variable release flow chart of a smart card RTR transient variable creation method provided by an embodiment of the present invention;

[0052] Figure 7It is a RTR transient variable update flow chart of a smart card RTR transient variable creation method provided by an embodiment of the present invention;

[0053] Figure 8 It is another flow chart of a method for creating a smart card RTR transient variable according to an embodiment of the present invention;

[0054] Fig. 9 It is a flow chart of RTR transient variable information reading of a smart card RTR transient variable creation method provided by one embodiment of the present invention;

[0055] Fig.10 It is a structural schematic diagram of a smart card RTR transient variable creation device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0056] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0057] In order to clearly describe the technical solution in the embodiment of the present invention, the smart card technology (JavaCard technology) is briefly introduced below.

[0058] First, some terminology concepts involved in the embodiments of the present invention are briefly explained:

[0059] Table 1 Terminology concept explanation table

[0060]

[0061] At present, most smart card applications (Applets) are developed in Java language. Java applications are compiled into bytecodes and run on Java virtual machines. Many features of smart cards need to rely on the support of Java virtual machines. In the smart card industry, JavaCard transient variables include CLEAR_ON_RESET (reset clear, referred to as RTR) and CLEAR_ON_DESELECT (cancel clear, referred to as DTR). These are two different data object (Applet object) clearing strategies for JavaCard applications, which are used to manage the data life cycle of applications and help improve the security and reliability of JavaCard applications.

[0062] The underlying implementation of RTR transient variables in JavaCard is usually the responsibility of the JavaCard runtime environment. The implementation of these variables may vary depending on the JavaCard platform, but the following general implementation scheme is usually adopted:

[0063] 1. Special memory allocation: The JavaCard runtime environment allocates memory for RTR transient variables in a special memory area of ​​the card. This memory area is usually designed to be automatically cleared when the card is reset;

[0064] 2. Initialization: During the card initialization or application installation process, the JavaCard runtime environment will be responsible for initializing the RTR transient variable to its initial value, which can be setting all elements of the byte array corresponding to the RTR transient variable to 0 or other initial values;

[0065] 3. Automatic Clearing: The key feature of RTR transient variables is that they are automatically cleared when the card is reset. This is achieved through operations performed during the reset processing in the JavaCard runtime environment. When the card is reset, the storage area of ​​​​the RTR transient variables is reset to its initial value without the need for application intervention;

[0066] 4. Access control: RTR transient variables are usually managed by the access control mechanism of the JavaCard application. Only applications or objects with appropriate permissions can read and modify the values ​​of these variables.

[0067] Therefore, in general, after the Applet (application) creates the RTR transient variable, it will occupy it until the card reset (or power-on) event occurs, and the content of the RTR transient variable will be cleared to the default value. Before the card reset (or power-on) event occurs, the RTR transient variable is readable and writable, and the content (in the memory space) will not be cleared.

[0068] Therefore, an embodiment of the present invention proposes a method for creating RTR transient variables of a smart card, so that after a card reset (or power-on) event occurs, the RTR transient variables can be restored in the system initialization stage. After the restoration, all RTR transient variables created and used by all applications before the card reset (or power-on) event occurs will be pre-applied in a dedicated RTR HEAP memory heap. When the application is started, these RTR transient variables can be used directly. This pre-application operation can improve the efficiency of creating RTR transient variables and reduce the time consumed by re-applying for the memory space required for RTR transient variables in the memory area after the application is started.

[0069] It should be noted that the smart card system mentioned in the embodiment of the present invention involves multitasking and resource management, which are divided into two different execution modes: user state and kernel state. The smart card application runs in the user state, and the smart card operating system runs in the kernel state. Usually, in the user state, the application can only access its own memory space, and cannot directly access or modify the memory or hardware resources of the operating system kernel. The application in the user state has limited permissions and usually cannot execute privileged instructions (for example, directly access hardware devices or modify operating system data structures). When the application needs to perform some operations that require privileges or system resources, it will request the operating system to switch to the kernel state, and this switch is usually triggered by a system call (System Call) or an interrupt (Interrupt). When the operating system completes these operations, it will return control to the user state.

[0070] In addition, when the smart card is reset or powered on, and the system is initialized, the operating system kernel allocates a dedicated volatile memory (RAM, for example) storage space for all applications as memory allocation for RTR transient variables, which is called the RTRHEAP memory heap, and the size of the memory heap is configurable. After the RTR HEAP is initialized, when all applications apply to create RTR transient variables, the operating system kernel determines whether there is enough RTR HEAP memory space to allocate the memory required for the RTR transient variable creation application to the application. If the remaining space is sufficient, a section of memory is allocated for it in the RTR HEAP according to a certain allocation algorithm, and the kernel is responsible for the unified management of the memory space. Among them, the size of the allocated memory is related to the size of the transient variable.

[0071] See also Figure 1 , is a flow chart of a method for creating a smart card RTR transient variable provided by an embodiment of the present invention. Specifically, the method includes steps S1 to S4:

[0072] S1. When the smart card is in the initialization phase, responding to a target RTR transient variable creation request of an application on the smart card;

[0073] S2. Query the application registration table corresponding to the application according to the application ID; wherein the application registration table is used to store the address information of the RTR information linked list;

[0074] S3. When the address information of the RTR information linked list exists in the application registration table, the RTR information linked list is searched according to the address information of the RTR information linked list to obtain the RTR memory information;

[0075] S4. Allocate memory in a storage partition of a volatile memory for the target RTR transient variable according to the RTR memory information to complete creation of the target RTR transient variable.

[0076] Specifically, the RTR memory information includes the memory address of the target RTR transient variable, the memory size of the target RTR transient variable, and the application ID.

[0077] It should be noted that each time an RTR transient variable is successfully created, the application will initiate an RTR variable information storage request to the operating system kernel through a system call. After receiving the system call request, the operating system kernel stores a copy of RTR variable information (RTR Information, referred to as RTR INFO) in the RTR information linked list. The RTR variable information includes RTR memory information, wherein the RTR memory information includes the memory start address (Address, allocated by the operating system kernel in the memory heap RTR HEAP) of the RTR transient variable, the size (Size) of the RTR transient variable, and the application ID (Application ID, referred to as AID).

[0078] A smart card RTR transient variable creation method provided by an embodiment of the present invention uses a non-volatile linked list to store memory-related information of the RTR transient variable, so that the smart card uses this memory information to complete the pre-application of the RTR transient variable memory during the system initialization phase, thereby improving the efficiency of the smart card application RTR transient variable application and creation method, and providing a better user experience.

[0079] It should be noted that, in general, the number of RTR transient variables applied for by the application to be created is more than one, and the returned memory addresses are also multiple. If the scale of the RTR transient variables is large, it will affect the efficiency of subsequent RTR transient variable information search and maintenance, thereby further affecting the efficiency of creating RTR transient variables.

[0080] Therefore, in one implementation, searching the RTR information linked list according to the address information of the RTR information linked list to obtain the RTR memory information includes:

[0081] Querying the application registration table corresponding to the application according to the application ID; wherein the application registration table is also used to store address information of the non-volatile member variable linked list;

[0082] Searching the non-volatile member variable linked list according to the address information of the non-volatile member variable linked list to obtain the address information of the target RTR transient variable of the application program;

[0083] The RTR information linked list is queried according to the address information of the RTR information linked list to obtain RTR memory information matching the address information of the target RTR transient variable.

[0084] It is worth mentioning that the non-volatile member variable linked list can associate the RTR information with the memory address, making it convenient to find the corresponding memory address according to the RTR information. At the same time, the non-volatile member variable linked list is used to store the allocated memory address, which makes it more convenient to manage memory resources.

[0085] It should be noted that when an application is installed, the system will create a non-volatile application registry (Application Registry) for it in the non-volatile memory (FLASH for example) to store and manage the application properties of the application. The application properties include the address information of the RTR information list, the address information of the non-volatile member variable list, the application ID and other related information.

[0086] Specifically, the non-volatile member variable linked list is a non-volatile storage linked list with a fixed node order, which is used to store non-volatile member variables and a non-volatile memory reference value corresponding to each non-volatile member variable; the address information of the non-volatile member variable linked list is the non-volatile memory reference value corresponding to the header non-volatile member variable of the non-volatile member variable linked list;

[0087] Each of the non-volatile member variables is used to store the memory address of each RTR transient variable;

[0088] The non-volatile memory reference value corresponding to each of the non-volatile member variables is constructed through a C++ class according to the definition order of the non-volatile member variables.

[0089] Therefore, it should be noted that the smart card RTR transient variable creation method provided by the above implementation supports smart card applications to use C / C++ language to write source programs, which can greatly improve the execution efficiency of applications compared to applications written in Java language.

[0090] Specifically, the RTR information linked list is a non-volatile storage linked list, which is used to store each RTR memory information and the non-volatile memory reference value corresponding to each RTR memory information; the address information of the RTR information linked list is the non-volatile memory reference value corresponding to the header RTR memory information of the RTR information linked list.

[0091] It should be noted that, in an embodiment of the present invention, a virtual mapping table, i.e., a non-volatile member variable linked list, is established to store the mapping relationship between the NV (Non-Volatile) member variables of the RTR transient variable memory address and the non-volatile memory (FLASH for example) storage space that actually stores the NV member variable value. Furthermore, the access and read and write operations of these NV member variables can be realized through this virtual mapping relationship, thereby realizing the non-volatile storage of the RTR transient variable memory address.

[0092] Specifically, see Figure 2 , is a structural relationship diagram of a non-volatile member variable linked list provided by an embodiment of the present invention. The embodiment of the present invention uses a non-volatile member variable, namely, NV variable NV_ADDR to store the memory start address of the RTR transient variable. NV_ADDR and the RTR transient variable form a one-to-one correspondence. If an application applies to create multiple RTR transient variables, the system will use multiple NV variables to store the memory start addresses allocated to them in the RTR HEAP memory heap. For example, Figure 2 As shown: the memory starting address of RTR transient variable 1 uses variable NV_ADDR_1, the memory starting address of RTR transient variable 2 uses variable NV_ADDR_2...the memory starting address of RTR transient variable N uses variable NV_ADDR_N, and these NV variables and related RTR transient variables form a one-to-one correspondence.

[0093] Furthermore, all the above NV variables NV_ADDR need to be defined as member variables in the class of the C++ application. The data types of these variables are also a special NV variable class NVRTRAddress in the C++ application. The NVRTRAddress class inherits from a NVObject (NV variable class) parent class. When the application instantiates an APP class object, it instantiates these NV_ADDR member variables of the NVRTRAddress type in a fixed order. This instantiation order is the same after each card reset (or power-on). The present invention calls it the construction order. This construction order is only related to the definition order of these NV_ADDR variables in the C++ class.

[0094] For example, a C++ class of an application defines N NV_ADDR member variables in order from front to back, namely NV_ADDR_1, NV_ADDR_2...NV_ADDR_N, and their instantiation order is fixed to NV_ADDR_1, NV_ADDR_2...NV_ADDR_N, so their construction order values ​​are 1, 2...N respectively. The embodiment of the present invention utilizes this fixed construction sequence and defines a static member variable Construct Sequence Number (NV_CONSTR_SEQ_NUM for short) with an initial value of 0 in the parent class NVObject of the NVRTRAddress class. The member variable is modified with the static keyword in the NVObject class of the C++ application. When the C++ class instantiates the first NV_ADDR member variable NV_ADDR_1, the static member variable NV_CONSTR_SEQ_NUM increases by 1 to become 1, and a non-volatile storage space is allocated to the variable in the NVM (non-volatile memory) partition of the FLASH and initialized. After successful allocation, an NVM reference value, i.e., the non-volatile memory reference value NVM_REF_1, is returned, and NVM_REF_1 is used as the first node NODE_1 fixed in the non-volatile storage linked list. When the second NV_ADDR_2 is instantiated, NV_CONSTR_SEQ_NUM increases by 1 to 2, storage space is allocated in the NVM partition, the NVM reference value NVM_REF_2 is returned, and NVM_REF_2 is used as the second node NODE_2 fixed in the linked list. Similarly, when the Nth NV_ADDR_N is instantiated, NV_CONSTR_SEQ_NUM becomes N, storage space is allocated in the NVM partition, the NVM reference value NVM_REF_N is returned, and NVM_REF_N is used as the Nth node NODE_N fixed in the linked list.

[0095] It is worth noting that, in the embodiment of the present invention, the NVM reference value of the next node in the NVM storage space is also added to the storage space of each linked list node. Figure 2 As shown: in the linked list node 1: NODE_1, the NVM reference value NVM_REF_2 of the next node is added, in NODE_2, the NVM reference value NVM_REF_3 of the next node is added, in NODE_(N-1), the NVM reference value NVM_REF_N of the next node is added, and in NODE_N, the NVM reference value 0 of the next node is added as the end of the linked list.

[0096] At the same time, the NVM reference value NVM_REF_1 of the head node of the linked list is added to the application registration table of the application as the attribute of "address information of the non-volatile member variable linked list" for subsequent management of the linked list.

[0097] Exemplarily, when a card reset (or power-on) event occurs, the application C++ class uses the fixed order of NV member variable definitions as the construction order of NVRTRAddress class objects, and also starts from 1 to form construction order values ​​of 1, 2...N. By obtaining the NVM_REF_X stored in the Xth node NODE_X of the above non-volatile member variable linked list through the construction order value X, the corresponding non-volatile NV member variable NV_ADDR_X in the NVM storage area can be obtained. The NVM reference value NVM_REF_X can be obtained through this reference value. The reading and writing operations of the NV member variable NV_ADDR_X used to store the memory address of the RTR transient variable can be realized.

[0098] It should be noted that the embodiment of the present invention uses a special data structure to manage the relevant information of RTR transient variables, namely, the RTR information linked list (a non-volatile memory one-way linked list (taking the FLASH linked list as an example) can also be used here, with the same effect). Unlike the data managed by the traditional linked list, which is stored in the memory, the data of all nodes managed by the FLASH linked list are stored in the FLASH and are non-volatile. Through this RTR information FLASH linked list, the system manages all RTR variable information of the application.

[0099] See also Figure 3 , is a schematic diagram of the structural relationship of an RTR information link table provided by an embodiment of the present invention. Figure 3 As shown, in addition to storing RTR variable information (including RTR memory information: memory start address of RTR transient variables, RTR transient variable size, application ID), the RTR information linked list also stores the non-volatile memory reference value corresponding to the RTR memory information. Wherein, in order to implement the RTR information linked list data structure, the non-volatile memory reference value corresponding to the RTR memory information includes not only the non-volatile memory reference value (NVM reference value) of the current node, but also two information of the linked list data structure, one is the NVM reference value (NVM_REF_PREV) of the node above the current node, and the other is the NVM reference value (NVM_REF_NEXT) of the node next to the current node. In the embodiment of the present invention, the NVM reference value of the previous node of the linked list head node is set to 0 by default, and the NVM reference value of the next node of the linked list tail node is set to 0 by default. Then the non-volatile memory reference value corresponding to the RTR variable information of the RTR information linked list head is stored in the "address information of the RTR information linked list" attribute of the application registration table.

[0100] See also Figure 4 , is a RTR transient variable and its memory information storage mapping relationship diagram provided by an embodiment of the present invention. Through the above operations, in an embodiment of the present invention, if an RTR transient variable is created, it will form the following Figure 4 The corresponding relationship between the three subsystems shown (the memory heap that allocates memory to RTR transient variables: RTR HEAP, the non-volatile member variables that store the memory addresses of RTR transient variables: NV variables, and the RTR variable information that stores the memory information of RTR transient variables), among which the memory starting address Address of the RTR transient variable in the memory heap (RTR HEAP) is used as the key value Key to associate the three.

[0101] Based on the above embodiment, in one implementation manner, the smart card RTR transient variable creation method further includes:

[0102] When the address information of the RTR information linked list does not exist in the application registration table, memory is allocated in a storage partition of a volatile memory for the target RTR transient variable to complete the creation of the target RTR transient variable;

[0103] Obtaining RTR memory information corresponding to the target RTR transient variable;

[0104] Writing the RTR memory information into the RTR information linked list to obtain address information of the RTR information linked list;

[0105] Returning the memory address of the target RTR transient variable in the RTR memory information to the application program, so that the application program writes the memory address of the target RTR transient variable into the non-volatile member variable linked list to obtain the address information of the non-volatile member variable linked list;

[0106] The address information of the RTR information linked list and the address information of the non-volatile member variable linked list are written into the application registration table.

[0107] Specifically, after the RTR HEAP memory required by the RTR transient variable is allocated successfully, the operating system kernel returns the starting address of the memory to the application. After the application determines that the RTR transient variable is created successfully, it writes the memory starting address returned by the operating system kernel into the member variable NV_ADDR to store the starting address. The memory starting address returned after each RTR transient variable is successfully created is written into the corresponding NV_ADDR member variable.

[0108] For example, the specific process of creating the RTR transient variable in this embodiment can be found in Figure 5 ,like Figure 5As shown in the figure, when the application is downloaded and installed and the system is initialized, the operating system kernel will reserve and initialize the memory heap RTR HEAP; after the application is instantiated, the operating system kernel will create and initialize the corresponding application registration table according to the application ID; it is used to subsequently store the address information of the RTR information linked list and the address information of the non-volatile member variable linked list; at this time, the application also creates and initializes non-volatile member variables in the non-volatile member variable linked list accordingly, which is used to subsequently store the memory start address of the RTR transient variable to be created; further, when the user chooses to open the application, the application will apply to create the target RTR transient variable according to business needs, and then through system calls, the operating system kernel will create a target RTR transient variable in the memory heap RTR In the HEAP, memory is allocated to the target RTR transient variable, and the memory start address Address is returned to the application. After the application determines that the RTR transient variable is created successfully, the memory start address Address returned by the operating system kernel is written into the non-volatile member variable NV_ADDR. If it is a header, the non-volatile memory reference value corresponding to the header non-volatile member variable of the non-volatile member variable linked list is written into the application registry as the address information of the non-volatile member variable linked list; at the same time, the operating system kernel allocates a memory space in the storage partition of the RTR information linked list for storing the target RT The RTR variable information corresponding to the R transient variable (including RTR memory information: the memory starting address of the RTR transient variable, the size of the RTR transient variable, and the application ID), the non-volatile memory reference value (NVM reference value) of the current node, the NVM reference value (NVM_REF_PREV) of the node above the current node, and the NVM reference value (NVM_REF_NEXT) of the next node are written into the RTR information linked list. If it is a table header, the non-volatile memory reference value corresponding to the header RTR memory information of the RTR information linked list is written into the application registration table as the address information of the RTR information linked list.

[0109] In one embodiment, the smart card RTR transient variable creation method further includes:

[0110] responding to a target RTR transient variable release request of the application;

[0111] Querying the application registration table corresponding to the application according to the application ID to obtain the address information of the non-volatile member variable linked list and the address information of the RTR information linked list;

[0112] Searching the non-volatile member variable linked list according to the address information of the non-volatile member variable linked list to obtain the memory address of the target RTR transient variable;

[0113] Searching the RTR information linked list according to the address information of the RTR information linked list, and releasing the memory space of the RTR memory information in the RTR information linked list that matches the memory address of the target RTR transient variable;

[0114] Modify the address information of the RTR information linked list and the address information of the non-volatile member variable linked list in the application registration table.

[0115] For example, the specific process of releasing the RTR transient variable in this embodiment can be found in Figure 6 ,like Figure 6 As shown in the figure, when the RTR transient variable needs to be released, the memory start address Address of the RTR transient variable stored in the corresponding NV_ADDR variable is used as the key value Key, and a release request is initiated to the operating system kernel through a system call. After receiving the request, the operating system kernel first obtains the application ID to which the request belongs, and then accesses the registry of the application to obtain the address information of the RTR variable information chain of the application, and then reads out the RTR of each node in the linked list from the head node in turn according to the non-volatile memory reference value (NVM reference value) of the RTR variable information linked list header (RTR_INFO_HEAD). Variable information, compare the memory start address of the RTR transient variable stored in the RTR memory information in the RTR variable information with the Address passed in by the system call released by the application until a match is found or the tail node of the linked list. If the match is successful, release the corresponding RTR variable information storage space in the NVM partition storage of the RTR information linked list, and synchronously modify the linked list data structure information of the previous and next nodes of the RTR variable information node in the RTR information linked list. If necessary (that is, when the header node sends a change), the address information of the RTR information chain in the application registry can be updated after the RTR variable information is successfully released.

[0116] At the same time, after the RTR variable information node is released successfully, the non-volatile member variable NV_ADDR used to store the memory start address of the RTR variable is set to the initial value (0 or all F), and then the NV_ADDR variable can be used to store the memory start address of other RTR transient variables. Since NV_ADDR is a non-volatile member variable and a member variable of the application APP class, it is actually stored in the NVM (non-volatile memory) partition, so it is not recommended to delete it and can be reused in actual use.

[0117] In one embodiment, the smart card RTR transient variable creation method further includes:

[0118] Responding to a target RTR transient variable update request of the application; the update request includes RTR new memory information of the target RTR transient variable;

[0119] Querying the application registration table corresponding to the application according to the application ID to obtain the address information of the non-volatile member variable linked list and the address information of the RTR information linked list;

[0120] Searching the non-volatile member variable linked list according to the address information of the non-volatile member variable linked list to obtain the memory address of the target RTR transient variable;

[0121] The RTR information linked list is searched according to the address information of the RTR information linked list, and the RTR memory information in the RTR information linked list that matches the memory address of the target RTR transient variable is replaced with the RTR new memory information.

[0122] For example, the specific process of updating the RTR transient variable in this embodiment can be found in Figure 7 ,like Figure 7 As shown, when the RTR variable information RTR_INFO corresponding to the RTR transient variable needs to be updated, the RTR transient variable is stored in the RTR transient variable memory starting address Address in the corresponding non-volatile member variable NV_ADDR as the key value Key, and an update request is initiated to the operating system kernel through a system call, wherein the incoming update request includes RTR new variable information (including RTR new memory information: the memory starting address NEWAddress of the RTR transient variable to be updated, and the size NEWSize of the RTR transient variable); after receiving the request, the operating system kernel first obtains the application ID to which the request belongs, and then accesses the corresponding application registry to obtain the RTR variable information linked list of the application. Header RTR_INFO_HEAD, the system reads out the RTR variable information of each node in the linked list starting from the head node, and compares the RTR transient variable memory start address stored in the RTR memory information of the RTR variable information with the Address passed in by the system call updated by the application until a match is found or the tail node of the linked list. If the match is successful, the memory start address NEWAddress of the RTR transient variable to be updated, the size NEWSize of the RTR transient variable, the application APP_ID and other information are written into the NVM partition storage space where the linked list node is located. At this time, the position change of the node in the RTR information linked list is not involved, and the NVM reference values ​​of the previous node and the next node of the node do not need to be updated.

[0123] It should be noted that, in any of the above embodiments, the target RTR transient variable is at least one of all RTR transient variables of the application.

[0124] It should be noted that in the actual usage scenarios of smart cards, the RTR transient variables that need to be created each time the application is started (non-runtime creation scenario) need to be applied to the operating system kernel for creation of these RTR transient variables each time the application is started if the application is not upgraded or the business logic has not changed.

[0125] Therefore, based on all the above embodiments, the present invention further provides a method for creating a smart card RTR transient variable, such as Figure 8 As shown, when a card reset (or power-on) event occurs, the smart card system enters the card initialization phase. At this time, after the operating system kernel completes the initialization of the RTR HEAP memory heap, it traverses all possible application IDs set by the system (for example, from 1 to APP_ID_MAX), checks the application registration table stored in the non-volatile memory (taking FLASH as an example), and reads the "address information of the RTR information linked list" RTR_INFO_HEAD. If the address information of the RTR information linked list is not empty, it proves that the application has created an RTR transient variable before the card reset (or power-on) event occurs. The system starts from the head node and reads out the contents of the RTR variable information nodes in all RTR information linked lists in sequence, including the RTR memory information, that is, the memory start address Address of the RTR transient variable, the size Size of the RTR transient variable, and the application APP_ID. Then, they are used as parameters to call the relevant interface provided by the operating system kernel to pre-apply for the memory of Size starting from Address in the RTR HEAP memory heap to prevent the memory from being used for other purposes after the system is started. After completing these pre-application operations, the system will allocate the memory space required for RTR transient variables for all applications in advance. When the smart card application is launched, it can directly access and read and write these RTR transient variables, greatly improving the efficiency of application creation.

[0126] See also Fig. 9 , an embodiment of the present invention provides a process for reading RTR transient variable information of a smart card. In any of the above embodiments, if it involves the need to read the memory information corresponding to the RTR transient variable, such as Fig. 9As shown, the RTR transient variable is stored in the RTR transient variable memory starting address Address in the corresponding non-volatile member variable NV_ADDR as the key value Key, and a read request is initiated to the operating system kernel through a system call. After receiving the request, the operating system kernel first obtains the application ID (APP_ID) to which the request belongs, and then accesses the application registry to obtain the address information of the application's RTR variable information linked list. The linked list header stores the reference value of the first RTR variable information node in the linked list in the non-volatile storage area partition. According to the reference value, the RTR variable information of each node in the linked list is read out in sequence from the head node, and the RTR transient variable memory starting address stored in the RTR variable information is compared with the Address parameter passed in by the application system call until a match is found or the tail node of the linked list is found. If the match is successful, the content stored in the RTR variable information (such as RTR memory information) is returned.

[0127] See also Fig.10 , a schematic diagram of the structure of a smart card RTR transient variable creation device provided by an embodiment of the present invention, the smart card RTR transient variable creation device comprising:

[0128] A response module 21, used for responding to a target RTR transient variable creation request of an application on the smart card when the smart card is in an initialization phase;

[0129] The address information query module 22 is used to query the application registration table corresponding to the application according to the application ID; wherein the application registration table is used to store the address information of the RTR information linked list;

[0130] An RTR memory information reading module 23 is used to search the RTR information chain table according to the address information of the RTR information chain table to obtain the RTR memory information when the address information of the RTR information chain table exists in the application registration table;

[0131] The RTR transient variable creation module 24 is used to allocate memory in a storage partition of a volatile memory for the target RTR transient variable according to the RTR memory information, so as to complete the creation of the target RTR transient variable.

[0132] As an optional embodiment, the RTR memory information reading module is further used for:

[0133] Querying the application registration table corresponding to the application according to the application ID; wherein the application registration table is also used to store address information of the non-volatile member variable linked list;

[0134] Searching the non-volatile member variable linked list according to the address information of the non-volatile member variable linked list to obtain the address information of the target RTR transient variable of the application program;

[0135] The RTR information linked list is queried according to the address information of the RTR information linked list to obtain RTR memory information matching the address information of the target RTR transient variable.

[0136] As an optional embodiment, the smart card RTR transient variable creation device further includes a second RTR transient variable creation module, which is used to:

[0137] When the address information of the RTR information linked list does not exist in the application registration table, memory is allocated in a storage partition of a volatile memory for the target RTR transient variable to complete the creation of the target RTR transient variable;

[0138] Obtaining RTR memory information corresponding to the target RTR transient variable;

[0139] Writing the RTR memory information into the RTR information linked list to obtain address information of the RTR information linked list;

[0140] Returning the memory address of the target RTR transient variable in the RTR memory information to the application program, so that the application program writes the memory address of the target RTR transient variable into the non-volatile member variable linked list to obtain the address information of the non-volatile member variable linked list;

[0141] The address information of the RTR information linked list and the address information of the non-volatile member variable linked list are written into the application registration table.

[0142] As an optional embodiment, the smart card RTR transient variable creation device further includes an RTR transient variable release module, which is used to:

[0143] responding to a target RTR transient variable release request of the application;

[0144] Querying the application registration table corresponding to the application according to the application ID to obtain the address information of the non-volatile member variable linked list and the address information of the RTR information linked list;

[0145] Searching the non-volatile member variable linked list according to the address information of the non-volatile member variable linked list to obtain the memory address of the target RTR transient variable;

[0146] Searching the RTR information linked list according to the address information of the RTR information linked list, and releasing the memory space of the RTR memory information in the RTR information linked list that matches the memory address of the target RTR transient variable;

[0147] Modify the address information of the RTR information linked list and the address information of the non-volatile member variable linked list in the application registration table.

[0148] As an optional embodiment, the smart card RTR transient variable creation device further includes an RTR transient variable updating module, which is used to:

[0149] Responding to a target RTR transient variable update request of the application; the update request includes RTR new memory information of the target RTR transient variable;

[0150] Querying the application registration table corresponding to the application according to the application ID to obtain the address information of the non-volatile member variable linked list and the address information of the RTR information linked list;

[0151] Searching the non-volatile member variable linked list according to the address information of the non-volatile member variable linked list to obtain the memory address of the target RTR transient variable;

[0152] The RTR information linked list is searched according to the address information of the RTR information linked list, and the RTR memory information in the RTR information linked list that matches the memory address of the target RTR transient variable is replaced with the RTR new memory information.

[0153] Compared with the prior art, an embodiment of the present invention provides a smart card RTR transient variable creation device that uses a non-volatile linked list to store memory-related information of RTR transient variables, so that the smart card uses this memory information to complete the pre-application of RTR transient variable memory during the system initialization phase, thereby improving the efficiency of smart card application RTR transient variable application and creation method, and providing a better user experience.

[0154] It is worth noting that the specific working process of the smart card RTR transient variable creation device can refer to the working process of the smart card RTR transient variable creation method described in the above embodiment, which will not be repeated here.

[0155] The embodiment of the present invention further provides a smart card RTR transient variable creation device, comprising a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the steps in the smart card RTR transient variable creation method embodiment are implemented, for example Figure 1or, the processor implements the functions of each module in the above-mentioned device embodiments when executing the computer program.

[0156] Exemplarily, the computer program may be divided into one or more modules, and the one or more modules are stored in the memory and executed by the processor to complete the present invention. The one or more modules may be a series of computer program instruction segments capable of completing specific functions, and the instruction segments are used to describe the execution process of the computer program in the smart card RTR transient variable creation device. For example, the computer program may be divided into multiple modules, and the specific functions of each module are as follows:

[0157] A response module 21, used for responding to a target RTR transient variable creation request of an application on the smart card when the smart card is in an initialization phase;

[0158] The address information query module 22 is used to query the application registration table corresponding to the application according to the application ID; wherein the application registration table is used to store the address information of the RTR information linked list;

[0159] An RTR memory information reading module 23 is used to search the RTR information chain table according to the address information of the RTR information chain table to obtain the RTR memory information when the address information of the RTR information chain table exists in the application registration table;

[0160] The RTR transient variable creation module 24 is used to allocate memory in a storage partition of a volatile memory for the target RTR transient variable according to the RTR memory information, so as to complete the creation of the target RTR transient variable.

[0161] The specific working process of each module can refer to the working process of the smart card RTR transient variable creation device described in the above embodiment, which will not be repeated here.

[0162] The smart card RTR transient variable creation device can be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The smart card RTR transient variable creation device may include, but is not limited to, a processor and a memory. Those skilled in the art can understand that the smart card RTR transient variable creation device may also include an input and output device, a network access device, a bus, etc.

[0163] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the smart card RTR transient variable creation device, and uses various interfaces and lines to connect various parts of the entire smart card RTR transient variable creation device.

[0164] The memory can be used to store the computer program and / or module, and the processor realizes various functions of the smart card RTR transient variable creation device by running or executing the computer program and / or module stored in the memory, and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone, etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0165] Wherein, if the module integrated in the smart card RTR transient variable creation device is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Wherein, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.

[0166] The above is a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements and modifications without departing from the principle of the present invention. These improvements and modifications are also considered to be within the scope of protection of the present invention.

Claims

1. A method for creating a smart card RTR transient variable, characterized in that: include: When the smart card is in the initialization phase, responding to a target RTR transient variable creation request of an application on the smart card; Querying an application registration table corresponding to the application according to the application ID; wherein the application registration table is used to store address information of the RTR information linked list; When the address information of the RTR information linked list exists in the application registration table, searching the RTR information linked list according to the address information of the RTR information linked list to obtain the RTR memory information; Memory is allocated in a storage partition of a volatile memory for the target RTR transient variable according to the RTR memory information to complete creation of the target RTR transient variable.

2. The smart card RTR transient variable creation method according to claim 1, characterized in that: The step of searching the RTR information linked list according to the address information of the RTR information linked list to obtain the RTR memory information includes: Querying the application registration table corresponding to the application according to the application ID; wherein the application registration table is also used to store address information of the non-volatile member variable linked list; Searching the non-volatile member variable linked list according to the address information of the non-volatile member variable linked list to obtain the address information of the target RTR transient variable of the application program; The RTR information linked list is queried according to the address information of the RTR information linked list to obtain RTR memory information matching the address information of the target RTR transient variable.

3. The smart card RTR transient variable creation method according to claim 2, characterized in that: The RTR memory information includes the memory address of the target RTR transient variable, the memory size of the target RTR transient variable, and the application ID.

4. The smart card RTR transient variable creation method according to claim 3, characterized in that: Also includes: When the address information of the RTR information linked list does not exist in the application registration table, memory is allocated in a storage partition of a volatile memory for the target RTR transient variable to complete the creation of the target RTR transient variable; Obtaining RTR memory information corresponding to the target RTR transient variable; Writing the RTR memory information into the RTR information linked list to obtain address information of the RTR information linked list; Returning the memory address of the target RTR transient variable in the RTR memory information to the application program, so that the application program writes the memory address of the target RTR transient variable into the non-volatile member variable linked list to obtain the address information of the non-volatile member variable linked list; The address information of the RTR information linked list and the address information of the non-volatile member variable linked list are written into the application registration table.

5. The smart card RTR transient variable creation method according to claim 3, characterized in that: Also includes: responding to a target RTR transient variable release request of the application; Querying the application registration table corresponding to the application according to the application ID to obtain the address information of the non-volatile member variable linked list and the address information of the RTR information linked list; Searching the non-volatile member variable linked list according to the address information of the non-volatile member variable linked list to obtain the memory address of the target RTR transient variable; Searching the RTR information linked list according to the address information of the RTR information linked list, and releasing the memory space of the RTR memory information in the RTR information linked list that matches the memory address of the target RTR transient variable; Modify the address information of the RTR information linked list and the address information of the non-volatile member variable linked list in the application registration table.

6. The smart card RTR transient variable creation method according to claim 3, characterized in that: Also includes: Responding to a target RTR transient variable update request of the application; the update request includes RTR new memory information of the target RTR transient variable; Querying the application registration table corresponding to the application according to the application ID to obtain the address information of the non-volatile member variable linked list and the address information of the RTR information linked list; Searching the non-volatile member variable linked list according to the address information of the non-volatile member variable linked list to obtain the memory address of the target RTR transient variable; The RTR information linked list is searched according to the address information of the RTR information linked list, and the RTR memory information in the RTR information linked list that matches the memory address of the target RTR transient variable is replaced with the RTR new memory information.

7. The smart card RTR transient variable creation method according to any one of claims 2 to 6, characterized in that: The non-volatile member variable linked list is a non-volatile storage linked list with a fixed node order, used to store non-volatile member variables and a non-volatile memory reference value corresponding to each non-volatile member variable; the address information of the non-volatile member variable linked list is the non-volatile memory reference value corresponding to the header non-volatile member variable of the non-volatile member variable linked list; Each of the non-volatile member variables is used to store the memory address of each RTR transient variable; The non-volatile memory reference value corresponding to each of the non-volatile member variables is constructed through a C++ class according to the definition order of the non-volatile member variables.

8. The smart card RTR transient variable creation method according to any one of claims 2 to 6, characterized in that: The RTR information linked list is a non-volatile storage linked list, which is used to store each RTR memory information and the non-volatile memory reference value corresponding to each RTR memory information; the address information of the RTR information linked list is the non-volatile memory reference value corresponding to the header RTR memory information of the RTR information linked list.

9. The smart card RTR transient variable creation method according to any one of claims 1 to 6, characterized in that: The target RTR transient variable is at least one of all RTR transient variables of the application.

10. A smart card RTR transient variable creation device, characterized in that: include: A response module, used for responding to a target RTR transient variable creation request of an application on the smart card when the smart card is in an initialization phase; An address information query module, used to query an application registration table corresponding to the application according to the application ID; wherein the application registration table is used to store address information of the RTR information linked list; An RTR memory information reading module, configured to search the RTR information linked list according to the address information of the RTR information linked list to obtain the RTR memory information when the address information of the RTR information linked list exists in the application registration table; The RTR transient variable creation module is used to allocate memory in a storage partition of a volatile memory for the target RTR transient variable according to the RTR memory information to complete the creation of the target RTR transient variable.

11. A smart card RTR transient variable creation device, characterized in that: The method comprises a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, wherein when the processor executes the computer program, the method for creating a transient variable of the RTR of a smart card according to any one of claims 1 to 9 is implemented.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored computer program, wherein when the computer program is executed, the device where the computer-readable storage medium is located is controlled to execute the smart card RTR transient variable creation method according to any one of claims 1 to 9.