HSM-based MCU safe starting implementation method

By dividing the signature area, code area and data area in the MCU and using HSM for staged verification, the problem of time-consuming and security risks of MCU secure startup is solved, and a fast and secure startup process is achieved, satisfying the OEM's ECU Start time requirements.

CN119203154APending Publication Date: 2024-12-27YANGZHOU HANGSHENG TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411276525.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2024-12-27

AI Technical Summary

Technical Problem

The existing MCU secure boot mode takes a long time to verify the legitimacy of the firmware, and the parallel mode has unverified firmware that may run, resulting in security risks and it is difficult to meet the OEM requirements for ECU startup time.

Method used

Using the secure startup method based on HSM, the MCU application core runs Flash into a signature area, code area and data area. The HSM performs phased verification, first verify the code area, and then verify the data area. Use simple and complex signatures to reduce verification time, and back up firmware to secure core dedicated Flash when upgraded to ensure recovery.

Benefits of technology

Without reducing security, the startup time of the MCU is significantly reduced, the verification speed is improved, the ECU is fast booting, and the firmware matching is quickly identified through subdivided anti-degradation version features, avoiding firmware downgrade and unverified Risk of operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119203154A_ABST
    Figure CN119203154A_ABST
Patent Text Reader

Abstract

The invention discloses a method for realizing MCU (Microprogrammed Control Unit) safe starting based on HSM (Hardware Service Management) in the technical field of vehicle-mounted system safe starting, which comprises the following steps of: 1, dividing an application core running Flash in an MCU into a signature area, a code area and a data area; 2, an HSM, namely a hardware security module, is arranged in the MCU; and step 3, starting safe starting. According to the method, an MCU application core link file is processed, a code segment is specially separated from a data segment, a code area is verified firstly during verification, and a parallel verification method of an MCU application core and a data area is started when the code area is verified successfully; by using a simple signature and a complex signature, the MCU application core is started when the simple signature is verified successfully, and the complex signature is verified in parallel; during upgrading, the MCU application core firmware is compressed and backed up to the MCU security core special running Flash so as to protect the backup from being damaged, and the MCU application core firmware is recovered from the MCU security core special running Flash when verification fails.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to an HSM-based MCU secure booting implementation method in the technical field of secure booting of an in-vehicle system. Background Art

[0002] More and more OEMs have put forward the requirements for secure booting of ECUs. Secure booting requires the legality verification of the firmware to be run before the MCU runs, which takes a certain amount of time. However, the OEMs have not relaxed the requirements for the ECU startup time. This has brought great challenges to the development of ECUs that meet the requirements of OEMs. Currently, there are two modes for MCU secure booting: serial mode and parallel mode. In serial mode, the MCU application core is started only after the MCU application core firmware is verified. This method will increase the startup time of the MCU. In parallel mode, the MCU application core is started first, and then the MCU application core firmware is verified. Although this reduces the startup time, it will cause the unverified MCU application core firmware to run for a period of time, which poses a risk. Summary of the invention

[0003] The purpose of the present invention is to provide a method for realizing secure booting of MCU based on HSM, which can improve the verification speed and reduce the booting time of ECU without reducing the security, so as to meet the requirements of the host manufacturer.

[0004] To achieve the above object, the present invention provides a method for implementing MCU secure boot based on HSM, comprising the following steps: Step 1: Divide the application core running Flash in the MCU into a signature area, a code area, and a data area; Step 2: Set up HSM, or hardware security module, inside the MCU; Step 3: Enable secure boot.

[0005] As a further improvement of the present invention, the specific content of the division of the data area and the code area in step 1 is as follows: the link file in the compilation environment of the MCU application core running the Flash is processed to identify which segments are code segments and which segments are data segments. In the link file, all code segments are placed in the front to form the code area, and all data segments are placed in the back to form the data area. There is no order between code segments and between data segments; a boundary symbol and alignment length are placed between the code area and the data area, and the size of the code area is a binary integer multiple of the alignment length.

[0006] In this way, the code area is used for running, and the secure boot needs to verify it first. The data area does not need to be run and can be verified after the MCU application core is running. After each MCU application core firmware is compiled, the starting address of the data area can be successfully found in the map file, and the verification algorithm can meet the data alignment requirements.

