Firmware upgrade package verification method and device, terminal and storage medium
By verifying the firmware upgrade package in the trusted execution environment of the terminal, using the dual verification mechanism of the root certificate and the derived certificate, the security problem of the firmware upgrade package being tampered with during the transmission process is solved, and the security of the terminal is realized and stability guarantee.
Patent Information
- Application Number
- CN202411353592.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-26
- Publication Date
- 2024-12-13
AI Technical Summary
During the terminal firmware upgrade process, the firmware upgrade package is easily maliciously intercepted or tampered during transmission, resulting in a terminal security threat, and it is difficult for the existing technology to effectively ensure its security.
By obtaining a firmware upgrade verification package containing a firmware upgrade package and a first encrypted data block encrypted based on the derived certificate, and performing volume comparison and data extraction in a trusted execution environment, using the root certificate, the second verification value, the derived certificate Comprehensive verification with the first encrypted data block to ensure the security of the firmware upgrade package.
It effectively enhances the security of the firmware upgrade package, prevents unauthorized access and data tampering, ensures the confidentiality and accuracy of the verification process, and ensures the reliability and stability of the firmware upgrade.
Smart Images

Figure CN119128887A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and more specifically, to a firmware upgrade package verification method, device, terminal and storage medium in the field of terminal technology. Background Art
[0002] In the scenario of terminal firmware upgrade, the relevant technology is that the terminal initiates a request to the corresponding cloud platform to obtain the firmware upgrade package. Subsequently, the terminal will update the target firmware according to this firmware upgrade package. However, during the process of transmitting the firmware upgrade package from the cloud platform to the terminal, if the firmware upgrade package is maliciously intercepted or a virus file is added to the firmware upgrade package, it may pose a serious threat to the security of the terminal. Therefore, how to ensure the security of the firmware upgrade package has become an urgent problem to be solved. Summary of the invention
[0003] The present application provides a firmware upgrade package verification method, device, terminal and storage medium, which can effectively ensure the security of the firmware upgrade package.
[0004] In a first aspect, a firmware upgrade package verification method is provided, which is applied to a terminal, the terminal includes a trusted execution environment, and the trusted execution environment stores a root certificate. The method includes:
[0005] Obtain a firmware upgrade verification package, wherein the firmware upgrade verification package is composed of a firmware upgrade package and a first encrypted data block, the firmware upgrade package is provided with a derived certificate, and the first encrypted data block is obtained by encrypting a first verification value based on the derived certificate;
[0006] Compare the volume of the firmware upgrade verification package with the available storage space of the trusted execution environment to obtain a comparison result;
[0007] Based on the comparison result, extracting the second verification value, the derived certificate and the first encrypted data block of the firmware upgrade package from the firmware upgrade verification package to the trusted execution environment;
[0008] In the trusted execution environment, verification is performed based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block to obtain a verification result of the firmware upgrade package.
[0009] Through the above scheme, firstly, by obtaining a firmware upgrade verification package containing a firmware upgrade package and a first encrypted data block encrypted based on a derived certificate, a data basis is provided for firmware upgrade and verification. Secondly, by comparing the volume of the firmware upgrade verification package with the available storage space of the trusted execution environment, the verification failure caused by insufficient storage space is avoided. In addition, based on the comparison result, the necessary information of the firmware upgrade package is selectively extracted into the trusted execution environment, and finally, the root certificate, the second verification value, the derived certificate and the first encrypted data block are used in the trusted execution environment for comprehensive verification to obtain the verification result of the firmware upgrade package. In this way, by implementing verification of the firmware upgrade package in the trusted execution environment, the security of the firmware upgrade package is effectively enhanced.
[0010] In combination with the first aspect, in some possible implementations, based on the comparison result, a second verification value, a derived certificate, and a first encrypted data block of the firmware upgrade package are extracted from the firmware upgrade verification package to a trusted execution environment, including: if the comparison result indicates that the volume of the firmware upgrade verification package is less than or equal to the available storage space of the trusted execution environment, the firmware upgrade verification package is transmitted to the trusted execution environment; in the trusted execution environment, the firmware upgrade verification package is extracted to obtain the firmware upgrade package, the derived certificate, and the first encrypted data block, and a hash calculation is performed on the firmware upgrade package to obtain the second verification value of the firmware upgrade package.
[0011] Through the above scheme, it is first ensured that when the size of the firmware upgrade verification package is appropriate, it can be completely and securely transmitted to the trusted execution environment. Next, the key data is extracted and hashed in the trusted execution environment, further enhancing the security and accuracy of the verification process. The firmware upgrade package, the derived certificate, and the first encrypted data block are extracted to ensure the integrity and authenticity of the data required for subsequent verification operations. The hash calculation of the firmware upgrade package to obtain the second verification value is performed in a trusted environment using security features, which not only ensures the confidentiality of the hash calculation process, but also ensures the accuracy and reliability of the obtained verification value, thereby providing effective data support for the verification of the firmware upgrade package.
[0012] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, based on the comparison result, a second verification value, a derived certificate and a first encrypted data block of the firmware upgrade package are extracted from the firmware upgrade verification package to a trusted execution environment, including: if the comparison result indicates that the volume of the firmware upgrade verification package is larger than the available storage space of the trusted execution environment, then outside the trusted execution environment, the firmware upgrade verification package is extracted to obtain a firmware upgrade package, a target component in the firmware upgrade package containing the derived certificate, the first encrypted data block, and a hash calculation is performed on the firmware upgrade package to obtain the second verification value of the firmware upgrade package; the second verification value of the firmware upgrade package is transmitted to the trusted execution environment; the target component and the first encrypted data block are transmitted to the trusted execution environment; and in the trusted execution environment, the target component is extracted to obtain the derived certificate.
[0013] Through the above scheme, when the comparison result shows that the firmware upgrade verification package cannot be completely transmitted to the trusted execution environment, the firmware upgrade package, the target component containing the derived certificate, and the first encrypted data block are extracted by preprocessing outside the trusted execution environment, and the firmware upgrade package is hashed to obtain the second verification value. Subsequently, the second verification value, the target component, and the first encrypted data block are securely transmitted to the trusted execution environment. Finally, the target component is extracted in the trusted execution environment to obtain the derived certificate. In this way, it is ensured that even if the firmware upgrade verification package is too large, the key data required for verification can be effectively obtained.
[0014] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, the second verification value of the firmware upgrade package is transmitted to a trusted execution environment, including: encrypting the second verification value of the firmware upgrade package based on a preset encryption key to obtain a second encrypted data block; transmitting the second encrypted data block to the trusted execution environment; in the trusted execution environment, decrypting the second encrypted data block based on a preset decryption key to obtain the second verification value of the firmware upgrade package.
[0015] Through the above solution, the confidentiality and integrity of the second verification value of the firmware upgrade package during transmission to the trusted execution environment are ensured, data is prevented from being tampered with during transmission, and reliable data support is provided for subsequent verification operations. At the same time, the key generation algorithm ensures the security and non-traceability of the encryption process, further enhancing the security of the firmware upgrade verification process.
[0016] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, in a trusted execution environment, verification is performed based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block to obtain a verification result of the firmware upgrade package, including: in the trusted execution environment, certificate chain verification is performed based on the root certificate and the derived certificate to obtain a certificate chain verification result of the firmware upgrade package; the first encrypted data block is decrypted according to the derived certificate to obtain a first verification value; a verification value verification is performed based on the first verification value and the second verification value to obtain a verification value verification result of the firmware upgrade package; and the verification result of the firmware upgrade package is determined based on the certificate chain verification result of the firmware upgrade package and the verification value verification result of the firmware upgrade package.
[0017] Through the above solution, the dual verification mechanism based on certificate chain verification and verification value verification provides comprehensive security protection for the firmware upgrade package, effectively preventing security risks such as unauthorized access and data tampering, and ensuring the reliability and security of the firmware upgrade process.
[0018] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, the method also includes: if the certificate chain verification result indicates that the firmware upgrade package has not passed the certificate chain verification, pushing first verification failure information to the display interface of the terminal, wherein the first verification failure information is used to indicate that the firmware upgrade package has not passed the certificate chain verification; if the verification value verification result indicates that the firmware upgrade package has not passed the verification value verification, pushing second verification failure information to the display interface of the terminal, wherein the second verification failure information is used to indicate that the firmware upgrade package has not passed the verification value verification.
[0019] Through the above scheme, on the one hand, during the certificate chain verification process, if the certificate chain verification fails, the terminal will push the first verification failure information to the display interface. On the other hand, during the verification value verification process, if the verification value verification fails, the terminal will push the second verification failure information to the display interface. Through the timely push of these two verification failure information, the terminal user can quickly understand the security status of the firmware upgrade package and make reasonable decisions accordingly, effectively avoiding the use of unsafe or tampered firmware upgrade packages for upgrades, thereby protecting the security and stability of the terminal.
[0020] In combination with the first aspect and the above-mentioned implementation methods, in some possible implementation methods, in a trusted execution environment, after verification is performed based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block, and the verification result of the firmware upgrade package is obtained, it also includes: if the verification result of the firmware upgrade package indicates that the firmware upgrade package passes the verification, determining the target firmware corresponding to the firmware upgrade package in the firmware installed on the terminal; and upgrading the target firmware according to the firmware upgrade package.
[0021] Through the above scheme, after the verification result of the firmware upgrade package indicates that it has passed the verification, the terminal accurately identifies the target firmware corresponding to the firmware upgrade package in the installed firmware. This step ensures the pertinence and accuracy of the firmware upgrade operation. Then, the terminal performs the actual firmware upgrade operation, and writes the new firmware data in the firmware upgrade package to the storage area where the target firmware is located safely and completely, replacing the original firmware data, and realizing the smooth upgrade of the firmware.
[0022] In a second aspect, a firmware upgrade package verification device is provided, which is applied to a terminal, wherein the terminal includes a trusted execution environment, and the trusted execution environment stores a root certificate. The device includes:
[0023] An acquisition unit, used to acquire a firmware upgrade verification package, wherein the firmware upgrade verification package is composed of a firmware upgrade package and a first encrypted data block, the firmware upgrade package is provided with a derived certificate, and the first encrypted data block is obtained by encrypting a first verification value based on the derived certificate;
[0024] A comparison unit, used to compare the volume of the firmware upgrade verification package with the available storage space of the trusted execution environment to obtain a comparison result;
[0025] An extraction unit, configured to extract, based on the comparison result, a second verification value, a derived certificate, and a first encrypted data block of the firmware upgrade package from the firmware upgrade verification package to a trusted execution environment;
[0026] The verification unit is used to perform verification in a trusted execution environment based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate and the first encrypted data block to obtain a verification result of the firmware upgrade package.
[0027] According to a third aspect, a terminal is provided, wherein the terminal includes:
[0028] A memory for storing executable program codes;
[0029] The processor is used to call and run the executable program code from the memory, so that the terminal executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect.
[0030] In a fourth aspect, a computer program product is provided, comprising: a computer program code, which, when executed on a computer, enables the computer to execute the method in the first aspect or any possible implementation of the first aspect.
[0031] In a fifth aspect, a computer-readable storage medium is provided, which stores a computer program code. When the computer program code runs on a computer, the computer executes the method in the above-mentioned first aspect or any possible implementation manner of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 This is a schematic diagram of a scenario for obtaining a firmware upgrade package provided in an embodiment of the present application;
[0033] Figure 2 It is a flowchart of a firmware upgrade package verification method provided in an embodiment of the present application;
[0034] Figure 3 This is a schematic diagram of a process for extracting data required for verification provided by an embodiment of the present application;
[0035] Figure 4 This is a schematic diagram of a process for extracting data required for verification provided by an embodiment of the present application;
[0036] Figure 5 This is a schematic diagram of an encrypted transmission process provided by an embodiment of the present application;
[0037] Figure 6 It is a schematic diagram of a double verification process provided by an embodiment of the present application;
[0038] Figure 7 This is a schematic diagram of a process for pushing verification failure information provided by an embodiment of the present application;
[0039] Figure 8 It is a flowchart of a firmware upgrade provided by an embodiment of the present application;
[0040] Fig. 9 It is a schematic diagram of a firmware upgrade package verification process provided by an embodiment of the present application;
[0041] Fig.10 It is a structural schematic diagram of a firmware upgrade package verification device provided in an embodiment of the present application;
[0042] Fig.11 It is a structural diagram of a terminal provided in an embodiment of the present application. DETAILED DESCRIPTION
[0043] The technical solution in the present application will be described clearly and in detail below in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B: "and / or" in the text is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0044] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood as suggesting or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features.
[0045] See also Figure 1 , Figure 1 It is a schematic diagram of a scenario for obtaining a firmware upgrade package provided by an embodiment of the present application. Among them, terminal 002 can be a vehicle or other electronic equipment. In the scenario of terminal 002 firmware upgrade, the relevant technology usually follows a mode in which terminal 002 actively initiates a request to the corresponding cloud platform 001 to obtain the required firmware upgrade package. Once terminal 002 receives this firmware upgrade package, it will update the target firmware according to the content in the firmware upgrade package to achieve functional enhancement, performance improvement or security vulnerability repair. However, in the process of transmitting this firmware upgrade package from cloud platform 001 to terminal 002, there are possible security risks. If the firmware upgrade package is intercepted by a malicious attacker during this process, or a virus file is added to the firmware upgrade package, then when terminal 002 uses this tampered firmware upgrade package for update, it may pose a serious threat to the security of terminal 002, and may even cause the collapse of the terminal 002 system or be maliciously controlled.
[0046] Therefore, how to ensure the security of the firmware upgrade package during transmission and prevent it from being maliciously tampered with or added with viruses has become a technical problem that needs to be solved urgently.
[0047] In response to the above problems, the solution provided by the embodiment of the present application mainly includes: first, by obtaining a firmware upgrade verification package containing a firmware upgrade package and a first encrypted data block encrypted based on a derived certificate, a data basis is provided for firmware upgrade and verification. Secondly, by comparing the volume of the firmware upgrade verification package with the available storage space of the trusted execution environment, verification failures caused by insufficient storage space are avoided. In addition, based on the comparison results, the necessary information of the firmware upgrade package is selectively extracted into the trusted execution environment, and finally, the root certificate, the second verification value, the derived certificate, and the first encrypted data block are used in the trusted execution environment for comprehensive verification to obtain the verification result of the firmware upgrade package. In this way, by implementing verification of the firmware upgrade package in the trusted execution environment, the security of the firmware upgrade package is effectively enhanced.
[0048] based on Figure 1 The scene shown is shown below. Figure 2 - Fig. 9 , the firmware upgrade package verification method provided in the embodiment of the present application is introduced in detail.
[0049] See also Figure 2 , Figure 2 A flowchart of a firmware upgrade package verification method provided in an embodiment of the present application. Figure 2 As shown, the method of the embodiment of the present application is applied to a terminal, the terminal includes a trusted execution environment, and the trusted execution environment stores a root certificate. The method may include the following steps S101-S104.
[0050] S101, obtaining a firmware upgrade verification package, wherein the firmware upgrade verification package is composed of a firmware upgrade package and a first encrypted data block, the firmware upgrade package is provided with a derived certificate, and the first encrypted data block is obtained by encrypting a first verification value based on the derived certificate.
[0051] Specifically, the firmware upgrade involved in this embodiment can be implemented based on the Firmware Over-The-Air (FOTA) technology. Some common application scenarios are to upgrade the target firmware of the vehicle.
[0052] The firmware upgrade verification package comes from the cloud platform, which is equipped with a Key Management Service (KMS) server and a firmware upgrade server. Among them, the KMS server pre-stores the leaf certificate for encrypting the firmware upgrade package. Before the firmware upgrade server is ready to send the firmware upgrade package to the terminal, it will first calculate the first verification value of the firmware upgrade package and send the first verification value to the KMS server. Correspondingly, the KMS server uses the private key of the leaf certificate to encrypt the first verification value, generate a first encrypted data block, and return the first encrypted data block to the firmware upgrade server.
[0053] It should be noted that the firmware upgrade server calculates the first check value of the firmware upgrade package, where the first check value can be a hash value. The hash value is used to verify the integrity of the firmware upgrade package because it converts the content of the firmware upgrade package into a unique value of fixed length through a hash algorithm. Any slight change to the firmware upgrade package will cause the hash value to change significantly, so by comparing the hash value, it is possible to detect whether the firmware upgrade package has been tampered with or damaged during transmission or storage. In addition to the hash value, algorithms such as cyclic redundancy check (CRC), digital signature, sum check, and message digest algorithm version 5 (MD5) can also be used to verify the integrity of the upgrade package. These methods ensure that the data has not been tampered with during transmission or storage by generating a specific check value and comparing it with the original value.
[0054] In some possible implementations, for the triggering process of the firmware upgrade, the terminal displays a user interface corresponding to the firmware upgrade program installed thereon, and the user operates in the user interface to query whether the target firmware of the terminal can be upgraded. If the target firmware of the terminal can be upgraded, and the upgrade task of the target firmware is confirmed by the user's operation in the user interface, the firmware upgrade program of the terminal will automatically connect to the cloud platform and send a download request to the cloud platform.
[0055] Accordingly, the cloud platform responds to the download request of the terminal by sending a firmware upgrade verification package to the terminal through the firmware upgrade server, wherein the firmware upgrade verification package is composed of a firmware upgrade package corresponding to the target firmware and a first encrypted data block, and the firmware upgrade package is provided with a derived certificate.
[0056] It should be noted that a complete certificate chain is composed of at least a root certificate and a leaf certificate, and in some cases it can be composed of a root certificate, an intermediate certificate and a leaf certificate. Among them, the intermediate certificate and the leaf certificate are collectively referred to as derived certificates. The relationship between them is close and hierarchical. The root certificate is at the top of the certificate chain and is the starting point of the certificate chain. It is self-signed by a trusted certificate authority (here it can be a firmware upgrade server). The intermediate certificate is located between the root certificate and the leaf certificate, acting as a bridge. It is issued by the root certificate authority and is used to extend the certificate chain. The leaf certificate (also called the terminal certificate or user certificate) is located at the end of the certificate chain and is issued by the intermediate certificate authority to verify the authenticity of a specific domain name or entity. The entire certificate chain is verified by signatures at each level to ensure the credibility of each certificate, thereby constructing a complete trust path from the root certificate to the leaf certificate. It can be understood that the root certificate and the leaf certificate must exist in the certificate chain, and the number of both is one; the intermediate certificate may exist in the certificate chain, and the number is at least one.
[0057] S102, comparing the volume of the firmware upgrade verification package with the available storage space of the trusted execution environment to obtain a comparison result.
[0058] Specifically, the terminal's Trusted Execution Environment (TEE) is an isolated security area that is embedded in the terminal's hardware and provides an environment for performing sensitive operations and executing security functions. The Trusted Execution Environment ensures the security of the code and data executed in it through hardware and software security mechanisms, prevents unauthorized access and tampering, and is used to perform key operations such as identity authentication, data encryption, secure storage, and secure payment. In the Trusted Execution Environment, a special type of application, called Trusted Applications (TA), runs. Trusted applications are specially designed to be executed in the Trusted Execution Environment, and they use the security features provided by the Trusted Execution Environment to perform various security tasks. Trusted applications are isolated from ordinary operating system applications, ensuring the independence and security of their execution. The Trusted Execution Environment and trusted applications together form a security framework that provides a high level of security for the terminal.
[0059] Performing multiple operations required for verifying the firmware upgrade verification package in the trusted execution environment can better ensure that the verification process is controlled and improve the accuracy of the verification. However, the storage space of the trusted execution environment is limited. If the size of the firmware upgrade verification package exceeds the available storage space of the trusted execution environment, the entire firmware upgrade verification package cannot be transferred to the trusted execution environment for verification. Forcibly transferring the firmware upgrade verification package to the trusted execution environment may cause the verification to fail.
[0060] Therefore, before verifying the firmware upgrade package, it is necessary to first compare the volume of the firmware upgrade verification package with the available storage space of the trusted execution environment to obtain a comparison result.
[0061] S103: Based on the comparison result, extract the second verification value, the derived certificate and the first encrypted data block of the firmware upgrade package from the firmware upgrade verification package to the trusted execution environment.
[0062] Specifically, in some cases, the comparison result indicates that the volume of the firmware upgrade verification package is less than or equal to the available storage space of the trusted execution environment; in some cases, the comparison result indicates that the volume of the firmware upgrade verification package is greater than the available storage space of the trusted execution environment.
[0063] It can be understood that if the size of the firmware upgrade verification package is less than or equal to the available storage space of the trusted execution environment, then the entire firmware upgrade verification package can be transmitted to the trusted execution environment, and in the trusted execution environment, the second verification value, derived certificate and first encrypted data block of the firmware upgrade package are extracted from the firmware upgrade verification package.
[0064] If the size of the firmware upgrade verification package is larger than the available storage space of the trusted execution environment, then the second verification value, derived certificate and first encrypted data block of the firmware upgrade package can be extracted from the firmware upgrade verification package outside the trusted execution environment, and the second verification value, derived certificate and first encrypted data block of the firmware upgrade package can be transmitted to the trusted execution environment.
[0065] The second check value of the firmware upgrade package is determined based on the same algorithm as the first check value of the firmware upgrade package. For example, when the first check value of the firmware upgrade package is a hash value, the second check value of the firmware upgrade package is also a hash value, and the second check value of the firmware upgrade package is obtained by performing a hash calculation on the firmware upgrade package on the terminal side. In addition to hash calculation, algorithms such as CRC, digital signature, sum check, MD5, etc. can also be used to implement the calculation of the above check value, which will not be described in detail.
[0066] S104, in the trusted execution environment, performing verification based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block to obtain a verification result of the firmware upgrade package.
[0067] Specifically, the terminal will perform a series of verification operations in the trusted execution environment. The verification operations mainly involve certificate chain verification and check value verification. It is worth noting that the certificate chain verification process and the check value verification process do not have to be performed in a specific sequence. They can be performed separately, or their sequence can be changed, depending on the specific implementation method and security requirements.
[0068] On the one hand, regarding the verification of the certificate chain, the terminal will use the root certificate pre-stored in the trusted execution environment to verify the validity of the derived certificate. The root certificate is the starting point of the certificate chain and is self-signed by a trusted certificate authority, so it has the ability to verify the legitimacy of other derived certificates. It is understandable that the derived certificate will eventually be verified to determine whether it is legal or not.
[0069] On the other hand, regarding the verification of the verification value, the terminal will decrypt the first encrypted data block using the public key in the derived certificate to obtain the first verification value of the firmware upgrade package. Then, the terminal will compare the first verification value of the firmware upgrade package obtained by decryption with the second verification value of the firmware upgrade package obtained previously. If the two verification values match, it can be confirmed that the firmware upgrade package is complete and has not been tampered with. On the contrary, if the verification values do not match, it can be confirmed that the firmware upgrade package is incomplete and may have been tampered with.
[0070] During the verification process, the trusted execution environment also provides additional security protection to ensure the confidentiality and integrity of the verification operation, including but not limited to encrypted storage of sensitive data, isolated execution of the verification process, and confidentiality of the verification results.
[0071] Based on the above-mentioned certificate chain verification process and checksum verification process, the verification result of a firmware upgrade package can be finally determined. In some cases, if it is determined through verification that the derived certificate is legal, the firmware upgrade package is complete and has not been tampered with, then the verification result of the firmware upgrade package can indicate that the firmware upgrade package has passed the verification; in some cases, if it is determined through verification that the derived certificate is illegal, the firmware upgrade package is incomplete and may have been tampered with, then the verification result of the firmware upgrade package can indicate that the firmware upgrade package has not passed the verification.
[0072] It can be understood that if the verification result of the firmware upgrade package can indicate that the firmware upgrade package has passed the verification, the firmware upgrade package can be used to upgrade the target firmware of the terminal subsequently; if the verification result of the firmware upgrade package can indicate that the firmware upgrade package has failed the verification, it will subsequently indicate that the firmware upgrade package has security deficiencies, and the terminal will not use the firmware upgrade package to upgrade the target firmware of the terminal, and may push some security prompt information to the user of the terminal, or provide abnormal information feedback about the firmware upgrade package to the cloud platform.
[0073] In this embodiment, firstly, by obtaining a firmware upgrade verification package including a firmware upgrade package and a first encrypted data block encrypted based on a derived certificate, a data basis is provided for firmware upgrade and verification. Secondly, by comparing the volume of the firmware upgrade verification package with the available storage space of the trusted execution environment, verification failures caused by insufficient storage space are avoided. In addition, based on the comparison results, necessary information of the firmware upgrade package is selectively extracted into the trusted execution environment, and finally, a comprehensive verification is performed in the trusted execution environment using the root certificate, the second verification value, the derived certificate, and the first encrypted data block to obtain the verification result of the firmware upgrade package. In this way, by implementing verification of the firmware upgrade package in the trusted execution environment, the security of the firmware upgrade package is effectively enhanced.
[0074] See also Figure 3 , provides a schematic diagram of a process for extracting data required for verification in an embodiment of the present application, such as Figure 3 As shown, the method of the embodiment of the present application may include the following steps S201-S202, and steps S201-S202 may be used as Figure 2 The refinement of step S103 in the illustrated embodiment.
[0075] S201, if the comparison result indicates that the volume of the firmware upgrade verification package is less than or equal to the available storage space of the trusted execution environment, the firmware upgrade verification package is transmitted to the trusted execution environment;
[0076] S202, in a trusted execution environment, extracting the firmware upgrade verification package to obtain a firmware upgrade package, a derived certificate, and a first encrypted data block, and performing a hash calculation on the firmware upgrade package to obtain a second verification value of the firmware upgrade package.
[0077] Specifically, when the comparison result indicates that the volume of the firmware upgrade verification package is less than or equal to the available storage space of the trusted execution environment, the entire firmware upgrade verification package can be completely transferred to the trusted execution environment. The purpose of transferring the firmware upgrade verification package completely to the trusted execution environment is to perform a more secure and isolated verification operation in the trusted execution environment to ensure the confidentiality and integrity of the verification process.
[0078] Next, once the firmware upgrade verification package is successfully transmitted to the trusted execution environment, a series of extraction and calculation operations will be performed in the trusted execution environment. First, the firmware upgrade package, the derived certificate, and the first encrypted data block are extracted from the firmware upgrade verification package. These are the key data required for the subsequent firmware upgrade package verification. Among them, the firmware upgrade package contains the firmware information to be upgraded, the derived certificate is used to verify the legitimacy and authenticity of the source of the firmware upgrade package, and the first encrypted data block is obtained by encrypting the first verification value of the firmware upgrade package, which is used for subsequent verification value comparison.
[0079] In addition to extracting these key data, the firmware upgrade package also needs to be hashed in the trusted execution environment to obtain a second checksum of the firmware upgrade package. This calculation process is performed in the trusted execution environment, utilizing the security features provided by the trusted execution environment to ensure the confidentiality of the calculation process and the accuracy of the results. It should be noted that the hash calculation operation can be performed by a trusted reference in the trusted execution environment.
[0080] For example, assume that the volume of a firmware upgrade verification package is 800MB, and the available storage space of the trusted execution environment is 1GB. In this case, the comparison result will indicate that the volume of the firmware upgrade verification package is smaller than the available storage space of the trusted execution environment. Therefore, according to step S201, the entire firmware upgrade verification package will be transmitted to the trusted execution environment. Subsequently, according to step S202, the firmware upgrade verification package will be extracted in the trusted execution environment to obtain the firmware upgrade package, the derived certificate, and the first encrypted data block, and the firmware upgrade package will be hashed to obtain the second verification value of the firmware upgrade package, so as to perform subsequent verification operations.
[0081] In this embodiment, it is first ensured that when the size of the firmware upgrade verification package is appropriate, it can be completely and securely transmitted to the trusted execution environment. Next, the key data is extracted and hashed in the trusted execution environment to further enhance the security and accuracy of the verification process. The firmware upgrade package, the derived certificate, and the first encrypted data block are extracted to ensure the integrity and authenticity of the data required for subsequent verification operations. The hash calculation of the firmware upgrade package to obtain the second verification value is performed in a trusted environment using security features. This embodiment not only ensures the confidentiality of the hash calculation process, but also ensures the accuracy and reliability of the obtained verification value, thereby providing effective data support for the verification of the firmware upgrade package.
[0082] See also Figure 4 , provides a schematic diagram of a process for extracting data required for verification in an embodiment of the present application, such as Figure 4 As shown, the method of the embodiment of the present application may include the following steps S301-S304, and steps S301-S304 may be used as Figure 2 The refinement of step S103 in the illustrated embodiment.
[0083] S301, if the comparison result indicates that the volume of the firmware upgrade verification package is larger than the available storage space of the trusted execution environment, then outside the trusted execution environment, extracting the firmware upgrade verification package to obtain a firmware upgrade package, a target component of the derived certificate in the firmware upgrade package, and a first encrypted data block, and performing a hash calculation on the firmware upgrade package to obtain a second verification value of the firmware upgrade package;
[0084] S302, transmitting the second verification value of the firmware upgrade package to the trusted execution environment;
[0085] S303, transmitting the target component and the first encrypted data block to the trusted execution environment;
[0086] S304: In the trusted execution environment, extract the target component to obtain a derived certificate.
[0087] Specifically, when the comparison result shows that the volume of the firmware upgrade verification package is larger than the available storage space of the trusted execution environment, the entire firmware upgrade verification package cannot be completely transmitted to the trusted execution environment. Therefore, it is necessary to pre-process the firmware upgrade verification package outside the trusted execution environment, extract the firmware upgrade package, the target component containing the derived certificate in the firmware upgrade package, and the first encrypted data block, and perform hash calculation on the firmware upgrade package to obtain the second verification value of the firmware upgrade package. In this way, the key data required for subsequent verification can be obtained without transmitting the complete firmware upgrade verification package to the trusted execution environment.
[0088] Next, the second checksum of the firmware upgrade package, the target component, and the first encrypted data block need to be transmitted to the trusted execution environment. This process is based on the secure communication mechanism between the trusted execution environment and the external environment. The secure communication mechanism can ensure the confidentiality and integrity of the data during the transmission process and prevent the data from being tampered with or leaked during the transmission process. The second checksum of the firmware upgrade package, the target component, and the first encrypted data block are transmitted to the trusted execution environment in order to perform a more secure and isolated verification operation on these data in the trusted execution environment.
[0089] It should be noted that the above-mentioned secure communication mechanism refers to a series of technologies and algorithms used when transmitting data between a trusted execution environment and an external environment (such as a firmware upgrade program) to ensure the confidentiality, integrity and authenticity of the data. The secure communication mechanism may include encrypted communication, that is, using an encryption algorithm to encrypt data to prevent the data from being stolen or tampered with by unauthorized third parties during transmission.
[0090] After the target component is successfully transferred to the trusted execution environment, the trusted application in the trusted execution environment will perform an extraction operation on the target component to obtain a derived certificate.
[0091] For example, assume that the volume of a firmware upgrade verification package is 2GB, and the available storage space of the trusted execution environment is only 1GB. In this case, the comparison result will indicate that the volume of the firmware upgrade verification package is larger than the available storage space of the trusted execution environment. Therefore, according to step S301, it is necessary to pre-process the firmware upgrade verification package outside the trusted execution environment, extract the firmware upgrade package, the target component containing the derived certificate in the firmware upgrade package, and the first encrypted data block, and perform hash calculation on the firmware upgrade package to obtain the second verification value of the firmware upgrade package. Subsequently, according to steps S302 and S303, we transmit the second verification value of the firmware upgrade package as well as the target component and the first encrypted data block to the trusted execution environment. Finally, in step S304, the target component is extracted in the trusted execution environment to obtain the derived certificate for subsequent verification operations. Through such a process, it is ensured that even if the volume of the firmware upgrade verification package is larger than the available storage space of the trusted execution environment, the verification process of the firmware upgrade package can be completed safely and accurately.
[0092] In this embodiment, when the comparison result shows that the firmware upgrade verification package cannot be completely transmitted to the trusted execution environment, the firmware upgrade package, the target component containing the derived certificate, and the first encrypted data block are extracted by preprocessing outside the trusted execution environment, and the firmware upgrade package is hashed to obtain the second verification value. Subsequently, the second verification value, the target component, and the first encrypted data block are securely transmitted to the trusted execution environment using the secure communication mechanism between the trusted execution environment and the external environment. Finally, the target component is extracted in the trusted execution environment to obtain the derived certificate. In this way, it is ensured that even if the firmware upgrade verification package is too large, the key data required for verification can be effectively obtained.
[0093] See also Figure 5 , provides a schematic diagram of the encrypted transmission process for the embodiment of the present application, such as Figure 5 As shown, the method of the embodiment of the present application may include the following steps S401-S403, and steps S401-S403 may be used as Figure 4 The refinement of step S302 in the illustrated embodiment.
[0094] S401, encrypting a second verification value of the firmware upgrade package based on a preset encryption key to obtain a second encrypted data block;
[0095] S402, transmitting the second encrypted data block to the trusted execution environment;
[0096] S403, in the trusted execution environment, decrypt the second encrypted data block based on a preset decryption key to obtain a second verification value of the firmware upgrade package.
[0097] Specifically, after the calculation is completed, the second check value of the firmware upgrade package needs to be transmitted from outside the trusted execution environment to the trusted execution environment. If this transmission process is not protected, it may be used by a third party. To this end, the terminal uses a preset encryption key to encrypt the second check value of the firmware upgrade package, and an encrypted data block can be obtained, namely the second encrypted data block. The second encrypted data block can ensure the confidentiality of the second check value of the firmware upgrade package during the transmission process. Even if the data is intercepted by an unauthorized third party, it cannot be easily decrypted to obtain the second check value of the firmware upgrade package.
[0098] Next, the encrypted second encrypted data block is transmitted to the trusted execution environment, and the second encrypted data block is decrypted using a preset decryption key in the trusted execution environment. It can be understood that the decryption key corresponds to the encryption key used previously, so that the second verification value of the firmware upgrade package can be successfully decrypted in the trusted execution environment.
[0099] For example, assuming the terminal is a vehicle,
[0100] After hash calculation outside the trusted execution environment, the second check value of the firmware upgrade package is "1234567890ABCDEF". In order to ensure the confidentiality and integrity of the second check value of the firmware upgrade package during transmission to the trusted execution environment, a key generation algorithm dominated by the firmware upgrade program is used to encrypt it. This key generation algorithm combines the vehicle's vehicle identification number (VIN), the current system time, and the size of the firmware upgrade package to generate a unique, untraceable encryption key "VIN123+TIME456+FWPKG789".
[0101] This encryption key is used outside the trusted execution environment to encrypt the second verification value of the firmware upgrade package, and the second encrypted data block "XYZ9876543210FEDCBA" is obtained. Subsequently, the encrypted second encrypted data block is securely transmitted to the trusted execution environment. In the trusted execution environment, the second encrypted data block is decrypted using the same decryption key "VIN123+TIME456+FWPKG789" as used for encryption, and the second verification value "1234567890ABCDEF" of the firmware upgrade package is successfully obtained.
[0102] In this embodiment, through such an encrypted transmission process, the confidentiality and integrity of the second verification value of the firmware upgrade package during transmission to the trusted execution environment are ensured, data is prevented from being tampered with or leaked during transmission, and reliable data support is provided for subsequent verification operations. At the same time, the key generation algorithm ensures the security and non-traceability of the encryption process, further enhancing the security of the firmware upgrade verification process.
[0103] See also Figure 6 , a schematic diagram of a double check process is provided for an embodiment of the present application, such as Figure 6 As shown, the method of the embodiment of the present application may include the following steps S501-S504, and steps S501-S504 may be used as Figure 2 The refinement of step S104 in the illustrated embodiment.
[0104] S501, in a trusted execution environment, performing a certificate chain verification based on a root certificate and a derived certificate to obtain a certificate chain verification result of the firmware upgrade package;
[0105] S502, decrypting the first encrypted data block according to the derived certificate to obtain a first check value;
[0106] S503, performing a check value check based on the first check value and the second check value to obtain a check value check result of the firmware upgrade package;
[0107] S504: Determine a verification result of the firmware upgrade package based on a certificate chain verification result of the firmware upgrade package and a verification value verification result of the firmware upgrade package.
[0108] Specifically, in the isolated security area of the trusted execution environment, a root certificate is stored. It is the starting point of the certificate chain and is self-signed by a trusted certificate authority. It has the ability to verify the legitimacy of other derived certificates. As part of the certificate chain, a derived certificate is issued by a root certificate or an intermediate certificate to verify the authenticity of a specific entity or domain name. During the verification process, the terminal will use the root certificate pre-stored in the trusted execution environment to verify the validity of the derived certificate step by step, and then obtain the certificate chain verification result of the firmware upgrade package.
[0109] It can be understood that, in some cases, the certificate chain verification result of the firmware upgrade package indicates that the firmware upgrade package passes the certificate chain verification; in some cases, the certificate chain verification result of the firmware upgrade package indicates that the firmware upgrade package fails the certificate chain verification.
[0110] Next, the first encrypted data block is obtained by encrypting the first verification value of the firmware upgrade package based on the private key of the derived certificate, and it is sent from the cloud platform to the terminal together with the firmware upgrade verification package. In the trusted execution environment, by using the public key in the derived certificate, the terminal can decrypt the first encrypted data block to obtain the first verification value of the firmware upgrade package. The implementation of this process relies on the asymmetric encryption mechanism of public and private keys, which ensures the confidentiality and integrity of the encrypted data block during transmission and prevents the data from being accessed or tampered with without authorization.
[0111] The second check value of the firmware upgrade package is obtained by performing the same hash calculation or other algorithm calculation on the firmware upgrade package on the terminal side, and it is determined based on the same algorithm as the first check value of the firmware upgrade package. In a trusted execution environment, the terminal will compare the first check value of the firmware upgrade package with the second check value of the firmware upgrade package. If the two check values match exactly, it can be confirmed that the firmware upgrade package is complete and has not been tampered with, because any slight change to the firmware upgrade package will result in a significant change in the check value. Conversely, if the check values do not match, it can be confirmed that the firmware upgrade package is incomplete and may have been tampered with. After comparing the above check values, the check value verification result of the firmware upgrade package can be obtained.
[0112] It can be understood that, in some cases, the checksum verification result of the firmware upgrade package indicates that the firmware upgrade package passes the checksum verification; in some cases, the checksum verification result of the firmware upgrade package indicates that the firmware upgrade package fails the checksum verification.
[0113] Finally, based on the certificate chain verification result of the firmware upgrade package and the check value verification result of the firmware upgrade package, the verification result of the firmware upgrade package can be determined. Specifically, if the certificate chain verification result of the firmware upgrade package indicates that the firmware upgrade package passes the certificate chain verification, and the check value verification result of the firmware upgrade package indicates that the firmware upgrade package passes the check value verification, then a verification result of the firmware upgrade package can be determined, and the verification result of the firmware upgrade package indicates that the firmware upgrade package passes the verification; if the certificate chain verification result of the firmware upgrade package indicates that the firmware upgrade package fails to pass the certificate chain verification, or the check value verification result of the firmware upgrade package indicates that the firmware upgrade package fails to pass the check value verification, then a verification result of the firmware upgrade package can be determined, and the verification result of the firmware upgrade package indicates that the firmware upgrade package fails to pass the verification.
[0114] In this embodiment, the root certificate stored in the trusted execution environment is first used to perform a certificate chain check on the derived certificate to ensure the legitimacy and authenticity of the source of the firmware upgrade package. Subsequently, the first encrypted data block is decrypted using the public key in the derived certificate to obtain the first check value of the firmware upgrade package. This step utilizes the asymmetric encryption mechanism of the public key and the private key to ensure the confidentiality and integrity of the first check value during transmission. Next, the first check value of the firmware upgrade package is compared with the second check value calculated on the terminal side to ensure the integrity and non-tampering of the firmware upgrade package. Finally, the verification result of the firmware upgrade package is comprehensively determined based on the certificate chain verification result and the verification value verification result. This dual verification mechanism provides comprehensive security protection for the firmware upgrade package, effectively prevents security risks such as unauthorized access and data tampering, and ensures the reliability and security of the firmware upgrade process.
[0115] Based on the above Figure 6 For the example shown, see Figure 7 , provides a schematic diagram of a process for pushing verification failure information in an embodiment of the present application, such as Figure 7 As shown, the method of the embodiment of the present application may also include the following steps S601-S602.
[0116] S601, if the certificate chain verification result indicates that the firmware upgrade package fails to pass the certificate chain verification, push first verification failure information to a display interface of the terminal, wherein the first verification failure information is used to indicate that the firmware upgrade package fails to pass the certificate chain verification;
[0117] S602: If the check value verification result indicates that the firmware upgrade package fails the check value verification, push second check failure information to the display interface of the terminal, wherein the second check failure information is used to indicate that the firmware upgrade package fails the check value verification.
[0118] Specifically, Figure 6The illustrated embodiment provides a dual verification process for the firmware upgrade package, including certificate chain verification and verification value verification, which ensures the integrity and non-tampering of the firmware upgrade package during transmission and storage, and provides security for the firmware upgrade of the terminal. However, in actual applications, due to various reasons, such as incomplete certificate chain, expired certificate, firmware upgrade package tampering during transmission, etc., the firmware upgrade package may not pass the verification. In order to promptly notify the terminal user of the firmware upgrade package verification failure and take corresponding security measures, the embodiment of the present application provides a solution for pushing verification failure information.
[0119] Regarding the certificate chain verification process, certificate chain verification is one of the important links in the firmware upgrade package verification, which involves a step-by-step verification process from the root certificate to the derived certificate. If any problems are found in this process, such as the derived certificate cannot be verified by the root certificate or the intermediate certificate, the certificate chain is incomplete, the certificate is expired, etc., the certificate chain verification will fail. At this time, in order to ensure that the terminal user can understand the security issues of the firmware upgrade package in a timely manner and provide them with clear security prompts, the terminal will push the first verification failure information to the display interface. The first verification failure information clearly indicates that the firmware upgrade package has not passed the certificate chain verification, prompting the user that the firmware upgrade package may have security risks and it is not recommended to perform the upgrade operation. Through such an information feedback mechanism, the terminal user can understand the security status of the firmware upgrade package in a timely manner, and make reasonable decisions based on this, avoid using unsafe firmware upgrade packages for upgrades, thereby protecting the security and stability of the terminal.
[0120] Regarding the process of checksum verification, checksum verification is another important part of the firmware upgrade package verification. It obtains a checksum by performing hash calculation or other algorithm calculation on the firmware upgrade package, and compares it with the pre-calculated and encrypted first checksum. If the two checksums do not match, it means that the firmware upgrade package may have been tampered with during the transmission or storage process, resulting in the failure of the checksum verification. At this time, in order to promptly notify the terminal user of the inconsistency of the firmware upgrade package and provide it with a clear security warning, the terminal will push the second check failure information to the display interface. The second check failure information clearly indicates that the firmware upgrade package has not passed the checksum verification, prompting the user that the firmware upgrade package may have been tampered with or damaged, and there is a security risk. It is not recommended to perform the upgrade operation. Through such an information feedback mechanism, the terminal user can promptly understand the integrity status of the firmware upgrade package, and make reasonable decisions based on this, avoiding the use of incomplete or tampered firmware upgrade packages for upgrading, thereby protecting the security and stability of the terminal.
[0121] The following are some examples of the first verification failure information and the second verification failure information:
[0122] First verification failure message (certificate chain verification failed): "Warning: The firmware upgrade package did not pass the certificate chain verification. To protect the security of your device, it is recommended not to perform the upgrade operation. Please contact the device manufacturer or service provider for more help."
[0123] Second verification failure message (checksum verification failed): "Warning: The firmware upgrade package did not pass the checksum verification. To protect the security of your device, it is recommended not to perform the upgrade operation. Please contact the device manufacturer or service provider for more help."
[0124] This information clearly points out the specific reasons why the firmware upgrade package verification failed and provides corresponding security recommendations to help end users make reasonable decisions.
[0125] In this embodiment, on the one hand, during the certificate chain verification process, once it is found that the firmware upgrade package has problems such as incomplete certificate chain, expired certificate or unverifiable certificate, resulting in certificate chain verification failure, the terminal will push the first verification failure information to the display interface. On the other hand, during the verification value verification process, if the verification value of the firmware upgrade package does not match the expected one, it indicates that the firmware upgrade package may have been tampered with during transmission or storage, resulting in verification value verification failure. At this time, the terminal will push the second verification failure information to the display interface. Through the timely push of these two verification failure information, the terminal user can quickly understand the security status of the firmware upgrade package and make reasonable decisions accordingly, effectively avoiding the use of unsafe or tampered firmware upgrade packages for upgrades, thereby protecting the security and stability of the terminal.
[0126] See also Figure 8 , a flowchart of a firmware upgrade is provided for an embodiment of the present application, such as Figure 8 As shown, the method of the embodiment of the present application may include the following steps S701-S702, and steps S701-S702 may be performed in Figure 2 In the illustrated embodiment, it is performed after step S104.
[0127] S701, if the verification result of the firmware upgrade package indicates that the firmware upgrade package passes the verification, determining the target firmware corresponding to the firmware upgrade package in the firmware installed on the terminal;
[0128] S702: Upgrade the target firmware according to the firmware upgrade package.
[0129] Specifically, when the verification result of the firmware upgrade package shows that the firmware upgrade package has passed the verification, it means that the firmware upgrade package is legal, complete and has not been tampered with. At this time, the terminal will further parse the information in the firmware upgrade package, such as firmware version, firmware type, firmware identifier, etc., and use this information to identify the target firmware corresponding to the firmware upgrade package in the installed firmware.
[0130] Once the target firmware is determined, the terminal will begin to perform the actual firmware upgrade operation. Specifically, the terminal will write the new firmware data in the firmware upgrade package to the storage area where the target firmware is located, replacing the original firmware data. During the upgrade process, the terminal will ensure the integrity and consistency of the firmware upgrade package to avoid data loss or corruption during the upgrade process. At the same time, in order to ensure the smooth progress of the firmware upgrade, the terminal may also perform some additional operations, such as suspending services or processes related to the target firmware to ensure that the normal operation of the device is not affected during the upgrade process. After the upgrade is completed, the terminal will restart or reload the target firmware so that it can run the new version of the firmware code.
[0131] In some possible implementations, the firmware upgrade process may also add some additional security measures. For example, during the upgrade process, the terminal may re-verify the firmware upgrade package to ensure that the firmware upgrade package has not been tampered with or damaged during the upgrade process. In addition, in order to prevent unexpected situations during the firmware upgrade process that cause the device to not work properly, the terminal may also create a backup of the target firmware before the upgrade, so that it can be restored to the original firmware version in the event of an upgrade failure or a problem.
[0132] In this embodiment, after the verification result of the firmware upgrade package indicates that the verification has been passed, the terminal accurately identifies the target firmware corresponding to the firmware upgrade package in the installed firmware. This step ensures the pertinence and accuracy of the firmware upgrade operation. Then, the terminal performs the actual firmware upgrade operation, and writes the new firmware data in the firmware upgrade package to the storage area where the target firmware is located safely and completely, replacing the original firmware data, and realizing a smooth firmware upgrade.
[0133] For easier understanding of the solution of the embodiment of the present application, please refer to Fig. 9 , which is a schematic diagram of a firmware upgrade package verification process provided in an embodiment of the present application.
[0134] First, the user will display the user interface corresponding to the installed firmware upgrade program on the terminal, and the user will operate in the user interface to query whether the target firmware of the terminal can be upgraded. If the target firmware of the terminal can be upgraded, and the upgrade task of the target firmware is confirmed by the user's operation in the user interface, the terminal's firmware upgrade program will automatically connect to the cloud platform and send a download request to the cloud platform.
[0135] Accordingly, in response to the download request of the terminal, the cloud platform sends a firmware upgrade verification package to the terminal through the firmware upgrade server, wherein the firmware upgrade verification package is composed of the firmware upgrade package and a first encrypted data block composed of a first verification value encrypted based on the derived certificate. Then, the volume of the firmware upgrade verification package is compared with the available storage space of the trusted execution environment to obtain a comparison result.
[0136] Different operations are performed according to the comparison result. If the size of the firmware upgrade verification package is less than or equal to the available storage space of the trusted execution environment, the entire firmware upgrade verification package is transmitted to the trusted execution environment, and the firmware upgrade package, the derived certificate, and the first encrypted data block are extracted from the firmware upgrade package, and a hash calculation is performed on the firmware upgrade package to obtain its second verification value.
[0137] If the size of the firmware upgrade verification package is larger than the available storage space of the trusted execution environment, the firmware upgrade package, the target component containing the derived certificate, and the first encrypted data block are extracted outside the trusted execution environment, and the firmware upgrade package is hashed to obtain its second verification value. Subsequently, the second verification value is encrypted and transmitted to the trusted execution environment, where it is decrypted to obtain the original second verification value. At the same time, the target component and the first encrypted data block are also transmitted to the trusted execution environment, where the derived certificate is extracted from the target component.
[0138] In the trusted execution environment, the root certificate and the derived certificate are used to perform certificate chain verification to obtain the certificate chain verification result of the firmware upgrade package. Then, the first encrypted data block is decrypted using the derived certificate to obtain the first verification value. Next, the first verification value is compared with the second verification value to perform a verification value verification to obtain the verification value verification result of the firmware upgrade package. Finally, the final verification result of the firmware upgrade package is determined by combining the certificate chain verification result and the verification value verification result.
[0139] During the above-mentioned certificate chain verification and checksum verification process: if the certificate chain verification result shows that the firmware upgrade package has not passed, the first verification failure information is pushed to the terminal display interface, prompting the user that the firmware upgrade package has a security risk. If the checksum verification result shows that the firmware upgrade package has not passed, the second verification failure information is pushed to the terminal display interface, prompting the user that the firmware upgrade package may have been tampered with or damaged.
[0140] If the verification result of the firmware upgrade package indicates that the firmware upgrade package has not passed the verification, then the firmware upgrade package may have security risks and will not be used for firmware upgrade of the terminal.
[0141] If the verification result of the firmware upgrade package indicates that the firmware upgrade package passes the verification, the target firmware corresponding to the firmware upgrade package is determined in the firmware installed on the terminal, and the firmware upgrade package is used to perform an upgrade operation on the target firmware.
[0142] The beneficial effects that can be achieved by this embodiment are detailed in the previous embodiments and will not be described again here.
[0143] Based on the above Figure 1 The following will combine Fig.10 The firmware upgrade package verification device provided in the embodiment of the present application is introduced in detail. It should be noted that: Fig.10 The firmware upgrade package verification device in the present application is used to execute Figure 2 - Fig. 9 For the convenience of explanation, only the part related to the embodiment of the present application is shown. For the specific technical details not disclosed, please refer to the present application. Figure 2 - Fig. 9 Specifically, the firmware upgrade package verification device 800 may include an acquisition unit 801, a comparison unit 802, an extraction unit 803 and a verification unit 804, as follows:
[0144] The acquisition unit 801 is used to acquire a firmware upgrade verification package, wherein the firmware upgrade verification package is composed of a firmware upgrade package and a first encrypted data block, the firmware upgrade package is provided with a derived certificate, and the first encrypted data block is obtained by encrypting a first verification value based on the derived certificate;
[0145] The comparison unit 802 is used to compare the volume of the firmware upgrade verification package with the available storage space of the trusted execution environment to obtain a comparison result;
[0146] The extracting unit 803 is used to extract the second verification value, the derived certificate and the first encrypted data block of the firmware upgrade package from the firmware upgrade verification package to the trusted execution environment based on the comparison result;
[0147] The verification unit 804 is used to perform verification in a trusted execution environment based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate and the first encrypted data block to obtain a verification result of the firmware upgrade package.
[0148] Optionally, in some embodiments, the extraction unit 803 can be used to: if the comparison result indicates that the volume of the firmware upgrade verification package is less than or equal to the available storage space of the trusted execution environment, then transmit the firmware upgrade verification package to the trusted execution environment; in the trusted execution environment, extract the firmware upgrade verification package to obtain the firmware upgrade package, the derived certificate, the first encrypted data block, and perform hash calculation on the firmware upgrade package to obtain a second verification value of the firmware upgrade package.
[0149] Optionally, in some embodiments, the extraction unit 803 can be used for: if the comparison result indicates that the volume of the firmware upgrade verification package is larger than the available storage space of the trusted execution environment, then outside the trusted execution environment, extracting the firmware upgrade verification package to obtain a firmware upgrade package, a target component containing a derived certificate in the firmware upgrade package, a first encrypted data block, and performing hash calculation on the firmware upgrade package to obtain a second verification value of the firmware upgrade package; transmitting the second verification value of the firmware upgrade package to the trusted execution environment; transmitting the target component and the first encrypted data block to the trusted execution environment; and extracting the target component in the trusted execution environment to obtain the derived certificate.
[0150] Optionally, in some embodiments, the extraction unit 803 can be used to: encrypt a second verification value of the firmware upgrade package based on a preset encryption key to obtain a second encrypted data block; transmit the second encrypted data block to a trusted execution environment; in the trusted execution environment, decrypt the second encrypted data block based on a preset decryption key to obtain a second verification value of the firmware upgrade package.
[0151] Optionally, in some embodiments, the verification unit 804 can be used to: in a trusted execution environment, perform a certificate chain verification based on a root certificate and a derived certificate to obtain a certificate chain verification result of the firmware upgrade package; decrypt a first encrypted data block according to the derived certificate to obtain a first verification value; perform a verification value verification based on the first verification value and the second verification value to obtain a verification value verification result of the firmware upgrade package; determine the verification result of the firmware upgrade package based on the certificate chain verification result of the firmware upgrade package and the verification value verification result of the firmware upgrade package.
[0152] Optionally, in some embodiments, the firmware upgrade package verification device 800 can be used to: if the certificate chain verification result indicates that the firmware upgrade package has not passed the certificate chain verification, then push first verification failure information to the display interface of the terminal, wherein the first verification failure information is used to indicate that the firmware upgrade package has not passed the certificate chain verification; if the verification value verification result indicates that the firmware upgrade package has not passed the verification value verification, then push second verification failure information to the display interface of the terminal, wherein the second verification failure information is used to indicate that the firmware upgrade package has not passed the verification value verification.
[0153] Optionally, in some embodiments, the firmware upgrade package verification device 800 can be used to: if the verification result of the firmware upgrade package indicates that the firmware upgrade package has passed the verification, determine the target firmware corresponding to the firmware upgrade package in the firmware installed on the terminal; and upgrade the target firmware according to the firmware upgrade package.
[0154] The beneficial effects that can be achieved by this embodiment are detailed in the previous embodiments and will not be described again here.
[0155] See also Fig.11, which is a schematic diagram of the structure of a terminal provided in an embodiment of the present application. Fig.11 As shown, the terminal 900 includes a processor 901 and a memory 902. The processor 901 is electrically connected to the memory 902.
[0156] The processor 901 is the control center of the terminal 900 and may include one or more processing cores. The processor 901 uses various interfaces and lines to connect various parts of the entire terminal 900, and executes various functions and processes data of the terminal 900 by running or calling computer programs stored in the memory 902, and calling data stored in the memory 902, so as to control the terminal 900 as a whole. Optionally, the processor 901 can be implemented in at least one hardware form of digital signal processing (DSP), field programmable gate array (FPGA), and programmable logic array (PLA). The processor 901 may integrate one or a combination of CPU, graphics processing unit (GPU), modem, etc. Among them, the CPU mainly processes the operating system, user pages, and applications; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It is understandable that the above-mentioned modem may not be integrated into the processor 901, but may be implemented separately through a communication chip.
[0157] The memory 902 may be used to store software programs and modules, and the processor 901 executes various functional applications and data processing by running computer programs and modules stored in the memory 902. The memory 902 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, a computer program required for at least one function, etc.; the data storage area may store data created according to the use of the terminal 900, etc.
[0158] In addition, the memory 902 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage devices. Accordingly, the memory 902 may also include a memory controller to provide the processor 901 with access to the memory 902.
[0159] In this embodiment, the terminal 900 includes a trusted execution environment, which stores a root certificate. The memory 902 is used to store executable program code; the processor 901 is used to call and run the executable program code from the memory 902, so that the terminal 900 implements various functions, as follows:
[0160] Obtain a firmware upgrade verification package, wherein the firmware upgrade verification package is composed of a firmware upgrade package and a first encrypted data block, the firmware upgrade package is provided with a derived certificate, and the first encrypted data block is obtained by encrypting a first verification value based on the derived certificate;
[0161] Compare the volume of the firmware upgrade verification package with the available storage space of the trusted execution environment to obtain a comparison result;
[0162] Based on the comparison result, extracting the second verification value, the derived certificate and the first encrypted data block of the firmware upgrade package from the firmware upgrade verification package to the trusted execution environment;
[0163] In the trusted execution environment, verification is performed based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block to obtain a verification result of the firmware upgrade package.
[0164] Optionally, when the processor 901 executes the comparison result and extracts the second verification value, the derived certificate and the first encrypted data block of the firmware upgrade package from the firmware upgrade verification package to the trusted execution environment, it specifically performs the following steps: if the comparison result indicates that the volume of the firmware upgrade verification package is less than or equal to the available storage space of the trusted execution environment, the firmware upgrade verification package is transmitted to the trusted execution environment; in the trusted execution environment, the firmware upgrade verification package is extracted to obtain the firmware upgrade package, the derived certificate, the first encrypted data block, and the hash calculation is performed on the firmware upgrade package to obtain the second verification value of the firmware upgrade package.
[0165] Optionally, when the processor 901 extracts the second verification value, the derived certificate and the first encrypted data block of the firmware upgrade package from the firmware upgrade verification package to the trusted execution environment based on the comparison result, the processor 901 specifically performs the following steps: if the comparison result indicates that the volume of the firmware upgrade verification package is larger than the available storage space of the trusted execution environment, then outside the trusted execution environment, the firmware upgrade verification package is extracted to obtain the firmware upgrade package, the target component containing the derived certificate in the firmware upgrade package, the first encrypted data block, and a hash calculation is performed on the firmware upgrade package to obtain the second verification value of the firmware upgrade package; the second verification value of the firmware upgrade package is transmitted to the trusted execution environment; the target component and the first encrypted data block are transmitted to the trusted execution environment; and in the trusted execution environment, the target component is extracted to obtain the derived certificate.
[0166] Optionally, when executing to transmit the second verification value of the firmware upgrade package to the trusted execution environment, the processor 901 specifically performs: encrypting the second verification value of the firmware upgrade package based on a preset encryption key to obtain a second encrypted data block; transmitting the second encrypted data block to the trusted execution environment; and in the trusted execution environment, decrypting the second encrypted data block based on a preset decryption key to obtain the second verification value of the firmware upgrade package.
[0167] Optionally, when the processor 901 is executed in a trusted execution environment and performs verification based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block to obtain the verification result of the firmware upgrade package, the processor 901 specifically executes: in the trusted execution environment, performing a certificate chain verification based on the root certificate and the derived certificate to obtain a certificate chain verification result of the firmware upgrade package; decrypting the first encrypted data block according to the derived certificate to obtain a first verification value; performing a verification value verification based on the first verification value and the second verification value to obtain a verification value verification result of the firmware upgrade package; and determining the verification result of the firmware upgrade package based on the certificate chain verification result of the firmware upgrade package and the verification value verification result of the firmware upgrade package.
[0168] Optionally, processor 901 may also execute: if the certificate chain verification result indicates that the firmware upgrade package has not passed the certificate chain verification, then pushing a first verification failure message to the display interface of the terminal, wherein the first verification failure message is used to indicate that the firmware upgrade package has not passed the certificate chain verification; if the verification value verification result indicates that the firmware upgrade package has not passed the verification value verification, then pushing a second verification failure message to the display interface of the terminal, wherein the second verification failure message is used to indicate that the firmware upgrade package has not passed the verification value verification.
[0169] Optionally, when executing in a trusted execution environment, the processor 901 performs verification based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block. After obtaining the verification result of the firmware upgrade package, the processor 901 specifically executes: if the verification result of the firmware upgrade package indicates that the firmware upgrade package has passed the verification, determining the target firmware corresponding to the firmware upgrade package in the firmware installed on the terminal; and upgrading the target firmware according to the firmware upgrade package.
[0170] The beneficial effects that can be achieved by this embodiment are detailed in the previous embodiments and will not be described again here.
[0171] It should be understood that the device provided in the embodiment of the present application is used to execute the above-mentioned firmware upgrade package verification method, and thus can achieve the same effect as the above-mentioned implementation method.
[0172] In the case of an integrated unit, the device may include a processing module and a storage module. When the device is applied to a terminal, the processing module may be used to control and manage the actions of the terminal. The storage module may be used to support the terminal to execute relevant program codes, etc.
[0173] The processing module may be a processor or a controller, which may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of digital signal processing (DSP) and a microprocessor, etc. The storage module may be a memory.
[0174] In addition, the device provided in the embodiment of the present application can specifically be a chip, component or module, and the chip may include a connected processor and memory; wherein the memory is used to store instructions, and when the processor calls and executes the instructions, the chip can execute a firmware upgrade package verification method provided in the above embodiment.
[0175] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program code. When the computer program code runs on a computer, the computer executes the above-mentioned related method steps to implement a firmware upgrade package verification method provided by the above-mentioned embodiment.
[0176] This embodiment also provides a computer program product. When the computer program product runs on a computer, the computer executes the above-mentioned related steps to implement a firmware upgrade package verification method provided by the above embodiment.
[0177] Among them, the device, computer-readable storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above, and will not be repeated here.
[0178] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0179] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0180] The above contents are only specific implementation methods of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A firmware upgrade package verification method, characterized in that: Applied to a terminal, the terminal includes a trusted execution environment, the trusted execution environment stores a root certificate, and the method includes: Obtain a firmware upgrade verification package, wherein the firmware upgrade verification package is composed of a firmware upgrade package and a first encrypted data block, the firmware upgrade package is provided with a derived certificate, and the first encrypted data block is obtained by encrypting a first verification value based on the derived certificate; Comparing the volume of the firmware upgrade verification package with the available storage space of the trusted execution environment to obtain a comparison result; Based on the comparison result, extracting the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block from the firmware upgrade verification package to the trusted execution environment; In the trusted execution environment, verification is performed based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block to obtain a verification result of the firmware upgrade package.
2. The method according to claim 1, characterized in that: The extracting, based on the comparison result, the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block from the firmware upgrade verification package to the trusted execution environment includes: If the comparison result indicates that the volume of the firmware upgrade verification package is less than or equal to the available storage space of the trusted execution environment, transmitting the firmware upgrade verification package to the trusted execution environment; In the trusted execution environment, the firmware upgrade verification package is extracted to obtain the firmware upgrade package, the derived certificate, and the first encrypted data block, and a hash calculation is performed on the firmware upgrade package to obtain a second verification value of the firmware upgrade package.
3. The method according to claim 1, characterized in that The extracting, based on the comparison result, the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block from the firmware upgrade verification package to the trusted execution environment includes: If the comparison result indicates that the volume of the firmware upgrade verification package is larger than the available storage space of the trusted execution environment, extracting the firmware upgrade verification package outside the trusted execution environment to obtain the firmware upgrade package, the target component of the derived certificate in the firmware upgrade package, and the first encrypted data block, and performing hash calculation on the firmware upgrade package to obtain a second verification value of the firmware upgrade package; transmitting a second verification value of the firmware upgrade package to the trusted execution environment; Transmitting the target component and the first encrypted data block to the trusted execution environment; In the trusted execution environment, the target component is extracted to obtain the derived certificate.
4. The method according to claim 3, characterized in that The transmitting the second verification value of the firmware upgrade package to the trusted execution environment includes: Encrypting the second verification value of the firmware upgrade package based on a preset encryption key to obtain a second encrypted data block; transmitting the second encrypted data block to the trusted execution environment; In the trusted execution environment, the second encrypted data block is decrypted based on a preset decryption key to obtain a second verification value of the firmware upgrade package.
5. The method according to claim 1, characterized in that The step of performing verification in the trusted execution environment based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block to obtain a verification result of the firmware upgrade package includes: In the trusted execution environment, performing a certificate chain verification based on the root certificate and the derived certificate to obtain a certificate chain verification result of the firmware upgrade package; decrypting the first encrypted data block according to the derived certificate to obtain the first verification value; Performing a check value check based on the first check value and the second check value to obtain a check value check result of the firmware upgrade package; A verification result of the firmware upgrade package is determined based on a certificate chain verification result of the firmware upgrade package and a verification value verification result of the firmware upgrade package.
6. The method according to claim 5, characterized in that The method further comprises: If the certificate chain verification result indicates that the firmware upgrade package fails to pass the certificate chain verification, first verification failure information is pushed to the display interface of the terminal, wherein the first verification failure information is used to indicate that the firmware upgrade package fails to pass the certificate chain verification; If the check value verification result indicates that the firmware upgrade package has not passed the check value verification, second check failure information is pushed to the display interface of the terminal, wherein the second check failure information is used to indicate that the firmware upgrade package has not passed the check value verification.
7. The method according to claim 1, characterized in that After performing verification in the trusted execution environment based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block to obtain a verification result of the firmware upgrade package, the method further includes: If the verification result of the firmware upgrade package indicates that the firmware upgrade package passes the verification, determining the target firmware corresponding to the firmware upgrade package in the firmware installed on the terminal; The target firmware is upgraded according to the firmware upgrade package.
8. A firmware upgrade package verification device, characterized in that: Applied to a terminal, the terminal includes a trusted execution environment, the trusted execution environment stores a root certificate, and the device includes: An acquisition unit, configured to acquire a firmware upgrade verification package, wherein the firmware upgrade verification package is composed of a firmware upgrade package and a first encrypted data block, the firmware upgrade package is provided with a derived certificate, and the first encrypted data block is obtained by encrypting a first verification value based on the derived certificate; A comparison unit, configured to compare the volume of the firmware upgrade verification package with the available storage space of the trusted execution environment to obtain a comparison result; an extracting unit, configured to extract, based on the comparison result, a second verification value of the firmware upgrade package, the derived certificate, and the first encrypted data block from the firmware upgrade verification package to the trusted execution environment; A verification unit is used to perform verification in the trusted execution environment based on the root certificate, the second verification value of the firmware upgrade package, the derived certificate and the first encrypted data block to obtain a verification result of the firmware upgrade package.
9. A terminal, characterized in that: include: A memory for storing executable program codes; A processor, configured to call and run the executable program code from the memory, so that the terminal executes the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program code, and when the computer program code is executed, the method according to any one of claims 1 to 7 is implemented.
