Software component authorization method and device of embedded controller

Through hashing algorithm and signature algorithm signing software components and building a self-checking mechanism, the problem of authorizing multiple models or series products in embedded industrial control systems is solved, efficient authorization and maintenance is achieved, and management costs are reduced.

CN118981752AActive Publication Date: 2024-11-19NINGBO HOLLYSHI INFORMATION SECURITY RES INST CO LTD
View PDF 13 Cites 0 Cited by

Patent Information

Application Number
CN202411473602.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-22
Publication Date
2024-11-19
Estimated Expiration
2044-10-22

AI Technical Summary

Technical Problem

The existing embedded industrial control system software component licensing method is costly to manage in non-high value products, difficult to apply, and difficult to maintain software component integration and authorization for multiple models or series products.

Method used

Use hashing algorithms and signature algorithms to sign the data to be signed in software components, build a signature section, and insert it into the ELF file to realize a self-checking mechanism, support the authorization of multiple models or series products, reduce the number of versions and maintain it .

Benefits of technology

It simplifies the authorization and maintenance of software components, avoids dependence on the verification library of terminal products, improves the security and efficiency of authorization, and reduces production and use costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118981752A_ABST
    Figure CN118981752A_ABST
Patent Text Reader

Abstract

The invention discloses a software component authorization method and device of an embedded controller, and relates to the technical field of software component authorization. The method comprises the following steps: performing signature calculation on to-be-signed data based on a software component by using a first hash algorithm and a first signature algorithm to obtain a signature of the software component; wherein the to-be-signed data comprises a first type section of the software component, product information and a first type parameter of an operating system matched with the software component; constructing signature knots based on the signature, and inserting the signature knots into a plurality of knots of the software component; wherein the signature section comprises a plurality of signature segments corresponding to a plurality of models or series of software components; inserting a self-checking stub code into the first type of section; updating an ELF file header, a program header table and a node header table according to the signature node and the self-signature verification stub code to obtain an authorized software component; the same release version of the software component can support a plurality of products of different models or series, so that the number of versions is greatly reduced, and the maintenance work is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of software component authorization, and in particular relates to a method and device for authorizing software components of an embedded controller. Background Art

[0002] With the development of technology, the complexity of embedded software in industrial control systems is increasing. In the process of productization, it is often necessary to integrate third-party components, which are generally provided in the form of libraries or executable files. Products based on the same embedded platform generally have multiple models or series due to market reasons. The software, hardware and even basic library versions of these models / series may not be the same, which brings great inconvenience to third-party component manufacturers: it is difficult to maintain software components integrated into different models or series of products on the same embedded platform, and it is difficult to control the terminal manufacturers from using component applications across product series, resulting in infringement of their own rights and interests.

[0003] The goal of traditional component / software authorization is to allow users to use the software according to the purchased license, involving the number of software installations, usage time, application scope, and functional modules, among which usage time is the core item of authorization. Software authorization in the existing technology is generally completed through electronic authorization. With the continuous improvement of electronic encryption methods, the security of software authorization is getting higher and higher. Common electronic encryption software authorization methods include: online authorization method, which uses online encryption to perform authorization protection. All security algorithms and data are implemented and provided using network methods. Among them, typical cloud authorization technology solves the software developer's needs for digital, automated and manageable software sales; offline authorization method, only needs to connect to the server when the software is activated, authenticate and obtain authorization. Once the activation is successful, there is no need to connect to the server, and the software user can use it offline; offline authorization can also be physically imported to distribute a license for each authorized product, and the generation of the license requires the product to provide a unique identity ID, and it needs to be configured before use.

[0004] For a large number of software components that are not high-value embedded industrial control products, there is no interactive interface, and the use scenarios of non-networked applications, the management costs of license application, release, configuration, etc. are extremely high or even unacceptable, and the above authorization method is not applicable. For this scenario, in order to avoid excessive license maintenance costs, authorization time control is often carried out by issuing independent licenses or releasing independent versions for large categories of products. This method essentially reduces the cost of authorization maintenance management by reducing the granularity of authorization, but component manufacturers still need to maintain the basic settings and differential versions of license releases. Summary of the invention

[0005] In order to solve the above problems, the present invention proposes a method and device for authorizing software components of an embedded controller, wherein the same release version of the software component can support multiple products of different models or series, greatly simplifying the number of versions and maintenance work.

