Low-cost motor controller safe starting method and device based on SE chip

By adopting a new architecture based on SE chips in low-cost motor controllers, and using the combination of independent SE chips and MCU chips, the problem of low-cost motor controllers lacking independent safety cores is solved, and the safe start and safe write functions are realized, which improves the safety and cost-effectiveness of the motor controller.

CN119717632APending Publication Date: 2025-03-28HEFEI JUYI POWER SYST CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411889953.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-20
Publication Date
2025-03-28

AI Technical Summary

Technical Problem

The lack of independent safety cores of existing low-cost motor controllers leads to low security and the inability to achieve low-cost maintenance of information security of motor controllers.

Method used

Using a new architecture based on SE chips, a secure boot method is realized through mutually classified independent SE chips and MCU chips. The specific steps include obtaining a secure startup request, the MCU chip performs BootLoader code consistency verification, the SE chip performs Application code consistency verification, and device authentication and administrator authentication before starting the motor controller.

Benefits of technology

It realizes information security of low-cost motor controllers, improves the safety of safe start, and reduces the development cycle and manufacturing cost of motor controllers.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119717632A_ABST
    Figure CN119717632A_ABST
Patent Text Reader

Abstract

The invention discloses a motor controller information safety control method and system based on an SE chip, and the method comprises the steps: obtaining a safety starting request, carrying out the BootLoader code consistency verification based on the safety starting request through an MCU chip, carrying out the BootLoader code consistency verification success, carrying out the Application code consistency verification through the SE chip, and carrying out the Application code consistency verification success. And the starting process of the motor controller is completed. According to the invention, a new independent SE chip architecture separated from the MCU is provided, BootLoader code consistency verification is carried out on the MCU chip on the basis, Application code consistency verification is carried out on the SE chip, safe starting of the MCU chip is completed, a low-cost motor controller information safety function is realized, and the safety of the motor controller is improved. The problem that a low-cost motor controller does not have an independent safety kernel and is low in safety is solved, and meanwhile the development period and the manufacturing cost of the motor controller are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of information security technology, and in particular relates to a low-cost motor controller safety starting method and device based on an SE chip. Background Art

[0002] As the automotive industry accelerates the transformation of intelligent and networked technologies, automotive safety issues have expanded from traditional technical security issues to data-driven security and risk management issues. In the process of extending software and hardware functions, some application functions need to allow the Internet to access the core system of the car, so the car may be controlled and attacked by Internet hackers. Automotive information security is reflected in many aspects, and there are many types of attacks that may be suffered, mainly in three aspects. The first is the attack on the in-vehicle information system, which mainly includes attacks through the owner's mobile phone, remote attacks on the Internet of Vehicles and mobile Internet, etc. The second is the attack on the electronic control unit system, which generally includes data packet intrusion, data packet tampering, data packet replay, malicious code implantation, false information interference and other attack methods. The third is the attack on the environmental perception system. The current automotive motor controller MCU mainly has the following architectures: Architecture 1, HSM (Hardware Security Module) and CPU are on the same chip, with a state machine, but no security kernel. This architecture lacks flexibility and requires modification of hardware design. In addition, the CPU chip cost of this system is high, which is suitable for applications with low security requirements and long development cycles. Architecture 2: HSM and CPU are on the same chip and have a programmable security core. This architecture has both high security and flexible scalability and economy. However, the CPU chip is expensive and is suitable for applications with high security requirements. Architecture 3: Only the CPU is on the chip without HSM. This architecture is suitable for low-cost motor controllers that do not require information security. Therefore, a new architecture system and method are urgently needed to achieve low-cost maintenance of motor controller information security. Summary of the invention

[0003] To solve the above problems, the present invention provides a low-cost motor controller security startup method and device based on SE chip to solve the problem that the existing low-cost motor controller has no independent security kernel, low security, and cannot achieve low-cost maintenance of the information security of the motor controller.

[0004] A low-cost motor controller safety startup method based on an SE chip, the low-cost motor controller includes an independent SE chip and an MCU chip classified from each other, the MCU chip does not have an HSM module, and the method includes:

[0005] Get secure boot request;

[0006] Based on the secure boot request, the MCU chip performs BootLoader code consistency verification;

[0007] The BootLoader code consistency check succeeds, and the SE chip performs the Application code consistency check;

[0008] The Application code consistency check succeeds and the motor controller is started.

[0009] According to a specific embodiment of the present invention, based on the secure boot request, the MCU chip performs a BootLoader code consistency check including:

[0010] Jump to BootRom based on the secure boot request and calculate the CMAC value of the BootLoader data;

[0011] Compare the calculated CMAC value with the CMAC value stored in the MCU chip to see if they are consistent. If they are consistent, jump to the BootLoader to verify the valid flag bit. Otherwise, reset the MCU chip.

[0012] According to a specific embodiment of the present invention, jumping to the BootLoader to perform valid flag bit verification includes:

[0013] Determine whether there is an Application valid flag in the BootLoader. If so, establish a communication connection between the MCU chip and the SE chip through the SPI protocol. Otherwise, stay in the BootLoader.

[0014] According to a specific embodiment of the present invention, if the BootLoader code consistency check succeeds, the SE chip performs the Application code consistency check including:

[0015] Calculate the CMAC value of Application data;

[0016] Compare the calculated CMAC value with the CMAC value stored in the SE chip to see if they are consistent. If they are consistent, the verification is successful and jumps to the Application. Otherwise, the verification fails and stays in the BootLoader.

[0017] According to a specific embodiment of the present invention, before starting the MCU chip, the method further includes:

[0018] The MCU chip is securely authenticated through the SE chip, which includes device authentication and administrator authentication.

[0019] According to a specific embodiment of the present invention, performing security authentication on the MCU chip by the SE chip further includes:

[0020] Get device authentication request;

[0021] The MCU chip is authenticated based on the device authentication request. If the device authentication succeeds, the administrator authentication request is obtained and the MCU chip is authenticated. If the administrator authentication succeeds, a secure read and write operation instruction is sent to the MCU chip.

