A method, apparatus and device for managing a memory space of a smart card

By extracting and compiling the code to be released from the end of the data area from the COS code, and releasing it allocated to the data area during the personalization stage, the problem of insufficient smart card storage space is solved, and fine-grained management and maximization of storage space utilization are achieved.

CN120631273BActive Publication Date: 2026-06-19GUANGDONG CHUTIAN DRAGON SMART CARD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGDONG CHUTIAN DRAGON SMART CARD
Filing Date
2025-07-17
Publication Date
2026-06-19

AI Technical Summary

Technical Problem

Existing technologies offer limited space savings when optimizing smart card storage, failing to meet the ever-increasing storage demands.

Method used

The code to be released is extracted from the on-chip operating system (COS) code and executed a preset number of times only before the personalization stage. It is then compiled to the end of the data area of ​​the storage space and released and allocated to the data area based on the space release command of the host computer after the personalization stage.

Benefits of technology

Without affecting the normal operation of the smart card, the available storage space for users has been maximized, achieving refined management and optimized utilization of smart card storage space.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120631273B_ABST
    Figure CN120631273B_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, and device for managing the storage space of a smart card, applicable to the field of smart card technology. The storage space of the smart card includes a code area and a data area. The method includes extracting code to be released from the COS code based on a preset code extraction strategy. The code to be released is code that will only be executed 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. The space to be released is released based on a space release command sent by a host computer. The released code to be released area is allocated to the data area of ​​the storage space. This method can solve the problem of limited code space savings in current methods for optimizing the storage space of smart cards.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of smart card technology, and in particular to a method, apparatus and device for managing the storage space of a smart card. Background Technology

[0002] Smart cards, as a type of integrated circuit card, are widely used in finance, telecommunications, transportation, and other fields. The size of their storage space directly affects their functionality and performance. With the continuous expansion of smart card application scenarios, the demand for smart card storage space is also constantly increasing. However, smart cards have limited storage space, and how to implement more functions within this limited space has become a crucial issue in smart card design.

[0003] Currently, the main method for optimizing smart card storage space is code optimization. For example, code refactoring and extracting common function trees maximize code reuse to reduce redundancy. Furthermore, optimization features provided by compiler tools, such as code compression and removal of unused code segments, can be used to further reduce the storage space occupied by the code. However, while these methods can save code space to some extent, the space saved is very limited and cannot meet the ever-increasing storage demands. Summary of the Invention

[0004] The purpose of this application is to provide a method, apparatus, and device for managing the storage space of a smart card, thereby solving the problem that current methods for optimizing the storage space of smart cards have limited code space savings.

[0005] In a first aspect, embodiments of this application provide a method for managing the 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 code to be released from the chip operating system (COS) code based on a preset code extraction strategy. The code to be released is code that will only be executed a preset number of times before the smart card is personalized. The code to be released is compiled into a code area to be released using a compilation tool, and the storage space occupied by the code to be released is calculated. The code area to be released is located at the end of the data area. The code area to be released is released based on a space release command sent by a host computer. The released code area to be released is allocated to the data area of ​​the storage space.

[0006] The smart card storage space management method provided in this application extracts code that is executed only a preset number of times before the personalization stage and compiles it into a code-to-be-released area at the end of the data area of ​​the smart card's storage space. After the code to be released in this code-to-be-released area is executed, the code-to-be-released area is released based on a space release command sent by the host computer, and the released code-to-be-released area is allocated to the data area. This method can release and allocate the storage space corresponding to code that is executed only a preset number of times before the personalization stage to the data area without affecting the normal execution of the smart card's code. This can maximize the user's available space, thereby achieving fine-grained management of the smart card's storage space and maximizing the utilization rate of the smart card's storage space.

[0007] One possible implementation involves extracting the code to be released from the COS code based on a preset code extraction strategy. This includes: obtaining the initialization code to be released from the COS code. The initialization code to be released is code used only during card initialization. Next, obtaining the pre-personalized code to be released from the COS code. The pre-personalized code to be released is code used only during the card pre-personalization stage.

