A DSP secure boot method, device and computer readable medium
The hardware encryption and decryption chip and double verification mechanism are used to verify the DSP program update and startup, which solves the problems of FLASH writing errors and insufficient security in the traditional update method, and achieves efficient and safe startup of the DSP.
Patent Information
- Application Number
- CN202410574734.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-10
- Publication Date
- 2024-08-30
- Estimated Expiration
- 2044-05-10
AI Technical Summary
The traditional DSP program update method may cause the device to fail to start normally when FLASH writing errors occur, and lacks security verification. In extreme cases, it may cause irreversible damage to the system.
It uses a hardware encryption and decryption chip and a double verification mechanism to verify the legality of the updated image file through the TPM module, and verifies the image file again at each startup to ensure that only authorized programs run.
It improves the startup security of DSP, prevents unauthorized program solidification and tampering, and ensures system stability and security.
Smart Images

Figure CN118153066B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer data writing, and in particular to a DSP secure startup method, device and computer-readable medium. Background Art
[0002] DSP chip is a microprocessor designed for high-speed, real-time processing of digital signals, and is widely used in communications, image recognition, industrial control, aerospace, military defense and other fields. Due to its complex application scenarios and wide range, especially in the military and aerospace fields, and with the need for system upgrades, the DSP program needs to be updated and upgraded, and the traditional update method is generally to send the compiled binary update file to the DSP through Ethernet through the host computer; the DSP receives and temporarily stores the file in a temporary area through its boot loader; after the new program is verified, it is written to the flash memory or other non-volatile memory by the DSP, and finally restarted and restarted.
[0003] However, at the same time, during the actual use of the device, if the FLASH writes an incorrect program, the DSP will not start normally, causing the device to fail to operate normally. The device must suspend the current working state and perform maintenance and upgrades. This state greatly reduces the reliability of the system. Traditional software image management and untrusted startup are no longer able to meet security requirements. In extreme cases, serious accidents may occur due to image tampering. Summary of the invention
[0004] The purpose of the present invention is to provide a DSP secure boot method, device and computer-readable medium, wherein the received image is subjected to hardware verification and then stored in an off-chip FLASH, and when the DSP program is updated, the image file is read and verified again, and after the verification is passed, the original BIN file that has passed the verification is read from the FALSH by switching the control right of the FLASH for secure booting, and a hardware encryption and decryption chip is used to improve the security and decryption efficiency, thereby greatly improving the DSP startup security.
[0005] To achieve the above objectives, this application provides the following solutions:
[0006] On the one hand, the present application provides a DSP security startup method, where the MCU serves as the main control unit for DSP security update startup and performs the following process:
[0007] S1, receiving the DSP program update signal, controlling the CPLD switching module to switch the off-chip FLASH access right to the MCU;
[0008] S2. Receive and parse the complete image package with signature, obtain the original BIN file and file signature content, send the original BIN file and file signature content to the TPM security module for verification, receive the returned verification result, and if the verification passes, write the original BIN file to the off-chip FALSH and save the file signature content to the MCU internal memory;
[0009] S3. Each time a DSP secure boot signal is received, the original BIN file is read from the off-chip FLASH and the corresponding file signature content is read from the MCU internal memory, the TPM security module is controlled to verify the file signature content, and the returned signature verification result is received;
[0010] S4. If the signature verification is passed, the CPLD switching module is controlled to switch the access right of the off-chip FLASH to the DSP, and the DSP loads the original BIN file that has passed the signature verification from the off-chip FLASH for secure startup.
[0011] The concept of this application is:
[0012] When the DSP is updated and restarted, two FLASH are generally set up as backup and firmware redundancy. Generally, one is used to store the updated program files, and the other is used to store the program files when the DSP starts running. The firmware backup mechanism of two FLASH can improve the stability of the system, but the program update files are not security verified when they are stored, and the legitimacy of the updated program files cannot be guaranteed. At the same time, no security verification is performed during startup. It is not ensured whether the previously existing firmware that has passed the security verification has been violently modified. In extreme cases, the above vulnerabilities may cause unpredictable DSP startup due to illegal tampering of program files, and may even cause irreversible damage to the system.
[0013] In view of this, the present application sets up double verification and implements the control of an off-chip FLASH by the DSP and MCU main control unit through hardware switching, ensuring the secure startup of the DSP after the update and the efficient application of FLASH. The double verification is that when updating, the image file of the received encrypted program update is verified after being decrypted by the TPM hardware to prevent the solidification of unauthorized programs. The other verification is that the image file that needs to be loaded into the DSP is verified every time the DSP is started to determine whether the file has been tampered with. When the verification passes, the FLASH access right will be switched to the DSP, and the DSP will read the program file from the FLASH for secure startup. The double verification can prevent the program from being maliciously tampered with and the program from running illegally, ensuring that the DSP always runs the authorized program, thereby greatly improving the DSP startup security.
[0014] In an optional implementation, the file content of the complete image package with signature includes a header, an original BIN file, and a file signature content, wherein the file signature content includes the original BIN file size, signature information, and a public key.
[0015] In an optional implementation manner, the parsing verification process in step S2 is:
[0016] S21. Parse the complete image package with the signature to obtain the file content of the complete image package, and read the file signature content and the original BIN file from the file content;
[0017] S22. Send the file signature content and the original BIN file to the TPM security module. The TPM security module uses SM3 to calculate the second digest value of the original BIN file, and then performs SM2 verification based on the public key, signature information and the second digest value.
[0018] In an optional implementation manner, the process of verifying the signature content of the file in step S3 is:
[0019] S31, control the CPLD switching module to switch the off-chip FLASH access right to the MCU;
[0020] S32, read the original BIN file from the off-chip FLASH, and read the file signature content corresponding to the original BIN file from the MCU internal memory;
[0021] S33, the original BIN file and the file signature content are sent to the TPM security module, and the TPM security module uses SM3 to calculate the second digest value of the original BIN file, and then performs SM2 verification based on the public key, signature information and the second digest value.
[0022] In an optional implementation, the process of obtaining a complete image package with a signature is as follows:
[0023] S11, compile and generate the original BIN file, and use the SM2 algorithm to generate the SM2 public-private key pair, which includes a public key and a private key;
[0024] S12, using the SM3 hash algorithm to calculate the first summary value of the original BIN file;
[0025] S13, using SM2 to sign the first summary value using the private key to obtain an original BIN file with signature information;
[0026] S14. Encapsulate the original BIN file with signature information into a complete image package with signature according to the image package file format.
[0027] In a second aspect, the present application provides a DSP secure boot device, including an MCU main control unit, a TPM security module, a CPLD switching module, an off-chip FLASH and a DSP, wherein the TPM security module and the CPLD are respectively connected to the MCU main control unit for communication via an SPI bus, the I2C interface of the MCU main control unit is connected to the CPLD switching module, and the off-chip FLASH and the DSP are respectively connected to the CPLD switching module for communication via an SPI bus.
[0028] In an optional implementation, the MCU main control unit is used to receive and parse the complete image package with a signature, control the CPLD switching module to switch the access right of the off-chip FLASH, control the TPM security module to verify the complete image package with a signature, and write the original BIN file into the off-chip FLASH according to the received verification result, and save the file signature content into the MCU internal memory;
[0029] The TPM security module is used to verify the complete image package with the signature and return the verification result to the MCU main control unit;
[0030] The CPLD switching module is used to receive the switching signal of the MCU main control unit, switch the access right to the off-chip FLASH between the MCU main control unit and the DSP, and is used for the power-on startup control of the DSP;
[0031] The off-chip FLASH is used to store the original BIN files that have passed verification.
[0032] In an optional implementation, the file content of the complete image package with signature includes a header, an original BIN file, and a file signature content, wherein the file signature content includes the original BIN file size, signature information, and a public key.
[0033] In an optional implementation, the signature of the signed complete image package adopts the SM3 hash algorithm and the SM2 digest signature algorithm, the SM3 hash algorithm is used to calculate the first digest value of the original BIN file, and the SM2 digest signature algorithm is used to sign the first digest value.
[0034] In a third aspect, the present application provides a computer-readable storage medium, comprising instructions, which, when executed on an electronic device, enable the electronic device to execute a DSP secure boot method as described in the first aspect.
[0035] The present invention has the beneficial effects:
[0036] This application can prevent external violent tampering and prevent unauthorized programs from being solidified by performing a legitimacy check when storing the image file of the update program. At the same time, a legitimacy check is performed again each time the DSP reads the image file to start, ensuring that the DSP always runs authorized programs, thereby improving the DSP startup security.
[0037] This application uses the MCUMCU main control unit to control the CPLD to switch the access rights to the off-chip FLASH, thereby improving the utilization rate of FLASH. The MCU main control unit itself has an internal storage space to store information with a certain degree of security. The verification process is completed using a hardware verification chip TPM. The use of hardware can improve security and decryption efficiency, and avoid problems such as malicious tampering with the program and illegal operation of the program. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 A schematic diagram of the overall process of DSP update startup provided by an embodiment of the present invention;
[0039] Figure 2 A schematic diagram of a DSP program update process provided by an embodiment of the present invention;
[0040] Figure 3 A schematic diagram of a DSP startup process provided by an embodiment of the present invention;
[0041] Figure 4 A schematic diagram of the connection of a safe starting device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. The following description of at least one exemplary embodiment is actually only illustrative and is by no means intended to limit the present invention and its application or use. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] The relative arrangement of components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.
[0044] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0045] Additionally, descriptions of well-known structures, functions, and configurations may be omitted for clarity and conciseness.One of ordinary skill in the art will recognize that various changes and modifications may be made to the examples described herein without departing from the spirit and scope of the present disclosure.
[0046] Technologies, methods, and apparatus known to ordinary technicians in the relevant field may not be discussed in detail, but where appropriate, such technologies, methods, and apparatus should be considered part of the authorization specification.
[0047] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0048] Example 1
[0049] like Figure 1-Figure 3 As shown, this embodiment provides a DSP security boot method, and the MCU serves as the main control unit for DSP security update boot, and performs the following process:
[0050] S1, receiving the DSP program update signal, controlling the CPLD switching module to switch the off-chip FLASH access right to the MCU;
[0051] S2. Receive and parse the complete image package with signature, obtain the original BIN file and file signature content, send the original BIN file and file signature content to the TPM security module for verification, receive the returned verification result, and if the verification passes, write the original BIN file to the off-chip FALSH and save the file signature content to the MCU internal memory;
[0052] The complete image package with signature is generated in the host computer. The specific process is as follows:
[0053] S11. Compile and generate the original BIN file, and use the SM2 algorithm to generate the SM2 public-private key pair, which includes a public key and a private key; the private key is only used to sign the summary value, and then retained in the host computer, and is only responsible for signing the first summary.
[0054] S12, using the SM3 hash algorithm to calculate the first summary value of the original BIN file;
[0055] S13, using SM2 to sign the first summary value using the private key to obtain an original BIN file with signature information;
[0056] S14. Encapsulate the original BIN file with signature information and the public key into a complete image package with signature according to the image package file format.
[0057] Specifically, the file content of the complete image package with a signature includes a header, an original BIN file, and a file signature content. The file signature content includes the original BIN file size, signature information, and a public key. As shown in Table 1, a specific file structure format of an encrypted complete image package is given:
[0058] Table 1
[0059] head Original BIN file size Original BIN file Signature Information Public Key 0Xa5a5a5a5 …… …… …… …… 4Byte 4Byte Size is not fixed Fixed size Fixed size
[0060] The signature information is the signature information obtained by signing the first summary value using the SM2 private key using SM2, and the public key is the public key in the public-private key pair generated by the owner through the host computer.
[0061] Correspondingly, the MCU receives the encrypted complete image package from the host computer through the Ethernet port, and the process of parsing and verifying the encrypted complete image package is as follows:
[0062] S21. Parse the complete image package with signature to obtain the file content of the complete image package, read the file signature content and the original BIN file from the file content, wherein the reading process is as follows: the MCU obtains the complete image package, skips the 4-byte header and the 4-byte BIN file size according to the image package file format in Table 1, and obtains the next 4-byte original BIN file according to the 4-byte BIN file size, obtains the fixed-size signature information and the public key.
[0063] S22. The MCU sends the original BIN file and the file signature content to the TPM security module, and the TPM security module uses SM3 to calculate the second digest value of the original BIN file.
[0064] S23. The MCU controls the TPM security module to perform SM2 signature verification using the public key and signature information obtained in S21 and the second digest value calculated in S22.
[0065] S24, after the signature verification is successful, the signature information, public key and BIN file size are saved to the storage space inside the MCU. At the same time, the MCU obtains access to the off-chip FLASH through the CPLD and writes the original BIN file to the off-chip FLASH, where the original BIN file is associated with its corresponding signature information, public key and BIN file size. Among them, the SM3 algorithm and SM2 signature verification are commonly used methods, which will not be described in detail in this article.
[0066] In the above process, the legitimacy of the image file of the program update is verified to prevent external violent tampering and prevent unauthorized program solidification.
[0067] S3. Each time a DSP secure boot signal is received, the original BIN file is read from the off-chip FLASH and the corresponding file signature content is read from the MCU internal memory, the TPM security module is controlled to verify the file signature content, and the returned signature verification result is received;
[0068] Each time the DSP is started, the program needs to be verified for legitimacy to ensure that the DSP always runs authorized programs, which can improve the security of DSP startup. The specific process is as follows:
[0069] S31, MCU obtains the access right of the off-chip FLASH through CPLD and reads the original BIN file from the off-chip FLASH;
[0070] S32, MCU obtains the file signature content corresponding to the original BIN file stored in the off-chip FLASH from the internal storage space, including signature information, public key and original BIN file size;
[0071] S33, MCU sends the original BIN file content and file signature content to the TPM security module to calculate the third summary value through SM3;
[0072] S34, MCU controls the TPM security module to perform SM2 signature verification through the signature information and public key obtained in S32 and the third digest value calculated in S33;
[0073] S4. If the signature verification is successful, the CPLD switching module is controlled to switch the access right of the off-chip FLASH to the DSP. At the same time, the DSP chip is powered on through the CPLD. At this time, the DSP loads the original BIN file from the off-chip FLASH to start securely.
[0074] It is understandable that to ensure the secure startup of the DSP, it is first necessary to ensure that the firmware update file of the DSP can be safely stored in the FLASH. Therefore, it is necessary to first perform a security check on the update file, and then store the firmware file that has passed the check. And because only executable original BIN files can be stored in the FLASH, the file signature content of the original BIN file must be saved in the MCU internal memory of the MCU main control unit during storage. In this way, each time the DSP is started, it needs to be verified by the file signature content and the original BIN file. Only after the verification is passed can the DSP obtain access to the off-chip FLASH and directly load the executable original BIN file from it. Therefore, this application includes the following two processes:
[0075] 1. DSP program update process
[0076] like Figure 2As shown in the figure, in this process, the owner first needs to compile and generate the original BIN file and SM2 public-private key pair in the host computer. The public-private key pair includes a public key and a private key. SM3 is used to calculate the digest value of the original BIN file, and the digest value is signed by SM2 and the private key. Finally, the final encrypted complete image package is generated according to the format of Table 1, and then the encrypted complete image package is sent to the MCU.
[0077] MCU receives and parses the image package content, relies on TPM to use SM3 to calculate the summary value of the original BIN file, verifies the signature (SM2 signature verification, relies on the public key, signature, and calculated summary), and if the verification succeeds, saves the signature, public key, and original BIN file size information to the MCU internal storage space, and controls CPLD to switch FLASH access rights to MCU, and writes the original BIN file to FLASH; if the verification fails, it performs exception processing or alarms.
[0078] 2. DSP trusted startup process:
[0079] like Figure 3 As shown, the MCU is powered on and initialized, and the MCU controls the CPLD to switch the FLASH access right, so that the MCU obtains the FLASH access right, reads the BIN file in the current off-chip FLASH, uses SM3 to calculate the summary value, and the TPM calculates the summary through SM3 to verify the signature. After the verification passes, the CPLD switches the FLASH access right to the DSP, and the DSP is powered on and started.
[0080] Example 2
[0081] like Figure 4 As shown, this embodiment provides a DSP secure boot device, including an MCU main control unit, a TPM security module, a CPLD switching module, an off-chip FLASH and a DSP, wherein the TPM security module and the CPLD are respectively connected to the MCU main control unit through an SPI bus for communication, the I2C interface of the MCU main control unit is connected to the CPLD switching module, and the off-chip FLASH and the DSP are respectively connected to the CPLD switching module through an SPI bus for communication.
[0082] In an optional implementation, the MCU main control unit is used to receive the encrypted complete image package, control the CPLD to switch the control right of the off-chip FLASH, control the TPM security module to parse and verify the encrypted complete image package, and write the encrypted complete image package into the off-chip FLASH according to the received verification result;
[0083] MCU main control unit uses MCU as the main control unit of the device. The external network port (1000M) is used to receive version data, control the TPM security module for data stream signature verification, control the CPLD to switch FLASH access rights, control the power on and off and startup of the DSP chip, and write the original BIN file to the external FLASH according to the received verification result, and save the file signature content to the MCU internal memory; and the MCU cannot be updated or burned after leaving the factory to ensure the security of the original BIN file storage and update.
[0084] The TPM security module is used to verify the complete signed image package and return the verification result to the MCU main control unit. TPM is mainly used for signature verification of data streams. The use of TPM security module has higher security and better performance, and also meets its mandatory requirements in some special fields.
[0085] The signature verification process in the TPM security module mainly uses the SM3 hash algorithm and the SM2 digest signature algorithm. The SM3 hash algorithm is used to calculate the first digest value of the original BIN file, and the SM2 digest signature algorithm is used to sign the first digest value.
[0086] The CPLD switching module is used to receive the switching signal of the MCU main control unit, switch the access right to the off-chip FLASH between the MCU main control unit and the DSP, and is used for the power-on startup control of the DSP;
[0087] CPLD is mainly used to realize the switching of SPI bus between DSP and MCU and the power-on startup of DSP chip; CPLD is directly controlled by MCU through I2C interface.
[0088] The off-chip FLASH is used to store the original BIN files that have passed verification.
[0089] In an optional implementation, the file content of the complete image package with signature includes a header, an original BIN file, and a file signature content, wherein the file signature content includes the original BIN file size, signature information, and a public key.
[0090] Example 3
[0091] This embodiment provides a computer-readable storage medium, including instructions. When the instructions are executed on an electronic device, the electronic device executes the DSP secure boot method in Embodiment 1.
[0092] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. According to the technical essence of the present invention, within the spirit and principles of the present invention, any simple modification, equivalent replacement and improvement made to the above embodiment still falls within the protection scope of the technical solution of the present invention.
Claims
1. A DSP secure boot method, characterized in that: The MCU acts as the main control unit for starting the DSP security update and performs the following process: S1, receiving the DSP program update signal, controlling the CPLD switching module to switch the off-chip FLASH access right to the MCU; S2. Receive and parse the complete image package with signature, obtain the original BIN file and file signature content, send the original BIN file and file signature content to the TPM security module for verification, receive the returned verification result, and if the verification passes, write the original BIN file to the off-chip FALSH and save the file signature content to the MCU internal memory; The specific process of step S2 is: S21. Parse the complete image package with the signature to obtain the file content of the complete image package, and read the file signature content and the original BIN file from the file content; S22, sending the file signature content and the original BIN file to the TPM security module, the TPM security module uses SM3 to calculate the second digest value of the original BIN file, and then performs SM2 verification based on the public key, signature information and the second digest value; S3. Each time a DSP secure boot signal is received, the original BIN file is read from the off-chip FLASH and the corresponding file signature content is read from the MCU internal memory, the TPM security module is controlled to verify the file signature content, and the returned signature verification result is received; S4. If the signature verification is passed, the CPLD switching module is controlled to switch the access right of the off-chip FLASH to the DSP, and the DSP loads the original BIN file that has passed the signature verification from the off-chip FLASH for secure startup.
2. A DSP secure boot method according to claim 1, characterized in that: The file content of the complete image package with signature includes the header, the original BIN file, and the file signature content. The file signature content includes the original BIN file size, signature information, and public key.
3. A DSP secure boot method according to claim 2, characterized in that: The process of verifying the signature content of the file in step S3 is: S31, control the CPLD switching module to switch the off-chip FLASH access right to the MCU; S32, read the original BIN file from the off-chip FLASH, and read the file signature content corresponding to the original BIN file from the MCU internal memory; S33, the original BIN file and the file signature content are sent to the TPM security module, and the TPM security module uses SM3 to calculate the second digest value of the original BIN file, and then performs SM2 verification based on the public key, signature information and the second digest value.
4. A DSP secure boot method according to claim 1, characterized in that: The process of obtaining a complete image package with a signature is as follows: S11, compile and generate the original BIN file, and use the SM2 algorithm to generate the SM2 public-private key pair, which includes a public key and a private key; S12, using the SM3 hash algorithm to calculate the first summary value of the original BIN file; S13, using SM2 to sign the first summary value using the private key to obtain an original BIN file with signature information; S14. Encapsulate the original BIN file with signature information and the public key into a complete image package with signature according to the image package file format.
5. A DSP secure boot device, characterized in that: It includes an MCU main control unit, a TPM security module, a CPLD switching module, an off-chip FLASH and a DSP, wherein the TPM security module and the CPLD are respectively connected to the MCU main control unit through an SPI bus, the I2C interface of the MCU main control unit is connected to the CPLD switching module, and the off-chip FLASH and the DSP are respectively connected to the CPLD switching module through an SPI bus, wherein: MCU main control unit, used to receive DSP program update signals and control the CPLD switching module to switch the access right of the off-chip FLASH to the MCU; Receive and parse the complete image package with signature, obtain the file content of the complete image package, and read the file signature content and original BIN file from the file content; Send the original BIN file and file signature content to the TPM security module for verification; Control the TPM security module to verify the complete image package with signature, write the original BIN file into the off-chip FLASH according to the received verification result, and save the file signature content into the MCU internal memory; Each time the DSP secure boot signal is received, the original BIN file is read from the off-chip FLASH and the corresponding file signature content is read from the MCU internal memory, the TPM security module is controlled to verify the file signature content, and the returned signature verification result is received; if the signature verification passes, the CPLD switching module is controlled to switch the off-chip FLASH access right to the DSP, and the DSP loads the original BIN file that has passed the signature verification from the off-chip FLASH for secure boot; The TPM security module is used to verify the complete image package with signature, receive the file signature content and the original BIN file sent by the MCU main control unit, use SM3 to calculate the second digest value of the original BIN file, and then perform SM2 verification based on the public key, signature information and the second digest value; and return the verification result to the MCU main control unit; The CPLD switching module is used to receive the switching signal of the MCU main control unit, switch the access right to the off-chip FLASH between the MCU main control unit and the DSP, and is used for the power-on startup control of the DSP; The off-chip FLASH is used to store the original BIN files that have passed verification.
6. A DSP secure boot device according to claim 5, characterized in that: The file content of the complete image package with signature includes the header, the original BIN file, and the file signature content. The file signature content includes the original BIN file size, signature information, and public key.
7. A DSP secure boot device according to claim 6, characterized in that: The signature of the complete image package with signature adopts the SM3 hash algorithm and the SM2 digest signature algorithm. The SM3 hash algorithm is used to calculate the first digest value of the original BIN file, and the SM2 digest signature algorithm is used to sign the first digest value.
8. A computer-readable storage medium comprising instructions, characterized in that: When the instruction is executed on an electronic device, the electronic device executes a DSP secure boot method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Industrial control panel and method for updating programs by aid of networks in online manner
CN107203396A
Starting and online upgrading method and device for multiple C2000 DSPs
CN115373720A