[0007] As a further improvement of the present invention, the specific content of the signature area division in step 1 is as follows: the signature area includes the starting address of the code area, the length of the code area, the simple signature of the code area, the complex signature of the code area, the starting address of the data area, the length of the data area, the simple signature of the data area, the complex signature of the data area, and the end mark; The starting address of the code area, the length of the code area, the starting address of the data area and the length of the data area are obtained from the map file. The simple signature of the code area and the simple signature of the data area are obtained by using the hardware encryption engine of the HSM or an asymmetric algorithm with low computational intensity. The complex signature of the code area and the complex signature of the data area are obtained by using an asymmetric algorithm with high computational intensity.

[0008] In order to reduce the amount of verification data and shorten the verification time, the signature scope will only include the code area and the data area.

[0009] As a further improvement of the present invention, the signature area is also provided with an anti-downgrade version feature, which includes sub-feature 1, sub-feature 2, sub-feature 3 and a complex signature, wherein sub-feature 1 is used to distinguish products, sub-feature 2 is used to distinguish devices, and sub-feature 3 is used to distinguish anti-rollback version numbers. The complex signature is obtained by calculating sub-feature 1, sub-feature 2 and sub-feature 3 using an asymmetric algorithm with high computational intensity.

[0010] In this way, when performing anti-downgrade, it is necessary to determine whether sub-feature 1 is the same, whether sub-feature 2 is the same, and whether the size of sub-feature 3 is determined to complete the anti-downgrade judgment, which can avoid the problem of the anti-downgrade function failing due to the use of derivative firmware.

[0011] As a further improvement of the present invention, the specific content of step 2 is as follows: step 2.1, the HSM includes a dedicated CPU, dedicated RAM, a security core dedicated running Flash, and a security core dedicated data Flash, and the HSM also has the highest access permission for MCU storage. The size of the security core dedicated data Flash and the security core dedicated running Flash can be divided from the MCU's application core data Flash and the MCU's application core running Flash according to actual needs; step 2.2, the security core dedicated running Flash is divided into an application core firmware backup area and a security core firmware area.

[0012] In this way, the Flash of the application core starts from the head and ends at the boundary, and the Flash of the security core starts from the boundary and ends at the end. The boundary can be customized on a blank MCU, and once set, it cannot be changed. The application core of the MCU cannot access the dedicated Flash of the HSM outside the boundary, preventing the dedicated Flash of the HSM from being attacked and tampered.

[0013] As a further improvement of the present invention, the specific contents of step 2.2 are as follows: the application core firmware backup area is an area where the security core of the HSM compresses and backs up the application core firmware of the MCU after the MCU application core firmware upgrade is completed and the verification is successful; when the application core firmware of the MCU fails to be verified, it is restored from this area so that the application core of the MCU can run with the same version of firmware; the security core firmware area is the core content of the HSM, which includes the secure boot verification strategy, the MCU application core firmware recovery strategy and the anti-downgrade strategy.

[0014] In this way, during the upgrade, the application core firmware is compressed and backed up to the security core dedicated running Flash to protect the backup from being damaged. After the MCU application core firmware verification fails, the same version of the MCU application core firmware can be restored from the MCU security core dedicated running Flash.

[0015] As a further improvement of the present invention, the specific content of step 3 is as follows: Step 3.1, after enabling secure boot, the MCU will first run the HSM security core when powered on or reset; Step 3.2: Verification of anti-downgrade version features; Step 3.3, verification of code area and data area.

[0016] In this way, the increase in startup time is greatly reduced by using a method of phased verification and performing simple verification first and then complex verification, while not reducing security. After the upgrade is completed, the MCU application core firmware is compressed into the running Flash of the security core for backup. When the MCU application core firmware verification fails, the same version of the MCU application core firmware is available for recovery.

[0017] As a further improvement of the present invention, the specific content of step 3.2 is as follows: Step 3.2.1, the HSM security core verifies the complex signature in the anti-downgrade version feature, and detects the anti-downgrade version feature of the MCU's application core firmware and compares it with the anti-downgrade version feature that has been saved in the security core dedicated data Flash. If the complex signature verification fails or the comparison result is a mismatch, the MCU's application core firmware is restored from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; Step 3.2.2, if the complex signature verification succeeds and the anti-downgrade version comparison successfully matches, the HSM security core verifies the simple signature of the code area. If the simple signature verification of the code area fails, the MCU's application core firmware is restored from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; In step 3.2.3, if the simple signature verification of the code area succeeds, the application core of the MCU can be started and the application core function of the MCU can be executed to reduce the startup time.