[0008] One possible implementation involves the following initialization code to be released: at least one of the following functions: space management table initialization function, main security domain installation function, initialization state function, and chip hardware function detection function. The pre-personalized code to be released includes: private file creation function and default initial data.

[0009] One possible implementation involves using a compiler to compile the code to be released into the code area to be released, which includes: placing the code to be released in a preset file; and using a compiler to distribute and load the function code in the preset file into the code area to be released.

[0010] One possible implementation includes: initialization code to be released and pre-personalized code to be released. The step of placing the code to be released in preset files 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 the compiled storage space of the first preset file and the compiled storage space of the second preset file. The storage space occupied by the code to be released is calculated based on the compiled storage space of the first preset file and the compiled storage space of the second preset file.

[0011] One possible implementation involves releasing the space of the code area to be released based on a space release command sent by the host computer, including: based on the space release command sent by the host computer,

[0012] Based on the calculated starting address of the code area to be released and the storage space occupied by the code to be released, the code to be released is marked as unavailable.

[0013] One possible implementation involves releasing the storage space occupied by the code to be released, based on the calculated starting address of the code area to be released and the size of the storage space occupied by the code. The steps include: 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 and the original starting address; and modifying the initial value of the smart card's storage space management table 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 the storage space.

[0014] Secondly, embodiments of this application provide 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.

[0015] The extraction module is used to extract the code to be released from the COS code based on a preset code extraction strategy. The code to be released is the code that will be executed only a preset number of times before the smart card is personalized.

[0016] The calculation module is used to compile the code to be released into the code-to-be-released area using the compilation tools, and to calculate the storage space occupied by the code to be released. The code-to-be-released area is located at the end of the data area.

[0017] The release module is used to release the space of the code area to be released based on the space release command sent by the host computer.

[0018] The allocation module is used to allocate the released code area to the data area of ​​the storage space.

[0019] Thirdly, embodiments of this 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 thereof. This function can be implemented by hardware or by hardware executing corresponding software. The hardware or software includes one or more modules corresponding to the above-described function.

[0020] Fourthly, embodiments of this application provide a computer-readable storage medium storing instructions that, when executed on a computer, enable the computer to perform the smart card storage space management method described in the first aspect or any possible implementation thereof.

[0021] Fifthly, embodiments of this application provide a computer program product containing instructions that, when run on a computer, enable the computer to execute the smart card storage space management method described in the first aspect or any possible implementation thereof.

[0022] The technical effects of any of the second to fifth aspects can be referred to the technical effects of the possible implementations in the first aspect, and will not be repeated here. Attached Figure Description

[0023] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0024] Figure 1 A schematic diagram of a smart card storage space management system provided in an embodiment of this application;

[0025] Figure 2 A specific example diagram of the storage space of a smart card provided in an embodiment of this application;

[0026] Figure 3 A flowchart illustrating a method for managing the storage space of a smart card, as provided in an embodiment of this application;

[0027] Figure 4 A specific example diagram showing the location distribution of the compiled code to be released in the code segment, as provided in an embodiment of this application;

[0028] Figure 5 A specific example diagram of a smart card storage space management method provided in this application embodiment;

[0029] Figure 6 Another specific example diagram of a smart card storage space management method provided in this application embodiment;

[0030] Figure 7 A schematic diagram of a smart card storage space management device provided in an embodiment of this application;

[0031] Figure 8 This is another schematic diagram of a smart card storage space management system provided in an embodiment of this application. Detailed Implementation

[0032] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. The components of the embodiments of this application described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.

[0033] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