[0022] If the device authentication and / or administrator authentication fails, it is determined whether the number of device authentication and / or administrator authentication failures exceeds a preset threshold. If so, the SE chip is locked.

[0023] According to a specific embodiment of the present invention, performing device authentication on the MCU chip based on the device authentication request further includes:

[0024] A first random number is generated based on the device authentication request, and the first random number is encrypted using the MCU encryption algorithm and the SE encryption algorithm respectively. The two encrypted values ​​are compared to see if they are consistent. If they are consistent, the device authentication is successful.

[0025] According to a specific embodiment of the present invention, obtaining an administrator authentication request and performing administrator authentication on the MCU chip further includes:

[0026] A second random number is generated based on the administrator authentication request, and the second random number is encrypted using the MCU encryption algorithm and the SE encryption algorithm respectively. The two encrypted values ​​are compared to see if they are consistent. If they are consistent, the administrator authentication is successful.

[0027] According to a specific embodiment of the present invention, after starting the MCU chip, the method further includes:

[0028] When the MCU chip is undergoing a firmware upgrade, the MCU chip is securely flashed.

[0029] According to a specific embodiment of the present invention, in the case of performing firmware upgrade on the MCU chip, secure flashing of the MCU chip further includes:

[0030] Get the APP and Flashdriver source code to be flashed and compile them into S19 files or Hex files;

[0031] Encrypt and sign the S19 file or Hex file to generate the corresponding APP signature file and Flashdriver signature file;

[0032] Write the APP signature file and Flashdriver signature file to the flash memory of the MCU chip through BOOT and verify the signature of the APP signature file and Flashdriver signature file;

[0033] Check whether the public key in the ID of the SE chip exists. If it exists, check whether the public key is correct. If it is detected that the public key does not exist or is incorrect, store the public key ID in the SE chip;

[0034] The hardware algorithm of the SE chip is called based on the public key ID to calculate the CMAC value. When the flashing is completed, the CMAC value is written into the storage module of the SE chip.

[0035] A low-cost motor controller safety starting device based on SE chip, comprising:

[0036] An acquisition module, used to obtain a secure boot request;

[0037] The BootLoader code verification module is used to perform BootLoader code consistency verification on the MCU chip based on the secure boot request;

[0038] The Application code verification module is used to perform Application code consistency verification on the SE chip. If the verification is successful, the motor controller is started.

[0039] According to a specific embodiment of the present invention, the BootLoader code verification module further includes:

[0040] A first calculation module, used to jump to BootRom based on a secure boot request and calculate a CMAC value of BootLoader data;

[0041] The first verification module is used to compare whether the calculated CMAC value is consistent with the CMAC value stored in the MCU chip. If they are consistent, it jumps to the BootLoader to perform valid flag verification, otherwise, the MCU chip is reset.

[0042] According to a specific embodiment of the present invention, the first verification module further includes:

[0043] The valid flag identification module is used to determine whether there is an Application valid flag in the BootLoader. If so, a communication connection is established between the MCU chip and the SE chip through the SPI protocol. Otherwise, it stays in the BootLoader.

[0044] According to a specific embodiment of the present invention, the Application code verification module further includes:

[0045] The second calculation module is used to calculate the CMAC value of the Application data;

[0046] The second verification module is used to compare whether the calculated CMAC value is consistent with the CMAC value stored in the SE chip. If they are consistent, the verification is successful and jumps to the Application. Otherwise, the verification fails and stays in the BootLoader.

[0047] According to a specific embodiment of the present invention, the device further includes:

[0048] The security authentication module is used to perform security authentication on the MCU chip through the SE chip. Security authentication includes device authentication and administrator authentication.

[0049] According to a specific embodiment of the present invention, the security authentication module further includes:

[0050] A request acquisition module is used to acquire device authentication requests and administrator authentication requests;

[0051] The device authentication module is used to authenticate the MCU chip based on the device authentication request. If the device authentication succeeds, an administrator authentication request is sent. If the authentication fails, it determines whether the number of authentication failures exceeds a preset threshold. If so, the SE chip is locked.

[0052] The administrator authentication module is used to perform administrator authentication on the MCU chip based on the administrator authentication request. If the authentication is successful, a secure read and write operation instruction is sent to the MCU chip. If the authentication fails, it determines whether the number of authentication failures exceeds a preset threshold. If so, the SE chip is locked.

[0053] According to a specific embodiment of the present invention, the device further includes:

[0054] The secure flashing module is used to securely flash the MCU chip when the MCU chip firmware is upgraded.

[0055] According to a specific embodiment of the present invention, the secure flashing module further includes:

[0056] Compilation module, used to obtain the APP and Flashdriver source programs to be flashed and compile them into S19 files or Hex files;

[0057] The encryption and signature module is used to encrypt and sign the S19 file or Hex file to generate the corresponding APP signature file and Flashdriver signature file;

[0058] Flashing module, used to flash the APP signature file and Flashdriver signature file to the flash memory of the MCU chip through BOOT and verify the signature of the APP signature file and Flashdriver signature file;

[0059] The public key detection module is used to detect whether the public key in the ID of the SE chip exists. If it exists, it detects whether the public key is correct. If it is detected that the public key does not exist or is incorrect, the public key ID is stored in the SE chip;

[0060] The third calculation module is used to call the hardware algorithm of the SE chip based on the public key ID to calculate the CMAC value, and write the CMAC value into the storage module of the SE chip after the flashing is completed.

[0061] According to a specific embodiment of the present invention, the secure flashing module further includes:

[0062] Compilation module, used to obtain the APP and Flashdriver source programs to be flashed and compile them into S19 files or Hex files;

[0063] The encryption and signature module is used to encrypt and sign the S19 file or Hex file to generate the corresponding APP signature file and Flashdriver signature file;