[0006] In a first aspect, the present invention provides a method for authorizing a software component of an embedded controller, wherein the software component is an ELF file including an ELF file header, a program header table, a plurality of sections and a section header table, and the method comprises: Using a first hash algorithm and a first signature algorithm to perform signature calculation on the data to be signed based on the software component to obtain a signature of the software component; wherein the data to be signed includes a first category section of the software component, product information, and a first category parameter of an operating system adapted to the software component; Building the signature section based on the signature, and inserting the signature section into multiple sections of the software component; wherein the signature section includes multiple signature segments corresponding to multiple models or series of the software component; Inserting a self-verification stub code into the first type of section; The ELF file header, the program header table and the section header table are updated according to the signature section and the self-verification stub code to obtain an authorized software component.

[0007] In an optional implementation, the using a first hash algorithm and a first signature algorithm to perform signature calculation on the data to be signed based on the software component to obtain the signature of the software component includes: Performing hash calculation on the data to be signed based on the software component using a first hash algorithm to obtain a first hash value; The first hash value is signed and calculated using a first signature algorithm and a product private key to obtain a signature of the software component; wherein the first signature is calculated using an SM9 algorithm; the product private key is generated in advance by a software component provider at a key generation center based on a product public key and a signature master private key; the product public key is constructed based on a product identity and a signature master public key, the product identity at least includes a product name and an authorization expiration date of the product, and the signature master public key and the signature master private key are generated in advance by a software component provider at a key generation center.

[0008] In an optional implementation manner, the product identity further includes a product number and a product model; The step of constructing the signature section based on the signature includes: The signature section is constructed based on the product number, the signature, and the authorization expiration date.

[0009] In an optional embodiment, the method further comprises: Determine whether the authorized software component is expired, if so, return an error message and / or refuse to load the authorized software component; otherwise, proceed to the next step; Acquire the data to be verified of the authorized software component, wherein the data to be verified includes the first category section of the authorized software component, the product information of the authorized software component, and the operating system parameters of the current operating system; wherein the product information includes at least the authorization expiration date of the product; Performing hash calculation on the data to be verified using the first hash algorithm to obtain a second hash value; Obtain the product category and product model of the authorized software component, and construct the product identity in combination with the product number and the authorization expiration date; Constructing a product public key according to the product identity and the signature master public key; Perform signature verification calculation according to the product public key, operating system parameters of the current operating system, and the first signature algorithm to obtain a signature verification calculation result; Compare the signature verification calculation result with the second hash value, and if they are consistent, execute the next step; if they are inconsistent, return an error message and / or refuse to load the authorized software component; The authorized software component is loaded and executed.

[0010] In an optional implementation manner, before loading and executing the authorized software component, the method further includes: Determine the product authorization time based on the product number; The product authorization time is compared with the authorization expiration date. If they are consistent, the steps of loading and executing the authorized software component are performed. If they are inconsistent, an error message is returned and / or the loading of the authorized software component is refused.

[0011] In an optional implementation manner, the determining whether the authorized software component is expired, if so, returning an error message and / or refusing to load the authorized software component; otherwise, proceeding to the next step, including: Obtain product numbers for licensed software components; Locating the signature section of the authorized software component according to the product number; Determining the authorization expiration date of the authorized software component according to the signature section of the authorized software component; Get the system time of the current operating system; Determine whether the authorization expiration date in the product identity is less than the system time of the current operating system. If so, return an error message and / or refuse to load the authorized software component; otherwise, proceed to the next step.

[0012] In an optional embodiment, the first category of operating system parameters include a combination of one or more of the operating system version number, C library version number, kernel version number, central processing unit model and operating system storage capacity; the product information also includes a combination of one or more of the product authorization time, product version number and product type.

[0013] In an optional implementation, the first category of sections includes one or more combinations of .text, .data, .rel.text, and .rel.data.

[0014] In an optional implementation manner, the loading and executing the authorized software component includes: Map the dynamic linker into memory; Create a program execution stack; Prepare program execution stack information; The entry point that passes control to the authorized software component.

[0015] In a second aspect, the present invention provides a software component authorization device for an embedded controller, wherein the software component is an ELF file including an ELF file header, a program header table, a plurality of sections and a section header table, and the device comprises: A signature calculation module, used to perform signature calculation on the data to be signed based on the software component using a first hash algorithm and a first signature algorithm to obtain a signature of the software component; wherein the data to be signed includes a first category section of the software component, product information, and a first category parameter of an operating system compatible with the software component; A signature section module, configured to construct the signature section based on the signature, and insert the signature section into multiple sections of the software component; wherein the signature section includes multiple signature segments corresponding to multiple models or series of the software component; A stub code module, used for inserting a self-verification stub code into the first type of section; An update module is used to update the ELF file header, the program header table and the section header table according to the signature section and the self-verification stub code to obtain an authorized software component.