[0034] Currently, the primary approach to optimizing smart card storage space is code optimization. This can include code refactoring and extracting common functions. Code refactoring involves organizing and improving existing code, optimizing its structure without altering its functionality. For example, repetitive code snippets can be integrated into a single, universal function, or complex nested structures can be broken down into multiple simpler functions, thus simplifying the code and reducing redundancy. Extracting common functions involves identifying identical or similar code sections across multiple modules or functions, extracting them as independent common functions for use in different places, maximizing code reuse, and effectively reducing the overall code size.

[0035] Furthermore, the optimization features provided by compiler tools can be used to optimize the storage space of smart cards. For example, these optimization features can include code compression and removal of unused code segments. Code compression shortens variable names, function names, and other names in the code, removing unnecessary spaces and comments, thus reducing the space occupied during storage. Removing unused code segments optimizes storage space usage by identifying functions, variable declarations, etc., that are written into the codebase but are never called during actual operation.

[0036] However, while these methods can save code space to some extent, the space saved is relatively limited.

[0037] Based on this, embodiments of this application provide a method, apparatus, and device for managing the 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 code to be released from the chip operating system (COS) code based on a preset code extraction strategy. The code to be released is code that the smart card executes only a preset number of times before the personalization stage. The code to be released is compiled into a code area to be released using a compilation tool, and the storage space occupied by the code to be released is calculated. The code area to be released is located at the end of the data area. The code area to be released is released based on a space release command sent by a host computer. The released code area to be released is allocated to the data area of ​​the storage space.

[0038] The smart card storage space management method provided in this application extracts code that is executed only a preset number of times before the personalization stage and compiles it into a code-to-be-released area at the end of the data area of ​​the smart card's storage space. After the code to be released in this code-to-be-released area is executed, the code-to-be-released area is released based on a space release command sent by the host computer, and the released code-to-be-released area is allocated to the data area. This method can release and allocate the storage space corresponding to code that is executed only a preset number of times before the personalization stage to the data area without affecting the normal execution of the smart card's code. This can maximize the user's available space, thereby achieving fine-grained management of the smart card's storage space and maximizing the utilization rate of the smart card's storage space.

[0039] The solutions provided in the embodiments of this application will now be described in conjunction with the accompanying drawings.

[0040] First, the various operational stages related to the smart card and COS software in the embodiments of this application will be described. The operational stages related to 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 usage stage.

[0041] The smart card operating system code is downloaded to the smart card chip using a download tool during the COS code download phase. The card initialization phase occurs when the smart card is first powered on after the COS code download is complete. During card initialization, the smart card system space is initialized, including managing the space management table, installing the main security domain, and setting the card's initial state. After card initialization, a pre-personalization phase follows, allowing for file management, such as file creation and content updates. In the personalization phase, the smart card can be customized based on user or application needs, such as writing personal information or configuring application parameters. The user usage phase is the daily operation phase of the smart card, during which it interacts with various card readers to perform corresponding functions.

[0042] On the one hand, embodiments of this application provide a storage space management system for smart cards. For example... Figure 1 As shown, the smart card's storage space management system 100 may include: a compilation tool 101, a host computer 102, and a smart card 103. The smart card's storage space includes a code area and a data area. The code area to be released is located at the end of the data area of ​​the smart card's storage space and is used to store code extracted from the COS code that meets preset conditions.

[0043] The compilation tool 101 is responsible for compiling the code. Specifically, the compilation tool 101 can extract the code to be released from the COS code based on a preset code extraction strategy and compile it into the code to be released area of ​​the smart card's storage space.

[0044] The preset code extraction strategy specifically involves extracting code that is executed only a preset number of times before the personalization stage.

[0045] The host computer 102 is used to send space release commands.

[0046] Specifically, the host computer 102 can send a space release command to the smart card after the smart card completes a specific stage, so that the smart card can release the code area to be released in the storage space. It should be noted that the space release command can be sent by the host computer to the smart card after a certain stage of the smart card's operation related to the COS software has been completed. In this application, the space release command is sent to the smart card after the personalization stage is completed.