[0064] Flashing module, used to flash the APP signature file and Flashdriver signature file to the flash memory of the MCU chip through BOOT and verify the signature of the APP signature file and Flashdriver signature file;

[0065] The public key detection module is used to detect whether the public key in the ID of the SE chip exists. If it exists, it detects whether the public key is correct. If it is detected that the public key does not exist or is incorrect, the public key ID is stored in the SE chip;

[0066] The third calculation module is used to call the hardware algorithm of the SE chip based on the public key ID to calculate the CMAC value, and write the CMAC value into the storage module of the SE chip after the flashing is completed.

[0067] Compared with the prior art, the low-cost motor controller safety starting method and device based on SE chip provided by the present invention has the following advantages:

[0068] 1) A new architecture of an independent SE chip separated from the MCU is proposed, and the SE chip is combined with the MCU, which has the advantages of low cost and high security, and realizes the safe startup and safe flashing functions in the information security of the low-cost motor controller.

[0069] 2) Using the built-in startup function and encrypted communication method in low-cost MCU can improve the security of low-cost motor controllers.

[0070] 3) The independent SE chip architecture separated from the MCU has low cost and higher security, and uses the internal FLASH storage space of the SE to further reduce the cost of the motor controller. BRIEF DESCRIPTION OF THE DRAWINGS

[0071] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0072] Figure 1 The flowchart is a method for safely starting a low-cost motor controller based on an SE chip according to an embodiment of the present invention.

[0073] Figure 2 The present invention is a flowchart of a method for performing BootLoader code consistency verification on an MCU chip according to an embodiment of the present invention.

[0074] Figure 3 It is a flow chart of a valid flag bit verification method provided according to an embodiment of the present invention.

[0075] Figure 4 The flowchart is a method for performing Application code consistency verification on an SE chip according to an embodiment of the present invention.

[0076] Figure 5 The present invention is a flowchart of a method for performing security authentication on an MCU chip according to an embodiment of the present invention.

[0077] Figure 6 It is a flow chart of a method for securely flashing an MCU chip provided according to an embodiment of the present invention.

[0078] Figure 7 The figure is a schematic diagram of the overall process of safe startup of a low-cost motor controller based on an SE chip according to an embodiment of the present invention.

[0079] Figure 8 It is a schematic diagram of the overall process of securely flashing an MCU chip according to an embodiment of the present invention.

[0080] Fig. 9 It is a structural diagram of a low-cost motor controller safety starting device based on SE chip provided according to an embodiment of the present invention.

[0081] Fig.10 4 is a structural diagram of a BootLoader code verification module provided according to an embodiment of the present invention.

[0082] Fig.11 is a structural diagram of a first verification module provided according to an embodiment of the present invention.

[0083] Fig.124 is a structural diagram of an Application code verification module provided according to an embodiment of the present invention.

[0084] Fig.13 is a structural diagram of a security authentication module provided according to an embodiment of the present invention.

[0085] Fig.14 is a structural diagram of a secure flashing module provided according to an embodiment of the present invention.

[0086] Reference numerals:

[0087] 01-Acquisition module; 02-BootLoader code verification module; 03-Application code verification module; 04-Security authentication module; 05-Security flashing module;

[0088] 021-first calculation module; 022-first verification module;

[0089] 0221-valid flag identification module; 0222-communication connection module;

[0090] 031-second calculation module; 032-second verification module;

[0091] 041-Request acquisition module; 042-Device authentication module; 043-Administrator authentication module;

[0092] 051-compile module; 052-encryption and signature module; 053-flash module; 054-public key detection module; 055-third calculation module. DETAILED DESCRIPTION

[0093] In order to make those skilled in the art understand the concept and thought of the present invention more clearly, the present invention is described in detail below in conjunction with specific embodiment.It should be understood that the embodiment provided herein is only a part of all embodiments that the present invention may have.Those skilled in the art, after reading the specification of the application, have the ability to make improvements, transformations, or replacements to part or the whole of the following embodiments, and these improvements, transformations, or replacements are also included in the scope of the present invention.

[0094] In this article, the terms "first", "second" and other similar words are not intended to imply any order, quantity and importance, but are only used to distinguish different elements. In this article, the terms "one", "an" and other similar words are not intended to indicate that there is only one thing, but to indicate that the relevant description is only for one of the things, and the thing may have one or more. In this article, the terms "comprise", "include" and other similar words are intended to indicate logical mutual relations, and cannot be regarded as indicating spatial structural relations. For example, "A includes B" is intended to indicate that B belongs to A logically, but does not mean that B is located inside A in space. In addition, the meanings of the terms "comprise", "include" and other similar words should be regarded as open, rather than closed. For example, "A includes B" is intended to indicate that B belongs to A, but B does not necessarily constitute the whole of A, and A may also include other elements such as C, D, and E.

[0095] In this document, the terms "embodiment", "this embodiment", "one embodiment", and "an embodiment" do not mean that the relevant description is only applicable to a specific embodiment, but rather that the description may also be applicable to one or more other embodiments. Those skilled in the art should understand that in this document, any description of a certain embodiment can be replaced, combined, or combined in other ways with the relevant descriptions in one or more other embodiments, and the new embodiments generated by the replacement, combination, or combination in other ways are easily conceivable by those skilled in the art and fall within the scope of protection of the present invention.

[0096] Example 1

[0097] Additional aspects and advantages of embodiments of the present invention will be described in part in the following description, and will become apparent from the following description, or will be learned through practice of embodiments of the present invention. Figure 1-Figure 8 The embodiment of the present invention provides a low-cost motor controller safety startup method based on an SE chip, wherein the low-cost motor controller includes an independent SE chip and an MCU chip separated from each other, and the MCU chip does not have an HSM module. The method includes:

[0098] S1: Get secure boot request.

[0099] S2: Based on the secure boot request, the MCU chip performs a BootLoader code consistency check. If the check succeeds, execute step S3.

[0100] S3: The SE chip performs a consistency check on the Application code. If the check succeeds, step S4 is executed.

