Security firmware upgrading method and device, chip and electronic equipment
By obtaining and verifying the secure firmware upgrade data in the chip, using keys and signatures for decryption and calculation, the data security during the secure firmware upgrade process is ensured, the problem of insufficient secure firmware upgrade services in the existing technology is solved, and the data security is realized. High security and verification efficiency.
Patent Information
- Application Number
- CN202410767687.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-10-15
AI Technical Summary
The security firmware in existing chips lacks upgrade services after being programmed during manufacturing, making it difficult to improve data security. The upgrade method of ordinary firmware is not conducive to enhancing the data security of security firmware.
By obtaining secure firmware upgrade data, including ciphertext upgrade data and signatures, using the key to verify and decrypt it, and verifying the plaintext upgrade data after calculation, ensure secure firmware upgrade when the flash program is started, and utilize built-in security The firmware flashing program performs flashing to ensure that the data is not tampered with during transmission.
Improved data security of secure firmware to prevent tampering, and enhanced data verification and storage security during the upgrade process.
Smart Images

Figure CN118784239A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of integrated circuit technology, and in particular to a secure firmware upgrade method, device, chip and electronic device. Background Art
[0002] At present, the HSM (hardware security module) in the chip is generally burned with security firmware, which can be used for application scenarios such as encryption and decryption or signature verification. The above chip can be, for example, an MCU (Microcontroller Unit), which can be applied to automobile ECU (Electronic Control Unit) or other controllers with information security requirements. In the background technology, the security firmware is generally burned when the controller containing the chip is manufactured, and there is no configuration upgrade service for it. The upgrade method of ordinary firmware in the background technology is not conducive to improving the data security of the security firmware. Summary of the invention
[0003] In view of the above problems, the embodiments of the present application provide a secure firmware upgrade method, device, chip and electronic device to solve the above technical problems that are not conducive to improving the data security of secure firmware.
[0004] In a first aspect, an embodiment of the present application provides a secure firmware upgrade method, comprising:
[0005] Acquire secure firmware upgrade data, wherein the secure firmware upgrade data includes first ciphertext upgrade data and a first signature generated according to the first ciphertext upgrade data;
[0006] Verifying the signature of the secure firmware upgrade data according to the first key and the first signature;
[0007] When the security firmware upgrade data passes the signature verification, the first ciphertext upgrade data is decrypted according to the second key to obtain the corresponding plaintext upgrade data, and the plaintext upgrade data is operated according to the first preset algorithm to obtain the first operation data;
[0008] When the secure firmware flashing program is started, the plaintext upgrade data is verified according to the first operation data, so that the secure firmware flashing program performs secure firmware upgrade according to the plaintext upgrade data when the plaintext upgrade data is verified.
[0009] In a second aspect, an embodiment of the present application provides a secure firmware upgrade device, including a secure firmware running unit and a secure firmware flashing unit;
[0010] The secure firmware running unit is used to obtain secure firmware upgrade data, wherein the secure firmware upgrade data includes first ciphertext upgrade data and a first signature generated according to the first ciphertext upgrade data; the secure firmware upgrade data is verified according to the first key and the first signature; when the secure firmware upgrade data passes the signature verification, the first ciphertext upgrade data is decrypted according to the second key to obtain corresponding plaintext upgrade data, and the plaintext upgrade data is operated according to the first preset algorithm to obtain first operation data;
[0011] The secure firmware flashing unit is used to start the secure firmware flashing program;
[0012] The secure firmware running unit is further configured to verify the plaintext upgrade data according to the first operation data when the secure firmware flashing program is started, and send the verification result to the secure firmware flashing unit;
[0013] The secure firmware flashing unit is also used to execute the secure firmware flashing program according to the plaintext upgrade data to perform secure firmware upgrade when the plaintext upgrade data is verified.
[0014] In a third aspect, an embodiment of the present application provides a chip, wherein the chip includes the above-mentioned secure firmware upgrade device or the chip is used for the above-mentioned secure firmware upgrade device.
[0015] In a fourth aspect, an embodiment of the present application provides an electronic device, wherein the electronic device includes the above-mentioned chip.
[0016] The secure firmware upgrade method, device, chip and electronic device provided in the embodiments of the present application obtain secure firmware upgrade data; verify the secure firmware upgrade data according to the first key and the first signature; when the secure firmware upgrade data passes the verification, the first ciphertext upgrade data is decrypted according to the second key to obtain corresponding plaintext upgrade data, and the plaintext upgrade data is operated according to the first preset algorithm to obtain first operation data; when the secure firmware flashing program is started, the plaintext upgrade data is verified according to the first operation data, so that the secure firmware flashing program can be executed according to the plaintext upgrade data when the plaintext upgrade data verification passes. The secure firmware is upgraded with the level data; in the above manner, the secure firmware is flashed by the built-in secure firmware flashing program, which is burned during manufacturing and is not easily tampered with, thereby improving data security; and, before the secure firmware flashing program is started, the secure firmware upgrade data is verified, and the secure firmware upgrade data is decrypted after the verification; when the secure firmware flashing program is started, the decrypted secure firmware upgrade data is verified, and after the verification is passed, the secure firmware flashing program is flashed according to the decrypted secure firmware upgrade data, and the secure firmware upgrade data can be identified if it is tampered with during transmission and after the verification, thereby improving data security.
[0017] These and other aspects of the present application will become more clearly understood in the description of the following embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 A flow chart of a secure firmware upgrade method provided in an embodiment of the present application is shown.
[0019] Figure 2 A schematic diagram of the structure of a secure firmware upgrade device provided in an embodiment of the present application is shown.
[0020] Figure 3 An example diagram of the data structure in the secure firmware upgrade device provided in an embodiment of the present application is shown.
[0021] Figure 4 A schematic diagram of the structure of a secure firmware upgrade device provided in an embodiment of the present application is shown.
[0022] Figure 5 A schematic diagram of data interaction in a secure firmware upgrade device provided in an embodiment of the present application is shown.
[0023] Figure 6 An application scenario diagram of the secure firmware upgrade device provided in an embodiment of the present application is shown.
[0024] Figure 7 Another application scenario diagram of the secure firmware upgrade device provided in an embodiment of the present application is shown.
[0025] Figure 8 A schematic diagram of the structure of a chip provided in an embodiment of the present application is shown.
[0026] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0027] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application, and cannot be understood as limiting the present application.
[0028] In order to enable those skilled in the art to better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application.
[0029] In the embodiments of the present application, it should be noted that, in this article, relational terms such as first and second, etc. are merely used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations.
[0030] Moreover, the terms "comprises," "comprising," or any other variation thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or apparatus that includes a list of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or apparatus. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.
[0031] In the description of the embodiments of the present application, words such as "example" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "example" or "for example" in the embodiments of the present application is not to be interpreted as being more preferred or having more advantages than another embodiment or design. The use of words such as "example" or "for example" is intended to present relative concepts in a clear manner.
[0032] In addition, the "plurality" in the embodiments of the present application refers to two or more than two. In view of this, in the embodiments of the present application, "plurality" can also be understood as "at least two". "At least one" can be understood as one or more, for example, one, two or more. For example, including at least one means including one, two or more, and there is no limit on which ones are included. For example, including at least one of A, B and C, then A, B, C, A and B, A and C, B and C, or A, B and C can be included.
[0033] It should be noted that, in the embodiments of the present application, "and / or" describes the association relationship of the associated objects, indicating that three relationships may exist. For example, A and / or B may represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / ", unless otherwise specified, generally indicates that the associated objects before and after are in an "or" relationship.
[0034] It should be noted that in the embodiments of the present application, "connection" can be understood as electrical connection, and the connection between two electrical components can be a direct or indirect connection between the two electrical components. For example, the connection between A and B can be either a direct connection between A and B or an indirect connection between A and B through one or more other electrical components.
[0035] An embodiment of the present application provides a secure firmware upgrade method. Figure 1 As shown, the secure firmware upgrade method includes the following steps S11 to S14:
[0036] S11, obtaining secure firmware upgrade data, wherein the secure firmware upgrade data includes first ciphertext upgrade data and a first signature generated according to the first ciphertext upgrade data.
[0037] Among them, the first ciphertext upgrade data is the encrypted secure firmware data to be written, and the first signature can be obtained by signing the first ciphertext upgrade data. Exemplarily, the first ciphertext upgrade data can be encrypted according to the first signature key to obtain the first signature, or the hash value of the first ciphertext upgrade data can be encrypted according to the first signature key to obtain the first signature.
[0038] S12: Verify the signature of the secure firmware upgrade data according to the first key and the first signature.
[0039] Among them, the verification process and the signing process in step S11 are corresponding, the first key and the first signature key can be corresponding, the first signature key is used for encryption, the first key is used for decryption, the first signature is decrypted according to the first key to obtain a decryption result, and the verification result is determined based on whether the decryption result is consistent with the encryption object of the first signature key in the above step. For example, the encryption object can be the first ciphertext upgrade data itself or the hash value of the first ciphertext upgrade data.
[0040] S13, when the security firmware upgrade data passes the signature verification, the first ciphertext upgrade data is decrypted according to the second key to obtain the corresponding plaintext upgrade data, and the plaintext upgrade data is operated according to the first preset algorithm to obtain the first operation data.
[0041] Among them, the first ciphertext upgrade data is obtained by encrypting the secure firmware data to be written according to the second encryption key, the second key and the second encryption key can be the same or corresponding, the second signature key is used for encryption, and the second key is used for decryption. After decryption to obtain the plaintext upgrade data, the plaintext upgrade data is operated to obtain the first operation data.
[0042] Among them, the first preset algorithm can be an encryption algorithm, and the first operation data is obtained by encrypting the plaintext upgrade data. The encryption key can use the second key or other keys. For example, the first preset algorithm is a MAC (Message Authentication Codes) algorithm, and the encryption key (for example, the second key) is used to perform MAC operation on the plaintext upgrade data. The first operation data obtained is a MAC value, and the MAC value can be an HMAC (Hash-based Message Authentication Code) value or a CMAC (Cipher-Based Message Authentication Code) value. The first preset algorithm can also be a non-encryption algorithm. For example, the first preset algorithm can be a hash algorithm, and the first operation data is the hash value of the plaintext upgrade data.
[0043] S14, when the secure firmware flashing program is started, the plaintext upgrade data is verified according to the first operation data, so that the secure firmware flashing program performs secure firmware upgrade according to the plaintext upgrade data when the plaintext upgrade data verification passes.
[0044] Among them, the secure firmware flashing program is used to upgrade the secure firmware, and the secure firmware flashing program is a program burned into the electronic device (such as a chip) when the electronic device is manufactured. The way to upgrade the secure firmware can be to flash the secure firmware data, for example, the plaintext upgrade data can be used as new secure firmware data to replace the old secure firmware data; the way to upgrade the secure firmware can also be to use the plaintext upgrade data to replace part of the data in the old secure firmware data or to add the plaintext upgrade data as supplementary data to the old secure firmware data.
[0045] Among them, before the secure firmware flashing program performs a secure firmware upgrade, it is necessary to verify the plaintext upgrade data. After the verification is passed, the secure firmware flashing program will perform the upgrade operation. If the plaintext upgrade data is tampered with, it will not pass the above verification and the secure firmware upgrade cannot be performed.
[0046] The execution subject of the secure firmware upgrade method of this embodiment may be an electronic device with secure firmware burned in it. The electronic device may be a chip or the electronic device may include a chip, and the chip is, for example, an MCU.
[0047] In this embodiment, the secure firmware flashing is performed by a built-in secure firmware flashing program. The secure firmware flashing program is burned during manufacturing and is not easily tampered with, which is beneficial to improving data security. In addition, before the secure firmware flashing program is started, the secure firmware upgrade data is verified and the secure firmware upgrade data is decrypted after the verification. When the secure firmware flashing program is started, the decrypted secure firmware upgrade data is verified and after the verification, the secure firmware flashing program is flashed according to the decrypted secure firmware upgrade data. The secure firmware upgrade data can be identified if it has been tampered with during transmission and after the verification, which is beneficial to improving data security.
[0048] As an implementation method, the secure firmware upgrade data also includes user identification information (UID), and the first signature is generated based on the user identification information and the first ciphertext upgrade data. The first signature can be obtained by signing the user identification information and the first ciphertext upgrade data. For example, the user identification information and the first ciphertext upgrade data can be encrypted according to the first signature key to obtain the first signature, or the hash value of the user identification information and the first ciphertext upgrade data can be encrypted according to the first signature key to obtain the first signature.
[0049] Among them, the user identity information can be used to log in to the secure firmware flashing program. The user identity information is verified during login, and the secure firmware flashing program is started after the verification is passed.
[0050] Before step S14, the following steps are also included:
[0051] S21, verifying the user identity information.
[0052] Among them, at least one authorized identity information may be pre-stored in the secure firmware flashing program, and the user identity information is compared with the at least one authorized identity information. If the user identity information matches one of the authorized identity information, the user identity information verification is successful.
[0053] S22, when the user identity information is verified, the secure firmware flashing program is started.
[0054] Among them, the secure firmware flashing program will be officially started only after the user identity information is verified and the secure firmware flashing program logs in successfully.
[0055] In this embodiment, since the secure firmware flashing program is the only program that can upgrade the secure firmware, identity authentication is performed before it is started, which can further increase data security.
[0056] As an implementation method, the plaintext upgrade data obtained by decryption and the first operation data obtained by operation on the plaintext upgrade data can be stored. After step S13, the following steps are also included:
[0057] S31, storing the plaintext upgrade data in a first data area, and storing the first operation data in a second data area, wherein the data storage security of the first data area is lower than the data storage security of the second data area.
[0058] In this embodiment, the first operation data is stored in an area with higher data storage security to prevent the first operation data from being tampered with and ensure the reliability of subsequent verification of the plaintext upgrade data; the plaintext upgrade data is stored in an area with relatively low data storage security, which is conducive to reducing the space size of the area with higher data storage security and reducing costs.
[0059] In some implementations, in step S14, verifying the plaintext upgrade data according to the first operation data may include the following steps:
[0060] S41, obtaining plaintext upgrade data from the first data area, and performing calculations on the obtained plaintext upgrade data according to a first preset algorithm to obtain second calculation data;
[0061] The calculation method of the second operation data is similar to that of the first operation data, and the details may refer to the description of the first operation data.
[0062] S42, obtaining the first operation data from the second data area, and determining whether the first operation data and the second operation data are consistent, so as to verify the plaintext upgrade data.
[0063] Among them, the first operation data and the second operation data are both obtained by operating the plaintext upgrade data according to the first preset algorithm. If the plaintext upgrade data has not been tampered with in the first data area, the first operation data and the second operation data are consistent; if the plaintext upgrade data has been tampered with in the first data area, the first operation data and the second operation data obtained according to the tampered plaintext upgrade data are inconsistent.
[0064] In this embodiment, the plaintext upgrade data is again operated using the first preset algorithm, and the operation result is compared with the first operation data to verify the plaintext upgrade data, which is beneficial to improving data verification efficiency.
[0065] As an implementation manner, step S12 specifically includes the following steps:
[0066] S51, decrypting the first signature using the first key according to the first encryption algorithm to obtain a first decryption result;
[0067] Among them, the first signature is generated by encryption based on the first signature key and the first encryption algorithm. The first key and the first signature key may correspond to each other. The first signature key is used for encryption and the first key is used for decryption. The first signature is decrypted based on the first key to obtain a first decryption result.
[0068] S52, operating the portion of the secure firmware upgrade data except the first signature according to a second preset algorithm to obtain third operating data;
[0069] In the process of generating the first signature, the second preset algorithm is first used to calculate the part of the security firmware upgrade data except the first signature to obtain an encrypted object, and then the encrypted object is encrypted according to the first encryption algorithm and the first encryption key to obtain the first signature; the part of the security firmware upgrade data except the first signature is, for example, the first ciphertext upgrade data or the user identity information and the first ciphertext upgrade data. If the security firmware upgrade data has not been tampered with during the transmission process, the third operation data is consistent with the encrypted object, and the first decryption result is also consistent with the encrypted object.
[0070] S53, determining whether the first decryption result and the third operation data are consistent, so as to verify the signature of the secure firmware upgrade data;
[0071] Among them, the first decryption result and the third operation data are consistent, and the security firmware upgrade data signature verification passes; the first decryption result and the third operation data are not consistent, and the security firmware upgrade data signature verification fails.
[0072] In this embodiment, the second preset algorithm may be, for example, a hash algorithm, and the first decryption result is compared with the third operation data obtained by the second preset algorithm to verify the signature of the secure firmware upgrade data, which is beneficial to improving data verification efficiency.
[0073] As an implementation method, the secure firmware upgrade data also includes upgrade version information, which is the current version of the first ciphertext upgrade data. The first signature is generated based on the upgrade version information, the user identity information, and the first ciphertext upgrade data. The first signature can be obtained by signing the upgrade version information, the user identity information, and the first ciphertext upgrade data. For example, the first signature can be obtained by encrypting the upgrade version information, the user identity information, and the first ciphertext upgrade data according to the first signature key, or by encrypting the upgrade version information, the user identity information, and the hash value of the first ciphertext upgrade data according to the first signature key.
[0074] As an implementation, the first encryption key and the first key may be a key pair generated according to a first encryption algorithm. Exemplarily, the first encryption key may be a private key prib1, and the first key may be a public key pub1; exemplary, the first encryption algorithm may be an SM2 algorithm.
[0075] As an implementation method, the second key may be a symmetric key, the second encryption key is the same as the second key, and the first ciphertext upgrade data is obtained by encrypting the secure firmware data to be written using the second key according to the symmetric encryption algorithm; when decrypting, the first ciphertext upgrade data is decrypted using the second key according to the symmetric encryption algorithm to obtain plaintext upgrade data, which is the same as the above-mentioned secure firmware data to be written. Exemplarily, the symmetric encryption algorithm may be an SM4 algorithm.
[0076] As an implementation manner, before step S11, the following steps are also included:
[0077] S61, receiving a secure firmware upgrade file, wherein the secure firmware upgrade file includes the secure firmware upgrade data and a second signature generated according to the secure firmware upgrade data;
[0078] Among them, the second signature can be obtained by signing the secure firmware upgrade data. For example, the secure firmware upgrade data can be encrypted according to the third signature key to obtain the second signature, or the hash value of the secure firmware upgrade data can be encrypted according to the third signature key to obtain the second signature.
[0079] S62, verifying the signature of the secure firmware upgrade file according to the third key and the second signature;
[0080] Among them, the verification process and the signing process in step S61 are corresponding, the third key and the third signature key can be corresponding, the third signature key is used for encryption, and the third key is used for decryption. The third signature is decrypted according to the third key to obtain a decryption result, and the verification result is determined based on whether the decryption result is consistent with the encryption object of the third signature key in the above step. For example, the encryption object can be the secure firmware upgrade data itself or the hash value of the secure firmware upgrade data.
[0081] S63: When the security firmware upgrade file passes the signature verification, an upgrade data verification request is sent.
[0082] In this implementation, before the signature of the secure firmware upgrade data is verified, a signature verification is performed based on the second signature, which is beneficial to further improve data security.
[0083] Accordingly, in step S11 , in response to the upgrade data verification request, secure firmware upgrade data is acquired.
[0084] In some implementations, step S62 specifically includes the following steps:
[0085] S71, decrypting the second signature using the third key according to the second encryption algorithm to obtain a second decryption result;
[0086] Among them, the second signature is generated by encryption based on the third signature key and the second encryption algorithm. The third key and the third signature key may correspond to each other. The third signature key is used for encryption and the third key is used for decryption. The second signature is decrypted based on the third key and the second encryption algorithm to obtain a second decryption result.
[0087] S72, calculating the security firmware upgrade data according to the second preset algorithm to obtain fourth calculated data;
[0088] In the process of generating the second signature, the secure firmware upgrade data is first operated using the second preset algorithm to obtain an encrypted object, and then the encrypted object is encrypted according to the second encryption algorithm and the third encryption key to obtain the second signature. If the secure firmware upgrade file has not been tampered with during transmission, the fourth operation data is consistent with the encrypted object, and the second decryption result is also consistent with the encrypted object.
[0089] S73, determining whether the second decryption result is consistent with the fourth operation data, so as to verify the signature of the secure firmware upgrade file;
[0090] Among them, the second decryption result and the fourth operation data are consistent, and the security firmware upgrade file signature verification passes; the second decryption result and the fourth operation data are not consistent, and the security firmware upgrade file signature verification fails.
[0091] In this embodiment, the second preset algorithm may be, for example, a hash algorithm, and the second decryption result is compared with the fourth operation data obtained by the second preset algorithm to verify the signature of the secure firmware upgrade file, which is beneficial to improving data verification efficiency.
[0092] As an implementation, the third encryption key and the third key may be a pair of key pairs generated according to the second encryption algorithm. Exemplarily, the third encryption key may be the private key prib2, and the third key may be the public key pub2; exemplary, the second encryption algorithm may be the SM2 algorithm.
[0093] As an implementation, the secure firmware upgrade file also includes header information, and the second signature is generated based on the header information and the secure firmware upgrade data. The second signature can be obtained by signing the header information and the secure firmware upgrade data. For example, the second signature can be obtained by encrypting the header information and the secure firmware upgrade data according to a third signature key, or by encrypting the hash value of the header information and the secure firmware upgrade data according to the third signature key. For example, the header information can be used to characterize the manufacturer of the electronic device.
[0094] An embodiment of the present application provides a secure firmware upgrade device 100, see Figure 2 As shown, the secure firmware upgrade device 100 includes a secure firmware running unit 11 and a secure firmware flashing unit 12 .
[0095] The secure firmware flashing unit 12 includes a secure firmware flashing program.
[0096] Among them, the secure firmware running unit 11 is used to obtain secure firmware upgrade data, wherein the secure firmware upgrade data includes first ciphertext upgrade data and a first signature generated based on the first ciphertext upgrade data; the secure firmware upgrade data is verified based on the first key and the first signature; when the secure firmware upgrade data passes the verification, the first ciphertext upgrade data is decrypted based on the second key to obtain corresponding plaintext upgrade data, and the plaintext upgrade data is operated based on the first preset algorithm to obtain first operation data.
[0097] The secure firmware flashing unit 12 is used to start a secure firmware flashing program.
[0098] The secure firmware running unit 11 is also used to verify the plaintext upgrade data according to the first operation data when the secure firmware flashing program is started, and send the verification result to the secure firmware flashing unit 12.
[0099] The secure firmware flashing unit 12 is further configured to execute a secure firmware flashing program according to the plain text upgrade data to perform a secure firmware upgrade when the plain text upgrade data is verified.
[0100] In this embodiment, the secure firmware flashing is performed by a built-in secure firmware flashing program. The secure firmware flashing program is burned during manufacturing and is not easily tampered with, which is beneficial to improving data security. In addition, before the secure firmware flashing program is started, the secure firmware upgrade data is verified and the secure firmware upgrade data is decrypted after the verification. When the secure firmware flashing program is started, the decrypted secure firmware upgrade data is verified and after the verification, the secure firmware flashing program is flashed according to the decrypted secure firmware upgrade data. The secure firmware upgrade data can be identified if it has been tampered with during transmission and after the verification, which is beneficial to improving data security.
[0101] As an implementation, see Figure 3 As shown, the secure firmware upgrade data also includes user identity information, and the first signature is generated based on the user identity information and the first ciphertext upgrade data; the secure firmware flashing unit 12 is also used to verify the user identity information; when the user identity information verification is passed, the secure firmware flashing program is started.
[0102] As an implementation, see Figure 4 and Figure 5 As shown, the secure firmware upgrade device also includes a startup management unit 13.
[0103] In this embodiment, the secure firmware running unit 11 is also used to send a first verification result to the boot management unit 13 when the secure firmware upgrade data is verified. The boot management unit 13 is used to store the plaintext upgrade data in the first data area in response to the received first verification result, and send a secure firmware upgrade request to the secure firmware flashing unit 12. The secure firmware running unit 11 is also used to store the first operation data in the second data area, wherein the data storage security of the first data area is lower than the data storage security of the second data area. The secure firmware flashing unit 12 is also used to start the secure firmware flashing program in response to the received secure firmware upgrade request. In some embodiments, the secure firmware flashing unit 12 is also used to send a plaintext upgrade data verification request to the secure firmware running unit 11 while starting the secure firmware flashing program.
[0104] In some embodiments, the security firmware running unit 11 is also used to obtain plaintext upgrade data from the first data area, perform operations on the obtained plaintext upgrade data according to a first preset algorithm to obtain second operation data; obtain the first operation data from the second data area, and determine whether the first operation data and the second operation data are consistent, so as to verify the plaintext upgrade data.
[0105] In some embodiments, see Figure 3 and Figure 5As shown, the boot management unit 13 is also used to receive a secure firmware upgrade file, wherein the secure firmware upgrade file includes secure firmware upgrade data and a second signature generated according to the secure firmware upgrade data; the secure firmware upgrade file is verified according to the third key and the second signature; when the secure firmware upgrade file passes the signature verification, the secure firmware upgrade data is stored in the first data area, and an upgrade data verification request is sent to the secure firmware running unit 11. The secure firmware running unit 11 is also used to obtain the secure firmware upgrade data from the first data area in response to the received upgrade data verification request.
[0106] In some embodiments, please refer to Figure 5 As shown, the startup management unit 13 is also used to decrypt the second signature using a third key according to a second encryption algorithm to obtain a second decryption result; perform operations on the security firmware upgrade data according to a second preset algorithm to obtain fourth operation data; and determine whether the second decryption result and the fourth operation data are consistent to verify the signature of the security firmware upgrade file.
[0107] As an implementation mode, the secure firmware running unit 11 is also used to decrypt the first signature using the first key according to the first encryption algorithm to obtain a first decryption result; perform operations on the portion of the secure firmware upgrade data except the first signature according to the second preset algorithm to obtain third operation data; and determine whether the first decryption result and the third operation data are consistent to verify the signature of the secure firmware upgrade data.
[0108] In some embodiments, please refer to Figure 3 As shown, the secure firmware upgrade data also includes upgrade version information, and the first signature is generated based on the upgrade version information, user identity information, and the first ciphertext upgrade data. The first signature can be obtained by signing the upgrade version information, user identity information, and the first ciphertext upgrade data. For example, the upgrade version information, user identity information, and the first ciphertext upgrade data can be encrypted according to the first signature key to obtain the first signature, or the upgrade version information, user identity information, and the hash value of the first ciphertext upgrade data can be encrypted according to the first signature key to obtain the first signature.
[0109] In some embodiments, please refer to Figure 3 As shown, the secure firmware upgrade file also includes header information, and the second signature is generated based on the header information and the secure firmware upgrade data. The second signature can be obtained by signing the header information and the secure firmware upgrade data. For example, the second signature can be obtained by encrypting the header information and the secure firmware upgrade data according to a third signature key, or by encrypting the hash value of the header information and the secure firmware upgrade data according to the third signature key. For example, the header information can be used to characterize the manufacturer of the electronic device.
[0110] In some embodiments, please refer to Figure 5 As shown, the secure firmware flash writing unit 12 is also used to send an upgrade success result to the startup management unit 13 when the secure firmware is successfully upgraded. The startup management unit 13 receives the upgrade success result and deletes the plaintext upgrade data stored in the first data area.
[0111] The secure firmware upgrade device 100 of this embodiment can be used to implement the above secure firmware upgrade method, and the description of the embodiment and various implementation methods of the above secure firmware upgrade method can be used as a part of this embodiment.
[0112] The secure firmware upgrade device 100 provided in this application can be applied to Figure 6 In the MCU shown, the MCU includes an HSM (hardware security module), in which security firmware is burned. The HSM includes a second data area, and the security firmware running unit 11 and the security firmware flashing unit 12 in the security firmware upgrade device 100 are respectively located in the second data area.
[0113] As an implementation manner, the MCU further includes a first data area, and the data storage security of the first data area is lower than the data storage security of the second data area. The startup management unit 13 in the secure firmware upgrade device 100 is located in the first data area.
[0114] The secure firmware upgrade device 100 provided in this application can be applied to Figure 7 In the ECU shown, the ECU includes an MCU, the MCU includes an HSM (hardware security module), the HSM is programmed with security firmware, the HSM includes a second data area, and the security firmware running unit 11 and the security firmware flashing unit 12 in the security firmware upgrade device 100 are respectively located in the second data area. The security firmware running unit 11 can also be used to run the security firmware.
[0115] As an implementation manner, the MCU further includes a first data area, and the data storage security of the first data area is lower than the data storage security of the second data area. The startup management unit 13 in the secure firmware upgrade device 100 is located in the first data area.
[0116] In some implementations, the MCU further includes an application unit, a basic software (BSW) unit, and a runtime environment (RTE) respectively located in the first data area, wherein the boot management unit 13 may be a boot manager (Boot Manager).
[0117] In some embodiments, the ECU is connected to the diagnostic interface of the vehicle through the CAN bus, and the external device can be connected to the startup management unit 13 in the ECU through the diagnostic interface, and the external device can send a message to the startup management unit 13 through the diagnostic interface. Figure 3 The secure firmware upgrade file shown in the figure is used to enable Figure 5 The data interaction shown executes the secure firmware upgrade process. Exemplarily, the external device may be a diagnostic instrument.
[0118] In some embodiments, Figure 3 The header information shown may be OEM (Original Equipment Manufacturer) identification information, and the second signature may be an OEM signature.
[0119] An embodiment of the present application provides a chip 200, see Figure 8 As shown, the chip 200 includes the above-mentioned secure firmware upgrade device 100. A chip (Integrated Circuit, IC) is also called a chip, and the chip can be, but is not limited to, a SOC (System on Chip) chip or a SIP (system in package) chip. Exemplarily, the chip can be an MCU.
[0120] The chip of this embodiment executes secure firmware flashing by a built-in secure firmware flashing program. The secure firmware flashing program is burned during manufacturing and is not easily tampered with, which is beneficial to improving data security. In addition, before the secure firmware flashing program is started, the secure firmware upgrade data is signed and, after the signature verification is passed, the secure firmware upgrade data is decrypted. When the secure firmware flashing program is started, the decrypted secure firmware upgrade data is verified. After the verification is passed, the secure firmware flashing program is flashed according to the decrypted secure firmware upgrade data. The secure firmware upgrade data can be identified if it has been tampered with during transmission and after the signature verification, which is beneficial to improving data security.
[0121] An embodiment of the present application provides an electronic device 300, see Fig. 9As shown, the electronic device 300 includes a device body and a chip 200 as described above, which is arranged in the device body. The electronic device can be, but is not limited to, an ECU, a weight scale, a body fat scale, a nutrition scale, a pulse oximeter, a human body composition analyzer, a display, a USB (Universal Serial Bus) docking station, a car, a smart wearable device, a mobile terminal, and a smart home device. Smart wearable devices include, but are not limited to, smart watches, smart bracelets, and cervical massagers. Mobile terminals include, but are not limited to, smart phones, laptops, tablet computers, and POS (point of sales terminal). Smart home devices include, but are not limited to, smart sockets, smart rice cookers, smart sweepers, and smart lights.
[0122] The electronic device of this embodiment executes secure firmware flashing by a built-in secure firmware flashing program. The secure firmware flashing program is burned during manufacturing and is not easily tampered with, which is beneficial to improving data security. In addition, before the secure firmware flashing program is started, the secure firmware upgrade data is signed and, after the signature verification is passed, the secure firmware upgrade data is decrypted. When the secure firmware flashing program is started, the decrypted secure firmware upgrade data is verified and, after the verification is passed, the secure firmware flashing program is flashed according to the decrypted secure firmware upgrade data. Tampering of the secure firmware upgrade data during transmission and after signature verification can be identified, which is beneficial to improving data security.
[0123] The above is only an implementation method of the present application. It should be pointed out that a person skilled in the art can make improvements without departing from the inventive concept of the present application, but these improvements are within the scope of protection of the present application.
Claims
1. A secure firmware upgrade method, characterized in that: include: Acquire secure firmware upgrade data, wherein the secure firmware upgrade data includes first ciphertext upgrade data and a first signature generated according to the first ciphertext upgrade data; Verifying the signature of the secure firmware upgrade data according to the first key and the first signature; When the security firmware upgrade data passes the signature verification, the first ciphertext upgrade data is decrypted according to the second key to obtain the corresponding plaintext upgrade data, and the plaintext upgrade data is operated according to the first preset algorithm to obtain the first operation data; When the secure firmware flashing program is started, the plaintext upgrade data is verified according to the first operation data, so that the secure firmware flashing program performs secure firmware upgrade according to the plaintext upgrade data when the plaintext upgrade data is verified.
2. The secure firmware upgrade method according to claim 1, characterized in that: The secure firmware upgrade data further includes user identity information, and the first signature is generated according to the user identity information and the first ciphertext upgrade data; When the secure firmware flashing program is started, before verifying the plaintext upgrade data according to the first operation data, the method further includes: Verifying the user identity information; When the user identity information is verified, the secure firmware flashing program is started.
3. The secure firmware upgrade method according to claim 1, characterized in that: When the secure firmware flashing program is started, before verifying the plaintext upgrade data according to the first operation data, the method further includes: The plaintext upgrade data is stored in a first data area, and the first operation data is stored in a second data area, wherein the data storage security of the first data area is lower than the data storage security of the second data area.
4. The secure firmware upgrade method according to claim 3, characterized in that: The verifying the plaintext upgrade data according to the first operation data includes: Acquire the plaintext upgrade data from the first data area, and perform calculations on the acquired plaintext upgrade data according to the first preset algorithm to obtain second calculation data; The first operation data is obtained from the second data area, and it is determined whether the first operation data is consistent with the second operation data, so as to verify the plaintext upgrade data.
5. The secure firmware upgrade method according to claim 1, characterized in that: The verifying the signature of the secure firmware upgrade data according to the first key and the first signature includes: Decrypting the first signature using the first key according to a first encryption algorithm to obtain a first decryption result; Performing operation on the portion of the secure firmware upgrade data except the first signature according to a second preset algorithm to obtain third operation data; Determine whether the first decryption result is consistent with the third operation data to verify the signature of the secure firmware upgrade data.
6. The secure firmware upgrade method according to claim 1, characterized in that: Before obtaining the secure firmware upgrade data, the method further includes: Receiving a secure firmware upgrade file, wherein the secure firmware upgrade file includes the secure firmware upgrade data and a second signature generated according to the secure firmware upgrade data; Verifying the signature of the secure firmware upgrade file according to the third key and the second signature; When the security firmware upgrade file passes the signature verification, an upgrade data verification request is sent.
7. The secure firmware upgrade method according to claim 6, characterized in that: The verifying the signature of the secure firmware upgrade file according to the third key and the second signature includes: Decrypting the second signature using the third key according to a second encryption algorithm to obtain a second decryption result; Calculate the security firmware upgrade data according to a second preset algorithm to obtain fourth calculation data; Determine whether the second decryption result is consistent with the fourth operation data to verify the signature of the secure firmware upgrade file.
8. A secure firmware upgrade device, characterized in that: It includes a secure firmware running unit and a secure firmware flashing unit; The secure firmware running unit is used to obtain secure firmware upgrade data, wherein the secure firmware upgrade data includes first ciphertext upgrade data and a first signature generated according to the first ciphertext upgrade data; the secure firmware upgrade data is verified according to the first key and the first signature; when the secure firmware upgrade data passes the signature verification, the first ciphertext upgrade data is decrypted according to the second key to obtain corresponding plaintext upgrade data, and the plaintext upgrade data is operated according to the first preset algorithm to obtain first operation data; The secure firmware flashing unit is used to start the secure firmware flashing program; The secure firmware running unit is further configured to verify the plaintext upgrade data according to the first operation data when the secure firmware flashing program is started, and send the verification result to the secure firmware flashing unit; The secure firmware flashing unit is also used to execute the secure firmware flashing program according to the plaintext upgrade data to perform secure firmware upgrade when the plaintext upgrade data is verified.
9. The secure firmware upgrade device according to claim 8, characterized in that: The secure firmware upgrade data further includes user identity information, and the first signature is generated according to the user identity information and the first ciphertext upgrade data; The secure firmware flashing unit is also used to verify the user identity information; when the user identity information is verified, the secure firmware flashing program is started.
10. The secure firmware upgrade device according to claim 8, characterized in that: The secure firmware upgrade device also includes a startup management unit; The secure firmware running unit is further configured to send a first verification result to the startup management unit when the secure firmware upgrade data passes the signature verification; The boot management unit is used to store the plaintext upgrade data in a first data area in response to the received first verification result, and send a secure firmware upgrade request to the secure firmware flashing unit; The security firmware execution unit is further configured to store the first operation data in a second data area, wherein the data storage security of the first data area is lower than the data storage security of the second data area; The secure firmware flashing unit is further configured to start the secure firmware flashing program in response to the received secure firmware upgrade request.
11. The secure firmware upgrade device according to claim 10, characterized in that: The secure firmware running unit is further used to obtain the plaintext upgrade data from the first data area, and to perform operation on the obtained plaintext upgrade data according to the first preset algorithm to obtain second operation data; The first operation data is obtained from the second data area, and it is determined whether the first operation data is consistent with the second operation data, so as to verify the plaintext upgrade data.
12. The secure firmware upgrade device according to claim 10, characterized in that: The boot management unit is further configured to receive a secure firmware upgrade file, wherein the secure firmware upgrade file includes the secure firmware upgrade data and a second signature generated according to the secure firmware upgrade data; verify the secure firmware upgrade file according to the third key and the second signature; when the secure firmware upgrade file passes the verification, store the secure firmware upgrade data in the first data area, and send an upgrade data verification request to the secure firmware running unit; The secure firmware running unit is further configured to obtain the secure firmware upgrade data from the first data area in response to the received upgrade data verification request.
13. The secure firmware upgrade device according to claim 12, characterized in that: The startup management unit is further used to decrypt the second signature using the third key according to the second encryption algorithm to obtain a second decryption result; and to calculate the security firmware upgrade data according to the second preset algorithm to obtain fourth calculation data; Determine whether the second decryption result is consistent with the fourth operation data to verify the signature of the secure firmware upgrade file.
14. The secure firmware upgrade device according to claim 8, characterized in that: The secure firmware running unit is also used to decrypt the first signature using the first key according to a first encryption algorithm to obtain a first decryption result; perform operations on the portion of the secure firmware upgrade data except the first signature according to a second preset algorithm to obtain third operation data; and determine whether the first decryption result and the third operation data are consistent to verify the signature of the secure firmware upgrade data.
15. A chip, characterized in that: The chip includes the secure firmware upgrade device as described in any one of claims 8 to 14, or the chip is used to implement the secure firmware upgrade device as described in any one of claims 1 to 7.
16. An electronic device, characterized in that: Comprising the chip as claimed in claim 15.