[0018] As a further improvement of the present invention, the specific content of step 3.3 is as follows: Step 3.3.1, the HSM security core then verifies the simple signature of the data area. If the verification fails, it means that the MCU's application firmware is untrustworthy, because the MCU's application core has been started and cannot be executed according to the simple signature verification failure of the code area or the anti-downgrade version feature mismatch method. At this time, the signature area needs to be erased and the system restarted. After the system is restarted again, the HSM security core detects that the anti-downgrade version feature does not match, and restores the MCU's application core firmware from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; Step 3.3.2, if the simple signature verification of the data area succeeds, start to verify the complex signature of the code area. If the verification fails, it is necessary to erase the signature area and restart the system. After restarting the system again, the HSM security core detects that the anti-downgrade version feature does not match, and restores the MCU's application core firmware from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; Step 3.3.3, if the complex signature verification of the code area succeeds, start to verify the complex signature of the data area. If the verification fails, it is necessary to erase the signature area and restart the system. After restarting the system again, the HSM security core detects that the anti-downgrade version feature does not match, and restores the MCU's application core firmware from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; Step 3.3.4, if the complex signature verification of the data area is successful, it means that the entire MCU application core firmware verification is successful and the security strength is sufficient. At this time, the secure boot verification work is completed and the ECU starts normally.

[0019] As a further improvement of the present invention, when the application core firmware of the MCU is upgraded, after the application core firmware is written into the application core running Flash of the MCU, the application core of the MCU calls the verification service of the HSM, and the security core of the HSM verifies the simple signature of the code area, the complex signature of the code area, the simple signature of the data area, and the simple signature of the data area and the complex signature of the data area of ​​the application core firmware of the MCU, and then returns the verification result. If the verification is successful, the security core of the HSM will compress and back up the application core firmware of the MCU to the application core firmware backup area of ​​the security core running Flash; if the verification fails, the application core firmware backup area of ​​the HSM will retain the compressed backup of the application core firmware when the application core firmware was successfully upgraded last time.

[0020] This ensures that the MCU's application core firmware backup area is the latest available and reliable application core firmware. Even if the application core firmware upgrade fails, the application core firmware backup area can retain the compressed backup of the application core firmware when the last upgrade was successful.

[0021] Compared with the prior art, the beneficial effects of the present invention lie in that, by processing the MCU application core link file, the code segment and the data segment are specially distinguished, and the code area is verified first during verification, and the MCU application core is started when the code area verification is successful, and the data area is verified in parallel; by using simple signatures and complex signatures, the MCU application core is started when the simple signature verification is successful, and the complex signatures are verified in parallel; when upgrading, the MCU application core firmware is compressed and backed up to the MCU security core dedicated running Flash to protect the backup from being damaged, and the MCU application core firmware fails to be verified and restored from the MCU security core dedicated running Flash; the anti-downgrade version feature is subdivided into sub-feature 1, sub-feature 2, and sub-feature 3, which are used to quickly identify whether the MCU application core firmware matches the current device and prevent version downgrade. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 This is a block diagram of the MCU chip in the present invention.

[0023] Figure 2 This is a schematic diagram of Flash partitioning for running the application core of the present invention.

[0024] Figure 3 This is a schematic diagram of Flash partitioning for the security core operation of the present invention.

[0025] Figure 4 Schematic diagram of the signature area division of the present invention.

[0026] Figure 5 This is a schematic diagram of the feature division of downgraded versions of the present invention.

[0027] Figure 6 The present invention is a flowchart for implementing a safe startup detection.

[0028] Figure 7 This is a schematic diagram of the application core firmware upgrade backup process of the present invention. DETAILED DESCRIPTION

[0029] The present invention is further described below in conjunction with the accompanying drawings: like Figure 1-7 The method for implementing secure booting of an MCU based on HSM is characterized in that it includes the following steps: Step 1: Divide the application core running Flash in the MCU into a signature area, a code area, and a data area; Process the link file in the compilation environment of the Flash running in the MCU application core, identify which segments are code segments and which segments are data segments, put all code segments in the front of the link file to form a code area, and put all data segments in the back to form a data area. There is no order between code segments, and there is no order between data segments. Place a boundary symbol and alignment length between the code area and the data area, and the size of the code area is a binary integer multiple of the alignment length.