[0101] S4: Start the motor controller.

[0102] In the embodiment of the present invention, the SE (Secure Element) chip is an independent chip with a kernel, FLASH (flash memory), RAM / ROM (random access memory / read-only memory), and an encryption engine, which is used for the storage and operation of sensitive data and has anti-tampering capabilities. Compared with the HSM (Hardware Security Module), the SE chip supports national secret algorithms and mainstream encryption algorithms, and meets the national standard functional safety requirements. A low-cost motor controller refers to a motor controller whose main control chip does not have an HSM module and cannot implement information security functions, such as the automotive-grade main control chip TI F280039. The present invention uses an independent SE chip and an MCU chip to form a new motor controller architecture. The SE chip is adapted to the MCU architecture without HSM. There is no need to change the controller's software and hardware architecture on a large scale, and the low-cost motor controller information security function can be realized, solving the problem of low-cost motor controllers without independent security kernels and low security, while reducing the motor controller development cycle and manufacturing costs.

[0103] Specifically, in step S2, based on the secure boot request, the MCU chip performs a BootLoader code consistency check, including:

[0104] S21: Jump to BootRom based on the secure boot request and calculate the CMAC value of the BootLoader data.

[0105] S22: Compare the calculated CMAC value with the CMAC value stored in the MCU chip to see if they are consistent. If they are consistent, execute step S23; otherwise, execute step S24.

[0106] S23: Jump to BootLoader to verify the valid flag bit.

[0107] S24: MCU chip reset.

[0108] In the embodiment of the present invention, BootRom (Boot Read-Only Memory) is a small firmware program, usually stored in a read-only memory ROM, used to initialize the hardware and load and start the operating system or boot loader. BootLoader (boot loader) is the first code executed by the embedded system after power-on, and CMAC (Cipher-based Message Authentication Code) is a message authentication code based on a symmetric key block encryption algorithm. By using a symmetric key and a block encryption algorithm to generate a fixed-length output code, it is used to verify the integrity and authenticity of the message to confirm that the data has not been tampered with during transmission. In the embodiment of the present invention, when the MCU chip receives a secure boot request, the chip is started and jumps to the BootRom inherent in the chip. In the BootRom, CMAC calculation is performed on the BootLoader data of the secondary development, and the calculated CMAC value is verified with the CMAC value stored in the MCU at the FLASH address. If the verification is consistent, it jumps to the BootLoader, and if it is inconsistent, the MCU chip is reset. By comparing the CMAC value of the BootLoader data calculated in the BootRom with the CMAC value stored in the MCU chip, it is possible to verify whether the data has been tampered with during transmission. If the verification is consistent, it means that the data information has not been tampered with and the data information is safe. If the verification is inconsistent, it indicates that the data information may have been maliciously tampered with, and the MCU chip is reset at this time.

[0109] Further, in step S23, jumping to BootLoader to perform valid flag bit verification includes:

[0110] S231: Determine whether there is an Application valid flag in the BootLoader. If so, execute step S232; otherwise, execute step S233.

[0111] S232: Establish a communication connection between the MCU chip and the SE chip through the SPI protocol.

[0112] S233: Stay in BootLoader.

[0113] In the embodiment of the present invention, the Application valid flag refers to a special bit or a group of bits used to indicate whether a certain state or condition is valid in the application. During the data transmission process, the valid flag can be used to indicate whether the data has been verified and can be used safely. The embodiment of the present invention verifies whether the Application valid flag exists in the BootLoader. If the Application valid flag exists, it means that the data has been verified and the data information is safe. The MCU chip and the SE chip are connected to establish a communication connection through the SPI protocol. At this time, the MCU chip and the SE chip can exchange data securely. If the Application valid flag does not exist, it indicates that the data information security has not been verified, and it is kept in the BootLoader.

[0114] Specifically, step S3, the SE chip performs Application code consistency check including:

[0115] S31: Calculate the CMAC value of the Application data.

[0116] S32: Compare the calculated CMAC value with the CMAC value stored in the SE chip to see if they are consistent. If they are consistent, execute step S33; otherwise, execute step S34.

[0117] S33: Verification is successful and jumps to Application.

[0118] S34: Verification failed and stayed in BootLoader.

[0119] In the embodiment of the present invention, after the MCU chip establishes a communication connection with the SE chip, the SE chip calculates the CMAC value of the Application data, and compares and verifies the calculated CMAC value with the CMAC value stored in the SE. If the verification results are consistent, it jumps to the Application. If the verification results are inconsistent, it stays in the BootLoader. By comparing the CMAC value of the Application data with the CMAC value stored in the SE chip, it is verified whether the Application data has been tampered with during the transmission process. If the verification results are consistent, it means that the data information has not been tampered with and its data information is safe. If the verification is inconsistent, it indicates that the data information may be maliciously tampered with. If the verification results are consistent, staying in the BootLoader indicates that the data information is safe and reliable, and then jumping to the Application.

[0120] The present invention improves the complexity of secure boot code verification by dividing secure boot into two steps: BootLoader code consistency verification and Application code consistency verification, and performs BootLoader data verification inside the MCU, thereby improving the security of secure boot.

[0121] Specifically, before starting the MCU chip, the method further includes:

[0122] S0: The MCU chip is authenticated through the SE chip. The security authentication includes device authentication and administrator authentication.

[0123] Specifically, step S0 of performing security authentication on the MCU chip through the SE chip further includes:

[0124] S01: Obtain a device authentication request.

[0125] S02: Perform device authentication on the MCU chip based on the device authentication request. If the device authentication succeeds, execute step S03; if the device authentication fails, execute step S05.

[0126] S03: Obtain an administrator authentication request and perform administrator authentication on the MCU chip. If the administrator authentication succeeds, execute step S04; if the administrator authentication fails, execute step S05.

[0127] S04: Send secure read and write operation instructions to the MCU chip.

[0128] S05: Determine whether the number of device authentication and / or administrator authentication failures exceeds a preset threshold. If so, execute step S06.