[0016] The technical solution provided by the present invention has the following beneficial effects: the software component authorization method and device of the embedded controller of the present invention firstly uses the first hash algorithm and the first signature algorithm to sign the data to be signed based on the software component, and then constructs a signature section according to the signature, wherein the multiple signature segments in the signature section correspond to the multiple models or series of the software component, thereby realizing that the same release version of the software component can support multiple different models or series of products; finally, the self-verification stub code is inserted into the first type of section to realize the self-verification mechanism; the present invention can greatly simplify the number of versions and maintenance work; at the same time, the self-verification mechanism is adopted, and it does not rely on the verification library of the terminal product. The ELF executable file after verification will not retain the original image on the disk to avoid leakage. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] Figure 1 A schematic diagram of a flow chart of a method for authorizing software components of an embedded controller provided by an embodiment of the present invention; Figure 2 A schematic diagram of the signature principle in the software component authorization method of the embedded controller provided by an embodiment of the present invention; Figure 3 A schematic diagram of the signature verification principle in the software component authorization method of the embedded controller provided by an embodiment of the present invention; Figure 4 A schematic diagram of the system principle of a software component authorization device for an embedded controller provided by an embodiment of the present invention.

[0018] In the figure: 10 - signature calculation module; 20 - signature section module; 30 - stub code module; 40 - update module. DETAILED DESCRIPTION

[0019] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.

[0020] See also Figure 1 The present invention provides a method for authorizing a software component of an embedded controller. The software component is an ELF file including an ELF file header, a program header table, multiple sections and a section header table. The software component is pre-registered in a key generation center.

[0021] Here, the software component is a file in ELF format. ELF (Executable and Linkable Format) file is a commonly used file format in Linux system, such as Figure 2As shown, the ELF file header (ELFHeader) is located at the beginning of the file and is used to describe the organizational structure and properties of the entire file. The program header table (ProgramHeader Table), located between the ELF file header and the section, is used to describe the information of each section in the ELF file. The data and code in the ELF file are organized into multiple sections (Sections), which are combined into segments (Segments) when the file is loaded into memory. The section is the representation of the ELF file on the disk, and the segment is the representation of these sections in the memory. Common sections include code sections (.text), data sections (.data), read-only data sections (.rodata), symbol table sections (.symtab), etc. As shown in Figure 2 As shown, the sections in this embodiment include: .text (code section), .rodata (read-only data section), .data (data section), .bss (uninitialized data section), .symbtab (symbol table section), .rel.text (code relocation section), .rel.data (data relocation section), .debug (debugging information section), .line (line number information section), .strtab (string table), .shstrtab (section header string table). The section header table is used to describe the information of all sections in the ELF file, such as the name, type, address, offset, size and flags of the section.

[0022] The software component authorization method of the embedded controller of this embodiment includes the following steps S110 to S140.

[0023] Step S110, using the first hash algorithm and the first signature algorithm to perform signature calculation on the data to be signed based on the software component to obtain the signature of the software component; wherein the data to be signed includes the first category section of the software component, product information and the first category parameters of the operating system adapted to the software component.

[0024] Specifically, the first hash algorithm can be an SM3 algorithm, and the SM3 algorithm performs hash processing on the signature data to generate a summary of a fixed length. The first type of section refers to the main section of the ELF file, and these main sections may include .text, .data, .rel.text, .rel.data, etc., which may be one of the sections or a combination of multiple sections. These sections in the first type of section are the most critical information of the ELF file, and common tampering occurs in these sections. It should be noted that this embodiment only adds the signature segment and does not change the ELF file structure.

[0025] Product information includes one or more of the following: product authorization expiration date, product authorization time, product version number, and product type. It should be noted that product information is not limited to the aforementioned content. The first category of operating system parameters includes one or more of the following: operating system version number, C library version number, kernel version number, central processing unit model, and operating system storage capacity. The first category of operating system parameters is to extract product information with a universal and stable system interface for fine-grained matching. Here, attributes such as the operating system version number and the C library version number are used as part of the hash check during signature verification, which increases the difficulty for terminal manufacturers to change the general API to forge attributes to circumvent signature verification, and the manufacturer-extensible and other multi-terminal product information is used as a hash check unit, increasing the cost of cracking.