[0030] The signature area includes the starting address of the code area, the length of the code area, the simple signature of the code area, the complex signature of the code area, the starting address of the data area, the length of the data area, the simple signature of the data area, the complex signature of the data area and the end mark; The starting address of the code area, the length of the code area, the starting address of the data area and the length of the data area are obtained from the map file. The simple signature of the code area and the simple signature of the data area are obtained by using the hardware encryption engine of the HSM or an asymmetric algorithm with low computational intensity. The complex signature of the code area and the complex signature of the data area are obtained by using an asymmetric algorithm with high computational intensity.

[0031] The signature area also has anti-downgrade version features, which include sub-feature 1, sub-feature 2, sub-feature 3 and complex signatures. Sub-feature 1 is used to distinguish products, sub-feature 2 is used to distinguish devices, and sub-feature 3 is used to distinguish anti-rollback version numbers. The complex signature is calculated by using a high-computational intensity asymmetric algorithm on sub-feature 1, sub-feature 2 and sub-feature 3.

[0032] Step 2: Set up HSM, or hardware security module, inside the MCU; Step 2.1, HSM contains a dedicated CPU, dedicated RAM, security core dedicated operation Flash, security core dedicated data Flash, and HSM also has the highest access permission for MCU storage. The size of the security core dedicated data Flash and security core dedicated operation Flash can be divided from the MCU application core data Flash and MCU application core operation Flash according to actual needs; Step 2.2, divide the dedicated running Flash of the security core into the application core firmware backup area and the security core firmware area. The application core firmware backup area is used by the HSM security core to compress and back up the MCU's application core firmware after the MCU application core firmware upgrade is completed and verified successfully; it is restored from this area when the MCU's application core firmware verification fails, so that the MCU's application core can run with the same version of firmware; the security core firmware area is the core content of the HSM, which includes the secure boot verification strategy, the MCU application core firmware recovery strategy, and the anti-downgrade strategy.

[0033] Step 3: Enable secure boot.

[0034] Step 3.1, after enabling secure boot, the MCU will first run the HSM security core when powered on or reset; Step 3.2: Verification of anti-downgrade version features; Step 3.2.1, the HSM security core verifies the complex signature in the anti-downgrade version feature, and detects the anti-downgrade version feature of the MCU's application core firmware and compares it with the anti-downgrade version feature that has been saved in the security core dedicated data Flash. If the complex signature verification fails or the comparison result is a mismatch, the MCU's application core firmware is restored from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; Step 3.2.2, if the complex signature verification succeeds and the anti-downgrade version comparison successfully matches, the HSM security core verifies the simple signature of the code area. If the simple signature verification of the code area fails, the MCU's application core firmware is restored from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; In step 3.2.3, if the simple signature verification of the code area succeeds, the application core of the MCU can be started and the application core function of the MCU can be executed to reduce the startup time.

[0035] Step 3.3, verification of code area and data area.

[0036] Step 3.3.1, the HSM security core then verifies the simple signature of the data area. If the verification fails, it means that the MCU's application firmware is untrustworthy, because the MCU's application core has been started and cannot be executed according to the simple signature verification failure of the code area or the anti-downgrade version feature mismatch method. At this time, the signature area needs to be erased and the system restarted. After the system is restarted again, the HSM security core detects that the anti-downgrade version feature does not match, and restores the MCU's application core firmware from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; Step 3.3.2, if the simple signature verification of the data area succeeds, start to verify the complex signature of the code area. If the verification fails, it is necessary to erase the signature area and restart the system. After restarting the system again, the HSM security core detects that the anti-downgrade version feature does not match, and restores the MCU's application core firmware from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; Step 3.3.3, if the complex signature verification of the code area succeeds, start to verify the complex signature of the data area. If the verification fails, it is necessary to erase the signature area and restart the system. After restarting the system again, the HSM security core detects that the anti-downgrade version feature does not match, and restores the MCU's application core firmware from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; Step 3.3.4, if the complex signature verification of the data area is successful, it means that the entire MCU application core firmware verification is successful and the security strength is sufficient. At this time, the secure boot verification work is completed and the ECU starts normally.

[0037] When the application core firmware of the MCU is upgraded, after the application core firmware is written into the application core running Flash of the MCU, the application core of the MCU calls the verification service of the HSM. The security core of the HSM verifies the simple signature of the code area, the complex signature of the code area, the simple signature of the data area, and the simple signature of the data area and the complex signature of the data area of ​​the application core firmware of the MCU, and then returns the verification result. If the verification is successful, the security core of the HSM will compress and back up the application core firmware of the MCU to the application core firmware backup area of ​​the security core running Flash; if the verification fails, the application core firmware backup area of ​​the HSM will retain the compressed backup of the application core firmware when the application core firmware upgrade was successful last time.