[0129] S06: Lock the SE chip.

[0130] Before securely starting the MCU chip, the embodiment of the present invention needs to perform two-factor identity authentication on the MCU chip, namely device authentication and administrator authentication. If and only if the device authentication and administrator authentication are passed, the MCU chip establishes a communication connection with the SE chip through the SPI protocol, thereby realizing secure data interaction. By completing device authentication and administrator authentication before data interaction, the security of data interaction can be improved.

[0131] Further, step S02 performs device authentication on the MCU chip based on the device authentication request, including:

[0132] A first random number is generated based on the device authentication request, and the first random number is encrypted using the MCU encryption algorithm and the SE encryption algorithm respectively. The two encrypted values ​​are compared to see if they are consistent. If they are consistent, the device authentication is successful. If they are inconsistent, the device authentication fails. At this time, it is determined whether the number of device authentication failures exceeds the preset threshold. If so, the SE chip is locked.

[0133] Furthermore, step S03 of obtaining an administrator authentication request and performing administrator authentication on the MCU chip includes:

[0134] A second random number is generated based on the administrator authentication request, and the second random number is encrypted using the MCU encryption algorithm and the SE encryption algorithm respectively. The two encrypted values ​​are compared to see if they are consistent. If they are consistent, the administrator authentication is successful. If they are inconsistent, the device authentication fails. At this time, it is determined whether the number of device authentication failures exceeds the preset threshold. If so, the SE chip is locked.

[0135] Specifically, after starting the MCU chip, the method further includes:

[0136] S5: When upgrading the firmware of the MCU chip, the MCU chip is securely flashed, including:

[0137] S51: Get the APP and Flashdriver source programs to be flashed and compile them into S19 files or Hex files.

[0138] S52: Encrypt and sign the S19 file or Hex file to generate corresponding APP signature file and Flashdriver signature file.

[0139] S53: The APP signature file and the Flashdriver signature file are written to the flash memory of the MCU chip through BOOT and the APP signature file and the Flashdriver signature file are verified.

[0140] S54: Detect whether the public key exists in the ID of the SE chip. If so, detect whether the public key is correct. If it is detected that the public key does not exist or is incorrect, store the public key ID in the SE chip.

[0141] S55: Based on the public key ID, the hardware algorithm of the SE chip is called to calculate the CMAC value, and when the flashing is completed, the CMAC value is written into the storage module of the SE chip.

[0142] When upgrading the firmware of a device, secure flashing is usually used to ensure the integrity of the firmware and the security of the device. It usually involves the use of encryption technology, digital signatures, and security protocols to prevent the firmware from being tampered with or damaged during transmission and installation. The specific implementation methods of secure flashing mainly include: 1. Encryption technology, that is, using encryption algorithms to encrypt the firmware to ensure the confidentiality and integrity of the data during transmission. 2. Digital signature, that is, through digital signature technology, ensure the source and integrity of the firmware to prevent the firmware from being tampered with. 3. Security protocol, that is, using security protocols such as HTTPS or other encrypted communication protocols to ensure the security of data transmission.

[0143] In an embodiment of the present invention, when the MCU chip receives a secure flashing instruction, the APP and Flashdriver source programs to be flashed are first obtained and compiled into S19 files or Hex files through an integrated development tool (such as IDE), wherein the APP source program is the source code of the application, that is, the code written by the developer and not compiled, and these codes contain all the logic and functions of the application. The Flashdriver source program refers to a flash driver program for controlling and managing the read and write operations of the flash memory device. The S19 / Hex file is a file format for storing program code and data. Then, the S19 file or Hex file is encrypted and signed using encryption technology and signature technology to generate corresponding APP signature files and Flashdriver signature files to ensure that the data remains confidential and complete during transmission, and to prevent the firmware from being tampered with. After completing the digital signature, the APP signature file and the Flashdriver signature file are flashed into the flash memory of the MCU chip through BOOT and the APP signature file and the Flashdriver signature file are verified to prevent malware or unauthorized firmware updates. In the secure flashing process, the role of BOOT is to ensure that the new firmware or software can be correctly loaded and run. Since the CMAC value needs to be calculated synchronously during each secure flashing process, and the calculated CMAC value is written into the storage module of the SE chip after the flashing is completed, the SE chip needs to be tested for public key before this, to detect whether the public key exists in the ID of the SE chip, and to detect whether the public key is correct. If it is detected that the public key does not exist or is incorrect, the public key ID is stored in the SE chip. When the public key in the SE chip ID is detected and correct, the SE hardware algorithm is called to write the CMAC value into the SE chip. Since the SE chip has a large FLASH, RAM / ROM storage space, the SE's FLASH storage space can be used as an external EEPROM chip to further reduce the cost of the motor controller. In addition, the SE chip has an independent core, and it is difficult for attackers to read the stored information compared to the EEPROM chip.

[0144] Example 2

[0145] Based on the above method, the embodiment of the present invention also provides a low-cost motor controller safety starting device based on SE chip, such as Figure 9-14 As shown, including:

[0146] The acquisition module 01 is used to obtain a secure boot request.

[0147] The BootLoader code verification module 02 is used to perform BootLoader code consistency verification on the MCU chip based on a secure boot request.

[0148] Furthermore, the BootLoader code verification module 02 also includes:

[0149] The first calculation module 021 is used to jump to the BootRom based on the secure boot request and calculate the CMAC value of the BootLoader data.

[0150] The first verification module 022 is used to compare whether the calculated CMAC value is consistent with the CMAC value stored in the MCU chip. If they are consistent, it jumps to the BootLoader to perform valid flag verification, otherwise, the MCU chip is reset.