[0026] It should also be noted that before executing the method of this embodiment, the embedded terminal equipment vendor first needs to pre-register multiple products of the same platform in the key generation center (KGC) established by the software component provider. When registering, the information of each product needs to be configured, including but not limited to the product name, product model, product number, product-adapted operating system name and version number, product application libc name and version number, application authorization date, product MAC address (if any), etc. Then, the component provider generates a signature master public key and a signature master private key through the key generation center, which specifically includes the following steps (a) to (e).

[0027] Step (a) Choose a secure elliptic curve E and base point G.

[0028] Step (b) determines the order n of the elliptic curve, that is, the order of the base point G.

[0029] Step (c) randomly selects an integer s less than n as the signature master private key. The length of the signature master private key s should match the security of the selected elliptic curve. For example, for a 256-bit security level, s is usually a 256-bit random number.

[0030] Step (d) uses the selected base point G and the signature master private key s to calculate the signature master public key Ppub = s*G.

[0031] Step (e) publicly releases system parameters and keeps the signature master private key s secret. The system parameters include the elliptic curve E, the base point G, and the signature master public key Ppub.

[0032] On the basis of the signature master public key and signature master private key generated by the key generation center, the product public key is constructed and the product private key is generated. For each product, the product public key P is constructed by the product identity (P=H(pid)) and the signature master public key. The key generation center calculates the product private key (d=s*P) based on the product public key P and the signature master private key s. The product identity here includes at least the authorization expiration date, and can also include the product name, product model and product number.

[0033] After obtaining the product public key and product private key, step S110 can be implemented. First, the first hash algorithm is used to perform hash calculation on the data to be signed based on the software component to obtain a first hash value. Then, the first signature algorithm and the product private key are used to perform signature calculation on the first hash value to obtain the signature of the software component. Here, the first hash value is encrypted by the product private key to generate a signature (R, S), which is distributed with the software component to verify the integrity and authenticity of the component. The first signature algorithm can be an SM9 algorithm. Hash calculation is performed based on the main section of the software component (i.e., the first category section), product information (such as the product authorization expiration date) and the first category parameters of the operating system that are compatible with the software component (such as the operating system version number, C library version number, etc.), and the product private key is used for SM9 signature.

[0034] Step S120: construct a signature section based on the signature, and insert the signature section into multiple sections of the software component, wherein the signature section includes multiple signature segments corresponding to multiple models or series of the software component.

[0035] Specifically, a signature section is constructed based on the product number, signature (R, S) and authorization expiration date t. These signature sections are inserted into the ELF file section and laid out according to the product model. The signature section is as follows Figure 2 As shown in .signature_1, .signature_2, ....signature_n.

[0036] Step S130: inserting a self-verification stub code into the first type of section.

[0037] Here, insert the stub code of ELF self-verification into the .text section in the first category section, modify the ELF header entry address to point to the ELF signature verification code. Embed a section of stub code into the execution segment of the original ELF file. Stub code refers to a section of code embedded at the beginning of the executable segment of ELF. This section of code can be used for decompression, encryption, initial configuration and other functions.

[0038] Step S140, updating the ELF file header, program header table and section header table according to the signature section and the self-verification stub code to obtain a self-verification authorized software component.

[0039] Specifically, the section header table and program header table of the ELF file are modified to generate a self-signed authorized software component.

[0040] See also Figure 2 , the original ELF file adds SM9 signature verification stub code in the .text section, and adds KGC system parameters, product serial number, and authorization time array in the rodata section; when signing, the main section of the original ELF file and product attributes (the product attributes here include product information and the first-class operating system parameters that are compatible with the software component. The figure only lists the first-class operating system parameters that are compatible with the software component) are combined with the SM9 product private key to perform SM9 signature to obtain the authorized software component. The authorized software component adds a ".signature" string in the .shstrab section, adds a .signature section, and adds a .signature section header in the SectionHeader Table section header table to describe the .signature section.

[0041] This embodiment constructs an ELF self-verification file, including the original ELF file and the signature master public key, reads the file signature content (such as product authorization time, product authorization type) and product information (such as product name, product model, etc. provided by product registration), constructs the product public key and signature hash factor, performs SM9 self-verification, and jumps to the function entry of the original ELF library / the entry address of the original ELF executable file after the verification passes. This embodiment uses the product public information (product name, authorization expiration date, etc.) directly as the product public key mark, and uses the product operating system version number, system C library (such as the aforementioned C library version number) and other operating system attributes as hash verification elements during verification, and can expand the elements according to the information provided by the product to increase the difficulty of cracking. It avoids the complex links of certificate signing and verification under the PKI system. This embodiment supports encapsulation of multiple signature items in the same component version, and fine-grained adaptive authorization for multiple models of products in the same series on the terminal side.

