Safe starting method and device applied to micro-control unit, equipment and medium
By introducing two cores into the microcontroller unit and using the encryption algorithm and public key of the hardware security module for verification processing, the lack of flexibility and high cost of secure startup caused by traditional HSM design is solved, and more efficient secure startup is achieved process.
Patent Information
- Application Number
- CN202410956257.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-17
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-07-17
AI Technical Summary
The design of traditional hardware security modules (HSMs) leads to the lack of flexibility in secure startup, long development cycle, high resource investment and high hardware costs.
By introducing two cores into the microcontroller unit, the first core is used to run the hardware security module, and the second core is used to run the application, and the encryption algorithm and public key in the hardware security module are used to verify the relevant information. After the generated module is successfully run, the application is checked before starting to achieve secure startup.
It shortens the development cycle, reduces hardware costs, and improves the development efficiency of hardware security modules and the flexibility and diversity of secure startup.
Smart Images

Figure CN118965356A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a secure startup method, device, equipment and medium applied to a microcontroller unit. Background Art
[0002] Currently, the integrity and accuracy of user-defined key programs and contents in the memory can be verified through secure startup of the microcontroller unit (MCU), thereby preventing the application from being tampered with and causing operational risks.
[0003] In the prior art, MCU secure boot can be performed based on a hardware security module (HSM).
[0004] However, traditional HSM design is mainly based on hardware development and design. This implementation method will fix the HSM's secure boot method and process, resulting in a lack of flexibility in HSM-based secure boot. In addition, the hardware-based development and design approach will lead to problems such as long HSM development cycles, high resource investment, and high hardware costs. Summary of the invention
[0005] The embodiments of the present application provide a secure boot method, device, equipment and medium applied to a microcontroller unit, so as to shorten the development cycle and reduce hardware costs.
[0006] In a first aspect, an embodiment of the present application provides a secure boot method applied to a micro control unit, comprising:
[0007] In response to a power-on operation of the microcontroller unit, initial startup codes are started in a first kernel and a second kernel running in the microcontroller unit, respectively; wherein the first kernel is used to run a hardware security module; and the second kernel is used to run an application program;
[0008] By using the initial startup code started in the first kernel, the encryption algorithm and the encryption public key stored in the hardware security module are called to verify the startup related information provided by the hardware security module to obtain a module verification result; wherein the module verification result is used to indicate whether the startup related information provided by the hardware security module is accurate;
[0009] If the module verification result indicates that each startup-related information provided by the hardware security module is accurate, then module successful operation information is generated; wherein the module successful operation information indicates that the hardware security module has been successfully operated;
[0010] After the initial startup code started in the second kernel detects the successful operation information of the module, based on the hardware security module, a pre-startup check is performed on the application program required to be run by the second kernel, and after the check passes, the application program in the micro control unit is started.
[0011] In a possible implementation, the initial startup code started in the first kernel calls the encryption algorithm and the encryption public key stored in the hardware security module, verifies the startup related information provided by the hardware security module, and obtains the module verification result, including:
[0012] Calling the encryption algorithm and encryption public key stored in the hardware security module from the read-only memory of the hardware security module through the initial startup code started in the first kernel;
[0013] Based on the encryption algorithm and encryption public key stored in the hardware security module, encrypt and calculate the startup related information provided by the hardware security module to obtain an information encryption result;
[0014] The information encryption result is compared with a preset encryption result stored in the non-read-only memory of the hardware security module to obtain the module verification result.
[0015] In a possible implementation manner, the method further includes: calling the encryption algorithm and the encryption public key stored in the hardware security module through the initial startup code started in the first kernel, and before verifying each startup related information provided by the hardware security module:
[0016] Reading a life cycle register in the hardware security module through an initial startup code started in the first kernel;
[0017] Determine the enable state of the hardware security module based on the value of the life cycle register; wherein the enable state indicates whether the hardware security module is enabled;
[0018] If it is determined based on the enable state that the hardware security module is enabled, initialization processing is performed on the hardware security module.
[0019] In a possible implementation, if it is determined based on the enable state that the hardware security module is enabled, initialization processing is performed on the hardware security module, including:
[0020] Through the initial startup code started in the first kernel, the encryption algorithm and encryption public key stored in the hardware security module are called from the read-only memory of the hardware security module, and encryption calculation is performed on various startup related information provided by the hardware security module to obtain a preset encryption result, and the preset encryption result is saved in the non-read-only memory of the hardware security module.
[0021] In a possible implementation, the method further includes:
[0022] If it is determined that the hardware security module is not enabled, the application program in the micro control unit is directly started.
[0023] In a possible implementation, the startup-related information includes at least: public key list information, address mapping table information and code mirror information; wherein the public key list information includes public key information required for pre-startup verification of an application that the second kernel needs to run; the address mapping table information includes address information required for pre-startup verification of an application that the second kernel needs to run; and the code mirror information indicates a mirror file of code required for pre-startup verification of an application that the second kernel needs to run.
[0024] In a possible implementation, the method further includes:
[0025] If the initial startup code started in the second kernel does not detect the module successful operation information, the initial startup code started in the second kernel is controlled to be in a dormant state.
[0026] In a second aspect, an embodiment of the present application provides a secure startup device applied to a micro control unit, comprising:
[0027] A startup module, configured to start initial startup codes in a first kernel and a second kernel respectively running in the microcontroller unit in response to a power-on operation of the microcontroller unit; wherein the first kernel is used to run a hardware security module; and the second kernel is used to run an application program;
[0028] A first verification module is used to call the encryption algorithm and encryption public key stored in the hardware security module through the initial startup code started in the first kernel, and verify the startup related information provided by the hardware security module to obtain a module verification result; wherein the module verification result is used to indicate whether the startup related information provided by the hardware security module is accurate;
[0029] A generating module, configured to generate module successful operation information if the module verification result indicates that each startup related information provided by the hardware security module is accurate; wherein the module successful operation information indicates that the hardware security module has been successfully operated;
[0030] The second verification module is used to perform a pre-startup verification on the application required to be run by the second kernel based on the hardware security module after the initial startup code started in the second kernel detects the successful operation information of the module, and start the application in the micro control unit after the verification passes.
[0031] In a possible implementation, the first verification module is used to:
[0032] Calling the encryption algorithm and encryption public key stored in the hardware security module from the read-only memory of the hardware security module through the initial startup code started in the first kernel;
[0033] Based on the encryption algorithm and encryption public key stored in the hardware security module, encrypt and calculate the startup related information provided by the hardware security module to obtain an information encryption result;
[0034] The information encryption result is compared with a preset encryption result stored in the non-read-only memory of the hardware security module to obtain the module verification result.
[0035] In a possible implementation manner, the device further includes an initialization module, configured to:
[0036] The initial startup code started in the first kernel is used to call the encryption algorithm and the encryption public key stored in the hardware security module, and before verifying each startup related information provided by the hardware security module, the life cycle register in the hardware security module is read by the initial startup code started in the first kernel;
[0037] Determine the enable state of the hardware security module based on the value of the life cycle register; wherein the enable state indicates whether the hardware security module is enabled;
[0038] If it is determined based on the enable state that the hardware security module is enabled, initialization processing is performed on the hardware security module.
[0039] In a possible implementation, the initialization module is used to:
[0040] Through the initial startup code started in the first kernel, the encryption algorithm and encryption public key stored in the hardware security module are called from the read-only memory of the hardware security module, and encryption calculation is performed on various startup related information provided by the hardware security module to obtain a preset encryption result, and the preset encryption result is saved in the non-read-only memory of the hardware security module.
[0041] In a possible implementation, the device is also used for:
[0042] If it is determined that the hardware security module is not enabled, the application program in the micro control unit is directly started.
[0043] In a possible implementation, the startup-related information includes at least: public key list information, address mapping table information and code mirror information; wherein the public key list information includes public key information required for pre-startup verification of an application that the second kernel needs to run; the address mapping table information includes address information required for pre-startup verification of an application that the second kernel needs to run; and the code mirror information indicates a mirror file of code required for pre-startup verification of an application that the second kernel needs to run.
[0044] In a possible implementation manner, the second verification module is further used to:
[0045] If the initial startup code started in the second kernel does not detect the module successful operation information, the initial startup code started in the second kernel is controlled to be in a dormant state.
[0046] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor;
[0047] The memory stores computer-executable instructions;
[0048] The processor executes the computer-executable instructions stored in the memory, so that the processor executes the above first aspect and / or various possible implementations of the first aspect.
[0049] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the first aspect above and / or various possible implementations of the first aspect.
[0050] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the above first aspect and / or various possible implementation methods of the first aspect.
[0051] The secure boot method, device, equipment and medium applied to the microcontroller unit provided by the embodiment of the present application can respond to the power-on operation of the microcontroller unit, and respectively start the initial boot code in the first core and the second core running in the microcontroller unit to prepare for the startup of the microcontroller unit. Then, through the initial boot code started in the first core, the encryption algorithm and the encryption public key stored in the hardware security module are called to verify the various boot-related information provided by the hardware security module. At this time, the accuracy of the hardware security module for secure booting can be ensured by verifying the various boot-related information stored in the memory of the hardware security module, thereby helping to ensure the effectiveness of secure booting. Afterwards, when it is determined that the various boot-related information provided by the hardware security module is accurate, the module successful operation information can be generated. At this time, after the initial boot code started in the second core detects the module successful operation information, based on the hardware security module, the application required to run in the second core is pre-started and verified, and after the verification is passed, the application in the microcontroller unit is started. In this implementation, since the hardware security module is implemented as software, it not only saves costs, shortens the development cycle, and improves the development efficiency of the hardware security module, but also allows the application to customize the verification content before startup, thereby improving the flexibility and diversity of secure startup. BRIEF DESCRIPTION OF THE DRAWINGS
[0052] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0053] Figure 1 A schematic diagram of a process flow for secure startup of a microcontroller unit provided in an embodiment of the present application;
[0054] Figure 2 A schematic diagram of another process flow for secure startup of a microcontroller unit provided in an embodiment of the present application;
[0055] Figure 3 A schematic diagram of the memory arrangement of an HSM provided in an embodiment of the present application;
[0056] Figure 4 A flowchart of a secure startup method applied to a microcontroller unit provided in an embodiment of the present application;
[0057] Figure 5 A schematic diagram of the structure of a safety startup device applied to a micro control unit provided in an embodiment of the present application;
[0058] Figure 6 A schematic diagram of the structure of another safe starting device applied to a micro control unit provided in an embodiment of the present application;
[0059] Figure 7 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0060] The above drawings have shown clear embodiments of the present application, which will be described in more detail later. These drawings and text descriptions are not intended to limit the scope of the present application in any way, but to illustrate the concept of the present application to those skilled in the art by referring to specific embodiments. DETAILED DESCRIPTION
[0061] Here, exemplary embodiments will be described in detail, and examples thereof are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are only examples of devices and methods consistent with some aspects of the present application.
[0062] First, the terms involved in this application are explained.
[0063] BootRom: The full name is Boot Read-Only Memory, which is a read-only memory, usually used to store the initial startup code of a computer or embedded system.
[0064] AES: The full name is Advanced Encryption Standard, which is a symmetric encryption algorithm.
[0065] ROM: Read-Only Memory, read-only memory.
[0066] RAM: Random Access Memory.
[0067] FLASH: is a non-volatile memory.
[0068] MAC: Message Authentication Code, a value generated by a symmetric encryption algorithm and a key to verify the integrity and authenticity of a message.
[0069] HMAC: Hash-based Message Authentication Code, a hashed message authentication code, is a MAC value generated based on a hash function and a key.
[0070] Digital signature: Information generated using an asymmetric encryption algorithm and a key to verify the integrity of a message and the identity of the sender.
[0071] BootLoader: boot loader.
[0072] MCU secure boot is designed to verify the integrity and accuracy of key user-defined programs and content in the memory, thereby preventing the application from being tampered with and causing operational risks.
[0073] In the prior art, MCU secure boot can be performed based on HSM. However, the traditional HSM design is mainly based on hardware development and design. For example, various encryption algorithms can be implemented through hardware to achieve secure boot of MCU. However, this implementation method will fix the secure boot method and process of HSM, resulting in a lack of flexibility in secure boot based on HSM. In addition, the hardware development and design method will lead to the problems of long development cycle of HSM, high resource investment and high hardware cost.
[0074] The secure boot method for a microcontroller unit provided in the present application implements HSM through software, and then implements secure boot of the MCU based on HSM to solve the above technical problems.
[0075] The technical solution of the present application and how the technical solution of the present application solves the above-mentioned technical problems are described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present application will be described below in conjunction with the accompanying drawings.
[0076] Figure 1 A schematic diagram of a process flow for secure startup of a microcontroller unit provided in an embodiment of the present application is shown in FIG. Figure 1 As shown, the method includes:
[0077] S101 , in response to a power-on operation of a micro control unit, initial startup codes are respectively started in a first core and a second core running in the micro control unit.
[0078] The first core is used to run the hardware security module; the second core is used to run the application program.
[0079] In one example, a microcontroller unit may be applied to an embedded system. In this case, after detecting that the embedded system is powered on, it may be determined that the power-on operation of the microcontroller unit is detected. After that, in response to the power-on operation of the microcontroller unit, an initial startup code may be started in each core (for example, a first core and a second core) included in the microcontroller unit.
[0080] In the embodiment of the present application, the number of second cores running in the MCU may be one or more, which is not limited here.
[0081] In one example, the initial startup code can be understood as a code stored in the BootRom of the MCU for initial startup of the system.
[0082] S102: calling the encryption algorithm and encryption public key stored in the hardware security module through the initial startup code started in the first kernel, verifying various startup related information provided by the hardware security module, and obtaining a module verification result.
[0083] The module verification result is used to indicate whether the startup related information provided by the hardware security module is accurate.
[0084] In one example, the encryption algorithm stored in the HSM may be a symmetric encryption algorithm or an asymmetric encryption algorithm, which is not limited here. For example, the encryption algorithm stored in the HSM may be an AES algorithm (eg, AES128).
[0085] In an example, the encryption public key can be understood as the public key information generated when the MCU establishes a connection with the kernel, and the specific content of the encryption public key is not limited here.
[0086] In one example, before starting the MCU, the encryption algorithm and the encryption public key can be stored in the ROM of the HSM. At this time, the encryption algorithm and the encryption public key in the HSM can be prevented from being tampered with through the ROM, thereby ensuring the accuracy of the verification processing based on the encryption algorithm and the encryption public key.
[0087] In one example, the startup related information provided by the HSM is used to indicate the verification related information required by each application running in the MCU. For example, the startup related information may at least include: public key list information, address mapping table information, and code image files, etc. At this time, the startup related information may indicate the public key information relied on by all verification modules for secure startup (that is, the public key information required for the application running on the second core of the MCU to perform pre-startup verification), the address information required for secure startup (that is, the address information required for the application running on the second core of the MCU to perform pre-startup verification), and other algorithms / codes involved in the secure startup process (wherein, the code can be used to implement the various functional modules required in the verification process, such as a security log module, a public key information management module, etc., or the code indicates other algorithms, such as a hash algorithm, etc.) corresponding to the image file, etc.
[0088] S103: If the module verification result indicates that the startup-related information provided by the hardware security module is accurate, then module successful operation information is generated.
[0089] The module successful operation information indicates that the hardware security module has successfully operated.
[0090] In one example, after the module successful operation information is generated, the module successful operation information may be saved in a preset register, or the module successful operation information may be sent to the second core.
[0091] S104: After the initial startup code started in the second kernel detects the successful operation information of the module, based on the hardware security module, a pre-startup check is performed on the application program to be run by the second kernel, and after the check passes, the application program in the micro control unit is started.
[0092] For example, the boot loader loaded in the application program to be run by the second kernel may be verified by the HSM to ensure that the boot loader has not been tampered with.
[0093] In addition, the HSM can also be used to verify information such as images and data that the application program that the second core needs to run depends on, and after the verification is passed, the application program in the MCU can be started.
[0094] It can be known from the above description that the embodiment of the present application can start the initial startup code in the first kernel and the second kernel running in the microcontroller in response to the power-on operation of the microcontroller, respectively, to prepare for the startup of the microcontroller. Then, through the initial startup code started in the first kernel, the encryption algorithm and the encryption public key stored in the hardware security module are called, and the startup related information provided by the hardware security module is verified. At this time, the accuracy of the hardware security module for safe startup can be ensured by verifying the startup related information stored in the memory of the hardware security module, so as to help ensure the effectiveness of safe startup. Afterwards, when it is determined that the startup related information provided by the hardware security module is accurate, the module successful operation information is generated. At this time, after the initial startup code started in the second kernel detects the module successful operation information, based on the hardware security module, the application program required to run in the second kernel is pre-started and verified, and after the verification is passed, the application program in the microcontroller is started. In this implementation, since the hardware security module is implemented by software, it not only saves costs, shortens the development cycle, and improves the development efficiency of the hardware security module, but also can customize the verification content of the application program for pre-start verification, thereby improving the flexibility and diversity of safe startup.
[0095] Figure 2 Another flowchart of secure startup of a microcontroller unit provided in an embodiment of the present application is as follows: Figure 2 As shown, the method includes:
[0096] S201 , in response to a power-on operation of a micro control unit, initial startup codes are respectively started in a first core and a second core running in the micro control unit.
[0097] The first core is used to run the hardware security module; the second core is used to run the application program.
[0098] S202: Read the life cycle register in the hardware security module through the initial startup code started in the first kernel.
[0099] In an example, the lifecycle register may indicate the lifecycle register. In this case, the lifecycle stage of the MCU secure boot may be determined based on the value of each register bit in the lifecycle register.
[0100] S203: Determine the enable state of the hardware security module based on the value of the life cycle register.
[0101] The enablement status indicates whether the hardware security module is enabled. For example, the enablement status may indicate that the HSM is enabled, or indicate that the HSM is not enabled.
[0102] Among them, enabling is used to indicate that the HSM can execute corresponding security functions and policies, and disabling indicates that the HSM does not execute corresponding security functions and policies.
[0103] S204: If it is determined that the hardware security module is not enabled, directly start the application program in the micro control unit.
[0104] At this time, when it is determined that the HSM is not enabled, it means that the HSM is not started. Therefore, the application program in the micro control unit can be directly started, thereby speeding up the startup speed of the application program.
[0105] S205: If it is determined based on the enabling state that the hardware security module is enabled, initialization processing is performed on the hardware security module.
[0106] At this time, the value of the life cycle register can be used to quickly determine whether the HSM is enabled, that is, to quickly determine whether to start the HSM for secure boot, so that secure boot can be performed based on the HSM on demand, thereby improving the performance of the embedded system / device where the microcontroller unit is located.
[0107] In one example, when it is determined that the hardware security module is enabled and the hardware security module is initialized, the encryption algorithm and encryption public key stored in the hardware security module can be called from the read-only memory of the hardware security module through the initial startup code started in the first kernel, and the startup related information provided by the hardware security module is encrypted and calculated to obtain a preset encryption result, and the preset encryption result is saved in the non-read-only memory of the hardware security module. Among them, the non-read-only memory can be RAM, FLASH, etc., and the type of the non-read-only memory is not limited here, and it is based on meeting actual needs.
[0108] At this time, during the HSM initialization process, the preset encryption result corresponding to each startup-related information in the HSM can be determined according to the encryption algorithm and encryption public key stored in the HSM's read-only memory, so as to verify the accuracy of each startup-related information used during the secure startup based on the HSM according to the preset encryption result.
[0109] In one example, the preset encryption result may indicate a MAC value, digital signature, etc. calculated according to an encryption algorithm, or an HMAC value, etc. generated using a hash function and an encrypted public key. There is no limitation on the type of the preset encryption result.
[0110] In one example, after determining that the HSM initialization is complete, a secure boot can be performed based on the HSM. In specific implementation, the steps described below can be performed.
[0111] S206: Call the encryption algorithm and encryption public key stored in the hardware security module from the read-only memory of the hardware security module through the initial startup code started in the first kernel.
[0112] S207: Based on the encryption algorithm and encryption public key stored in the hardware security module, encrypt the startup related information provided by the hardware security module to obtain an information encryption result.
[0113] S208: Compare the information encryption result with the preset encryption result stored in the non-read-only memory of the hardware security module to obtain a module verification result.
[0114] The module verification result is used to indicate whether the startup related information provided by the hardware security module is accurate.
[0115] In one example, if the information encryption result is the same as the preset encryption result, the obtained module verification result indicates that the startup related information provided by the hardware security module is accurate. At this time, the steps described in S209 below can be continued.
[0116] If the information encryption result is different from the preset encryption result, the obtained module verification result indicates that the startup-related information provided by the hardware security module is inaccurate. At this time, you can stop starting the application in the microcontroller unit, or you can enter the safe mode. The specific execution content of the safe mode is not limited here, and it is subject to what can be implemented.
[0117] S209: If the module verification result indicates that the startup-related information provided by the hardware security module is accurate, then module successful operation information is generated.
[0118] The module successful operation information indicates that the hardware security module has successfully operated.
[0119] S210: After the initial startup code started in the second kernel detects the successful operation information of the module, based on the hardware security module, a pre-startup check is performed on the application program to be run by the second kernel, and after the check passes, the application program in the micro control unit is started.
[0120] S211: If the initial startup code started in the second kernel does not detect the module successful operation information, the initial startup code started in the second kernel is controlled to be in a dormant state.
[0121] This implementation method can ensure that after confirming that the HSM is correct, the application program that needs to be run by the second kernel is checked before startup, thereby ensuring the accuracy of the check and further ensuring the effectiveness of the secure startup.
[0122] In one example, since the HSM is implemented by software, it is necessary to set up a corresponding memory space in the HSM to store the code and data implemented by the software.
[0123] In one example, the corresponding memory can be allocated to the HSM as needed, for example, a 74KB memory can be configured in the HSM, or a 100KB memory can be configured, etc. At this time, the memory space corresponding to the HSM can be arranged and processed according to the specific functions implemented by the HSM.
[0124] See also Figure 3 , Figure 3 A schematic diagram of the memory arrangement of an HSM provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the HSM memory may include two types of memory, one is a read-only memory and the other is a non-read-only memory (e.g., Figure 3 The random access memory shown in the figure) is configured, and the corresponding memory size is allocated according to the content to be stored in the HSM memory. For example, if 74KB of memory is configured for the HSM, the memory of the HSM can be configured as follows.
[0125] In one example, the encryption algorithm and encryption public key determined in the process of establishing a trust chain in the HSM can be stored in a read-only memory, so that the content of this part can be guaranteed not to be changed. At this time, the corresponding memory space can be configured for the encryption algorithm and the encryption public key according to the type of the encryption algorithm. For example, if the encryption algorithm is a 128-bit encryption algorithm, then 128-bit memory space can be allocated for the encryption public key and 10KB memory space can be allocated for the encryption algorithm.
[0126] At the same time, the random access memory portion of the HSM can also be divided into three sub-parts for storing different types of startup related information and preset encryption results corresponding to each startup related information. For example, the first sub-part can be used to store public key list information and the public key list information (such as Figure 3 As shown, the preset encryption result corresponding to 1KB of memory space) (such as Figure 3 As shown, corresponding to 128 bits of memory space); the second sub-part can be used to store address mapping table information (such as Figure 3 As shown, corresponding to 1KB of memory space), and the preset encryption result corresponding to the address mapping table information (such as Figure 3 As shown, corresponding to 128 bits of memory space); the third sub-part can be used to store code image information (such as Figure 3 As shown, corresponding to 61KB of memory space), and the preset encryption result corresponding to the code image information (such as Figure 3 As shown, it corresponds to 128 bits of memory space).
[0127] At this time, the preset encryption key stored in the first sub-part is used to verify the public key list information, the preset encryption key stored in the second sub-part is used to verify the address mapping table information, and the preset encryption key stored in the third sub-part is used to verify the code image information.
[0128] In one example, Figure 4 The following is a flowchart of a secure startup method for a microcontroller unit provided in an embodiment of the present application. Figure 4 As shown, after the microcontroller is powered on, the initial startup code can be started in the first core and the second core running in the microcontroller, respectively. The first core is used to run the hardware security module, and the second core is used to run the application program.
[0129] At this time, if it is determined that the hardware security module is started for the first time, the life cycle register in the hardware security module can be read through the initial startup code of the first kernel, and the value of the life cycle register can be used to determine whether the hardware security module is enabled. If it is not enabled, the hardware security module is disabled. At this time, the micro control unit is not verified based on the hardware security module, and the application in the micro control unit is directly started.
[0130] If it is determined that the hardware security module is enabled, the hardware security module is initialized first, that is, the preset encryption result corresponding to the public key list information stored in the hardware security module is calculated first, and stored in the corresponding memory space. Then, the preset encryption result corresponding to the address mapping table information stored in the hardware security module is calculated, and stored in the corresponding memory space. Finally, the preset encryption result corresponding to the code image information stored in the hardware security module is calculated, and stored in the corresponding memory space.
[0131] Afterwards, the hardware security module can be run, and the hardware security module can be verified according to the preset encryption result, and when the module verification result indicates that the various startup related information provided by the hardware security module is accurate, module successful operation information is generated.
[0132] When it is determined that the hardware security module is not started for the first time, the encryption algorithm and encryption public key stored in the hardware security module can be directly called to verify the startup-related information provided by the hardware security module. If the module verification result indicates that the startup-related information provided by the hardware security module is accurate (that is, the verification passes), module successful operation information is generated.
[0133] At this time, after the initial startup code started in the second kernel detects the successful operation information of the module, the application program to be run by the second kernel can be pre-started and verified based on the hardware security module. For example, the BootLoader loaded in the second kernel can be verified first, and the BootLoader can be started after the verification passes. Then, the image and data in the second kernel are verified, and the application program in the micro control unit is started after the verification passes.
[0134] In the embodiment of the present application, the MCU secure boot speed / verification processing speed can be increased by increasing the CPU main frequency, or increasing the number of second cores.
[0135] Figure 5 A schematic diagram of a safety startup device applied to a microcontroller unit provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the safety starting device 500 applied to the micro control unit provided in this embodiment includes:
[0136] The startup module 501 is used to start the initial startup code in the first core and the second core running in the microcontroller in response to the power-on operation of the microcontroller; wherein the first core is used to run the hardware security module; and the second core is used to run the application program.
[0137] The first verification module 502 is used to call the encryption algorithm and encryption public key stored in the hardware security module through the initial startup code started in the first kernel, verify the startup related information provided by the hardware security module, and obtain the module verification result; wherein the module verification result is used to indicate whether the startup related information provided by the hardware security module is accurate.
[0138] The generating module 503 is used to generate module successful operation information if the module verification result indicates that the startup related information provided by the hardware security module is accurate; wherein the module successful operation information indicates that the hardware security module has been successfully operated.
[0139] The second verification module 504 is used to perform a pre-startup verification on the application program to be run by the second kernel based on the hardware security module after the initial startup code started in the second kernel detects the successful operation information of the module, and starts the application program in the micro control unit after the verification passes.
[0140] Figure 6 A schematic diagram of the structure of another secure startup device applied to a microcontroller unit provided in an embodiment of the present application is shown in FIG. Figure 6 As shown, the safety starting device 600 applied to the micro control unit provided in this embodiment includes:
[0141] The startup module 601 is used to start the initial startup code in the first kernel and the second kernel running in the microcontroller unit in response to the power-on operation of the microcontroller unit. The first kernel is used to run the hardware security module, and the second kernel is used to run the application program.
[0142] The first verification module 602 is used to call the encryption algorithm and encryption public key stored in the hardware security module through the initial startup code started in the first kernel, verify the startup related information provided by the hardware security module, and obtain the module verification result; wherein the module verification result is used to indicate whether the startup related information provided by the hardware security module is accurate.
[0143] The generating module 603 is used to generate module successful operation information if the module verification result indicates that the startup related information provided by the hardware security module is accurate; wherein the module successful operation information indicates that the hardware security module has been successfully operated.
[0144] The second verification module 604 is used to perform a pre-startup verification on the application program to be run by the second kernel based on the hardware security module after the initial startup code started in the second kernel detects the successful operation information of the module, and starts the application program in the micro control unit after the verification passes.
[0145] In a possible implementation, the first verification module 602 is configured to:
[0146] Calling the encryption algorithm and encryption public key stored in the hardware security module from the read-only memory of the hardware security module through the initial startup code started in the first kernel;
[0147] Based on the encryption algorithm and encryption public key stored in the hardware security module, encryption calculation is performed on each startup related information provided by the hardware security module to obtain an information encryption result;
[0148] The information encryption result is compared with the preset encryption result stored in the non-read-only memory of the hardware security module to obtain the module verification result.
[0149] In a possible implementation manner, the device further includes an initialization module 605, configured to:
[0150] The initial startup code started in the first kernel is used to call the encryption algorithm and the encryption public key stored in the hardware security module, and before verifying the startup related information provided by the hardware security module, the life cycle register in the hardware security module is read through the initial startup code started in the first kernel;
[0151] Determine the enable state of the hardware security module based on the value of the life cycle register; wherein the enable state indicates whether the hardware security module is enabled;
[0152] If it is determined based on the enable state that the hardware security module is enabled, the hardware security module is initialized.
[0153] In a possible implementation, the initialization module 605 is used to:
[0154] Through the initial startup code started in the first kernel, the encryption algorithm and encryption public key stored in the hardware security module are called from the read-only memory of the hardware security module, and encryption calculations are performed on various startup related information provided by the hardware security module to obtain a preset encryption result, and the preset encryption result is saved in the non-read-only memory of the hardware security module.
[0155] In a possible implementation, the device is also used for:
[0156] If it is determined that the hardware security module is not enabled, the application program in the micro control unit is directly started.
[0157] In a possible implementation, each startup-related information includes at least: public key list information, address mapping table information and code mirror information; wherein the public key list information includes public key information required for pre-startup verification of an application that needs to be run by the second kernel; the address mapping table information includes address information required for pre-startup verification of an application that needs to be run by the second kernel; and the code mirror information indicates a mirror file of code required for pre-startup verification of an application that needs to be run by the second kernel.
[0158] In a possible implementation manner, the second verification module 604 is further configured to:
[0159] If the initial startup code started in the second kernel does not detect the module successful operation information, the initial startup code started in the second kernel is controlled to be in a dormant state.
[0160] The secure boot device applied to a micro control unit provided in this embodiment can execute the method provided in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be described in detail here.
[0161] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 7 As shown, the electronic device 700 provided in this embodiment includes: at least one processor 701 and a memory 702. Optionally, the electronic device 700 further includes a communication component 703. The processor 701, the memory 702 and the communication component 703 are connected via a bus 704.
[0162] In a specific implementation process, at least one processor 701 executes the computer-executable instructions stored in the memory 702, so that at least one processor 701 executes the above method.
[0163] The specific implementation process of the processor 701 can be found in the above method embodiment, and its implementation principle and technical effect are similar, so this embodiment will not be repeated here.
[0164] In the above embodiments, it should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.
[0165] The memory may include a high-speed memory (Random Access Memory, RAM), and may also include a non-volatile memory (Non-volatile Memory, NVM), such as at least one disk memory.
[0166] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.
[0167] The present application also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0168] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When a processor executes the computer-executable instructions, the above method is implemented.
[0169] The above-mentioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general or special-purpose computer.
[0170] An exemplary readable storage medium is coupled to a processor so that the processor can read information from the readable storage medium and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (Application Specific Integrated Circuits, referred to as: ASIC). Of course, the processor and the readable storage medium can also exist in the device as discrete components.
[0171] The division of units is only a logical function division, and there may be other divisions in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interface, device or unit, which can be electrical, mechanical or other forms.
[0172] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0173] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0174] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, 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. The computer software product is stored in a storage medium, including several instructions for enabling an electronic device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, and other media that can store program codes.
[0175] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.
[0176] Finally, it should be noted that those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention, which follow the general principles of the present invention and include common knowledge or customary technical means in the art not disclosed by the present invention, are not limited to the precise structure described above and shown in the drawings, and may be modified and changed in various ways without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.
Claims
1. A secure startup method applied to a microcontroller unit, characterized in that: The method comprises: In response to a power-on operation of the microcontroller unit, initial startup codes are started in a first kernel and a second kernel running in the microcontroller unit, respectively; wherein the first kernel is used to run a hardware security module; and the second kernel is used to run an application program; By using the initial startup code started in the first kernel, the encryption algorithm and the encryption public key stored in the hardware security module are called to verify the startup related information provided by the hardware security module to obtain a module verification result; wherein the module verification result is used to indicate whether the startup related information provided by the hardware security module is accurate; If the module verification result indicates that each startup-related information provided by the hardware security module is accurate, then module successful operation information is generated; wherein the module successful operation information indicates that the hardware security module has been successfully operated; After the initial startup code started in the second kernel detects the successful operation information of the module, based on the hardware security module, a pre-startup check is performed on the application program required to be run by the second kernel, and after the check passes, the application program in the micro control unit is started.
2. The method according to claim 1, characterized in that The initial startup code started in the first kernel calls the encryption algorithm and encryption public key stored in the hardware security module, verifies and processes various startup related information provided by the hardware security module, and obtains a module verification result, including: Calling the encryption algorithm and encryption public key stored in the hardware security module from the read-only memory of the hardware security module through the initial startup code started in the first kernel; Based on the encryption algorithm and encryption public key stored in the hardware security module, encrypt and calculate the startup related information provided by the hardware security module to obtain an information encryption result; The information encryption result is compared with a preset encryption result stored in the non-read-only memory of the hardware security module to obtain the module verification result.
3. The method according to claim 1, characterized in that The method further includes, before the initial startup code started in the first kernel is used to call the encryption algorithm and the encryption public key stored in the hardware security module and verify the startup related information provided by the hardware security module: Reading a life cycle register in the hardware security module through an initial startup code started in the first kernel; Determine the enable state of the hardware security module based on the value of the life cycle register; wherein the enable state indicates whether the hardware security module is enabled; If it is determined based on the enable state that the hardware security module is enabled, initialization processing is performed on the hardware security module.
4. The method according to claim 3, characterized in that If it is determined based on the enabled state that the hardware security module is enabled, initializing the hardware security module, including: Through the initial startup code started in the first kernel, the encryption algorithm and encryption public key stored in the hardware security module are called from the read-only memory of the hardware security module, and encryption calculation is performed on various startup related information provided by the hardware security module to obtain a preset encryption result, and the preset encryption result is saved in the non-read-only memory of the hardware security module.
5. The method according to claim 3, characterized in that: The method further comprises: If it is determined that the hardware security module is not enabled, the application program in the micro control unit is directly started.
6. The method according to any one of claims 1 to 4, characterized in that The startup-related information includes at least: public key list information, address mapping table information and code mirror information; wherein the public key list information includes public key information required for pre-startup verification of an application that the second kernel needs to run; the address mapping table information includes address information required for pre-startup verification of an application that the second kernel needs to run; and the code mirror information indicates a mirror file of code required for pre-startup verification of an application that the second kernel needs to run.
7. The method according to any one of claims 1 to 3, characterized in that The method further comprises: If the initial startup code started in the second kernel does not detect the module successful operation information, the initial startup code started in the second kernel is controlled to be in a dormant state.
8. A safe starting device applied to a micro control unit, characterized in that: include: A startup module, configured to start initial startup codes in a first kernel and a second kernel respectively running in the microcontroller unit in response to a power-on operation of the microcontroller unit; wherein the first kernel is used to run a hardware security module; and the second kernel is used to run an application program; A first verification module is used to call the encryption algorithm and encryption public key stored in the hardware security module through the initial startup code started in the first kernel, and verify the startup related information provided by the hardware security module to obtain a module verification result; wherein the module verification result is used to indicate whether the startup related information provided by the hardware security module is accurate; A generating module, configured to generate module successful operation information if the module verification result indicates that each startup related information provided by the hardware security module is accurate; wherein the module successful operation information indicates that the hardware security module has been successfully operated; The second verification module is used to perform a pre-startup verification on the application required to be run by the second kernel based on the hardware security module after the initial startup code started in the second kernel detects the successful operation information of the module, and start the application in the micro control unit after the verification passes.
9. An electronic device, characterized in that: include: Memory, processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor executes the secure boot method applied to a micro control unit according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the secure startup method applied to a microcontroller unit according to any one of claims 1 to 7.
Citation Information
Patent Citations
ECU and starting method thereof
CN111832012A
Safe starting method and device for vehicle-mounted MCU
CN115422545A
Secure startup control method and device of chip, electronic equipment and storage medium
CN115795472A
Navigation system starting method, MCU and navigation terminal
CN116467000A
Chip security starting method and chip
CN116775150A
Cited By
Starting method, system and device of embedded system and storage medium
CN120469724A