[0038] In the present invention, HSM is a hardware security module inside the MCU, which includes a dedicated CPU, dedicated RAM, dedicated operation Flash, and dedicated data Flash. At the same time, it also has the highest access rights stored in the MCU, such as Figure 1 As shown in the figure, the shaded area is the HSM part. The size of the dedicated data Flash and dedicated operation Flash can be divided from the data Flash and operation Flash according to actual needs, that is, the Flash of the MCU application core starts from the head and ends at the dividing line, and the Flash of the MCU security core starts from the dividing line and ends at the tail. The dividing line can be customized on a blank MCU, and once set, it cannot be changed.

[0039] The application core firmware is divided into a signature area, a code area, and a data area. Identify which segments are code segments and which segments are data segments. In the link file, put the code segment in front to form the code area, and the data segment in the back to form the data area. There is no order between code segments and they can be placed at will. There is no order between data segments and they can be placed at will. If necessary, place a boundary symbol and alignment length between the code area and the data area. In this way, after each MCU application core firmware is compiled, the starting address of the data area can be successfully found in the map file, and the size of the code area is a multiple of the alignment length, which meets the verification algorithm's requirements for data alignment. After compiling the MCU application core firmware, the code area and data area are obtained. After adding the signature area, the MCU application core firmware with signature is completed. Figure 2 As shown. In order to reduce the amount of verification data and shorten the verification time, the signature range will only include the code area and the data area, and will not include the free area not used by the application core running Flash. The reason why the MCU application core firmware is divided into the code area and the data area is that the code area is used for running, and the secure boot needs to verify it first. The data area does not need to run and can be verified after the MCU application core is running.

[0040] The signature area includes: anti-downgrade version features, the starting address of the code area, the length of the code area, the simple signature of the code area, the complex signature of the code area, the starting address of the data area, the length of the data area, the simple signature of the data area, the complex signature of the data area, and the end mark, such as Figure 4 As shown. The starting address of the code area, the length of the code area, the starting address of the data area, and the length of the data area can be obtained from the map file. For simple signatures, it is recommended to use the hardware encryption engine provided by the HSM or an asymmetric algorithm with low computational intensity. For complex signatures, it is recommended to use an asymmetric algorithm with high computational intensity.

[0041] The anti-downgrade version feature is designed to prevent the MCU application core firmware from being downgraded, to prevent firmware collision attacks on different products using the same MCU, and to prevent firmware collision attacks on different devices of the same product. It can also quickly determine whether the firmware to be upgraded matches during an upgrade. During secure boot, it is also the first data used to determine matching data before verifying the signature. It is still necessary to add sub-feature 1 and sub-feature 2 to the anti-downgrade version feature. By dividing the anti-downgrade version feature into sub-feature 1, sub-feature 2, and sub-feature 3, they correspond to different products, different devices of the same product, and different versions of the same product and device. When performing anti-downgrade, it is necessary to determine whether sub-feature 1 is the same, sub-feature 2 is the same, and the size of sub-feature 3 to complete the anti-downgrade judgment. This can avoid the problem of the anti-downgrade function failing due to the use of derivative firmware. For example Figure 5 shown.

[0042] So far, the functions, changes, and work required for the MCU application core firmware have been described.

[0043] like Figure 6 As shown, the MCU security boot test is performed. First, the HSM security core is run, and the security core detects the anti-downgrade version features of the application core firmware and compares them with the anti-downgrade version features that have been saved in the security core dedicated data Flash. If they do not match, the MCU application core firmware is restored from the security core dedicated running Flash to the MCU application core running Flash.

[0044] If the anti-downgrade version comparison matches successfully, the simple signature of the code area is verified. If the verification fails, the MCU application core firmware is restored from the security core dedicated running Flash to the MCU application core running Flash. If the simple signature verification of the code area is successful, the application core can be started and the application core function can be executed to reduce the startup time.

[0045] After the simple signature verification of the code area is successful, the HSM security core then verifies the simple signature of the data area. If the verification fails, the signature area needs to be erased and the system restarted. After the system is restarted again, the MCU's application core firmware is restored from the security core's dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally.