[0042] The aforementioned steps S110 to S140 are the signing process. The following describes the signature verification process, as shown in the following steps S210 to S290. The signature verification principle is shown in Figure 3 .

[0043] Step S210, determining whether the authorized software component is expired, if so, returning an error message and / or refusing to load the authorized software component; otherwise, continuing to execute S220.

[0044] Specifically, step S210 specifically includes the following steps S211 to S215.

[0045] Step S211, obtaining the product number of the authorized software component.

[0046] Step S212, locating the signature section of the authorized software component according to the product number.

[0047] Step S213, determining the authorization expiration date t of the authorized software component according to the signature section of the authorized software component.

[0048] Step S214, obtaining the system time of the current operating system.

[0049] Step S215, determining whether the authorization expiration date t in the product identity is less than the system time of the current operating system, if so, returning an error message and / or refusing to load the authorized software component; otherwise, proceeding to the next step.

[0050] Specifically, when the software component is executed on the terminal product, it enters the self-verification process. First, the product number is read, and the corresponding signature section is found according to the product number. The authorization expiration date t is obtained in the corresponding signature section. This time is compared with the system time of the current operating system. If the system time is less than the authorization expiration date t, the next step is entered, otherwise an error is reported and the system exits.

[0051] Step S220, obtaining the data to be verified of the authorized software component, the data to be verified includes the first category section of the authorized software component, the product information of the authorized software component and the operating system parameters of the current operating system; wherein the product information includes at least the product authorization expiration date.

[0052] Step S230: Perform hash calculation on the data to be verified using the first hash algorithm to obtain a second hash value.

[0053] Specifically, the software component reads relevant file attributes, namely the operating system version number, its own main data sets, namely the first-class sections .text, .rodata, .data, .rel.text, .rel.data, the C library version number of the application layer, and the product's authorization expiration date t to perform SM3 hash calculation (SHA256, SH3 and other algorithms can also be used), where the authorization expiration date is included in the .rodata section (KGC system parameters are also included in this section).

[0054] Step S240, obtaining the product category and product model of the authorized software component, and constructing a product identity in combination with the product number and the authorization expiration date.

[0055] Step S250, constructing a product public key according to the product identity and the signature master public key.

[0056] Here, the software component reads the product category and product model, and combines the product number obtained in step S210 and the authorization expiration date obtained in step S220 to construct a product identity. The same hash function H as the signing process is used to convert the product ID into a point Q=H(id) on the elliptic curve, which is the product verification public key (the verification is the same as the aforementioned product public key).

[0057] Step S260, performing signature verification calculation according to the product public key, operating system parameters and the first signature algorithm to obtain a signature verification calculation result.

[0058] Step S270, compare the signature verification calculation result with the second hash value, if they are consistent, execute step S280; if they are inconsistent, return an error message and / or refuse to load the authorized software component.

[0059] Here, the software component obtains the GC system parameters (elliptic curve E and base point G) in the .rodata segment, and performs SM9 verification based on the product verification public key and system parameters. If passed, continue to step S280.

[0060] Step S280, determine the product authorization time according to the product number, compare the product authorization time with the authorization expiration date, if they are consistent, execute step S290, if they are inconsistent, return an error message and / or refuse to load the authorized software component.

[0061] Specifically, after the signature verification is passed, the corresponding product authorization time of .rodata is obtained again based on the product number and compared with the authorization expiration date obtained in step S220. If they are consistent, continue to step S290.

[0062] Step S290, loading and executing the authorized software component. Specifically, this step includes the following steps S291~S291.

[0063] Step S291, the software component maps the dynamic linker into the memory.

[0064] Step S292: the software component creates a program execution stack.

[0065] Step S293, prepare program execution stack information (eg, argv, envp, auxiliary vector).

[0066] Step S294: The software component hands over the control right to the entry point of the authorized software component.

[0067] Here, usually, the call triggers the corresponding system call parsing and builds the operating environment according to the executable file type. However, since the software component of this embodiment is constructed as a self-contained file and has self-executing capability, the original system EXEC system preparation work, such as dynamic linker call and stack allocation, is implemented by its own stub code.

