Method, device and equipment for managing storage space of intelligent card
By extracting and compiling the to-be-released code from the COS code to the end of the data area and releasing it to the data area during the personalization phase, the problem of insufficient storage space in the smart card is solved and efficient use of storage space is achieved.
Patent Information
- Application Number
- CN202510989014.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-17
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-07-17
AI Technical Summary
When optimizing the storage space of smart cards, the existing technology saves limited space and cannot meet the growing storage demand.
By extracting the code to be released that is executed only a preset number of times before the personalization stage from the on-chip operating system (COS) code, compiling it to the end of the data area of the storage space, and releasing it and allocating it to the data area based on the space release instruction of the host computer after the personalization stage.
Without affecting the normal execution of the smart card, the user's available space is maximized, and the refined management and utilization optimization of the smart card storage space are achieved.
Smart Images

Figure CN120631273A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of smart card technology, and in particular to a method, apparatus, and device for managing storage space of a smart card. Background Art
[0002] Smart cards, as integrated circuit cards, are widely used in finance, communications, transportation, and other fields. The size of their storage space directly affects their functionality and performance. As smart card applications continue to expand, the demand for smart card storage space is also increasing. However, smart card storage space is limited, and how to implement more functions within this limited storage space has become a key issue in smart card design.
[0003] Currently, smart card storage space optimization primarily relies on code optimization. For example, code refactoring and common function tree refinement maximize code reuse to reduce code redundancy. Furthermore, compiler tool optimization features, such as code compression and removal of unused code segments, can be leveraged to further reduce code storage space. However, while these methods can reduce code space to a certain extent, the savings are very limited and cannot meet the growing storage needs. Summary of the Invention
[0004] The purpose of this application is to provide a method, device and equipment for managing the storage space of a smart card, so as to solve the problem that the current method for optimizing the storage space of a smart card saves limited code space.
[0005] In a first aspect, an embodiment of the present application provides a method for managing storage space of a smart card, wherein the storage space of the smart card includes a code area and a data area. The method comprises: extracting code to be released from the on-chip operating system (COS) code based on a preset code extraction strategy. The code to be released is code that is executed only a preset number of times before the smart card is personalized. A compilation tool is used to compile the code to be released into the code to be released area, and the storage space occupied by the code to be released is calculated. The code to be released area is located at the end of the data area. Space in the code to be released area is released based on a space release instruction sent by a host computer. The released code to be released area is allocated to the data area of the storage space.
[0006] The storage space management method for a smart card provided in an embodiment of the present application extracts code that is executed only a preset number of times before the personalization phase and compiles it into a to-be-released code area at the end of the data area of the smart card's storage space. After the to-be-released code in the to-be-released code area is executed, the to-be-released code area is released based on a space release instruction sent by a host computer, and the released to-be-released code area is allocated to the data area. This method can release and allocate the storage space corresponding to the code that is executed only a preset number of times before the personalization phase to the data area without affecting the normal execution of the smart card's code, thereby maximizing the user's available space, thereby achieving refined management of the smart card's storage space and maximizing the utilization of the smart card's storage space.
[0007] In one possible implementation, the step of extracting the code to be released from the COS code based on a preset code extraction strategy includes: obtaining an initialization code to be released from the COS code. The initialization code to be released is a code used only during the card initialization process; and obtaining a pre-personalization code to be released from the COS code. The pre-personalization code to be released is a code used only during the card pre-personalization stage.
[0008] In one possible implementation, the initialization code to be released includes at least one of: a space management table initialization function, a primary security domain installation function, an initialization state function, and a chip hardware function detection function. The pre-personalization code to be released includes a private file creation function and default initial data.
[0009] A possible implementation method is to use a compilation tool to compile the code to be released into the code area to be released, including: placing the code to be released in a preset file; and using the compilation tool to scatter-load the function code in the preset file into the code area to be released.
[0010] In one possible implementation, the code to be released includes: an initialization code to be released and a pre-personalized code to be released. Placing the code to be released in a preset file includes: placing the initialization code to be released in a first preset file and placing the pre-personalized code to be released in a second preset file. Calculating the storage space occupied by the code to be released includes: calculating the storage space after compiling the first preset file and the storage space after compiling the second preset file. The storage space occupied by the code to be released is calculated based on the storage space after compiling the first preset file and the storage space after compiling the second preset file.
[0011] A possible implementation method is to release the space of the code area to be released based on the space release instruction sent by the host computer, including: based on the space release instruction sent by the host computer, According to the calculated starting address of the to-be-released code area and the size of the storage space occupied by the to-be-released code, the to-be-released code is marked as unavailable.
[0012] In one possible implementation, based on the calculated starting address of the code area to be released and the amount of storage space occupied by the code to be released, the step of releasing the storage space occupied by the code to be released includes: obtaining the original starting address of the data area; determining the starting address of the data area to be released based on the storage space occupied by the code to be released and the original starting address; and modifying the initial value of a space management table of the smart card's storage space based on the starting address to be released so as to allocate the storage space occupied by the code to be released to the data area. The space management table is used to manage storage space.
[0013] In a second aspect, an embodiment of the present application provides a storage space management device for a smart card. The storage space of the smart card includes a code area and a data area. The device includes: an extraction module, a calculation module, a release module and an allocation module.
[0014] The extraction module is used to extract the to-be-released code from the COS code based on a preset code extraction strategy. The to-be-released code is a code that is executed only a preset number of times before the personalization phase of the smart card.
[0015] The calculation module is used to use a compilation tool to compile the code to be released into the code area to be released, and calculate the storage space occupied by the code to be released. The code area to be released is located at the end of the data area.
[0016] The release module is used to release the space of the code area to be released based on the space release instruction sent by the host computer.
[0017] The allocation module is used to allocate the released code area to the data area of the storage space.
[0018] In a third aspect, embodiments of the present application provide a smart card storage space management device, which has the function of implementing the smart card storage space management method of the first aspect or any possible implementation of the first aspect. This function can be implemented in hardware, or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above-mentioned functions.
[0019] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores instructions. When the computer-readable storage medium is run on a computer, the computer can execute the storage space management method of the smart card of the above-mentioned first aspect or any possible implementation method of the first aspect.
[0020] In a fifth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the storage space management method of a smart card according to the first aspect or any possible implementation method.
[0021] Among them, the technical effects brought about by any implementation method in the second to fifth aspects can refer to the technical effects brought about by the possible implementation method in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the following is a brief introduction to the drawings required for use in the specific implementation methods or the description of the prior art. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0023] Figure 1 A schematic structural diagram of a storage space management system for a smart card provided in an embodiment of the present application; Figure 2 A specific example diagram of a storage space of a smart card provided in an embodiment of the present application; Figure 3 A flowchart of a method for managing storage space of a smart card provided in an embodiment of the present application; Figure 4 A specific example diagram of the position distribution of the compiled code to be released in the code area provided in an embodiment of the present application; Figure 5 A specific example diagram of a storage space management method for a smart card provided in an embodiment of the present application; Figure 6 Another specific example diagram of a storage space management method for a smart card provided in an embodiment of the present application; Figure 7 A schematic structural diagram of a storage space management device for a smart card provided in an embodiment of the present application; Figure 8 This is another structural diagram of a storage space management system for a smart card provided in an embodiment of the present application. DETAILED DESCRIPTION
[0024] To make the objectives, technical solutions, and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Generally, the components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations.
[0025] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for protection, but merely represents selected embodiments of the present application. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments in the present application without creative work are within the scope of protection of the present application.
[0026] Currently, code optimization is the primary approach to optimizing smart card storage space. For example, code optimization solutions can include code refactoring and extracting common functions. Code refactoring organizes and improves existing code, optimizing its structure without changing its original functionality. For example, repetitive code snippets can be consolidated into a common function, or complex nested structures can be split into multiple simple functions, streamlining the code and reducing redundancy. Extracting common functions involves identifying identical or similar code sections across multiple modules or functions, extracting them into independent common functions that can be called from different locations, maximizing code reuse and effectively reducing the total code footprint.
[0027] In addition, you can utilize the optimization features provided by the compilation tool to optimize smart card storage space. For example, these optimization features can include code compression and removal of unused code segments. Code compression shortens variable and function names in the code, removing unnecessary spaces and comments, and reducing the code's storage space. Removing unused code segments optimizes storage space by identifying function and variable declarations that are written into the code base but never called during actual execution and removing these unused code segments.
[0028] However, although these methods can save code space to a certain extent, the space saved is relatively limited.
[0029] Based on this, embodiments of the present application provide a method, apparatus, and device for managing storage space of a smart card. The storage space of the smart card includes a code area and a data area. The method includes: extracting to-be-released code from the on-chip operating system (COS) code based on a preset code extraction strategy. The to-be-released code is code that is executed only a preset number of times by the smart card before the personalization phase. A compilation tool is used to compile the to-be-released code into the to-be-released code area, and the storage space occupied by the to-be-released code is calculated. The to-be-released code area is located at the end of the data area. Space in the to-be-released code area is released based on a space release instruction sent by a host computer. The released to-be-released code area is allocated to the data area of the storage space.
[0030] The storage space management method for a smart card provided in an embodiment of the present application extracts code that is executed only a preset number of times before the personalization phase and compiles it into a to-be-released code area at the end of the data area of the smart card's storage space. After the to-be-released code in the to-be-released code area is executed, the to-be-released code area is released based on a space release instruction sent by a host computer, and the released to-be-released code area is allocated to the data area. This method can release and allocate the storage space corresponding to the code that is executed only a preset number of times before the personalization phase to the data area without affecting the normal execution of the smart card's code, thereby maximizing the user's available space, thereby achieving refined management of the smart card's storage space and maximizing the utilization of the smart card's storage space.
[0031] The solution provided by the embodiments of the present application will be described below with reference to the accompanying drawings.
[0032] First, the various operating stages of the smart card and COS software in the embodiments of the present application are described. The operating stages of the smart card and COS software may include the COS code download stage, the card initialization stage, the pre-personalization stage, the personalization stage, and the user use stage.
[0033] Among them, in the COS code download stage, the smart card operating system code can be downloaded to the smart card chip through the download tool. The card initialization stage is executed when the smart card is powered on for the first time after the COS code download is completed in the COS code download stage. In the card initialization stage, the smart card system space can be initialized, such as managing the space management table, installing the main security domain, and setting the initial state of the card. After the card initialization stage is completed, the pre-personalization stage is carried out. In the pre-personalization stage, the smart card files can be managed, such as creating files and updating file contents. In the personalization stage, the smart card can be customized based on user needs or application needs, such as writing user personal information or configuring application parameters of characteristics, etc. The user use stage is the daily operation stage of the smart card. In the user use stage, the smart card can interact with a variety of card reading devices to perform corresponding functions.
[0034] On the one hand, the embodiment of the present application provides a storage space management system for a smart card. Figure 1 As shown, the smart card storage space management system 100 may include: a compilation tool 101, a host computer 102, and a smart card 103. The smart card storage space includes a code area and a data area. The to-be-released code area is located at the end of the data area of the smart card storage space and is used to store the to-be-released code that meets preset conditions extracted from the COS code.
[0035] The compilation tool 101 is responsible for compiling the code. Specifically, the compilation tool 101 can extract the code to be released that meets the conditions from the COS code based on a preset code extraction strategy, and compile it into the code area to be released in the storage space of the smart card.
[0036] The preset code extraction strategy is specifically: extracting codes that are executed only a preset number of times before the personalization stage.
[0037] The host computer 102 is used to send a space release instruction.
[0038] Specifically, the host computer 102 may send a space release instruction to the smart card after the smart card completes a specific stage, causing it to release the code area in the storage space to be released. It should be noted that the space release instruction may be sent by the host computer to the smart card after a stage of the smart card and COS software operation phase is completed. In the present application, the space release instruction is sent to the smart card after the personalization stage is completed.
[0039] Smartcard 103 is configured to receive a space release instruction from host computer 102 and execute corresponding space release and allocation operations. Specifically, upon receiving the space release instruction from host computer 102, smartcard 103 releases space in the code area to be released based on the space release instruction and allocates the released code area to the data area of the storage space.
[0040] It should be noted that the above Figure 1 The illustrated smart card storage space management system 100 is merely an example of an application scenario of the present application solution, and is not intended to limit the application scenario of the present application solution.
[0041] On the other hand, an embodiment of the present application provides a smart card 103. Figure 2 FIG. 1 is a specific example diagram of the storage space of the smart card. Figure 2 As shown, the storage space of the smart card 103 may include a code area 201 , a data area 202 , a to-be-released code area 203 , and a page backup and transaction area 204 .
[0042] The code area 201 is used to store the smart card operating system (COS) code. For example, the code may include initialization, installation of the primary security domain, setting the initial state of the card, file creation, file content update, security authentication, encryption algorithm, and communication protocol.
[0043] The data area 202 is used to store data generated during the operation of the smart card, such as user data, application data, and system data.
[0044] The code area 203 is used to temporarily store the code to be released of the smart card. The code to be released is a code that is executed only a preset number of times before personalization. The code to be released may include an initialization code to be released and a pre-personalization code to be released.
[0045] Page backup and transaction area 204 is used to store copies of the original data of modified pages during write or update operations. This ensures that the original data of the modified pages can be promptly restored if the write or update operation fails. Page backup and transaction area 204 is also used to store intermediate transaction results and related status information during complex operations or transactions. This ensures that transactions are completely successful or rolled back during execution, preventing inconsistent data states.
[0046] On the one hand, the embodiment of the present application provides a method for managing storage space of a smart card, which can be Figure 1 The storage space management system 100 of the smart card shown is executed. Figure 3 As shown, the method may include the following steps.
[0047] S301: Extract the code to be released from the COS code based on a preset code extraction strategy.
[0048] The preset code extraction strategy may be determined based on the operation phase related to the smart card and the COS software, the specific execution phase of the code, and the number of execution times of the code.
[0049] Specifically, the preset code extraction strategy may be to extract a to-be-released code from the code area of the smart card, wherein the to-be-released code is a code that is executed only a preset number of times by the smart card before the personalization phase.
[0050] In this embodiment, the preset code extraction strategy may be to extract a code that has only been executed a preset number of times before the personalization stage from the code area of the smart card.
[0051] Exemplarily, the code to be released may include initialization code to be released and pre-personalization code to be released. The initialization code to be released may include at least one of: a space management table initialization function, a primary security domain installation function, an initialization state function, and a chip hardware function detection function. The pre-personalization code to be released may include: a private file creation function and default initial data.
[0052] The space management table initialization function can be used to manage the storage space of the smart card. The smart card only writes the current maximum available space to the smart card by executing the space management table initialization function during the card initialization phase. For example, the space management table initialization function can correspond to the code e2p_table_init().
[0053] The main security domain installation function can be used to install the main security domain. This main security domain installation function is only executed during the card initialization phase. For example, the main security domain installation function can correspond to the code install_isd().
[0054] The initialization state function can be used to set the card initialization state. This initialization state function is only executed during the card initialization phase and corresponds to the code set_card_init().
[0055] The private file creation function can be used to manage files on the smart card. The smart card only creates files by executing the private file creation function in the pre-personalization stage. The private file creation function can correspond to the code create_p_file().
[0056] One possible implementation is to obtain the to-be-released initialization code and pre-personalization code from the COS code based on a preset code extraction strategy.
[0057] Specifically, based on the preset code extraction strategy, the space management table initialization function, the main security domain installation function, the initialization status function, the chip hardware function detection function, the private file creation function and the default initial data can be extracted from the COS code as the code to be released.
[0058] like Figure 4 As shown, Figure 4 This diagram illustrates the distribution of the code to be released after compilation. The original function e2p_table_init() is compiled to address @A and size size_A; install_isd() is compiled to address @B and size size_B; set_card_init() is compiled to address @C and size size_C; and create_p_file() is compiled to address @D and size size_D.
[0059] It should be noted that the initialization code to be released and the pre-personalization code to be released provided in the embodiment of the present application are only examples of the code to be released, and are not specific limitations on the code to be released. The code to be released can also be other codes that are executed only before the personalization stage and only for a preset number of times.
[0060] S302: Use a compilation tool to compile the code to be released into a code area to be released, and calculate the storage space occupied by the code to be released.
[0061] The code area to be released is located at the end of the data area.
[0062] One possible implementation method is to place the code to be released in a preset file for easy management, and use a compilation tool to scatter-load the functions in the preset file into the code area to be released.
[0063] Specifically, the extracted initialization code to be released is placed in a first preset file, and the pre-personalized code to be released is placed in a second preset file. A compilation tool is used to place the addresses of the initialization function code to be released in the first preset file in the code-to-be-released area, and the addresses of the pre-personalized function code to be released in the second preset file in the to-be-released area. Finally, the storage space occupied by each compiled function in the first preset file and each compiled function in the second preset file is calculated to determine the total storage space occupied by the code to be released.
[0064] For example, Figure 5As shown in the following example, the extracted functions e2p_table_init(), install_isd(), and set_card_init() are placed in the first preset file, first_power.c, and create_p_file() is placed in the second preset file, create_p_file.c. Use scatter-loading files to locate the functions in these two files at the end of the data area. The function address of e2p_table_init() becomes @A', the function address of install_isd() becomes @B', the function address of set_card_init() becomes @C', and the function address of create_p_file() becomes @D'.
[0065] Based on the sizes of e2p_table_init(), install_isd(), set_card_init(), and create_p_file(), we can calculate the size of the code area to be released as size_free = size_A + size_B + size_C +size_D, and determine the starting address of the code area to be released as @free_code.
[0066] Furthermore, after each function in the preset file is scattered and loaded into the code area to be released, the initial value of the space management table of the smart card is modified so that the starting address is @free_code and the space occupied by size_free is not included in the initial space management range to prevent the area from being allocated as a data area.
[0067] S303: releasing space in the code area to be released based on the space release instruction sent by the host computer.
[0068] Specifically, the space release instruction can be implemented using the E2P_free() function. By entering the specific starting address to be released and the storage space occupied by the code to be released in E2P_free(), the space release operation is performed on the storage space occupied by the code to be released, starting from the starting address. For example, the starting address to be released in E2P_free() can be @free_code, and the storage space occupied by the code to be released can be size_free.
[0069] In a possible implementation, the space release instruction releases the storage space occupied by the code to be released based on the starting address of the code area to be released.
[0070] Specifically, after the smart card completes the pre-personalization phase, the host computer sends a space release instruction to the smart card. For example, the space release instruction can be sent from the host computer to the smart card after the file system of the smart card is created during the pre-personalization phase, and the smart card receives the space release instruction.
[0071] After receiving the space release instruction, the COS of the smart card performs a space release operation on the code area to be released stored at the end of the data area according to the preset calculated start address to be released and the storage space size.
[0072] When the smart card performs a space release operation on the code area to be released stored at the end of the data area, the E2P_free() function can be used to allocate the code area to be released to the data area after the space release operation is performed.
[0073] Specifically, the original starting address of the data area is obtained. Based on the starting address and the size of the space to be released, the initial values of the smart card's storage space management table are modified to allocate the storage space occupied by the code to be released to the data area. The space management table is used to manage storage space. This process, by adjusting the various parameters in the storage space management table, ensures that the smart card can correctly identify and manage the new storage space allocation.
[0074] S304: Allocate the released code area to be released to the data area of the storage space.
[0075] Specifically, after releasing the space in the code area to be released based on the space release instruction sent by the host computer, the smart card allocates the released storage space to the data area.
[0076] For example, Figure 6 As shown in FIG. 1 , the space release instruction is used to release the code area whose starting address is @free_code and the storage space occupied by the code is size_free. After the space is released, the space management table of the smart card is modified to allocate the released storage space to the data area.
[0077] This process can maximize the user's available space by releasing the storage space corresponding to the code that is executed only a preset number of times before the personalization stage and allocating it to the data area, thereby achieving refined management of the smart card's storage space and maximizing the utilization of the smart card's storage space.
[0078] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the working principle of the device. It can be understood that in order to realize the above functions, the storage space management device of the smart card includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily realize that, in combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0079] In the embodiments of the present application, the storage space management device of the smart card can be divided into functional modules according to the above-mentioned method example. For example, different functional modules can be divided according to different functions, or two or more functions can be integrated into a single processing module. The above-mentioned integrated modules can be implemented in the form of hardware or software functional modules.
[0080] It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. In actual implementation, there may be other division methods. Figure 7 FIG. 1 shows a possible schematic diagram of the composition of the storage space management device of the smart card involved in the above and embodiments. Figure 7 As shown, the storage space management device 700 of the smart card may include: an extraction module 701 , a calculation module 702 , a release module 703 and an allocation module 704 .
[0081] The extraction module 701 is used to support the smart card storage space management device 700 to execute Figure 3 S301 in the storage space management method of the smart card is shown.
[0082] The computing module 702 is used to support the smart card storage space management device 700 to execute Figure 3 S302 in the storage space management method of the smart card is shown.
[0083] Release module 703, used to support the smart card storage space management device 700 to execute Figure 3 S303 in the storage space management method of the smart card is shown.
[0084] Allocation module 704, used to support the smart card storage space management device 700 to execute Figure 3 S304 in the storage space management method of the smart card is shown.
[0085] In one possible implementation, the smart card storage space management device provided in an embodiment of the present application can be specifically configured to obtain the initialization code to be released from the COS code. The initialization code to be released is used only during the card initialization process. The pre-personalization code to be released is obtained from the COS code. The pre-personalization code to be released is used only during the card pre-personalization phase.
[0086] In one possible implementation, the initialization code to be released includes at least one of: a space management table initialization function, a primary security domain installation function, an initialization state function, and a chip hardware function detection function. The pre-personalization code to be released includes a private file creation function and default initial data.
[0087] In a possible implementation, the storage space management device for a smart card provided in an embodiment of the present application may specifically place the code to be released in a preset file and use a compilation tool to disperse and load the function code in the preset file into the code area to be released.
[0088] In one possible implementation, the code to be released includes: an initialization code to be released and a pre-personalized code to be released. The storage space management device for a smart card provided in an embodiment of the present application can specifically place the initialization code to be released in a first preset file and place the pre-personalized code to be released in a second preset file. The storage space management device for a smart card provided in an embodiment of the present application can specifically calculate the storage space after compiling the first preset file and the storage space after compiling the second preset file. The storage space occupied by the code to be released is calculated based on the storage space after compiling the first preset file and the storage space after compiling the second preset file.
[0089] In a possible implementation, the storage space management device of the smart card provided in the embodiment of the present application can be specifically based on the calculated starting address of the code area to be released and The amount of storage space occupied by the code to be released , release the storage space occupied by the code to be released.
[0090] In one possible implementation, the storage space management device for a smart card provided in an embodiment of the present application can specifically obtain the original starting address of the data area. Based on the storage space occupied by the code to be released and the original starting address, the starting address of the data area to be released is determined. Based on the starting address to be released, the initial value of the space management table of the smart card's storage space is modified to allocate the storage space occupied by the code to be released to the data area. The space management table is used to manage storage space.
[0091] It should be noted that all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module and will not be repeated here.
[0092] The storage space management device 700 of the smart card provided in the embodiment of the present application is used to perform the above Figure 3 The storage space management method of the smart card shown can therefore achieve the same effect as the storage space management method of the smart card described above.
[0093] An embodiment of the present application further provides a storage space management device for a smart card, which can execute the storage space management method and related steps of the smart card in the above method embodiment.
[0094] An embodiment of the present application further provides a computer-readable storage medium having instructions stored thereon, which, when executed, execute the storage space management method and related steps of the smart card in the above method embodiment.
[0095] An embodiment of the present application further provides a computer program product, which, when executed on a computer, enables the computer to execute the storage space management method and related steps of the smart card in the above method embodiment.
[0096] In some embodiments, the methods described herein may be implemented as computer program instructions encoded in a machine-readable format on a computer-readable storage medium or on other non-transitory media or articles of manufacture.
[0097] The embodiment of the present application also provides a smart card storage space management system 100, such as Figure 8 As shown, the storage space management system 100 of the smart card includes at least one processor 801 and at least one interface circuit 802 .
[0098] As an example, when the storage space management system 100 of the smart card includes a processor and an interface circuit, the processor may be Figure 8 The processor 801 shown in the solid line frame (or the processor 801 shown in the dotted line frame) may be Figure 8 The interface circuit 802 shown in the solid line frame (or the interface circuit 802 shown in the dotted line frame). When the storage space management system 100 of the smart card includes two processors and two interface circuits, the two processors include Figure 8 The processor 801 shown in the solid line frame and the processor 801 shown in the dotted line frame, the two interface circuits include Figure 8 The interface circuit 802 shown in the solid line frame and the interface circuit 802 shown in the dotted line frame are not limited to this.
[0099] The processor 801 and the interface circuit 802 can be interconnected via a line. For example, the interface circuit 802 can be used to receive signals. For another example, the interface circuit 802 can be used to send signals to other devices (such as the processor 801). For example, the interface circuit 802 can read computer instructions stored in the memory and send the computer instructions to the processor 801. The processor 801 executes the instructions and, in conjunction with the input and output devices, implements the various steps in the above embodiments, such as implementing Figure 3-Figure 6 Of course, the storage space management system of the smart card may also include other discrete components, which is not specifically limited in the embodiments of the present application.
[0100] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0101] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0102] The units described as separate components may or may not be physically separate, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0103] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0104] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the contributing part or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0105] The above content is only a specific embodiment of this application, but the scope of protection of this application is not limited to this. Any changes or replacements within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
Claims
1. A method for managing storage space of a smart card, characterized in that: The storage space of the smart card includes a code area and a data area, and the method includes: Extracting a code to be released from the COS code based on a preset code extraction strategy; the code to be released is a code that is executed only a preset number of times before the personalization stage of the smart card; Compiling the code to be released into a code area to be released using a compilation tool, and calculating the storage space occupied by the code to be released; the code area to be released is located at the end of the data area; Release the space of the code area to be released based on the space release instruction sent by the host computer; Allocate the released code area to be released to the data area of the storage space.
2. The method according to claim 1, characterized in that The step of extracting the code to be released from the COS code based on the preset code extraction strategy includes: Obtaining an initialization code to be released from the COS code; the initialization code to be released is a code used only during the card initialization process; A pre-personalized code to be released is obtained from the COS code; the pre-personalized code to be released is a code used only in the card pre-personalized stage.
3. The method according to claim 2, characterized in that The initialization code to be released includes: at least one function among a space management table initialization function, a main security domain installation function, an initialization state function, and a chip hardware function detection function; The pre-personalized code to be released includes: a private file creation function and default initial data.
4. The method according to claim 1, wherein The step of using a compilation tool to compile the code to be released into the code area to be released includes: Placing the code to be released in a preset file; Use a compilation tool to scatter-load the function codes in the preset file into the code area to be released.
5. The method according to claim 4, characterized in that The code to be released includes: an initialization code to be released and a pre-personalized code to be released; The step of placing the code to be released in a preset file includes: Placing the initialization code to be released in a first preset file, and placing the pre-personalized code to be released in a second preset file; The step of calculating the storage space occupied by the code to be released includes: Calculating a storage space after compiling the first preset file and a storage space after compiling the second preset file; The storage space occupied by the to-be-released code is calculated based on the storage space after the first preset file is compiled and the storage space after the second preset file is compiled.
6. The method according to claim 1, characterized in that The step of releasing space in the code area to be released based on the space release instruction sent by the host computer includes: Based on the space release instruction sent by the host computer, the storage space occupied by the code to be released is released according to the calculated starting address of the code area to be released and the size of the storage space occupied by the code to be released, and the code to be released is marked as unavailable.
7. The method according to claim 6, characterized in that The step of releasing the storage space occupied by the code to be released based on the calculated starting address of the code to be released area and the size of the storage space occupied by the code to be released comprises: Obtaining the original starting address of the data area; Determining the to-be-released starting address of the data area according to the storage space occupied by the to-be-released code and the original starting address; Based on the start address to be released, the initial value of the space management table of the storage space of the smart card is modified so as to allocate the storage space occupied by the code to be released to the data area; the space management table is used to manage the storage space.
8. A storage space management device for a smart card, characterized in that: The storage space of the smart card includes a code area and a data area, and the device includes: An extraction module, configured to extract a to-be-released code from the COS code based on a preset code extraction strategy; the to-be-released code is a code that is executed only a preset number of times on the smart card before the personalization stage; a calculation module, configured to use a compilation tool to compile the code to be released into a code area to be released, and calculate the storage space occupied by the code to be released; the code area to be released is located at the end of the data area; A release module is used to release space in the code area to be released based on a space release instruction sent by a host computer; An allocation module is used to allocate the released code area to the data area of the storage space.
9. A storage space management device for a smart card, characterized in that: The storage space management device of the smart card includes a processor and a memory, the memory stores machine-executable instructions that can be executed by the processor, and the processor executes the machine-executable instructions to implement the storage space management method of the smart card according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the storage space management method for a smart card according to any one of claims 1 to 7.
Citation Information
Patent Citations
Storage space recovery method for intelligent card
CN107729260A
Source code compiling method, executable file running method and terminal equipment
CN111767056A
Data updating method and device of intelligent card, equipment and storage medium
CN118426814A
Method for supporting oversized source code file compiling based on antlr tool
CN118939276A
IC card issuing system, and IC card issuing method
JP2008158715A