[0047] The smart card 103 is used to receive space release commands sent by the host computer 102 and execute corresponding space release and allocation actions. Specifically, after receiving the space release command sent by the host computer, the smart card 103 releases the space of the code area to be released based on the space release command, and allocates the released code area to the data area of ​​the storage space.

[0048] It should be noted that the above Figure 1 The illustrated smart card storage space management system 100 is merely an example of the application scenario of this application solution and is not intended to limit the application scenario of this application solution.

[0049] On the other hand, this application provides a smart card 103. Figure 2 This is a specific example diagram of the smart card's storage space. For example... Figure 2 As shown, the storage space of the smart card 103 may include a code area 201, a data area 202, a code area to be released 203, and a page backup and transaction area 204.

[0050] Code section 201 stores the code for the smart card operating system (COS). This code may include, for example, initialization, installation of the primary security domain, setting the card's initial state, file creation, file content updates, security authentication, encryption algorithms, and communication protocols.

[0051] Data area 202 is used to store data generated by the smart card during operation, such as user data, application data, and system data.

[0052] The code to be released area 203 is used to temporarily store the code to be released from the smart card. The code to be released is code that will only be executed a preset number of times before personalization. The code to be released may include the initialization code to be released and the pre-personalization code to be released.

[0053] Page backup and transaction area 204 is used to store copies of the original data of pages modified during write or update operations. This ensures that the original data of the modified pages can be restored in a timely manner if the write or update operation fails. Page backup and transaction area 204 is also used to store intermediate results and related status information of transactions during complex operations or transactions. This ensures that transactions are completely successful or completely rolled back during execution, avoiding inconsistent data states.

[0054] On the one hand, embodiments of this application provide a method for managing the storage space of a smart card, which can be implemented by... Figure 1 The smart card's storage space management system 100 is executed. For example... Figure 3 As shown, the method may include the following steps.

[0055] S301 extracts the code to be released from the COS code based on a preset code extraction strategy.

[0056] The preset code extraction strategy can determine the running stage, the specific execution stage of the code, and the number of times the code is executed based on the smart card and COS software.

[0057] Specifically, the preset code extraction strategy can be to extract the code to be released from the code area of ​​the smart card. This code to be released is a code that the smart card will only execute a preset number of times before the personalization stage.

[0058] In this embodiment, the preset code extraction strategy can be to extract code from the smart card's code area that will be executed only a preset number of times before the personalization stage.

[0059] For example, the code to be released may include initialization code to be released and pre-personalized code to be released. The initialization code to be released may include at least one function selected from the following: space management table initialization function, main security domain installation function, initialization state function, and chip hardware function detection function. The pre-personalized code to be released may include: private file creation function and default initial data.

[0060] The space management table initialization function can be used to manage the smart card's storage space. The smart card only executes this space management table initialization function during the card initialization phase to write the maximum available space to the smart card; for example, this space management table initialization function can correspond to the code e2p_table_init().

[0061] The primary security domain installation function can be used to install the primary security domain. This primary security domain installation function is executed only during the card initialization phase; for example, the primary security domain installation function can be represented by the code install_isd().

[0062] The initialization state function can be used to set the card's initialization state. This initialization state function is executed only during the card initialization phase, and its corresponding code is set_card_init().

[0063] The private file creation function can be used for file management on smart cards. The smart card only executes this private file creation function to create files during the pre-personalization phase; the corresponding code is `create_p_file()`.

[0064] One possible implementation is to obtain the initialization code and pre-personalized code to be released from the COS code based on a preset code extraction strategy.

[0065] Specifically, based on the preset code extraction strategy, the space management table initialization function, main security domain installation function, initialization state function, chip hardware function detection function, private file creation function, and default initial data can be extracted from the COS code as code to be released.

[0066] like Figure 4 As shown, Figure 4 This diagram illustrates the location distribution of the compiled code to be released within the code segment. The original function e2p_table_init() is compiled to address @A and has a size of size_A; install_isd() is compiled to address @B and has a code size of size_B; set_card_init() is compiled to address @C and has a code size of size_C; and create_p_file() is compiled to address @D and has a code size of size_D.