[0068] The main authorization check of this embodiment is performed during the signature verification. When obtaining common product attributes such as the operating system version number, system C library, product name, product model, etc., a general interface function API is used to prevent terminal users from customizing the API interface to bypass the check. It is also possible to directly obtain feature codes such as the product MAC address. In this way, the authorization will be more refined, but it is necessary to obtain feature codes such as the MAC address for each independent product in advance and register them with KGC. This embodiment adopts a self-verification mechanism through ELF stub technology. The SM9 verification code is integrated into the stub code and does not rely on the verification library of the terminal product. This embodiment also supports authorization control of the use date of multiple series / models of products on the same platform.

[0069] Embedded controllers are all mass-produced, and users often do not connect to the Internet during use. In addition, the human-computer interaction interface that embedded controllers can provide is limited, and the operation is cumbersome and non-intuitive, or there is no human-computer interaction interface. The most convenient way to use components in embedded controllers is to compile the components into the controller's firmware, or to dynamically load the components after the controller system is started. Regardless of the method, if the traditional method of exporting the controller's unique identification information, generating an authorization code through an external authorization server, and importing the controller for authorization is adopted, it will lead to reduced production efficiency or inconvenience for users. Compared with the traditional method of obtaining the unique information of the device, exporting it to the authorization server to generate an authorization code, and then importing it into the device for authorization, this embodiment does not require external interaction, does not need to increase production links, and has no dependence on the host machine except for the attributes and authorization information that can be made public.

[0070] This embodiment uses the product name and authorization expiration date as the public key mark directly, which is simple and direct, and is convenient for component providers and terminal product manufacturers to establish consensus and reduce maintenance costs for both parties. In this embodiment, the same release version can support the same functional components of multiple products (such as different models of PLC products all use the Linux system, which can integrate the functional components of the same key negotiation. This functional component has multiple signature segments and will be independently authorized for each model of PLC product), which greatly simplifies the number of versions and maintenance work. This embodiment adopts a self-verification mechanism and does not rely on the verification library of the terminal product. The ELF executable file after verification will not retain the original image on the disk to avoid leakage.

[0071] This embodiment uses the product public information (product name and authorization expiration date, etc.) directly as the product public key mark, and uses the product operating system version number, system C library and other attributes as hash verification factors during signature verification, and can expand the factors according to the information provided by the product to increase the difficulty of cracking. This embodiment avoids the complex links of certificate signing and verification under the PKI system. This embodiment adopts a self-verification mechanism through ELF stub technology, and the SM9 verification code is integrated into the stub code and does not rely on the verification library of the terminal product. This embodiment encapsulates multiple signature items in the same component version to support adaptive authorization of multiple products.

[0072] See also Figure 4 , a software component authorization device for an embedded controller provided in this embodiment includes a signature calculation module 10, a signature section module 20, a stub code module 30, and an update module 40. The signature calculation module 10 is used to perform signature calculation on the data to be signed based on the software component using the first hash algorithm and the first signature algorithm to obtain the signature of the software component; wherein the data to be signed includes the first category section of the software component, product information, and the first category parameters of the operating system adapted to the software component. The signature section module 20 is used to construct a signature section based on the signature, and insert the signature section into multiple sections of the software component; wherein the signature section includes multiple signature segments corresponding to multiple models or series of the software component. The stub code module 30 is used to insert a self-verification stub code into the first category section. The update module 40 is used to update the ELF file header, the program header table, and the section header table according to the signature section and the self-verification stub code to obtain an authorized software component.

[0073] In an optional embodiment, the signature calculation module 10 includes a hash calculation module and a signature calculation module. The hash calculation module is used to perform a hash calculation on the data to be signed based on the software component using a first hash algorithm to obtain a first hash value. The signature calculation module is used to perform a signature calculation on the first hash value using a first signature algorithm and a product private key to obtain a signature of the software component; wherein the first signature algorithm is an SM9 algorithm; the product private key is generated in advance by the software component provider at the key generation center based on the product public key and the signature master private key; the product public key is constructed based on the product identity and the signature master public key, the product identity includes at least the product name and the product authorization expiration date, and the signature master public key and the signature master private key are generated in advance by the software component provider at the key generation center.

[0074] In an optional embodiment, the product identity identifier also includes a product number and a product model; the signature section module is specifically used to construct a signature section according to the product number, signature and authorization expiration date.