[0151] In the embodiment of the present invention, the MCU chip receives a secure boot request through the acquisition module 01. When receiving the secure boot request, the BootLoader code consistency check is performed on the MCU chip through the BootLoader code verification module 02, the chip is started and jumps to the BootRom inherent in the chip, and the CMAC calculation is performed on the secondary developed BootLoader data in the BootRom through the first calculation module 021. The calculated CMAC value is verified with the CMAC value stored in the MCU at the FLASH address through the first verification module 022. If the verification is consistent, it jumps to the BootLoader. If it is inconsistent, the MCU chip is reset. The CMAC value of the BootLoader data calculated in the BootRom is compared with the CMAC value stored in the MCU chip to verify whether the data has been tampered with during the transmission process. If the verification is consistent, it means that the data information has not been tampered with and its data information is safe. If the verification is inconsistent, it indicates that the data information may be maliciously tampered with, and the MCU chip is reset at this time.

[0152] Furthermore, the first verification module 022 also includes:

[0153] The valid flag bit identification module 0221 is used to determine whether there is a valid flag bit in the BootLoader.

[0154] The communication connection module 0222 is used to establish a communication connection between the MCU chip and the SE chip through the SPI protocol.

[0155] In the embodiment of the present invention, the valid flag bit identification module 0221 verifies whether there is an Application valid flag bit in the BootLoader. If there is an Application valid flag bit, it means that the data has been verified and the data information is safe. The communication connection module 0222 establishes a communication connection between the MCU chip and the SE chip through the SPI protocol. At this time, the MCU chip and the SE chip can exchange data securely. If there is no Application valid flag bit, it indicates that the data information security has not been verified, and it is kept in the BootLoader.

[0156] The Application code verification module 03 is used to perform Application code consistency verification on the SE chip. If the verification is successful, the motor controller is started.

[0157] Furthermore, the Application code verification module 03 also includes:

[0158] The second calculation module 031 is used to calculate the CMAC value of the Application data.

[0159] The second verification module 032 is used to compare whether the calculated CMAC value is consistent with the CMAC value stored in the SE chip. If they are consistent, the verification is successful and jumps to the Application. Otherwise, the verification fails and stays in the BootLoader.

[0160] In the embodiment of the present invention, after the MCU chip establishes a communication connection with the SE chip, the CMAC value of the Application data of the SE chip is calculated by the second calculation module 031, and the calculated CMAC value is compared and verified with the CMAC value stored in the SE by the second verification module 032. If the verification results are consistent, it jumps to the Application, and if the verification results are inconsistent, it stays in the BootLoader. By comparing the CMAC value of the Application data with the CMAC value stored in the SE chip, it is verified whether the Application data has been tampered with during the transmission process. If the verification results are consistent, it means that the data information has not been tampered with and its data information is safe. If the verification is inconsistent, it indicates that the data information may be maliciously tampered with. If the verification results are consistent, staying in the BootLoader indicates that the data information is safe and reliable, and then jumping to the Application.

[0161] The present invention improves the complexity of secure boot code verification by setting a BootLoader code verification module 02 and an Application code verification module 03, and performs BootLoader data verification inside the MCU, thereby improving the security of secure boot.

[0162] The security authentication module 04 is used to perform security authentication on the MCU chip through the SE chip. The security authentication includes device authentication and administrator authentication.

[0163] Furthermore, the security authentication module 04 also includes:

[0164] The request acquisition module 041 is used to acquire a device authentication request and an administrator authentication request;

[0165] The device authentication module 042 is used to authenticate the MCU chip based on the device authentication request. If the device authentication succeeds, an administrator authentication request is sent. If the authentication fails, it is determined whether the number of authentication failures exceeds a preset threshold. If so, the SE chip is locked.

[0166] The administrator authentication module 043 is used to perform administrator authentication on the MCU chip based on the administrator authentication request. If the authentication is successful, a secure read and write operation instruction is sent to the MCU chip. If the authentication fails, it determines whether the number of authentication failures exceeds a preset threshold. If so, the SE chip is locked.

[0167] Before securely starting the MCU chip, the embodiment of the present invention needs to perform two-factor identity authentication on the MCU chip, namely device authentication and administrator authentication. If and only if the device authentication and administrator authentication are passed, the MCU chip establishes a communication connection with the SE chip through the SPI protocol, thereby realizing secure data interaction. By completing device authentication and administrator authentication before data interaction, the security of data interaction can be improved.

[0168] First, the device authentication request is obtained through the request acquisition module 041. When the MCU chip receives the device authentication request, the first random number is generated through the device authentication module 042. The first random number is encrypted using the MCU encryption algorithm and the SE encryption algorithm respectively. The two encrypted values ​​are compared to see if they are consistent. If they are consistent, the device authentication is successful. If they are inconsistent, the device authentication fails. At this time, it is determined whether the number of device authentication failures exceeds the preset threshold. If so, the SE chip is locked.

[0169] When the device authentication is passed, the administrator authentication request is obtained through the request acquisition module 041. When the MCU chip receives the administrator authentication request, the administrator authentication module 043 generates a second random number, and encrypts the second random number using the MCU encryption algorithm and the SE encryption algorithm respectively, and compares whether the two encrypted values ​​are consistent. If they are consistent, the administrator authentication is successful. If they are inconsistent, the device authentication fails. At this time, it is determined whether the number of device authentication failures exceeds the preset threshold. If it exceeds, the SE chip is locked.

[0170] The secure flashing module 05 is used to perform secure flashing on the MCU chip when the firmware of the MCU chip is upgraded.

[0171] Furthermore, the secure flashing module 05 also includes:

[0172] The compiling module 051 is used to obtain the APP and Flashdriver source programs to be flashed and compile them into S19 files or Hex files.

[0173] The encryption and signature module 052 is used to encrypt and sign the S19 file or Hex file to generate the corresponding APP signature file and Flashdriver signature file.

[0174] The flashing module 053 is used to flash the APP signature file and the Flashdriver signature file into the flash memory of the MCU chip through BOOT and verify the signature of the APP signature file and the Flashdriver signature file.

[0175] The public key detection module 054 is used to detect whether the public key exists in the ID of the SE chip. If so, it is used to detect whether the public key is correct. If it is detected that the public key does not exist or is incorrect, the public key ID is stored in the SE chip.