[0046] After the simple signature of the data area is successfully verified, the complex signature of the code area is verified. If the verification fails, the signature area needs to be erased, and then the system is restarted to restore the MCU's application core firmware from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally.

[0047] If the complex signature verification of the code area succeeds, the complex signature of the data area will be verified. If the verification fails, the signature area needs to be erased, and then the system is restarted to restore the MCU's application core firmware from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally.

[0048] If the complex signature verification of the data area is successful, it means that the entire MCU application core firmware is successfully verified and the security strength is sufficient. At this time, the secure boot verification work is completed and the ECU starts normally.

[0049] Therefore, in the above process, as long as one link of the verification fails, the application core firmware of the MCU is restored from the security core dedicated running Flash to the application core running Flash of the MCU.

[0050] In order to ensure that the application core firmware backup area is the latest available and trusted MCU application core firmware, when the MCU application core firmware is upgraded, after the application core firmware is written to the application core running Flash, the application core calls the HSM's verification service, and the HSM's security core verifies the simple signature and complex signature of the code area and data area of ​​the MCU application core firmware, and then returns the verification result. After successful verification, the HSM's MCU security core will compress and back up the MCU application core firmware to the MCU application core firmware backup area of ​​the MCU security core running Flash. If unsuccessful, the original application core firmware backup will be retained.

[0051] The present invention processes the MCU application core link file, specifically distinguishes the code segment from the data segment, verifies the code area first during verification, starts the MCU application core after successful verification of the code area, and verifies the data area in parallel. By using simple signatures and complex signatures, the MCU application core is started after successful verification of the simple signature, and the complex signature is verified in parallel.

[0052] During the upgrade, the MCU application core firmware is compressed and backed up to the MCU security core dedicated running Flash to protect the backup from being damaged. If the MCU application core firmware verification fails, the method of restoring it from the MCU security core dedicated running Flash is used. The anti-downgrade version feature is subdivided into sub-feature 1, sub-feature 2, and sub-feature 3, which are used to quickly identify whether the MCU application core firmware matches the current device and the method of preventing version downgrade.

[0053] The present invention is not limited to the above-mentioned embodiments. On the basis of the technical solution disclosed herein, technicians in this field can make some substitutions and deformations to some technical features therein according to the disclosed technical content without creative labor, and these substitutions and deformations are all within the protection scope of the present invention.

Claims

1. A method for implementing secure booting of MCU based on HSM, characterized in that: The following steps are included: Step 1: Divide the application core running Flash in the MCU into a signature area, a code area, and a data area; Step 2: Set up HSM, or hardware security module, inside the MCU; Step 3: Enable secure boot.

2. According to a HSM-based MCU secure boot implementation method according to claim 1, it is characterized in that: The specific contents of the division of data area and code area in step 1 are as follows: Process the link file in the compilation environment of the Flash running in the MCU application core, identify which segments are code segments and which segments are data segments, put all code segments in the front of the link file to form a code area, and put all data segments in the back to form a data area. There is no order between code segments, and there is no order between data segments. Place a boundary symbol and alignment length between the code area and the data area, and the size of the code area is a binary integer multiple of the alignment length.

3. The method for implementing secure boot of MCU based on HSM according to claim 2, characterized in that: The specific contents of the signature area division in step 1 are as follows: The signature area includes the starting address of the code area, the length of the code area, the simple signature of the code area, the complex signature of the code area, the starting address of the data area, the length of the data area, the simple signature of the data area, the complex signature of the data area and the end mark; The starting address of the code area, the length of the code area, the starting address of the data area and the length of the data area are obtained from the map file. The simple signature of the code area and the simple signature of the data area are obtained by using the hardware encryption engine of the HSM or an asymmetric algorithm with low computational intensity. The complex signature of the code area and the complex signature of the data area are obtained by using an asymmetric algorithm with high computational intensity.

4. The method for implementing secure boot of MCU based on HSM according to claim 3, characterized in that: The signature area also has anti-downgrade version features, which include sub-feature 1, sub-feature 2, sub-feature 3 and complex signatures. Sub-feature 1 is used to distinguish products, sub-feature 2 is used to distinguish devices, and sub-feature 3 is used to distinguish anti-rollback version numbers. The complex signature is calculated by using a high-computational intensity asymmetric algorithm on sub-feature 1, sub-feature 2 and sub-feature 3.