[0075] In an optional embodiment, the device further includes a judgment module, a first acquisition module, a second hash value module, a second acquisition module, a construction module, a signature verification calculation module, a comparison module and a loading module. The judgment module is used to judge whether the authorized software component is expired. If so, an error message is returned and / or the authorized software component is refused to be loaded; otherwise, the next step is continued. The first acquisition module is used to obtain the signature data to be verified of the authorized software component, and the signature data to be verified includes the first category section of the authorized software component, the product information of the authorized software component and the operating system parameters of the current operating system; wherein the product information at least includes the product authorization expiration date. The second hash value module is used to perform hash calculation on the signature data to be verified using the first hash algorithm to obtain a second hash value. The second acquisition module is used to obtain the product category and product model of the authorized software component, and construct a product identity in combination with the product number and the authorization expiration date. The construction module is used to construct a product public key according to the product identity and the signature master public key. The signature verification calculation module is used to perform signature verification calculation according to the product public key, the first category parameter of the operating system and the first signature algorithm to obtain the signature verification calculation result. The comparison module is used to compare the signature verification calculation result with the second hash value. If they are consistent, the next step is executed; if they are inconsistent, an error message is returned and / or the loading of the authorized software component is refused. The loading module is used to load and execute the authorized software component.

[0076] In an optional embodiment, the device of this embodiment also includes a date determination module located before the loading module, and the determination module is used to determine the product authorization time based on the product number; compare the product authorization time with the authorization expiration date, and if they are consistent, execute the steps of loading and executing the authorized software component; if they are inconsistent, return an error message and / or refuse to load the authorized software component.

[0077] In an optional embodiment, the judgment module specifically includes a product number module, a positioning module, a determination module, a system time module and a time judgment module. The product number module is used to obtain the product number of the authorized software component. The positioning module is used to locate the signature section of the authorized software component according to the product number. The determination module is used to determine the authorization expiration date of the authorized software component according to the signature section of the authorized software component. The system time module is used to obtain the system time of the current operating system. The time judgment module is used to determine whether the authorization expiration date in the product identity is less than the system time of the current operating system. If so, an error message is returned and / or the loading of the authorized software component is refused; otherwise, the next step is continued.

[0078] In an optional embodiment, the first category of operating system parameters includes a combination of one or more of the operating system version number, C library version number, kernel version number, central processing unit model and operating system storage capacity; the product information also includes a combination of one or more of the product authorization time, product version number and product type.

[0079] In an optional embodiment, the first category section includes one or more combinations of .text, .data, .rel.text, and .rel.data.

[0080] In an optional embodiment, the loading module includes a mapping module, a creation module, an information preparation module and a control right module. The mapping module is used to map the dynamic linker to the memory. The creation module is used to create a program execution stack. The information preparation module is used to prepare program execution stack information. The control right module is used to hand over control to the entry point of the authorized software component.

[0081] The device provided in the embodiment of the present application is adopted. Since the device adopts the same inventive concept as the above-mentioned method provided in the embodiment of the present application, on the premise that the method can solve the technical problem, the device can also solve the technical problem, which will not be repeated here.

[0082] It is known from common technical knowledge that the present invention can be implemented by other embodiments that do not deviate from its spirit or essential features. Therefore, the above disclosed embodiments are only illustrative in all respects and are not exclusive. All changes within the scope of the present invention or within the scope equivalent to the present invention are included in the present invention.

Claims

1. A method for authorizing software components of an embedded controller, characterized in that: The software component is an ELF file including an ELF file header, a program header table, a plurality of sections and a section header table, and the method comprises: Using a first hash algorithm and a first signature algorithm to perform signature calculation on the data to be signed based on the software component to obtain a signature of the software component; wherein the data to be signed includes a first category section of the software component, product information, and a first category parameter of an operating system adapted to the software component; Building the signature section based on the signature, and inserting the signature section into multiple sections of the software component; wherein the signature section includes multiple signature segments corresponding to multiple models or series of the software component; Inserting a self-verification stub code into the first type of section; The ELF file header, the program header table and the section header table are updated according to the signature section and the self-verification stub code to obtain an authorized software component.

