Method, electronic device and storage medium for upgrading signed firmware
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- FUZHOU ROCKCHIP SEMICON
- Filing Date
- 2022-08-26
- Publication Date
- 2026-08-07
AI Technical Summary
这类方案要求能在系统升级过程中直接读取保存在芯片一次性密钥存储区域(如OTP)中的公钥信息,但是在有些安全性要求高的设备中,在用户空间的应用系统中通常无法直接读取芯片一次性密钥存储区域等敏感区域的数据;同时芯片的一次性密钥存储区域空间有限,很多时候无法直接存储密钥信息本身,而是存储公钥的哈希值,这就意味着无法从一次性密钥存储区域中获取实际使用的密钥信息
Smart Images

Figure CN115357293B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of embedded device technology, and in particular to methods for upgrading signed firmware, electronic devices, and storage media. Background Technology
[0002] Devices that support Secure Boot require firmware to be signed and to use a master key to verify various firmware components involved in the boot process. If the device fails to boot and the verification fails, the device will be unable to boot.
[0003] Existing upgrade solutions for signed firmware mainly include the following:
[0004] 1. Most upgrade solutions rely on users ensuring the firmware is signed and verifying a successful upgrade before releasing it to the firmware upgrade server. Firmware upgrades are typically direct firmware updates. This means that if an unsigned firmware or firmware signed with an incorrect key is accidentally upgraded, the upgraded device will fail to boot.
[0005] 2. Relying on the chip's one-time key storage area (such as OTP, a special type of non-volatile memory) to store public key information. This type of solution requires the ability to directly read the public key information stored in the chip's one-time key storage area (such as OTP) during system upgrades. However, in some high-security devices, data in sensitive areas such as the chip's one-time key storage area is often not directly accessible from user-space application systems. Furthermore, the chip's one-time key storage area has limited space, often storing only the hash value of the public key instead of the key information itself. This means that the actual key information used cannot be obtained from the one-time key storage area.
[0006] 3. Dependence on device trees and related technical infrastructure exists. This scheme transmits key information through the device tree during the secure boot process, which depends on the device tree and related technical infrastructure. Therefore, it is limited in scenarios that do not support device trees and related technical infrastructure. Summary of the Invention
[0007] Embodiments of the present invention provide a method, electronic device, and storage medium for upgrading signed firmware, which can improve the reliability of signed firmware upgrades.
[0008] In one aspect of the present invention, a method for upgrading signed firmware is provided. The method includes: obtaining public key parameter information, a digital signature algorithm type, and a message digest algorithm type from the bootloader firmware in the signed firmware to be upgraded; calculating a message digest corresponding to the digital signature algorithm type and the public key parameter information based on the message digest algorithm type; writing the message digest and a system flag into command-line parameters; and writing the public key parameter information, the digital signature algorithm type, and a circuit breaker flag into a first position of a boot communication partition; encrypting the message digest and the message digest algorithm type; and writing the encrypted message digest and message digest algorithm type into a second position of the boot communication partition; determining whether verification is required based on the system flag and the circuit breaker flag; if verification is required, verifying the signed firmware to be upgraded based on the command-line parameters and the boot communication partition; and if the verification result is successful, upgrading the signed firmware to be upgraded.
[0009] In another aspect of the invention, an electronic device is provided. The electronic device includes a memory configured to store a computer program; and a processor configured to execute the computer program to perform the aforementioned method for upgrading and signing firmware.
[0010] In another aspect of the invention, a computer-readable medium is provided. This medium stores a computer program that is executed by a processor to implement the above-described method for upgrading signed firmware.
[0011] According to an embodiment of the present invention, public key parameter information, digital signature algorithm type, and message digest algorithm type are obtained through the bootloader firmware in the signed firmware to be upgraded. A message digest corresponding to the digital signature algorithm type and public key parameter information is calculated based on the message digest algorithm type. The message digest and system flag are written into command line parameters. The public key parameter information, digital signature algorithm type, and circuit breaker flag are written into the first position of the boot communication partition. The encrypted message digest and message digest algorithm type are written into the second position of the boot communication partition. When verification is required based on the system flag and circuit breaker flag, the signed firmware to be upgraded is verified based on the command line parameters and the boot communication partition. If the verification result is successful, the signed firmware to be upgraded is upgraded. By writing the message digest into the command line parameters and the public key parameter information, digital signature algorithm type, encrypted message digest, and message digest algorithm type into the boot communication partition, the system eliminates the need for device trees and related technical facilities. Before firmware upgrade, the signed firmware to be upgraded is verified, ensuring that the firmware signature is correct before upgrading. This avoids upgrading unsigned firmware or firmware signed with an incorrect key, thereby improving the reliability of signed firmware upgrades. Attached Figure Description
[0012] Figure 1 This is a flowchart of the steps of a method for upgrading signed firmware according to an embodiment of the present invention;
[0013] Figure 2 This is a flowchart illustrating a method for upgrading signed firmware according to an embodiment of the present invention;
[0014] Figure 3 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0015] To explain in detail the technical content, objectives, and effects of the present invention, the following description is provided in conjunction with the embodiments and accompanying drawings.
[0016] In existing technologies, upgrade solutions for signed firmware rely on the user to ensure that the firmware itself is signed and to actually verify the successful upgrade before publishing it to the firmware upgrade server. Alternatively, they rely on the chip's one-time key storage area to store public key information, or they transmit the key information through the device tree. This involves dependence on the device tree and related technical facilities. When upgrading unsigned firmware or firmware signed with an incorrect key, the upgraded device will fail to boot properly.
[0017] To address at least the aforementioned technical problems, this disclosure provides a method for upgrading signed firmware. According to this disclosure, a message digest containing the digital signature algorithm type and public key parameter information is written into command-line parameters. The public key parameter information, digital signature algorithm type, encrypted message digest, and message digest algorithm type are then written into a boot communication partition. After successful verification of the signed firmware to be upgraded based on the command-line parameters and the boot communication partition, the firmware is upgraded. In this manner, embodiments of this disclosure can upgrade firmware only when the firmware signature is correct, without relying on device trees and related technical facilities, thus avoiding the upgrade of unsigned firmware or firmware signed with an incorrect key, thereby improving the reliability of signed firmware upgrades.
[0018] In the following, the technical solutions according to this disclosure will be described with reference to specific embodiments and in conjunction with the accompanying drawings.
[0019] Figure 1 This is a flowchart illustrating a method 100 for upgrading signed firmware according to an embodiment of the present disclosure. (Refer to...) Figure 1 The method 100 includes the following steps 102 to 112.
[0020] In step 102, public key parameter information, digital signature algorithm type, and message digest algorithm type are obtained from the bootloader firmware in the signed firmware to be upgraded. A message digest corresponding to the digital signature algorithm type and the public key parameter information is calculated based on the message digest algorithm type. In some embodiments, the device securely boots, loads and verifies the corresponding signed firmware to be upgraded from the boot storage medium (such as eMMC, embedded Multi Media Card). After securely booting the bootloader firmware, public key parameter information, digital signature algorithm type, and message digest algorithm type are obtained from the bootloader firmware in the signed firmware to be upgraded. A message digest corresponding to the digital signature algorithm type and the public key parameter information is calculated based on the message digest algorithm type.
[0021] In some embodiments, the method 100 may further include: signing the firmware to be upgraded to obtain the signed firmware to be upgraded; writing the public key parameter information, the digital signature algorithm type, and the message digest algorithm type into a preset location of the bootloader firmware in the signed firmware to be upgraded; and storing the signed firmware to be upgraded into a firmware upgrade package. In this way, it is ensured that the firmware signature information can be obtained through the bootloader firmware.
[0022] In some embodiments, a digital digest of the public key parameter information is calculated and compared with a preset digital digest. If the comparison is successful, the digital signature algorithm type and the public key parameter information are used as input to calculate the message digest based on the message digest algorithm type. If the comparison is unsuccessful, the upgrade process is terminated. In some embodiments, the preset digital digest is stored in an OTP or efuse (one-time programmable memory) in the device chip. In this way, the key used for signing can be verified once, improving security.
[0023] In step 104, the message digest and system tag are written into the command line parameters (such as the hash parameter), and the public key parameter information, the digital signature algorithm type, and the circuit breaker tag are written into the first position of the boot communication partition.
[0024] In step 106, the message digest and the message digest algorithm type are encrypted, and the encrypted message digest and message digest algorithm type are written to the second location of the boot communication partition. In some embodiments, the message digest and the message digest algorithm type are encrypted using a preset symmetric encryption algorithm and key in the bootloader firmware. In this way, without relying on the device tree and related technical facilities, subsequent verification can be performed based on the data in the boot communication partition, improving the applicability of signed firmware upgrades. In addition, the corresponding verification process is executed by determining whether the device is "fuse-out" through the fuse flag in the boot communication partition.
[0025] In step 108, it is determined whether verification is required based on the system flag and the fuse flag. In some embodiments, it is determined whether the system flag indicates that the device is a single system. If so, it is determined whether the fuse flag indicates that the device is fuse-broken. If the fuse flag indicates that the device is fuse-broken, it is determined that verification is required; and if the fuse flag indicates that the device is not fuse-broken, it is determined that verification is not required. The method also includes directly upgrading the signed firmware to be upgraded. In some embodiments, the single system is a non-A / B system, that is, there is only one set of firmware. In this way, it is avoided that unsigned or incorrectly signed firmware is obtained after firmware upgrade, thereby ensuring that the device can start normally after upgrade and improving the upgrade reliability of signed firmware.
[0026] In some embodiments, it is determined whether the system flag indicates that the device is a dual-system device; if so, it is determined whether the fuse flag indicates that the device is fuse-broken; if the device is fuse-broken, it is determined that verification is required; and if the device is not fuse-broken, it is determined that verification is not required. The method also includes directly upgrading the signed firmware to be upgraded. In some embodiments, the dual-system is an A / B system, i.e., there are two sets of firmware. In this way, the A / B system can be upgraded directly without entering upgrade mode, while non-A / B systems need to enter upgrade mode before upgrading, and execute the corresponding firmware verification process according to the system flag or fuse flag, thus improving verification efficiency.
[0027] In step 110, if verification is required, the signed firmware to be upgraded is verified based on the command-line parameters and the boot communication partition. In some embodiments, the signed firmware to be upgraded is verified based on the digital signature algorithm type and public key parameter information in the first location of the boot communication partition, the message digest in the command-line parameters, and the encrypted message digest and message digest algorithm type in the second location of the boot communication partition. In some embodiments, verification is performed based on the encrypted message digest and the message digest in the command-line parameters; and verification is performed based on the digital signature algorithm type, the public key parameter information, and the encrypted message digest algorithm type and the message digest in the command-line parameters.
[0028] In some embodiments, a symmetric encryption algorithm and key are used to decrypt the encrypted message digest and message digest algorithm type read from the second location of the boot communication partition to obtain a decrypted message digest and message digest algorithm type; it is determined whether the decrypted message digest is consistent with the message digest read from the command line parameters; if they are inconsistent, the upgrade process is exited and the verification result is determined to be a failure; if they are consistent, the digital signature algorithm type and public key parameter information read from the first location of the boot communication partition are used as input, and the corresponding verification message digest is calculated using the decrypted message digest algorithm type; it is determined whether the verification message digest is consistent with the message digest read from the command line parameters; if they are inconsistent, the upgrade process is exited and the verification result is determined to be a failure; and if they are consistent, the verification result is determined to be a success.
[0029] In step 112, if the verification result is successful, the signed firmware to be upgraded is upgraded. In some embodiments, if the system flag in the command line parameters indicates that the device is a single system, a firmware to be verified is randomly selected from the firmware upgrade package, and the binary file of the firmware to be verified is written into memory or a read / write file system partition; the firmware to be verified is verified using the digital signature algorithm type and the public key parameter information; if the verification fails, the upgrade process is exited; and if the verification is successful, the signed firmware to be upgraded is upgraded. In this way, for single-system devices, a firmware is randomly selected for signature verification before entering the upgrade mode, and if the verification fails, the upgrade process is exited directly, thereby improving the upgrade efficiency of signed firmware.
[0030] In some embodiments, if verification is successful, the device is guided into firmware upgrade mode; firmware to be upgraded is selected sequentially from the firmware upgrade package, and the binary file of the firmware to be upgraded is written to memory or a read / write file system partition; each firmware to be upgraded is verified using the digital signature algorithm type and the public key parameter information; if any firmware to be upgraded fails verification, and if the circuit breaker flag indicates that the device has been tripped, the upgrade process is exited; and if each firmware to be upgraded succeeds in verification, the firmware upgrade process is executed to upgrade the signed firmware. In this way, after the randomly selected firmware signature verification is successful, the upgrade mode is entered to verify all firmware, and the upgrade process exits as soon as any firmware verification fails, thus ensuring the reliability of verification and improving upgrade efficiency.
[0031] In some embodiments, if the system flag in the command-line parameters indicates that the device is a dual-system device, then the firmware to be upgraded is selected sequentially from the firmware upgrade package, and the binary file of the firmware to be upgraded is written to memory or a read / write file system partition; each firmware to be upgraded is verified using the digital signature algorithm type and the public key parameter information; if any firmware to be upgraded fails verification, the upgrade process is exited; and if each firmware to be upgraded succeeds in verification, the firmware upgrade process is executed to upgrade the signed firmware. In this way, reliable signature firmware verification is ensured in a dual-system scenario.
[0032] The following will describe, through examples, the application scenarios of the signature firmware upgrade method and device according to embodiments of the present invention.
[0033] Figure 2 This is a flowchart illustrating a signed firmware upgrade method according to an embodiment of the present invention, including the following steps 201 to 230.
[0034] In step 201, the firmware to be upgraded is signed to obtain the signed firmware, and then placed into the firmware upgrade package. Specifically, when signing the bootloader firmware within the firmware to be upgraded, the public key parameter information, digital signature algorithm type, and message digest algorithm type are written to a preset location in the bootloader firmware.
[0035] In step 202, the device securely boots up and loads the bootloader. The bootloader reads the public key parameter information, digital signature algorithm type, and message digest algorithm type contained in the bootloader firmware, and calculates the digital digest corresponding to the public key parameter information using the corresponding message digest algorithm based on the message digest algorithm type.
[0036] In step 203, it is determined whether the digital digest is consistent with the OTP or efuse in the device SoC chip. If yes, step 204 is executed; otherwise, an error is prompted and the upgrade process is exited.
[0037] In step 204, the corresponding message digest algorithm is used to calculate the message digest based on the digital signature algorithm type and public key parameter information as input, and the corresponding message digest is output. Then, the calculated message digest is written to the command line parameter (such as the hash parameter). At the same time, the flag indicating whether the current system is an A / B system is also written to the command line parameter (such as androidboot.slot_suffix). The digital signature algorithm type, public key parameter information, and whether the device is circuit breaker flag are written to the first position of the boot communication partition.
[0038] In step 205, the calculated message digest and the message digest algorithm type are encrypted using a preset symmetric encryption algorithm and key embedded in the bootloader firmware, and the encrypted data is written to the second location of the boot communication partition.
[0039] In step 206, the bootloader verifies the boot firmware (such as boot) in the storage medium to be booted. If the verification is successful, the boot firmware is booted.
[0040] In step 207, when the device detects that a new version of firmware needs to be upgraded, it reads the data in the first position of the boot communication partition to obtain the corresponding digital signature algorithm type, public key parameter information and whether the device is a circuit breaker flag, and reads the flag of whether the current system is an A / B system from the command line parameters.
[0041] Specifically, if the current system is an A / B system and the device has a fuse, proceed to step 208. If the current system is an A / B system and the device has not a fuse, initiate the normal A / B system streaming upgrade process, downloading firmware and upgrading simultaneously. If the current system is not an A / B system and the device has a fuse, proceed to step 209. If the current system is not an A / B system and the device has not a fuse, proceed to step 218.
[0042] In step 208, obtain the complete firmware upgrade package and check its legality.
[0043] In step 209, the message digest in the command line parameters is read, the encrypted data in the second location of the boot communication partition is read, and the read encrypted data is decrypted using a preset symmetric encryption algorithm and key to obtain the decrypted message digest and message digest algorithm type.
[0044] In step 210, it is determined whether the decrypted message digest is consistent with the message digest read from the command line parameters. If yes, step 211 is executed; otherwise, an error message is displayed and the upgrade process is exited.
[0045] In step 211, the digital signature algorithm type and public key parameter information read from the first position of the boot communication partition are used as input, and the corresponding verification message digest is calculated using the above-mentioned decrypted message digest algorithm type.
[0046] In step 212, it is determined whether the verification message digest is consistent with the message digest read in the command line parameters. If yes, step 213 is executed; otherwise, an error message is displayed and the upgrade process is exited.
[0047] In step 213, determine whether the current system is an A / B system. If yes, proceed to step 214; otherwise, proceed to step 216.
[0048] In step 214, the signed firmware to be upgraded is extracted sequentially from the firmware upgrade package, and its corresponding binary file is written into memory or a read / write file system partition. The obtained digital signature algorithm type and public key parameter information are used to verify the firmware to be upgraded, and the verification result is obtained.
[0049] In step 215, it is determined whether the verification result is that all signed firmware to be upgraded in the firmware upgrade package has passed the verification. If so, the firmware upgrade process is executed to complete the device firmware upgrade. If not, an error is prompted and the upgrade process is exited.
[0050] In step 216, a signed firmware to be upgraded is randomly selected from the firmware upgrade package as the firmware to be verified, and the binary file corresponding to the firmware to be verified is written into memory or a read / write file system partition. The firmware to be verified is verified using the obtained digital signature algorithm type and public key parameter information to obtain the verification result.
[0051] In step 217, it is determined whether the verification result is successful. If yes, step 218 is executed; otherwise, an error is prompted and the upgrade process is exited.
[0052] In step 218, the firmware upgrade is initiated, and the device is guided into firmware upgrade mode.
[0053] In step 219, the device securely boots up and loads the bootloader. The bootloader reads the public key parameter information, digital signature algorithm type, and message digest algorithm type contained in the bootloader firmware, and calculates the digital digest corresponding to the public key parameter information using the corresponding message digest algorithm based on the message digest algorithm type.
[0054] In step 220, it is determined whether the digital digest is consistent with the OTP or efuse in the device SoC chip. If yes, step 221 is executed; otherwise, an error is prompted and the upgrade process is exited.
[0055] In step 221, the corresponding message digest algorithm is used to calculate the message digest based on the digital signature algorithm type and public key parameter information as input, and the corresponding message digest is output. Then, the calculated message digest is written to the command line parameter, and the flag indicating whether the current system is an A / B system is also written to the command line parameter. The digital signature algorithm type, public key parameter information and device circuit breaker flag are written to the first position of the boot communication partition.
[0056] In step 222, the calculated message digest and the message digest algorithm type are encrypted using a symmetric encryption algorithm and key preset in the bootloader firmware, and the encrypted data is written to the second location of the boot communication partition.
[0057] In step 223, the bootloader is started to verify the upgrade mode firmware (such as recovery) in the storage medium to be booted. After the verification is successful, the upgrade mode firmware is booted.
[0058] In step 224, the message digest in the command line parameters is read, the encrypted data in the second location of the boot communication partition is read, and the read encrypted data is decrypted using a preset symmetric encryption algorithm and key to obtain the corresponding message digest and message digest algorithm type.
[0059] In step 225, it is determined whether the decrypted message digest is consistent with the message digest read in the command line parameters. If yes, step 226 is executed; otherwise, an error message is displayed and the upgrade process is exited.
[0060] In step 226, the digital signature algorithm type and public key parameter information read from the second preset location of the boot communication partition are used as input, and the corresponding verification message digest is calculated using the above-mentioned decrypted message digest algorithm type.
[0061] In step 227, it is determined whether the verification message digest is consistent with the message digest read in the command line parameters. If yes, step 228 is executed; otherwise, an error is prompted and the upgrade process is exited.
[0062] In step 228, the signed firmware to be upgraded is extracted sequentially from the firmware upgrade package, and its corresponding binary file is written into memory or a read / write file system partition. The obtained digital signature algorithm type and public key parameter information are used to verify the firmware to be upgraded, and the verification result is obtained.
[0063] In step 229, determine whether the verification result is that all signed firmware to be upgraded in the firmware upgrade package has passed the verification. If yes, execute the firmware upgrade process to complete the device firmware upgrade. If no, execute step 230.
[0064] In step 230, it is determined whether the device has blown. If so, an error message is displayed and the upgrade process is exited. If not, the firmware upgrade process is executed to complete the device firmware upgrade.
[0065] Since non-A / B systems require a reboot to enter upgrade mode, a random firmware is selected for signature verification before entering upgrade mode. If the verification passes, all signed firmware is verified in upgrade mode. If the verification fails, the upgrade process exits without rebooting, improving the efficiency of signed firmware upgrades. If the random verification passes, a full verification is performed after entering upgrade mode. A / B systems, on the other hand, do not require a reboot to enter upgrade mode. They upgrade from system A to system B when currently running system A, and vice versa. Therefore, a random verification process is unnecessary; all firmware is verified directly, resulting in higher efficiency.
[0066] According to another aspect of the invention, Figure 3 This is a schematic diagram illustrating an upgrade device 300 for signed firmware according to an embodiment of the present invention. (Refer to...) Figure 3 The electronic device 300 includes a memory 302, a processor 304, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the various steps of the signature firmware upgrade method as described above.
[0067] According to another aspect of the present invention, a computer-readable medium is provided. The computer-readable medium stores a computer program that is executed by a processor to implement the signature firmware upgrade method as described above.
[0068] In summary, the firmware upgrade method, electronic device, and storage medium provided by this invention obtain public key parameter information, digital signature algorithm type, and message digest algorithm type from the bootloader firmware in the signed firmware to be upgraded; calculate a message digest corresponding to the digital signature algorithm type and the public key parameter information based on the message digest algorithm type; write the message digest and system flag into command line parameters; and write the public key parameter information, the digital signature algorithm type, and circuit breaker flag into a first position of the boot communication partition; encrypt the message digest and message digest algorithm type, and write the encrypted message digest and message digest algorithm type into a second position of the boot communication partition; determine whether verification is required based on the system flag and circuit breaker flag; if so, perform verification based on the command line parameters and the boot communication partition. The signed firmware to be upgraded is verified; and if the verification result is successful, the signed firmware to be upgraded is upgraded. This does not rely on device trees and related technical facilities. Before the firmware upgrade, the signed firmware to be upgraded is verified, and the key used is double-verified to ensure the legality of the public key parameter information. The firmware is only upgraded after ensuring that the firmware signature is correct, which avoids upgrading unsigned firmware or firmware signed with an incorrect key. It also supports upgrades for A / B systems and non-A / B systems. For non-A / B systems, before entering the upgrade mode, a firmware is randomly selected for signature verification. After the verification is successful, the upgrade mode is entered to verify all signed firmware. If the verification fails, there is no need to enter the upgrade mode again, which improves the upgrade efficiency of signed firmware and thus improves the reliability of signed firmware upgrades.
[0069] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A method for upgrading signed firmware, characterized in that, include: Obtain public key parameter information, digital signature algorithm type, and message digest algorithm type from the bootloader firmware in the signed firmware to be upgraded, and calculate the message digest of the digital signature algorithm type and the public key parameter information based on the message digest algorithm type; Write the message digest and system tag into the command line parameters, and write the public key parameter information, the digital signature algorithm type and the circuit breaker tag into the first position of the boot communication partition; The message digest and the message digest algorithm type are encrypted, and the encrypted message digest and message digest algorithm type are written into the second location of the boot communication partition; Determine whether verification is required based on the system flag and the circuit breaker flag; If it is determined that verification is required, the signed firmware to be upgraded is verified based on the command line parameters and the boot communication partition; as well as If the verification result is successful, then the signed firmware to be upgraded will be upgraded. The encryption of the message digest and the message digest algorithm type includes: encrypting the message digest and the message digest algorithm type using a preset symmetric encryption algorithm and key in the bootloader firmware. The verification of the signed firmware to be upgraded based on the command-line parameters and the boot communication partition includes: decrypting the encrypted message digest and message digest algorithm type read from the second position of the boot communication partition using a symmetric encryption algorithm and a key to obtain the decrypted message digest and message digest algorithm type; determining whether the decrypted message digest is consistent with the message digest read from the command-line parameters; if they are inconsistent, the upgrade process is exited and the verification result is determined to be a failure; if they are consistent, the digital signature algorithm type and public key parameter information read from the first position of the boot communication partition are used as input, and the corresponding verification message digest is calculated using the decrypted message digest algorithm type; determining whether the verification message digest is consistent with the message digest read from the command-line parameters; if they are inconsistent, the upgrade process is exited and the verification result is determined to be a failure; and if they are consistent, the verification result is determined to be a success.
2. The method according to claim 1, characterized in that, Verification of the signed firmware to be upgraded based on the command-line parameters and the boot communication partition includes: The signed firmware to be upgraded is verified based on the digital signature algorithm type and public key parameter information in the first position of the boot communication partition, the message digest in the command line parameters, and the encrypted message digest and message digest algorithm type in the second position of the boot communication partition.
3. The method according to claim 2, characterized in that, Verification of the signed firmware to be upgraded based on the command-line parameters and the boot communication partition includes: Verification is performed based on the encrypted message digest and the message digest in the command-line parameters; and The verification is performed based on the digital signature algorithm type, the public key parameter information, and the encrypted message digest algorithm type, and the message digest in the command line parameters.
4. The method according to claim 1, characterized in that, Also includes: Sign the firmware to be upgraded to obtain the signed firmware to be upgraded. Write the public key parameter information, the digital signature algorithm type, and the message digest algorithm type into the preset location of the bootloader firmware in the signed firmware to be upgraded; as well as The signed firmware to be upgraded is stored in the firmware upgrade package.
5. The method according to claim 1, characterized in that, The message digest calculated based on the message digest algorithm type, the digital signature algorithm type, and the public key parameter information includes: Calculate the digital digest of the public key parameter information and compare the digital digest with a preset digital digest; If the comparison results in a match, then the digital signature algorithm type and the public key parameter information are used as input to calculate the message digest based on the message digest algorithm type; and If the comparison results are inconsistent, the upgrade process will be terminated.
6. The method according to claim 1, characterized in that, Determining whether verification is required based on the system flag and the circuit breaker flag includes: Determine whether the system flag indicates that the device is a single system; If so, determine whether the fuse mark indicates that the device has blown; If the device indicates a blown fuse, then verification is required; and If the device is not found to be faulty, then it is determined that no verification is required, and the method also includes directly upgrading the signed firmware to be upgraded.
7. The method according to claim 1, characterized in that, Determining whether verification is required based on the system flag and the circuit breaker flag includes: Determine whether the system flag indicates that the device is a dual-system device; If so, determine whether the fuse mark indicates that the device has blown; If the device indicates a blown fuse, then verification is required; and If the device is not found to be faulty, then it is determined that no verification is required, and the method also includes directly upgrading the signed firmware to be upgraded.
8. The method according to claim 4, characterized in that, Upgrading the signed firmware to be upgraded includes: If the system flag in the command line parameters indicates that the device is a single system, then a firmware to be verified is randomly selected from the firmware upgrade package, and the binary file of the firmware to be verified is written into memory or a readable and writable file system partition. The firmware to be verified is verified using the digital signature algorithm type and the public key parameter information; If verification fails, the upgrade process will be terminated; and If the verification is successful, the signed firmware to be upgraded will be upgraded.
9. The method according to claim 8, characterized in that, Upgrading the signed firmware to be upgraded includes: If the verification is successful, the device will be guided into firmware upgrade mode; Select the firmware to be upgraded sequentially from the firmware upgrade package, and write the binary file of the firmware to be upgraded into memory or a read / write file system partition; Each firmware to be upgraded is verified using the digital signature algorithm type and the public key parameter information. If any firmware update fails verification, and if the fuse flag indicates that the device is blown, then the upgrade process is terminated; and If each firmware to be upgraded is successfully verified, the firmware upgrade process is executed to upgrade the signed firmware.
10. The method according to claim 4, characterized in that, Upgrading the signed firmware to be upgraded also includes: If the system flag in the command line parameters indicates that the device is a dual system, then the firmware to be upgraded is selected sequentially from the firmware upgrade package, and the binary file of the firmware to be upgraded is written to memory or a read / write file system partition. Each firmware to be upgraded is verified using the digital signature algorithm type and the public key parameter information. If any firmware to be upgraded fails verification, the upgrade process will exit; and If each firmware to be upgraded is successfully verified, the firmware upgrade process is executed to upgrade the signed firmware.
11. An electronic device, characterized in that, include: Memory, configured to store computer programs; as well as A processor is configured to execute the computer program to perform the method according to any one of claims 1 to 10.
12. A computer-readable medium having a computer program stored thereon, characterized in that, The computer program is executed by a processor to implement the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Signature firmware upgrading method and device and computer readable medium
CN114547620A