[0067] It should be noted that the initialization code and pre-personalization code to be released provided in the embodiments of this application are merely examples of the code to be released, and are not a specific limitation on the code to be released. The code to be released may also be other code that is executed only a preset number of times before the personalization stage.

[0068] S302, use the compiler to compile the code to be released into the code to be released area, and calculate the storage space occupied by the code to be released.

[0069] The code area to be released is located at the end of the data area.

[0070] One possible implementation is to place the code to be released in a pre-defined file for easier management. The compiler then uses tools to distribute and load the functions from the pre-defined file into the code to be released section.

[0071] 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. The compiler is used to place the addresses of the initialization function code to be released in the first preset file into the code to be released section, and the addresses of the pre-personalized function code to be released in the second preset file into the code to be released section. Finally, the storage space of each function after compilation in the first preset file and the storage space of each function after compilation in the second preset file are calculated to determine the total storage space occupied by the code to be released.

[0072] For example, such as Figure 5As shown, 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. A scatter loading method is used to position the functions in these two files at the end of the data area. The address of e2p_table_init() becomes @A', the address of install_isd() becomes @B', the address of set_card_init() becomes @C', and the address of create_p_file() becomes @D'.

[0073] Based on the sizes of e2p_table_init(), install_isd(), set_card_init(), and create_p_file(), the size of the code segment to be freed can be calculated as size_free = size_A + size_B + size_C + size_D, and the starting address of the code segment to be freed can be determined as @free_code.

[0074] Furthermore, after distributing and loading the functions in the preset file into the code area to be released, the initial value of the smart card's space management table is modified so that the space with the starting address @free_code and the size of size_free is not included in the initial space management scope, in order to prevent this area from being allocated as a data area.

[0075] S303 releases the space of the code area to be released based on the space release command sent by the host computer.

[0076] Specifically, space release instructions can be implemented using the E2P_free() function. By inputting 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 can be performed starting from the specified starting address and the storage space occupied by the code to be released. 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.

[0077] One possible implementation is that the space release instruction releases the storage space occupied by the code to be released based on the starting address of the code segment to be released.

[0078] Specifically, after the smart card completes the pre-personalization stage, the host computer sends a space release command to the smart card. For example, this space release command can be sent from the host computer to the smart card after the smart card's file system is created during the pre-personalization stage, and the smart card receives the space release command.

[0079] After receiving the space release command, the smart card uses the COS to release the code area stored at the end of the data area according to the preset calculated start address to be released and the size of the storage space.

[0080] When a smart card performs a space release operation on the code area to be released stored at the end of the data area, it can use the E2P_free() function to allocate the code area to be released to the data area after the space release operation is performed.

[0081] Specifically, the initial address of the data area is obtained. Then, based on the starting address to be released 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 the storage space. This process, by adjusting various parameters in the storage space management table, ensures that the smart card can correctly identify and manage new storage space allocations.

[0082] S304 allocates the released code area to the data area of ​​the storage space.

[0083] Specifically, after the space release command sent by the host computer releases the space of the code area to be released, the smart card allocates the released storage space to the data area.

[0084] For example, such as Figure 6 As shown, the space release instruction releases the code area to be released, starting at address @free_code and occupying a storage space of size_free. After the space is released, the smart card's space management table is modified to allocate the released storage space to the data area.

[0085] This process maximizes the user's available space by releasing and allocating the storage space corresponding to the code that is executed only a preset number of times before the personalization stage to the data area. This enables fine-grained management of the smart card's storage space and optimizes its utilization rate.

[0086] The above primarily describes the solutions provided in this application from the perspective of the device's working principle. It is understood that, in order to achieve the above functions, the smart card's storage space management device includes corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that, based on the algorithm steps of the examples described in conjunction with the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0087] This application embodiment can divide the smart card storage space management device into functional modules according to the above method example. For example, each function can be divided into a separate functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module.