2. The method for authorizing software components of an embedded controller according to claim 1, characterized in that: The using the first hash algorithm and the first signature algorithm to perform signature calculation on the data to be signed based on the software component to obtain the signature of the software component includes: Performing hash calculation on the data to be signed based on the software component using a first hash algorithm to obtain a first hash value; The first hash value is signed and calculated using a first signature algorithm and a product private key to obtain a signature of the software component; wherein the first signature is calculated using an SM9 algorithm; the product private key is generated in advance by a software component provider at a key generation center based on a product public key and a signature master private key; the product public key is constructed based on a product identity and a signature master public key, the product identity at least includes a product name and an authorization expiration date of the product, and the signature master public key and the signature master private key are generated in advance by a software component provider at a key generation center.

3. The method for authorizing software components of an embedded controller according to claim 2, characterized in that: The product identification also includes the product number and product model; The step of constructing the signature section based on the signature includes: The signature section is constructed based on the product number, the signature, and the authorization expiration date.

4. The method for authorizing software components of an embedded controller according to claim 3, characterized in that: The method further comprises: Determine whether the authorized software component is expired, if so, return an error message and / or refuse to load the authorized software component; otherwise, proceed to the next step; Acquire the data to be verified of the authorized software component, wherein the data to be verified includes the first category section of the authorized software component, the product information of the authorized software component, and the operating system parameters of the current operating system; wherein the product information includes at least the authorization expiration date of the product; Performing hash calculation on the data to be verified using the first hash algorithm to obtain a second hash value; Obtain the product category and product model of the authorized software component, and construct the product identity in combination with the product number and the authorization expiration date; Constructing a product public key according to the product identity and the signature master public key; Perform signature verification calculation according to the product public key, operating system parameters of the current operating system, and the first signature algorithm to obtain a signature verification calculation result; Compare the signature verification calculation result with the second hash value, and if they are consistent, execute the next step; if they are inconsistent, return an error message and / or refuse to load the authorized software component; The authorized software component is loaded and executed.

5. The method for authorizing software components of an embedded controller according to claim 4, characterized in that: Before loading and executing the authorized software component, the method further includes: Determine the product authorization time based on the product number; The product authorization time is compared with the authorization expiration date. If they are consistent, the steps of loading and executing the authorized software component are performed. If they are inconsistent, an error message is returned and / or the loading of the authorized software component is refused.

6. The method for authorizing software components of an embedded controller according to claim 4, characterized in that: Determining whether the authorized software component is expired, and if so, returning an error message and / or refusing to load the authorized software component; Otherwise, continue to the next step, which includes: Obtain product numbers for licensed software components; Locating the signature section of the authorized software component according to the product number; Determining the authorization expiration date of the authorized software component according to the signature section of the authorized software component; Get the system time of the current operating system; Determine whether the authorization expiration date in the product identity is less than the system time of the current operating system. If so, return an error message and / or refuse to load the authorized software component; otherwise, proceed to the next step.

7. The method for authorizing software components of an embedded controller according to claim 3, characterized in that: The first category of operating system parameters includes one or more combinations of operating system version number, C library version number, kernel version number, central processing unit model and operating system storage capacity; the product information also includes one or more combinations of product authorization time, product version number and product type.

8. The method for authorizing software components of an embedded controller according to claim 1, characterized in that: The first category of sections includes one or more combinations of .text, .data, .rel.text, and .rel.data.

9. The method for authorizing software components of an embedded controller according to claim 4, characterized in that: The loading and executing of the authorized software component comprises: Map the dynamic linker into memory; Create a program execution stack; Prepare program execution stack information; The entry point that passes control to the authorized software component.

10. A software component authorization device for an embedded controller, characterized in that: The software component is an ELF file including an ELF file header, a program header table, a plurality of sections and a section header table, and the device comprises: A signature calculation module, used to perform signature calculation on the data to be signed based on the software component using a first hash algorithm and a first signature algorithm to obtain a signature of the software component; wherein the data to be signed includes a first category section of the software component, product information, and a first category parameter of an operating system compatible with the software component; A signature section module, configured to construct the signature section based on the signature, and insert the signature section into multiple sections of the software component; wherein the signature section includes multiple signature segments corresponding to multiple models or series of the software component; A stub code module, used for inserting a self-verification stub code into the first type of section; An update module is used to update the ELF file header, the program header table and the section header table according to the signature section and the self-verification stub code to obtain an authorized software component.

Citation Information

Patent Citations

  • Secure guiding system, method, code signature construction method and authentication method

    CN101034991A

  • POS digital signature anti-switching machine system

    CN106789075A

  • ELF file release method, ELF file verification method, server and terminal

    CN107786504A

  • Identity management method, industrial control system and storage medium

    CN112966291A

  • Program protection method and device based on code signature, equipment and storage medium

    CN114168909A