[0176] The third calculation module 055 is used to call the hardware algorithm of the SE chip based on the public key ID to calculate the CMAC value, and write the CMAC value into the storage module of the SE chip after the flashing is completed.

[0177] When upgrading the firmware of a device, secure flashing is usually used to ensure the integrity of the firmware and the security of the device. It usually involves the use of encryption technology, digital signatures, and security protocols to prevent the firmware from being tampered with or damaged during transmission and installation. The specific implementation methods of secure flashing mainly include: 1. Encryption technology, that is, using encryption algorithms to encrypt the firmware to ensure the confidentiality and integrity of the data during transmission. 2. Digital signature, that is, through digital signature technology, ensure the source and integrity of the firmware to prevent the firmware from being tampered with. 3. Security protocol, that is, using security protocols such as HTTPS or other encrypted communication protocols to ensure the security of data transmission.

[0178] In an embodiment of the present invention, when the MCU chip receives a secure flashing instruction, the compiling module 051 is first used to obtain the APP and Flashdriver source programs to be flashed and compiled into S19 files or Hex files through an integrated development tool (such as IDE), wherein the APP source program is the source code of the application, that is, the code written by the developer and not compiled, and these codes contain all the logic and functions of the application. The Flashdriver source program refers to a flash driver program, which is used to control and manage the read and write operations of the flash device. The S19 / Hex file is a file format for storing program code and data. Then the S19 file or Hex file is encrypted and signed by the encryption and signature module 052 to generate the corresponding APP signature file and Flashdriver signature file to ensure that the data remains confidential and complete during transmission, and to prevent the firmware from being tampered with. After completing the digital signature, the flashing module 053 is used to flash the APP signature file and the Flashdriver signature file into the flash memory of the MCU chip through BOOT and the APP signature file and the Flashdriver signature file are verified to prevent malware or unauthorized firmware updates. In the secure flashing process, the role of BOOT is to ensure that the new firmware or software can be correctly loaded and run. Since the CMAC value needs to be calculated synchronously during each secure flashing process, and the calculated CMAC value is written into the storage module of the SE chip after the flashing is completed, the SE chip needs to be tested for public keys before this. The public key detection module 054 detects whether the public key exists in the ID of the SE chip and detects whether the public key is correct. If it is detected that the public key does not exist or is incorrect, the public key ID is stored in the SE chip. When the public key in the SE chip ID is detected and correct, the third calculation module 055 is used to call the SE hardware algorithm to calculate the CMAC value. After the flashing is completed, the CMAC value is written into the storage module of the SE chip. Since the SE chip has a large FLASH and RAM / ROM storage space, the FLASH storage space of the SE can be used as an external EEPROM chip to further reduce the cost of the motor controller. In addition, the SE chip has an independent core, and it is difficult for attackers to read the stored information compared to the EEPROM chip.

[0179] In summary, the low-cost motor controller safety starting method and device based on SE chip provided by the present invention has the following advantages:

[0180] 1) A new architecture of an independent SE chip separated from the MCU is proposed, and the SE chip is combined with the MCU, which has the advantages of low cost and high security, and realizes the safe startup and safe flashing functions in the information security of the low-cost motor controller.

[0181] 2) Using the built-in startup function and encrypted communication method in low-cost MCU can improve the security of low-cost motor controllers.

[0182] 3) The independent SE chip architecture separated from the MCU has low cost and higher security, and uses the internal FLASH storage space of the SE to further reduce the cost of the motor controller.

[0183] The above describes in detail the concepts, principles and ideas of the present invention in conjunction with specific implementation methods (including embodiments and examples). Those skilled in the art should understand that the implementation methods of the present invention are not limited to the forms given above. After reading this application document, those skilled in the art can make any possible improvements, substitutions and equivalent forms to the steps, methods, systems and components in the above implementation methods. These improvements, substitutions and equivalent forms should be deemed to fall within the scope of the present invention, and the protection scope of the present invention is subject only to the claims.

Claims

1. A low-cost motor controller safety startup method based on SE chip, characterized in that: The low-cost motor controller includes an independent SE chip and an MCU chip classified from each other, the MCU chip does not have an HSM module, and the method includes: Get secure boot request; Based on the secure boot request, the MCU chip performs a BootLoader code consistency check; If the BootLoader code consistency check succeeds, the SE chip performs an Application code consistency check; The Application code consistency check succeeds, and the motor controller is started.

2. The low-cost motor controller safety startup method based on SE chip according to claim 1 is characterized in that: Based on the secure boot request, the MCU chip performs BootLoader code consistency verification including: Jump to BootRom based on the secure boot request and calculate the CMAC value of the BootLoader data; Compare the calculated CMAC value with the CMAC value stored in the MCU chip to see if they are consistent. If they are consistent, jump to BootLoader to perform valid flag verification. Otherwise, reset the MCU chip.

3. The low-cost motor controller safety startup method based on SE chip according to claim 2 is characterized in that: The jump to the BootLoader to perform valid flag bit verification includes: Determine whether there is an Application valid flag in the BootLoader. If so, establish a communication connection between the MCU chip and the SE chip through the SPI protocol. Otherwise, stay in the BootLoader.

4. The low-cost motor controller safe startup method based on SE chip according to claim 1 is characterized in that: The BootLoader code consistency check is successful, and the SE chip performs Application code consistency check including: Calculate the CMAC value of Application data; Compare the calculated CMAC value with the CMAC value stored in the SE chip to see if they are consistent. If they are consistent, the verification is successful and jumps to the Application. Otherwise, the verification fails and stays in the BootLoader.

5. The low-cost motor controller safety startup method based on SE chip according to claim 1 is characterized in that: Before starting the MCU chip, the method further includes: The MCU chip is securely authenticated through the SE chip, and the security authentication includes device authentication and administrator authentication.