[0088] It should be noted that the module division in this embodiment is illustrative and represents only one logical functional division; in actual implementation, other division methods may be used. When dividing functional modules according to their respective functions, Figure 7 A schematic diagram illustrating a possible configuration of the smart card's storage space management device described above and in the embodiments is shown. Figure 7 As shown, the smart card storage space management device 700 may include: an extraction module 701, a calculation module 702, a release module 703, and an allocation module 704.

[0089] The extraction module 701 is used to support the execution of the smart card's storage space management device 700. Figure 3 S301 in the illustrated smart card storage space management method.

[0090] The computing module 702 is used to support the execution of the smart card's storage space management device 700. Figure 3 S302 in the illustrated smart card storage space management method.

[0091] Release module 703 is used to support the execution of the smart card's storage space management device 700. Figure 3 S303 in the illustrated smart card storage space management method.

[0092] Allocation module 704 is used to support the execution of the smart card's storage space management device 700. Figure 3 S304 in the illustrated smart card storage space management method.

[0093] One possible implementation is that the smart card storage space management device provided in this application embodiment can be used to obtain the initialization code to be released from the COS code. The initialization code to be released is code used only during the card initialization process. The device also obtains the pre-personalization code to be released from the COS code. The pre-personalization code to be released is code used only during the card pre-personalization stage.

[0094] One possible implementation involves the following initialization code to be released: at least one of the following functions: space management table initialization function, main security domain installation function, initialization state function, and chip hardware function detection function. The pre-personalized code to be released includes: private file creation function and default initial data.

[0095] One possible implementation is that the smart card storage space management device provided in this application embodiment can place the code to be released in a preset file. A compilation tool is then used to distribute and load the function code from the preset file into the code to be released area.

[0096] One possible implementation is that the code to be released includes: initialization code to be released and pre-personalized code to be released. Specifically, the smart card storage space management device provided in this application embodiment can place the initialization code to be released in a first preset file and the pre-personalized code to be released in a second preset file. Specifically, the smart card storage space management device provided in this application embodiment can calculate the storage space after compilation of the first preset file and the storage space after compilation of the second preset file. The storage space occupied by the code to be released is calculated based on the storage space after compilation of the first preset file and the storage space after compilation of the second preset file.

[0097] One possible implementation is that the smart card storage space management device provided in this application embodiment can be based on the calculated starting address of the code area to be released and Storage space occupied by code to be released This releases the storage space occupied by the code to be released.

[0098] In one possible implementation, the smart card storage space management device provided in this application embodiment 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 to be released of the data area is determined. Based on the starting address to be released, the initial value of the smart card's storage space management table is modified so that the storage space occupied by the code to be released is allocated to the data area. The space management table is used to manage the storage space.

[0099] It should be noted that all relevant content of each step involved in the above method embodiments can be referenced from the functional description of the corresponding functional module, and will not be repeated here.

[0100] The smart card storage space management device 700 provided in this application embodiment is used to perform the above-mentioned... 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.

[0101] This application also provides a smart card storage space management device, which can execute the smart card storage space management method and related steps in the above method embodiments.

[0102] This application also provides a computer-readable storage medium storing instructions thereon, which, when executed, perform the smart card storage space management method and related steps in the above method embodiments.

[0103] This application also provides a computer program product that, when run on a computer, causes the computer to execute the smart card storage space management method and related steps described in the above method embodiments.

[0104] In some embodiments, the methods shown in this application can 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 art.

[0105] This application embodiment also provides a smart card storage space management system 100, such as... Figure 8 As shown, the smart card's storage space management system 100 includes at least one processor 801 and at least one interface circuit 802.

