Application downloading method and device, intelligent card and medium
By building the application method structure and platform function interface structure in the NativeCOS smart card operating system, generating application scripts and installing target applications, the problem that smart card applications cannot be dynamically installed or updated is solved, and the flexibility of smart card is improved.
Patent Information
- Application Number
- CN202411728698.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-28
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2044-11-28
AI Technical Summary
Existing smart cards use the NativeCOS operating system, and their applications are pre-installed before leaving the factory, resulting in users being unable to install or update applications dynamically, and lacking flexibility.
Provides an application download method, by building the application method structure and platform function interface structure in NativeCOS, compiling and assigning the address of the target application project, generating application scripts, and installing the target application on the smart card, realizing post-download of the smart card application.
It realizes dynamic installation and update of smart card applications, improves the flexibility of smart cards, and meets the needs of users to install different applications according to their needs.
Smart Images

Figure CN119645522A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of smart card operating systems, and in particular to an application downloading method, device, smart card and medium. Background Art
[0002] In the prior art, applications on smart cards using NativeCOS are usually pre-installed in NativeCOS before leaving the factory, which means that the functions of smart cards using NativeCOS are fixed after leaving the factory, which makes it impossible for users to install or update applications according to their needs. Summary of the invention
[0003] In view of this, the embodiments of the present application provide an application downloading method, device, smart card and medium, which can realize post-download of smart card applications and improve the flexibility of the smart card.
[0004] In a first aspect, an embodiment of the present application provides an application download method, the application download method is applied to an application of NativeCOS, the NativeCOS includes a file system, the file system includes a security domain directory and an application module directory; the method includes:
[0005] Obtaining a target application project, and assigning an address to the target application project in a flash area;
[0006] Compiling the target application project to obtain an executable file of the target application project;
[0007] Constructing an application method structure and a platform function interface structure based on the function of the target application project, wherein the target application project calls the application method in the application method structure based on the platform function interface structure;
[0008] Obtaining the starting address and identification information of the target application project, constructing an application module parameter structure based on the starting address, identification information and application method structure of the target application project, compiling the application module parameter structure, and placing the compiled application module parameter structure into an executable file of the target application project;
[0009] Receive an application script sent by an external device, execute instructions in the application script, register the identification information in the security domain directory, create an application module directory, and create a target application directory in the application module directory; wherein the application script is obtained by converting the executable file through the preset conversion tool;
[0010] The application module parameter structure is obtained based on the start address of the target application project, the target application is installed based on the application method structure, and the installation data of the target application is stored in the target application directory.
[0011] In some embodiments, there are multiple target application projects;
[0012] The allocating addresses for the target application projects in the flash area includes: allocating unique storage addresses for each target application project in the flash area.
[0013] In some embodiments, the application method structure includes: an application installation method, an application selection method, an application deselection method, an application instruction processing method, an application deletion method, an application multiple selection method, a multiple selection application recommendation method, and an application sharing method;
[0014] The platform function interface structure includes: a communication processing interface, an application registration and callback interface, a checksum operation interface, a key management interface, a key pair management interface, a cryptographic operation interface, a hash operation interface, a random number generation interface, a signature calculation interface and a PIN management interface.
[0015] In some embodiments, the method further includes a process of converting the executable file into an application script based on a preset conversion tool, specifically:
[0016] The preset conversion tool obtains the executable file of the target application project based on the file path selected by the user, and determines whether the executable file corresponding to the file path is in a preset format;
[0017] In the case where it is determined that the executable file corresponding to the file path is in a preset format, receiving package identification information input by a user, and verifying whether the package identification information is legal;
[0018] In the case where the package identification information is legal, the executable file of the target application project corresponding to the file path is converted into an application script.
[0019] In some embodiments, the name of the application script includes the package identification information, the application script includes installation instructions, and before executing the installation instructions in the application script, the method further includes:
[0020] Based on the package identification information in the application script name, it is determined whether the flash area has the same package identification information. If not, the installation instruction is executed; otherwise, an error is reported.
[0021] In some embodiments, the application script further includes a plurality of download instructions; the step of executing the instructions in the application script to register the identification information in the security domain directory includes:
[0022] Execute the first download instruction of the application script, cache the data meta tag, read the first write address corresponding to the first download instruction, and write the executable file data in the first download instruction into the first write address;
[0023] Determine whether there is a next download instruction. If so, continue to execute the next download instruction, read the next write address corresponding to the next download instruction, and write the executable file data in the next download instruction into the next write address. If not, register the package identification information and the module identification information under the security domain directory.
[0024] In some embodiments, the application module parameter structure further includes an application initialization method, the method further includes:
[0025] The target application project is selected based on the application selection method in the application method structure, and the interface library address corresponding to the platform function interface structure is passed to the target application project through the initialization application method, so that the target application project calls the registration callback function of the interface library to pass the application method in the application method structure to the NativeCOS.
[0026] In a second aspect, an embodiment of the present application provides an application downloading device based on NativeCOS, wherein the application downloading device is applied to an application of NativeCOS, wherein the NativeCOS includes a file system, wherein the file system includes a security domain directory and an application module directory; the device includes:
[0027] An address allocation module is used to obtain a target application project and allocate an address to the target application project in a flash area;
[0028] An executable file generation module, used for compiling the target application project to obtain an executable file of the target application project;
[0029] A structure construction module, used to construct an application method structure and a platform function interface structure based on the function of the target application project, wherein the target application project calls the application method in the application method structure based on the platform function interface structure;
[0030] The structure construction module is further used to obtain the starting address and identification information of the target application project, construct an application module parameter structure based on the starting address, identification information and the application method structure of the target application project, compile the application module parameter structure, and place the compiled application module parameter structure into the executable file of the target application project;
[0031] an application script execution module, configured to receive an application script sent by an external device, execute instructions in the application script, register the identification information in the security domain directory, create an application module directory, and create a target application directory in the application module directory; wherein the application script is obtained by converting the executable file through the preset conversion tool;
[0032] The application installation module is used to obtain the application module parameter structure based on the starting address of the target application project, install the target application based on the application method structure, and store the installation data of the target application in the target application directory.
[0033] In a third aspect, an embodiment of the present application provides a smart card, comprising a processor and a memory, wherein the memory stores a computer program, and the processor is used to execute the computer program to implement the above-mentioned application downloading method.
[0034] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium storing a computer program, which, when executed on a processor, implements the above-mentioned application downloading method.
[0035] The embodiments of the present application have the following beneficial effects: the embodiments of the present application first compile the target application project to obtain the executable file of the target application project, then construct the application method structure and the platform function interface structure in NativeCOS based on the functions of the target application project in advance, and further construct the application module parameter structure, and compile the application module parameter structure and place it in the executable file, compile the executable file through an external device to generate an application script, and then send it to NativeCOS, NativeCOS receives the application script sent by the external device, executes the instructions in the application script, and registers the identification information in the security domain directory, creates an application module directory, and then creates a target application directory under the application module directory, and when installing the target application, installs the corresponding target application according to the application method structure in the corresponding application module parameter structure. Through the method of the present application, it is possible to dynamically install or update applications according to demand after the smart card leaves the factory, thereby improving the flexibility of installing or updating smart card applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0037] Figure 1 A schematic diagram of a file system in an embodiment of the present application is shown;
[0038] Figure 2 A first flow chart of the application downloading method according to an embodiment of the present application is shown;
[0039] Figure 3 A second flow chart of the application downloading method according to an embodiment of the present application is shown;
[0040] Figure 4 A first schematic diagram of application script generation according to an embodiment of the present application is shown;
[0041] Figure 5 A second schematic diagram of application script generation according to an embodiment of the present application is shown;
[0042] Figure 6 A third flow chart of the application downloading method according to an embodiment of the present application is shown;
[0043] Figure 7 A structural schematic diagram of an application downloading device according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0044] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments.
[0045] The components of the embodiments of the present application generally described and shown in the drawings herein may be arranged and designed in various configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0046] Hereinafter, the terms "including", "having" and their cognates that can be used in various embodiments of the present application are intended only to indicate specific features, numbers, steps, operations, elements, components or a combination of the foregoing items, and should not be understood as first excluding the existence of one or more other features, numbers, steps, operations, elements, components or a combination of the foregoing items or increasing the possibility of one or more features, numbers, steps, operations, elements, components or a combination of the foregoing items. In addition, the terms "first", "second", "third" and the like are only used to distinguish descriptions and cannot be understood as indicating or implying relative importance.
[0047] Unless otherwise defined, all terms (including technical terms and scientific terms) used herein have the same meanings as those generally understood by those skilled in the art to which the various embodiments of the present application belong. The terms (such as those defined in generally used dictionaries) will be interpreted as having the same meanings as the contextual meanings in the relevant technical field and will not be interpreted as having idealized meanings or overly formal meanings unless clearly defined in the various embodiments of the present application.
[0048] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0049] In the prior art, the applications of smart cards using NativeCOS (Native Card Operating System) are usually pre-installed before leaving the factory, which leads to poor flexibility of smart cards (users cannot dynamically install or update applications according to needs) and poor user experience (users need to purchase multiple smart cards to meet different application scenarios, which increases costs and management difficulties). For example, a user has a bank card, which initially only has payment-related applications installed on it. However, the user later finds that he also needs to use the transportation card function, but the bank card cannot be installed with new transportation applications. Therefore, the user has to purchase a new smart card to use as a transportation card, which not only increases the user's cost, but also increases the difficulty of managing the smart card for the user.
[0050] Based on this, the present application proposes an application downloading method, so that after the smart card leaves the factory, the user can dynamically install or update the application in the smart card according to the needs.
[0051] Before describing the application downloading method of NativeCOS according to the embodiment of the present application, NativeCOS according to the embodiment of the present application is described first.
[0052] like Figure 1As shown, NativeCOS includes a file system 10, which is used to support various application functions, such as installation, loading, and deletion of application packages, installation and deletion of applications, application selection, and establishment of secure channels. Specifically, NativeCOS runs on a smart card, and the flash area of the smart card is divided into a data management area 20 and a code management area 30; wherein, the data management area 20 includes a security domain directory 40 and an application module directory 50, that is, the data in the data management area 20 are all stored in the form of directory files, which facilitates data isolation between applications. The data in the application module directory 50 is the data generated after NativeCOS downloads and installs the application; the data in the security domain directory 40 is the data generated by the preset specification function supported by nativeCOS, which is used to manage and maintain the internal structure and security mechanism of the smart card. If the smart card supports the GP function, the data in the security domain directory 40 is the data generated by the GP function supported by nativeCOS. The code management area 30 includes an operating system function interface library; wherein the operating system function interface library includes structures (application method structure, platform function interface structure, application module parameter structure, etc.) for installing the smart card application.
[0053] The main directory includes a security domain directory 40 and an application module directory 50; the security domain directory 40 includes a main security domain directory, and the data in the main security domain directory is the data created after the smart card is powered on for the first time, including but not limited to a registry file, a main security domain key file, a loading package management file, an application module management file, and an audit data file. Among them, under the main security domain directory, the registry file will store the life cycle of the smart card, the information of the loaded applications (including application identification, application installation quantity, life cycle and permissions, etc., the corresponding application module directory number, the directory number in the application module directory), and the data element tag; the main security domain key file is a record file, and the main security domain key file may include multiple records, such as 8 records, the first record is a management record, the subsequent 7 records store keys, 2-4 records store a group of security channel keys respectively, and 5-8 records are reserved and not used for the time being; the management record on the main security domain will have the first three bytes as the default security channel key version number and counter, and the subsequent data is in the format of: key version + counter + key type + key ID + key length, the key record stores the key value + check, and the secure channel key stores three key values + check; the loading package management file is used to manage the loading package (executable file package) information, loading file identification, file start address and end address, and the maximum number of loading file information that can be loaded can be limited in the package management file, such as it can be limited to a maximum of four loading file information that can be stored in the loading package management file; the application module management file is used to manage application module information, application module identification, application module directory number, application module start address, instance directory map (that is, the application instance directory number information corresponding to the application module, there can be multiple instance directory numbers), and matches the loading package management information; the audit data file is used to manage abnormal audit data records.
[0054] The number of application module directories 50 can be determined according to the number specified in the loading package management file. For example, if the loading package management file specifies that a maximum of four loading file information can be stored, then a maximum of four application module directories 50 can be created, corresponding to four application executable files (loading files). Multiple applications can be created under each application module directory 50, but the total number of applications is limited to eight. In addition, each application module directory 50 corresponds to an auxiliary security domain directory. If a maximum of four application module directories 50 are created, then a maximum of four auxiliary security domain directories are also created.
[0055] Among them, the application module directory 50 is a directory file created when the executable file is loaded successfully. When the application is installed through the application module, an application directory will be created under the application directory file. The files under the application directory include but are not limited to default files, nvm (non-volatile data object) record files, nvm management files, dtr / rtr (volatile data, RTR data type, data will be lost after the card is reset, DTR data type) management files, and dtr / rtr key management files.
[0056] The application downloading method is described below in conjunction with some specific embodiments.
[0057] Figure 2 A schematic diagram of a flow chart of an application download method according to an embodiment of the present application is shown. Exemplarily, the application download method includes the following steps:
[0058] Step S100, obtaining a target application project, and allocating an address for the target application project in a flash area.
[0059] Among them, the target application project is the application project of the smart card to be developed. After the requirements and functions of the target application are determined, the target application project includes writing source code and resources according to the functions and requirements of the target application to generate an application that can run on the smart card.
[0060] After the target application project is determined, a fixed address is allocated to the corresponding target application project in the flash area of NativeCOS, that is, the starting address and the ending address of the corresponding target application project in the flash area are defined in the flash area to store the relevant data of the corresponding target application project.
[0061] If there are multiple target application projects, allocate a corresponding area in the flash area for each target application project, and define the start address and end address of each target application project in the flash area. Ensure that the storage address allocated to each target application project in the flash area is unique to avoid storage address conflicts.
[0062] Step S200, compile the target application project to obtain an executable file of the target application project.
[0063] When compiling the target application project, you must first determine the development environment and programming language. After determining the functions and requirements that need to be implemented by the programming language according to the target application project, write the code. After the code is written, run the corresponding compilation instructions to generate an executable file.
[0064] Step S300: construct an application method structure and a platform function interface structure based on the functions of the target application project.
[0065] In this step, when building a local target application project, first define the application method structure and platform function interface structure according to the functions and requirements of the target application project, and then provide the defined application method structure and platform function interface structure to the target application project for application development. The target application project can only call the interface provided by NativeCOS, and the target application project calls the application method in the application method structure through the provided platform function interface structure.
[0066] Among them, Figure 3 As shown, the application method structure includes but is not limited to an application installation method, an application selection method, an application withdrawal method, an application instruction processing method, an application deletion method, an application multiple selection method, a multiple selection application recommendation method and an application sharing method.
[0067] The construction of the application method structure is as follows:
[0068] typedef struct appletInfo{
[0069] selectFunc selectMethod; / / Application selection method
[0070] deselectFunc deselectMethod; / / Apply deselect method
[0071] processFunc processMethod; / / Application instruction processing method
[0072] uninstallFunc uninstallMethod; / / Application deletion method
[0073] mulSelectFunc mulSelectMethod; / / Apply multiple selection method
[0074] mulDeselectFunc mulDeselectMethod; / / Multiple selection application deselection method
[0075] getSccLibInterface getSccLibInterfaceMethod; / / Application sharing method
[0076] }appletInfo; / / Application method structure
[0077] like Figure 4As shown, the platform function interface structure includes but is not limited to a communication processing interface, an application registration and callback interface, a checksum operation interface, a key management interface, a key pair management interface, a cryptographic operation interface, a hash operation interface, a random number generation interface, a signature calculation interface, and a PIN management interface.
[0078] The platform function interface structure is constructed as follows:
[0079]
[0080]
[0081] Step S400, obtaining the starting address and identification information of the target application project, constructing an application module parameter structure based on the starting address, identification information and application method structure of the target application project, compiling the application module parameter structure, and placing the compiled application module parameter structure into the executable file of the target application project.
[0082] The application module parameter structure is mainly used to organize and store key information about the application module so as to effectively manage and use the corresponding application module in the system. In order to accurately locate the location of the corresponding application module in the flash area, the starting address of the corresponding target application project defined in step S100 in the flash area needs to be obtained when constructing the application module parameter structure.
[0083] The identification information includes but is not limited to the application module identifier and the associated security domain identifier. Among them, the application module identifier is a string used to uniquely identify an application module. In the development of smart card applications, the application module identifier is usually used to distinguish different application modules to ensure that each application module has a unique identifier; when constructing the application module parameter structure, the application module identifier is constructed in the application module parameter structure, and the configuration information or execution code of the corresponding application module can be quickly located through the application module identifier. The associated security domain identifier is used to associate the security domain to which each application module belongs, which helps the system to perform fine-grained security management of the application module and ensure that the application module runs within the security domain to which it belongs. By associating the security domain identifier, the system can better control the permissions of the application module, such as which modules can access specific resources, perform specific operations, etc. Therefore, the associated security domain identifier is usually also included when constructing the application module parameter structure.
[0084] Based on this, when constructing the application module parameter structure, the application method structure, the starting address, the application module identifier and the associated security domain identifier of the corresponding target application module need to be used together to construct the application module parameter structure; in addition, in order to ensure the correctness and efficiency of the identifier processing, when constructing the application module parameter structure, the application module identifier length and the associated security domain identifier length can also be included. Therefore, the constructed application module parameter structure includes the application method structure, the starting address, the application module identifier, the application module identifier length, the application module identifier and the application module identifier length, and after the application module parameter structure is constructed, the application module parameter structure is compiled, and the compiled application module parameter structure is placed in the executable file of the target application project, usually the compiled application module parameter structure is placed in the starting position (file header position) of the executable file of the target application project, so that the system can immediately access these key information when loading the executable file without additional search or reading operations; and placing the module parameter structure at the starting position of the executable file also helps to maintain the continuity of the memory layout and reduce the complexity of memory fragmentation and page tables.
[0085] In some implementations, the application module parameter structure further includes an initialization application method, the method further includes:
[0086] The target application project is selected based on the application selection method in the application method structure, and the interface library address corresponding to the platform function interface structure is passed to the target application project by initializing the application method, so that the target application project calls the registration callback function of the interface library to pass the application method in the application method structure to NativeCOS.
[0087] It can be understood that when the target application project receives the application selection instruction, the initialization application method is called; in the initialization application method, the target application project receives the starting address of the interface library provided by NativeCOS, and finds the specific registration callback function according to this address; then the application method implemented by the target application project is passed to NativeCOS. In this way, communication interaction is achieved between the target application project and NativeCOS. The target application project registers its own methods in NativeCOS through the initialization application method, so that NativeCOS can call these methods when needed, thereby realizing functional expansion and interaction.
[0088] Step S500, receiving an application script sent by an external device, executing instructions in the application script, registering identification information in a security domain directory, creating an application module directory, and creating a target application directory in the application module directory.
[0089] The external device is a terminal device that can communicate with NativeCOS, and the application script is obtained by converting the executable file through a preset conversion tool installed on the external device.
[0090] For example, Figure 3 As shown in the figure, the process of converting an executable file into an application script based on a preset conversion tool is as follows:
[0091] Step S10: The preset conversion tool obtains the executable file of the target application project based on the file path selected by the user, and determines whether the executable file corresponding to the file path is in a preset format.
[0092] The preset conversion tool may be a Python environment implementation tool or other compilation tools. Figure 4 In the example shown, the user can click the path selection button and then select the required file path. After selecting the file path, the executable file of the target application project can be directly obtained according to the file path. After obtaining the executable file, it is necessary to determine whether the format of the executable file is a preset format. If the executable file corresponding to the file path is determined to be a preset format, step S20 is executed to receive the package identification information entered by the user and verify whether the package identification information is legal.
[0093] If the preset format is a file in hex format, if the executable file obtained in step S10 is in hex format, execute step S20; if the executable file obtained in step S10 is not in hex format, execute step S40 to perform error processing; the error processing can be to display an ERROR indication and indicate that the file is not in hex format.
[0094] In step S20, after the user inputs the packet identification information, the preset conversion tool will check whether the packet identification information is legal, such as checking whether its length meets the preset length. If not, it is illegal, and if it meets, it is legal; Figure 6 As shown, the user can enter the package identification information in the AID input box. If it is illegal, step S50 will be executed to perform error processing.
[0095] If it is determined in step S20 that the package identification information is legal, step S30 is executed to convert the executable file of the target application project corresponding to the file path into an application script.
[0096] like Figure 5In the example shown, after entering the package identifier, click Generate Script, and the preset conversion tool starts to generate the script. The name of each generated application script contains the package identifier information, where the package identifier is a string used to uniquely identify an application package. In smart card application development, the package identifier is usually used to distinguish different application packages to ensure that each application package has a unique identifier. The generated application script includes installation instructions.
[0097] In step S500, before installing the application, after NativeCOS receives the application script sent by the external device, it is necessary to execute the instructions in the application script one by one. Before executing the installation instructions, it is necessary to determine whether the same package identification information is stored in the flash area based on the package identification in the current application script name. If it is determined that the same package identification information is stored in the flash area, an error instruction is issued. If it is determined that there is no identical package identification information in the flash area, the instructions in the current application script can be executed normally. After executing the instructions in the application script, it is necessary to register the identification information (including the application module identification information) and the package identification of the current application script in the registry file under the NativeCOS security domain directory, and create an application module directory, and when installing the target application, create a corresponding target application directory under the corresponding application module directory.
[0098] In some implementations, the application script also includes multiple download instructions, such as Figure 6 As shown, execute the instructions in the application script to register the identification information in the security domain directory, including:
[0099] Step S510, execute the first download instruction of the application script, cache the data meta tag, read the first write address corresponding to the first download instruction, and write the executable file data in the first download instruction into the first write address.
[0100] Step S520, determining whether there is a next download instruction.
[0101] If it is determined in step S520 that there is a next download instruction, step S530 is executed to continue executing the next download instruction, read the next write address corresponding to the next download instruction, and write the executable file data in the next download instruction into the next write address.
[0102] If it is determined in step S520 that the next download instruction does not exist, step S540 is executed to register the package identification information and the module identification information in the security domain directory.
[0103] It is understandable that the application script may include multiple download instructions, and multiple download instructions need to be executed in sequence during the execution process. The download instruction instructs NativeCOS to read data from a storage location; the cache data meta tag includes but is not limited to verifying the integrity of the data or recording the location information of the data. The write address corresponding to each download instruction is pre-defined, and each download instruction corresponds to an independent write address, which can ensure that the data of each executable file will not interfere with each other. At the same time, such a design is easy to track and debug, because the write location of each executable file is clear; in addition, by storing different executable file data at different addresses, the risk of data overwriting is avoided.
[0104] Step S600, obtaining an application module parameter structure based on the start address of the target application project, installing the target application based on the application method structure, and storing the installation data of the target application in the target application directory.
[0105] When installing the application, the corresponding application module parameter structure is obtained through the starting address of the target application project, and the corresponding target application is installed based on the application installation method in the application method structure in the determined application module parameter structure. The data written during the installation process is stored in the form of files in the corresponding target application directory. If there are no abnormalities in the installation process, the application is installed successfully.
[0106] The embodiment of the present application first compiles the target application project to obtain the executable file of the target application project, then constructs the application method structure and the platform function interface structure in NativeCOS based on the functions of the target application project in advance, and further constructs the application module parameter structure, and compiles the application module parameter structure and places it into the executable file, compiles the executable file through an external device to generate an application script, and then sends it to NativeCOS, NativeCOS receives the application script sent by the external device, executes the instructions in the application script, and registers the identification information in the security domain directory, creates an application module directory, and then creates a target application directory under the application module directory, and when installing the target application, installs the corresponding target application according to the application installation method in the corresponding application module parameter structure. The method of the present application can realize the post-download of the smart card application of NativeCOS, which improves the flexibility of installing or updating the smart card application.
[0107] Figure 7 A schematic diagram of the structure of an application download device of an embodiment of the present application is shown. Exemplarily, the application download device is applied to NativeCOS applications, NativeCOS includes a file system, the file system includes a security domain directory and an application module directory, and the application download device based on NativeCOS includes:
[0108] The address allocation module 100 is used to obtain a target application project and allocate an address to the target application project in a flash area.
[0109] The executable file generation module 200 is used to compile the target application project to obtain the executable file of the target application project.
[0110] The structure construction module 300 is used to construct an application method structure and a platform function interface structure based on the functions of the target application project, wherein the target application project calls the application method in the application method structure based on the platform function interface structure.
[0111] The structure construction module 300 is also used to obtain the starting address and identification information of the target application project, construct the application module parameter structure based on the starting address, identification information and application method structure of the target application project, compile the application module parameter structure, and place the compiled application module parameter structure into the executable file of the target application project.
[0112] The application script execution module 400 is used to receive the application script sent by the external device, execute the instructions in the application script, register the identification information in the security domain directory, create an application module directory, and create a target application directory under the application module directory; wherein the application script is obtained by converting the executable file through a preset conversion tool.
[0113] The application installation module 500 is used to obtain the application module parameter structure based on the starting address of the target application project, install the target application based on the application method structure, and store the installation data of the target application in the target application directory.
[0114] It can be understood that the device of this embodiment corresponds to the application downloading method of the above embodiment, and the optional items in the above embodiment are also applicable to this embodiment, so they will not be described repeatedly here.
[0115] The present application also provides a smart card. Exemplarily, the smart card includes a processor and a memory, wherein the memory stores a computer program, and the processor runs the computer program to enable the terminal device to execute the functions of each module in the above-mentioned application download method or the above-mentioned application download device.
[0116] Among them, the processor can be an integrated circuit chip with signal processing capabilities. The processor can be a general-purpose processor, including a central processing unit (CPU), a graphics processing unit (GPU) and a network processor (NP), a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or at least one of other programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc., which can implement or execute the disclosed methods, steps and logic block diagrams in the embodiments of the present application.
[0117] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc. The memory is used to store a computer program, and the processor may execute the computer program accordingly after receiving an execution instruction.
[0118] The present application also provides a computer-readable storage medium for storing the computer program used in the above-mentioned terminal device. For example, the computer-readable storage medium may include, but is not limited to, 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.
[0119] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and structure diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in an alternative implementation, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the structure diagram and / or the flow diagram, and the combination of boxes in the structure diagram and / or the flow diagram, can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0120] In addition, the functional modules or units in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0121] If the functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or the 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 a computer device (which can be a smart phone, a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in the various embodiments of the present application.
[0122] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application.
Claims
1. An application downloading method, characterized in that: The application download method is applied to NativeCOS applications, wherein NativeCOS includes a file system, and the file system includes a security domain directory and an application module directory; the method includes: Obtaining a target application project, and assigning an address to the target application project in a flash area; Compiling the target application project to obtain an executable file of the target application project; Constructing an application method structure and a platform function interface structure based on the function of the target application project, wherein the target application project calls the application method in the application method structure based on the platform function interface structure; Obtaining the starting address and identification information of the target application project, constructing an application module parameter structure based on the starting address, identification information and application method structure of the target application project, compiling the application module parameter structure, and placing the compiled application module parameter structure into an executable file of the target application project; Receive an application script sent by an external device, execute instructions in the application script, register the identification information in the security domain directory, create an application module directory, and create a target application directory in the application module directory; wherein the application script is obtained by converting the executable file through a preset conversion tool; The application module parameter structure is obtained based on the start address of the target application project, the target application is installed based on the application method structure, and the installation data of the target application is stored in the target application directory.
2. The application download method according to claim 1, characterized in that: There are multiple target application projects; The allocating addresses for the target application projects in the flash area includes: allocating unique storage addresses for each target application project in the flash area.
3. The application download method according to claim 1, characterized in that: The application method structure includes: an application installation method, an application selection method, an application deselection method, an application instruction processing method, an application deletion method, an application multiple selection method, a multiple selection application recommendation method and an application sharing method; The platform function interface structure includes: a communication processing interface, an application registration and callback interface, a checksum operation interface, a key management interface, a key pair management interface, a cryptographic operation interface, a hash operation interface, a random number generation interface, a signature calculation interface and a PIN management interface.
4. The application download method according to claim 1, characterized in that: The method further includes a process of converting the executable file into an application script based on a preset conversion tool, specifically: The preset conversion tool obtains the executable file of the target application project based on the file path selected by the user, and determines whether the executable file corresponding to the file path is in a preset format; In the case where it is determined that the executable file corresponding to the file path is in a preset format, receiving package identification information input by a user, and verifying whether the package identification information is legal; In the case where the package identification information is legal, the executable file of the target application project corresponding to the file path is converted into an application script.
5. The application download method according to claim 4, characterized in that: The name of the application script includes the package identification information, the application script includes an installation instruction, and before executing the installation instruction in the application script, the method further includes: Based on the package identification information in the application script name, it is determined whether the flash area has the same package identification information. If not, the installation instruction is executed; otherwise, an error is reported.
6. The application download method according to claim 5, characterized in that: The application script further includes a plurality of download instructions; the step of executing the instructions in the application script to register the identification information in the security domain directory includes: Execute the first download instruction of the application script, cache the data meta tag, read the first write address corresponding to the first download instruction, and write the executable file data in the first download instruction into the first write address; Determine whether there is a next download instruction. If so, continue to execute the next download instruction, read the next write address corresponding to the next download instruction, and write the executable file data in the next download instruction into the next write address. If not, register the package identification information and module identification information under the security domain directory.
7. The application download method according to claim 1, characterized in that: The application module parameter structure also includes an application initialization method, which also includes: The target application project is selected based on the application selection method in the application method structure, and the interface library address corresponding to the platform function interface structure is passed to the target application project through the initialization application method, so that the target application project calls the registration callback function of the interface library to pass the application method in the application method structure to the NativeCOS.
8. An application downloading device, characterized in that: The application downloading device is applied to NativeCOS applications, wherein NativeCOS includes a file system, and the file system includes a security domain directory and an application module directory; the device includes: An address allocation module is used to obtain a target application project and allocate an address to the target application project in a flash area; An executable file generation module, used for compiling the target application project to obtain an executable file of the target application project; A structure construction module, used to construct an application method structure and a platform function interface structure based on the function of the target application project, wherein the target application project calls the application method in the application method structure based on the platform function interface structure; The structure construction module is further used to obtain the starting address and identification information of the target application project, construct an application module parameter structure based on the starting address, identification information and the application method structure of the target application project, compile the application module parameter structure, and place the compiled application module parameter structure into the executable file of the target application project; an application script execution module, configured to receive an application script sent by an external device, execute instructions in the application script, register the identification information in the security domain directory, create an application module directory, and create a target application directory in the application module directory; wherein the application script is obtained by converting the executable file using a preset conversion tool; The application installation module is used to obtain the application module parameter structure based on the starting address of the target application project, install the target application based on the application method structure, and store the installation data of the target application in the target application directory.
9. A smart card, characterized in that: The smart card comprises a processor and a memory, wherein the memory stores a computer program, and the processor is configured to execute the computer program to implement the application downloading method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The device stores a computer program, which, when executed on a processor, implements the application downloading method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and equipment for dynamically switching Native and JavaCard
CN113692576A