6. The low-cost motor controller safety startup method based on SE chip according to claim 5 is characterized in that: The security authentication of the MCU chip by the SE chip further includes: Get device authentication request; Performing device authentication on the MCU chip based on the device authentication request, if the device authentication is successful, obtaining an administrator authentication request and performing administrator authentication on the MCU chip, if the administrator authentication is successful, sending a secure read and write operation instruction to the MCU chip; If the device authentication and / or administrator authentication fails, it is determined whether the number of device authentication and / or administrator authentication failures exceeds a preset threshold. If so, the SE chip is locked.

7. The low-cost motor controller safety startup method based on SE chip according to claim 6 is characterized in that: The performing device authentication on the MCU chip based on the device authentication request further includes: A first random number is generated based on the device authentication request, and the first random number is encrypted using the MCU encryption algorithm and the SE encryption algorithm respectively, and the two encrypted values ​​are compared to see if they are consistent. If they are consistent, the device authentication is successful.

8. The low-cost motor controller safety startup method based on SE chip according to claim 6 is characterized in that: The obtaining of the administrator authentication request and performing administrator authentication on the MCU chip further comprises: A second random number is generated based on the administrator authentication request, and the second random number is encrypted using the MCU encryption algorithm and the SE encryption algorithm respectively, and the two encrypted values ​​are compared to see if they are consistent. If they are consistent, the administrator authentication is successful.

9. The low-cost motor controller safety startup method based on SE chip according to claim 1 is characterized in that: After starting the MCU chip, the method further includes: When the firmware of the MCU chip is upgraded, the MCU chip is securely flashed.

10. The low-cost motor controller safety startup method based on SE chip according to claim 9, characterized in that: In the case of performing firmware upgrade on the MCU chip, securely flashing the MCU chip further includes: Get the APP and Flashdriver source code to be flashed and compile them into S19 files or Hex files; Encrypt and sign the S19 file or Hex file to generate corresponding APP signature file and Flashdriver signature file; Writing the APP signature file and the Flashdriver signature file into the flash memory of the MCU chip through BOOT and verifying the signatures of the APP signature file and the Flashdriver signature file; Detect whether the public key in the ID of the SE chip exists. If it exists, detect whether the public key is correct. If it is detected that the public key does not exist or is incorrect, store the public key ID in the SE chip; The hardware algorithm of the SE chip is called based on the public key ID to calculate the CMAC value, and the CMAC value is written into the storage module of the SE chip after the flashing is completed.

11. A low-cost motor controller safety starting device based on SE chip, characterized in that: include: An acquisition module, used to obtain a secure boot request; A BootLoader code verification module, used to perform a BootLoader code consistency check on the MCU chip based on the secure boot request; The application code verification module is used to perform an application code consistency check on the SE chip, and if the check is successful, the motor controller is started.

12. The low-cost motor controller safety starting device based on SE chip according to claim 11, characterized in that: The BootLoader code verification module also includes: A first calculation module, used to jump to BootRom based on the secure boot request and calculate the CMAC value of BootLoader data; The first verification module is used to compare whether the calculated CMAC value is consistent with the CMAC value stored in the MCU chip. If they are consistent, it jumps to the BootLoader to perform valid flag verification, otherwise, the MCU chip is reset.

13. The low-cost motor controller safety starting device based on SE chip according to claim 12, characterized in that: The first verification module also includes: The valid flag identification module is used to determine whether there is an Application valid flag in the BootLoader. If so, a communication connection between the MCU chip and the SE chip is established through the SPI protocol. Otherwise, it stays in the BootLoader.

14. The low-cost motor controller safety starting device based on SE chip according to claim 11, characterized in that: The Application code verification module also includes: The second calculation module is used to calculate the CMAC value of the Application data; The second verification module is used to compare whether the calculated CMAC value is consistent with the CMAC value stored in the SE chip. If they are consistent, the verification is successful and jumps to the Application. Otherwise, the verification fails and stays in the BootLoader.

15. The low-cost motor controller safety starting device based on SE chip according to claim 11, characterized in that: The device also includes: The security authentication module is used to perform security authentication on the MCU chip through the SE chip, and the security authentication includes device authentication and administrator authentication.

16. The low-cost motor controller safety starting device based on SE chip according to claim 15, characterized in that: The security authentication module also includes: A request acquisition module is used to acquire device authentication requests and administrator authentication requests; The device authentication module is used to authenticate the MCU chip based on the device authentication request. If the device authentication succeeds, an administrator authentication request is sent. If the authentication fails, it is determined whether the number of authentication failures exceeds a preset threshold. If so, the SE chip is locked. The administrator authentication module is used to perform administrator authentication on the MCU chip based on the administrator authentication request. If the authentication is successful, a secure read and write operation instruction is sent to the MCU chip. If the authentication fails, it is determined whether the number of authentication failures exceeds a preset threshold. If so, the SE chip is locked.

17. The low-cost motor controller safety starting device based on SE chip according to claim 11, characterized in that: The device also includes: The secure flashing module is used to securely flash the MCU chip when the firmware of the MCU chip is upgraded.

18. The low-cost motor controller safety starting device based on SE chip according to claim 17, characterized in that: The secure flashing module also includes: Compilation module, used to obtain the APP and Flashdriver source programs to be flashed and compile them into S19 files or Hex files; An encryption and signature module, used to encrypt and sign the S19 file or Hex file, and generate corresponding APP signature files and Flashdriver signature files; A flashing module, used to flash the APP signature file and the Flashdriver signature file into the flash memory of the MCU chip through BOOT and verify the signature of the APP signature file and the Flashdriver signature file; A public key detection module is used to detect whether the public key in the ID of the SE chip exists. If it exists, it detects whether the public key is correct. If it is detected that the public key does not exist or is incorrect, the public key ID is stored in the SE chip; The third calculation module is used to call the hardware algorithm of the SE chip based on the public key ID to calculate the CMAC value, and write the CMAC value into the storage module of the SE chip after the flashing is completed.