[0106] As an example, when the smart card's storage management system 100 includes a processor and an interface circuit, the processor can be... Figure 8 The processor 801 shown in the solid box (or the processor 801 shown in the dashed box) can be an interface circuit. Figure 8 The interface circuit 802 is shown in the solid box (or the interface circuit 802 shown in the dashed box). When the smart card's storage management system 100 includes two processors and two interface circuits, then the two processors include... Figure 8 The processor 801 shown in the solid box and the processor 801 shown in the dashed box, these two interface circuits include Figure 8 Interface circuit 802 is shown in both solid and dashed boxes. No limitations are imposed on this.

[0107] Processor 801 and interface circuit 802 can be interconnected via a line. For example, interface circuit 802 can be used to receive signals. Alternatively, interface circuit 802 can be used to send signals to other devices (e.g., processor 801). For instance, interface circuit 802 can read computer instructions stored in memory and send those instructions to processor 801. Processor 801 executes the instructions and, in conjunction with input / output devices, implements the various steps in the above embodiments, such as implementing... Figures 3-6 The steps performed in any of the method embodiments shown herein. Of course, the smart card's storage space management system may also include other discrete components, and this application embodiment does not specifically limit this.

[0108] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above 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.

[0109] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0110] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0111] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0112] If the integrated unit is implemented as 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 embodiments of this application, or the part that contributes to it, or all or part of the technical solution, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0113] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for managing a memory space of a smart card, characterized in that, The smart card's storage space includes a code area and a data area, and the method includes: The code to be released is extracted from the COS code based on a preset code extraction strategy; the code to be released is the code that is executed only a preset number of times before the smart card is in the personalization stage. The code to be released is compiled into the code area to be released using a compilation tool, and the storage space occupied by the code to be released is calculated; the code area to be released is located at the end of the data area; Based on the space release command sent by the host computer, the original starting address of the data area is obtained; according to the storage space occupied by the code to be released and the original starting address, the starting address to be released of the data area 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 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; the code to be released is marked as unavailable. The released code area is allocated to the data area of ​​the storage space.

2. The method of claim 1, wherein, The step of extracting the code to be released from the COS code based on a preset code extraction strategy includes: Obtain the initialization code to be released from the COS code; the initialization code to be released is code used only during card initialization. Obtain the pre-personalized code to be released from the COS code; the pre-personalized code to be released is code used only in the card pre-personalization stage.

3. The method of claim 2, wherein, The initialization code to be released includes at least one of the following functions: space management table initialization function, main security domain installation function, initialization state function, and 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 of claim 1, wherein, The step of compiling the code to be released into the code-to-release area using a compilation tool includes: Place the code to be released in a preset file; The compiler is used to distribute and load the function code from the preset file into the code area to be released.

5. The method of claim 4, wherein, The code to be released includes: initialization code to be released and pre-personalized code to be released; The step of placing the code to be released in a preset file includes: The 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; The step of calculating the storage space occupied by the code to be released includes: 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 compilation of the first preset file and the storage space after compilation of the second preset file.

6. A memory space management apparatus of a smart card, characterized by comprising: The smart card's storage space includes a code area and a data area, and the device includes: The extraction module is used to extract the code to be released from the COS code based on a preset code extraction strategy; the code to be released is the code that is executed only a preset number of times before the smart card is in the personalization stage; The calculation module is used to compile the code to be released into the code area to be released using compilation tools, and to 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; The release module is used to obtain the original starting address of the data area based on the space release command sent by the host computer; determine the starting address to be released of the data area according to the storage space occupied by the code to be released and the original starting address; modify the initial value of the 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 the storage space; and mark the code to be released as unavailable. The allocation module is used to allocate the released code area to the data area of ​​the storage space.

7. A memory space management device for a smart card, characterized in that The smart card storage space management device includes a processor and a memory, the memory storing machine-executable instructions that can be executed by the processor, and the processor executing the machine-executable instructions to implement the smart card storage space management method according to any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the storage space management method of the smart card according to any one of claims 1 to 5.