5. The method for implementing secure boot of MCU based on HSM according to claim 4, characterized in that: The specific contents of step 2 are as follows: Step 2.1, HSM contains a dedicated CPU, dedicated RAM, security core dedicated operation Flash, security core dedicated data Flash, and HSM also has the highest access permission for MCU storage. The size of the security core dedicated data Flash and security core dedicated operation Flash can be divided from the MCU application core data Flash and MCU application core operation Flash according to actual needs; Step 2.2, divide the safety core dedicated operation Flash into the application core firmware backup area and the safety core firmware area.

6. The method for implementing secure boot of MCU based on HSM according to claim 5, characterized in that: The specific contents of step 2.2 are as follows: The application core firmware backup area is used by the HSM security core to compress and back up the MCU's application core firmware after the MCU application core firmware upgrade is completed and verified successfully. If the MCU's application core firmware fails verification, it is restored from this area so that the MCU's application core can run with the same version of firmware. The secure core firmware area is the core content of the HSM, which includes the secure boot verification strategy, MCU application core firmware recovery strategy and anti-downgrade strategy.

7. The method for implementing secure boot of MCU based on HSM according to claim 6, characterized in that: The specific contents of step 3 are as follows: Step 3.1, after enabling secure boot, the MCU will first run the HSM security core when powered on or reset; Step 3.2: Verification of anti-downgrade version features; Step 3.3, verification of code area and data area.

8. The method for implementing secure boot of MCU based on HSM according to claim 7, characterized in that: The specific contents of step 3.2 are as follows: Step 3.2.1, the HSM security core verifies the complex signature in the anti-downgrade version feature, and detects the anti-downgrade version feature of the MCU's application core firmware and compares it with the anti-downgrade version feature that has been saved in the security core dedicated data Flash. If the complex signature verification fails or the comparison result is a mismatch, the MCU's application core firmware is restored from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; Step 3.2.2, if the complex signature verification succeeds and the anti-downgrade version comparison successfully matches, the HSM security core verifies the simple signature of the code area. If the simple signature verification of the code area fails, the MCU's application core firmware is restored from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; In step 3.2.3, if the simple signature verification of the code area succeeds, the application core of the MCU can be started and the application core function of the MCU can be executed to reduce the startup time.

9. The method for implementing secure boot of MCU based on HSM according to claim 8, characterized in that: The specific contents of step 3.3 are as follows: Step 3.3.1, the HSM security core then verifies the simple signature of the data area. If the verification fails, it means that the MCU's application firmware is untrustworthy, because the MCU's application core has been started and cannot be executed according to the simple signature verification failure of the code area or the anti-downgrade version feature mismatch method. At this time, the signature area needs to be erased and the system restarted. After the system is restarted again, the HSM security core detects that the anti-downgrade version feature does not match, and restores the MCU's application core firmware from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; Step 3.3.2, if the simple signature verification of the data area succeeds, start to verify the complex signature of the code area. If the verification fails, it is necessary to erase the signature area and restart the system. After restarting the system again, the HSM security core detects that the anti-downgrade version feature does not match, and restores the MCU's application core firmware from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; Step 3.3.3, if the complex signature verification of the code area succeeds, start to verify the complex signature of the data area. If the verification fails, it is necessary to erase the signature area and restart the system. After restarting the system again, the HSM security core detects that the anti-downgrade version feature does not match, and restores the MCU's application core firmware from the security core dedicated running Flash to the MCU's application core running Flash. At this time, the secure boot verification work is completed and the ECU starts normally; Step 3.3.4, if the complex signature verification of the data area is successful, it means that the entire MCU application core firmware verification is successful and the security strength is sufficient. At this time, the secure boot verification work is completed and the ECU starts normally.

10. The method for implementing secure booting of an MCU based on HSM according to claim 6, characterized in that: When the MCU's application core firmware is upgraded, after the application core firmware is written into the MCU's application core running Flash, the MCU's application core calls the HSM's verification service. The HSM's security core verifies the code area simple signature, code area complex signature, data area simple signature, and data area simple signature and data area complex signature of the MCU's application core firmware, and then returns the verification result. If the verification is successful, the HSM's security core will compress and back up the MCU's application core firmware to the application core firmware backup area of ​​the security core running Flash. If the verification fails, the HSM's application core firmware backup area will retain the compressed backup of the application core firmware when the last application core firmware upgrade was successful.