Upgrade package verification method and device, server and storage medium

By verifying the hash values of the streaming upgrade package header and hash table, the problem that traditional full-scale upgrade solutions cannot verify the streaming upgrade package is solved, and efficient subcontracted checksum security guarantee is achieved.

CN120449133APending Publication Date: 2025-08-08ANYSMART TECH CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510434815.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-08
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

The traditional full-scale upgrade solution cannot be applied to streaming upgrade solutions, and each subcontract of the upgrade package cannot be verified, resulting in the upgrade security not being guaranteed and the tampered subcontract cannot be located, and the verification process is long.

Method used

By verifying the package header of the upgraded upgrade package, obtain the hash table hash value, and streaming the subcontract download after the match is successful, comparing the subcontract hash value to confirm the integrity and security of the subcontract.

Benefits of technology

It realizes verification of each subcontract of the streaming upgrade package, improves verification efficiency, and can locate matching failed subcontracts to ensure the integrity and security of the upgrade package.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120449133A_ABST
    Figure CN120449133A_ABST
Patent Text Reader

Abstract

The invention discloses an upgrade package verification method and device, a server and a storage medium. The upgrade package verification method comprises the following steps: acquiring a packet header of a to-be-upgraded upgrade package; the packet header is verified, if verification succeeds, a hash value of a hash table carried in the packet header is obtained, the hash value of the hash table is the hash value of the hash table of the upgrade packet, and the hash value of each sub-packet of the upgrade packet is recorded in the hash table; obtaining a hash table, and matching the hash table hash value of the obtained hash table with the hash table hash value in the packet header; if the matching is successful, downloading the upgrade package in a streaming manner to obtain the current subpackage, and matching the subpackage hash value of the downloaded current subpackage with the subpackage hash value of the current subpackage in the hash table; and if the matching is successful, confirming that the current subpackage is not rewritten. According to the embodiment of the invention, whether the current sub-package is rewritten or not can be determined, the verification of the whole upgrade package is completed, the sub-package which fails in verification can be positioned, and the verification efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an upgrade package verification method, device, server, and storage medium. Background Art

[0002] Traditional full upgrade solutions usually require loading the entire upgrade package into memory at once, which places high demands on memory resources. Streaming upgrade solutions, on the other hand, use a block-by-block loading method, dividing the upgrade package into multiple sub-packages and loading them gradually. This is more adaptable to resource-constrained scenarios such as embedded systems. However, traditional full upgrade package verification methods are not suitable for streaming upgrade solutions because they cannot verify each sub-package of the upgrade package to complete the verification of the entire upgrade package. If the sub-package of the upgrade package is tampered with, the full upgrade package verification method may not be able to detect it, resulting in the upgrade still being successful. The upgrade security cannot be guaranteed, and the tampered sub-package cannot be located. The verification process is also relatively long.

[0003] Therefore, how to verify the upgrade package in the streaming upgrade scenario has become a technical problem that needs to be solved urgently in the industry. Summary of the Invention

[0004] Embodiments of the present application provide an upgrade package verification method, device, server, and storage medium.

[0005] On the one hand, an embodiment of the present application provides an upgrade package verification method, including:

[0006] Get the header of the upgrade package to be upgraded;

[0007] Verify the packet header, and if the packet header verification succeeds, obtain a hash value of a hash table carried in the packet header, where the hash value of the hash table is a hash value of a hash table of the upgrade package, where the hash table records a sub-packet hash value of each sub-packet of the upgrade package;

[0008] Obtaining the hash table, and matching the obtained hash value of the hash table with the hash value in the packet header;

[0009] If the match is successful, streaming download the upgrade package to obtain the current subpackage, and matching the subpackage hash value of the downloaded current subpackage with the subpackage hash value of the current subpackage in the hash table;

[0010] If the match is successful, it is confirmed that the current sub-packet has not been rewritten.

[0011] On the other hand, an embodiment of the present application further provides an upgrade package verification device, comprising:

[0012] An acquisition module is used to obtain the header of the upgrade package to be upgraded;

[0013] a verification module, configured to verify the packet header and, if the packet header verification succeeds, obtain a hash value of a hash table carried in the packet header, wherein the hash value of the hash table is a hash value of a hash table of the upgrade package, wherein the hash table records a sub-packet hash value of each sub-packet of the upgrade package;

[0014] A matching module, configured to obtain the hash table and match the obtained hash value of the hash table with the hash value of the hash table in the packet header;

[0015] a download module, configured to, if the match is successful, stream-download the upgrade package to obtain the current subpackage, and match the subpackage hash value of the downloaded current subpackage with the subpackage hash value of the current subpackage in the hash table;

[0016] A confirmation module is used to confirm that the current sub-package has not been rewritten when the match is successful. On the other hand, an embodiment of the present application further provides a server including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any of the upgrade package verification methods provided in the embodiments of the present application.

[0017] On the other hand, an embodiment of the present application further provides a computer-readable storage medium on which a computer program is stored. The computer program is loaded by a processor to execute the steps in any upgrade package verification method provided in the embodiment of the present application.

[0018] On the other hand, an embodiment of the present application also provides a computer program product, including a computer program or instructions, which, when executed by a processor, implements the steps of any upgrade package verification method provided in the embodiment of the present application.

[0019] The upgrade package verification method, device, server and storage medium provided in the embodiments of the present application verify the header of the upgrade package to be upgraded, and after the header verification is successful, further verify the obtained hash table through the hash value of the hash table carried in the header. When the hash table verification is successful, it can be determined that the sub-package hash value recorded in the hash table is correct; the sub-packages of the upgrade package are downloaded by streaming download, and the sub-package hash value of the current sub-package is matched with the sub-package hash value of the current sub-package in the hash table. According to the matching result, it can be determined whether the current sub-package is rewritten, thereby completing the verification of each sub-package of the upgrade package and completing the verification of the entire upgrade package; because each sub-package is matched and verified separately, when the sub-package matching fails, the sub-package that fails to match can be directly located, thereby improving the verification efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0021] Figure 1 This is one of the flowcharts of the upgrade package verification method provided in the embodiment of the present application;

[0022] Figure 2 1 is a flow chart of the third stage of verification provided by an embodiment of the present application;

[0023] Figure 3 This is a flow chart of the first stage of signing provided by an embodiment of the present application;

[0024] Figure 4 This is a flow chart of the first stage of verification provided by an embodiment of the present application;

[0025] Figure 5 This is a schematic diagram of the process of obtaining a hash value from a hash table provided in an embodiment of the present application;

[0026] Figure 6 This is the second flow chart of the upgrade package verification method provided in the embodiment of the present application;

[0027] Figure 7 Schematic diagram of the structure of the upgrade package verification device provided in an embodiment of the present application;

[0028] Figure 8 It is a structural diagram of the server provided in an embodiment of the present application. DETAILED DESCRIPTION

[0029] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.

[0030] In the following description, the specific embodiments of the present application will be described with reference to steps and symbols performed by one or more computers, unless otherwise stated. Therefore, these steps and operations will be mentioned several times as being performed by a computer, and the computer execution referred to in this application includes the operation of a computer processing unit by an electronic signal representing data in a structured form. This operation converts the data or maintains it at a location in the computer's memory system, which can be reconfigured or otherwise change the operation of the computer in a manner familiar to testers in the field. The data structure in which the data is maintained is a physical location in the memory, which has specific characteristics defined by the data format. However, the principles of the present application are described in the above text, which does not represent a limitation, and testers in the field will understand that the various steps and operations described below can also be implemented in hardware.

[0031] The terms "module" or "unit" used in this application can be considered as software objects executed on the computing system. The various components, modules, engines, and services described in this application can be considered as implementation objects on the computing system. While the devices and methods described in this application are preferably implemented in software, they can also be implemented in hardware and are within the scope of protection of this application.

[0032] It will be understood by those skilled in the art that, unless expressly stated otherwise, the singular forms "a", "an", "said" and "the" used herein may also include the plural forms. It should be further understood that the term "comprising" used in the specification of the present application refers to the presence of the features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof. It should be understood that when we refer to an element as being "connected" or "coupled" to another element, it may be directly connected or coupled to the other element, or there may be intermediate elements. In addition, "connected" or "coupled" as used herein may include wireless connections or wireless couplings. The term "and / or" used herein includes all or any units and all combinations of one or more associated listed items.

[0033] The upgrade package verification method provided in the embodiment of the present application is applicable to a terminal, which may be various electronic devices having a display screen and supporting web browsing, including but not limited to servers, smart phones, tablet computers, laptop computers, and desktop computers.

[0034] Figure 1 This is one of the flow charts of the upgrade package verification method provided in the embodiment of the present application, such as Figure 1 As shown, the method includes step 110, step 120, step 130, step 140 and step 150. The steps of the method flow are only a possible implementation of the present application.

[0035] Step 110: Obtain the header of the upgrade package to be upgraded.

[0036] Specifically, the upgrade package verification method provided in the embodiments of the present application is implemented by an upgrade package verification device, which can be a hardware device independently provided in the terminal or a software program running in the terminal. For example, when the terminal is a mobile phone, the upgrade package verification device can be embodied as an application such as upgrade software in the mobile phone.

[0037] The upgrade package to be upgraded refers to a data package or program that includes firmware or software update content and is used to upgrade the firmware or software of a device.

[0038] The header is part of the upgrade package and includes important metadata information about the entire upgrade package, such as signature information, hash table hash value, and sub-package size, which is used to verify and describe the content of the upgrade package.

[0039] Data integrity refers to the fact that data has not been tampered with or damaged during storage, transmission, or processing. The purpose of ensuring integrity is to ensure that data remains consistent from source to destination, without being maliciously modified or altered due to errors.

[0040] Data security refers to protecting data from unauthorized access, tampering, disclosure, or destruction. The goal of security is to ensure that only authorized entities can access and use data, and that data is protected during transmission and storage.

[0041] The purpose of obtaining the header of the upgrade package to be upgraded is to verify the integrity and security of the header.

[0042] After obtaining the header of the upgrade package, the first phase of verification may be started. The first phase of verification may include verifying the integrity and security of the header through a certificate chain and a digital signature.

[0043] Digital signature is a security mechanism based on asymmetric key technology, used to protect the integrity of data and verify the authenticity of data. The specific verification steps are as follows:

[0044] Signing process: Use the private key to sign the data to be protected (such as the header hash value of the packet header) to generate a digital signature. This signature contains the hash value of the data to be protected and other information to ensure the integrity and authenticity of the data to be protected.

[0045] Verification process: The receiver uses the sender's public key to verify the signature. By comparing the hash value in the signature with the received hash value of the protected data, it can be determined whether the protected data has been tampered with. If the hash values match, the protected data is intact and has not been tampered with; otherwise, the protected data may have been tampered with.

[0046] Digital Certificate: A digital certificate contains not only the public key information, but also the issuing authority, certificate version number, and other information. The certificate is issued by a trusted third-party organization to ensure the authenticity and credibility of the public key.

[0047] Trust anchor: When verifying a certificate, a trust anchor is required, that is, an absolutely trustworthy root certificate. By verifying each certificate in the certificate chain and ultimately tracing back to the root certificate, the credibility of the entire certificate chain is ensured.

[0048] Secure Boot: When secure boot is enabled, the chip writes the root certificate value in the certificate chain to the fuse area. Writing to the fuse means that once the data is written, it cannot be recovered or changed.

[0049] Root certificate verification: By comparing the hash value of the root certificate in the certificate chain with the root certificate hash value stored in FUSE, the authenticity of the root certificate can be ensured. If the two match, the root certificate is authentic, and thus the entire certificate chain is also authentic.

[0050] Therefore, digital signatures ensure data integrity and authenticity through private key signing and public key verification, combined with digital certificates and trust anchors. In the secure boot mechanism, the security of the protected data is further guaranteed by writing the root certificate into the fuse area and verifying its hash value.

[0051] Step 120: Verify the packet header, and if the packet header verification is successful, obtain the hash value of the hash table carried in the packet header, where the hash value is the hash value of the hash table of the upgrade package, and the hash table records the sub-packet hash value of each sub-packet of the upgrade package.

[0052] Specifically, the hash table (subpack_hash_table) is a data structure that records the hash value of each subpacket in the upgrade package and is used to verify the integrity and correctness of each subpacket during the download process.

[0053] A hash value is a fixed-length string or number generated by processing input data using a hash algorithm. For example, a hash table hash value is the hash value of the hash table obtained by processing the data in the hash table using a hash algorithm. A subpacket hash value is the hash value of a subpacket obtained by processing the subpacket data using a hash algorithm. A subpacket is an independent data unit within an upgrade package, obtained by splitting the upgrade package into multiple smaller parts.

[0054] A successful header verification indicates that the content recorded in the header is authentic. The hash value in the hash table is obtained from the header. The sub-packet hash value of each sub-packet in the upgrade package can be calculated in advance using a hash algorithm. Each sub-packet is then associated with its sub-packet hash value and stored in the hash table.

[0055] If the packet header verification fails, it indicates that the packet header may have been tampered with, and the upgrade should be stopped. You can also pause the upgrade and re-obtain the packet header and re-verify it. If the verification still fails, stop the upgrade and find the cause of the verification failure.

[0056] Step 130: Obtain the hash table, and match the obtained hash value of the hash table with the hash value in the packet header;

[0057] Step 140: If the match is successful, stream the upgrade package to obtain the current subpackage, and match the subpackage hash value of the downloaded current subpackage with the subpackage hash value of the current subpackage in the hash table.

[0058] Specifically, streaming download is a data transmission method that allows a device to process data while downloading it, rather than waiting for the entire file to be downloaded before starting processing. Streaming download is suitable for large files or data that needs to be processed step by step.

[0059] The upgrade package's hash table records the hash values of each sub-package of the upgrade package. After downloading the upgrade package's hash table, you can start the second phase of verification to verify the hash table to ensure its integrity and security.

[0060] The second stage of verification specifically includes: calculating the hash value of the downloaded hash table through a hash algorithm to obtain a hash table hash value, and matching the hash table hash value of the downloaded hash table with the hash table hash value carried in the packet header that has successfully been verified.

[0061] If the match is successful, the verification is successful, indicating that the sub-packet hash value of each sub-packet recorded in the hash table is credible, and the third stage of verification can be started to verify the streaming downloaded sub-packets.

[0062] If the match fails, which means verification failed and the hash table may have been tampered with, the upgrade should be stopped. Alternatively, the upgrade can be paused and the hash table can be retrieved and re-matched. If the match still fails, the upgrade should be stopped and the cause of the match failure should be investigated.

[0063] Figure 2 This is a flow chart of the third stage of verification provided by the embodiment of the present application, such as Figure 2As shown, you can start downloading the subpackages of the upgrade package in a streaming download mode. Each time you download a subpackage, use that subpackage as the current subpackage, calculate the subpacket hash value (subpack_hash) of the current subpackage through a hash algorithm, and compare the subpacket hash value with the subpacket hash value of the current subpackage stored in the hash table.

[0064] Subpackages can be downloaded to random access memory (RAM) via the protocol. Since the entire upgrade package header is downloaded during the first download, which includes the hash value in the hash table, and the integrity and security of the header and hash table are ensured through the first and second phases of verification, the subpackage can be verified by simply comparing the hash value of the currently downloaded subpackage with the hash value in the hash table.

[0065] Step 150: If the match is successful, confirm that the current sub-packet has not been rewritten.

[0066] Specifically, if the subpackage hash value of the current subpackage being downloaded matches the subpackage hash value of the current subpackage in the hash table, that is, the subpackage hash value of the current subpackage is the same as the subpackage hash value of the current subpackage in the hash table, the match is confirmed to be successful. A successful match means that the verification is successful, indicating that the current subpackage has not been rewritten. The current subpackage can be written to the flash memory, and the next subpackage can be downloaded, and the same subpackage verification process will be executed.

[0067] If the subpackage hash value of the downloaded current subpackage does not match the subpackage hash value of the current subpackage in the hash table, that is, the subpackage hash value of the current subpackage is different from the subpackage hash value of the current subpackage in the hash table, the match is confirmed to have failed. A match failure means a verification failure, indicating that the current subpackage may have been tampered with, and the upgrade is stopped. You can also pause the upgrade and re-obtain the current subpackage for re-matching. If the match still fails, stop the upgrade and find the cause of the match failure.

[0068] If each subpackage is verified successfully, the upgrade is completed, which ensures that all downloaded subpackages are complete and safe.

[0069] The upgrade package verification method provided in the embodiment of the present application verifies the header of the upgrade package to be upgraded, and after the header verification is successful, further verifies the downloaded hash table through the hash value of the hash table carried in the header. When the hash table verification is successful, it can be determined that the sub-package hash value recorded in the hash table is correct; the sub-packages of the upgrade package are downloaded by streaming download, and the sub-package hash value of the current sub-package is matched with the sub-package hash value of the current sub-package in the hash table. According to the matching result, it can be determined whether the current sub-package is rewritten, so that the verification of each sub-package of the upgrade package can be completed, and the verification of the entire upgrade package can be completed; because each sub-package is matched and verified separately, when the sub-package matching fails, the sub-package that fails to match can be directly located, thereby improving the verification efficiency.

[0070] It should be noted that the method steps are only one possible implementation of the present application. Each implementation method of the present application can be freely combined, the order can be changed, or it can be executed separately, and does not need to rely on or depend on a fixed execution order.

[0071] In some embodiments, before step 110, the method further includes:

[0072] Obtaining the packet header hash value based on a hash algorithm;

[0073] The packet header hash value is digitally signed, and the digital signature and the certificate chain are appended to the packet header.

[0074] Specifically, you can calculate the header hash value of the upgrade package and digitally sign the header hash value, then add the relevant information to the header to prepare for subsequent verification. The signing process is a pre-processing process for the upgrade package and is performed during the packaging process.

[0075] Figure 3 This is a flow chart of the first stage of signature provided by the embodiment of the present application, such as Figure 3 As shown in the figure, the header hash value of the upgrade package header (pacakage_header) is digitally signed, and the signature information and certificate chain are attached to the end of the upgrade package header.

[0076] The embodiment of the present application adds new content to the streaming upgrade protocol, including signature algorithm type, hash algorithm type, header signature and certificate chain, etc.

[0077] The upgrade package verification method provided in the embodiment of the present application calculates the header hash value of the packet header, digitally signs the header hash value and attaches relevant information to the packet header, thereby realizing packet header verification and improving the verification efficiency of the packet header verification.

[0078] In some embodiments, step 120 includes:

[0079] Parsing the packet header to obtain a field indicating the size of the packet header;

[0080] Reading the header data of the packet header based on the field;

[0081] Extracting the certificate chain and digital signature of the packet header from the packet header data;

[0082] The certificate chain and the digital signature are verified.

[0083] The verifying the certificate chain and the digital signature includes:

[0084] Verifying the certificate chain based on the root certificate and key; and

[0085] The digital signature is verified based on the header hash value in the digital signature.

[0086] Specifically, Figure 4 This is a flow chart of the first stage of verification provided by the embodiment of the present application, such as Figure 4 As shown, the first stage of verification includes verifying the packet header, including parsing the packet header data of the packet header. There is a field in the packet header data that identifies the packet header size. According to the read packet header size field, the remaining packet header data continues to be read until the entire packet header data is completely read into the memory.

[0087] Extract the certificate chain from the packet header data. The certificate chain consists of multiple certificates and is used to establish a chain of trust. Load the root certificate from local storage or another trusted source. Use the local root certificate to verify each certificate in the chain, ensuring that each certificate is signed by its signer and has not been tampered with or revoked. Check that the certificate is within its validity period. Confirm that the certificate is used as intended.

[0088] Extract the digital signature and the hash algorithm used from the packet header. Calculate the header hash value using the same hash algorithm on the original data of the packet header (excluding the signature). Verify the extracted signature using the public key of the last certificate in the certificate chain to ensure that the calculated header hash value matches the signature.

[0089] If the signature verification passes, it indicates that the header data is intact and has not been tampered with, and the subsequent upgrade process can continue. If the signature verification fails, it indicates that the header data may have been tampered with or damaged, and the upgrade process is stopped.

[0090] The upgrade package verification method provided in the embodiment of the present application can verify the packet header through digital signature and certificate chain, thereby improving the accuracy of verification.

[0091] In some embodiments, before step 110, the method further includes:

[0092] Splitting the image to be upgraded in the upgrade package into multiple subpackages;

[0093] Generate a subpacket hash value for each of the subpackets based on a hash algorithm;

[0094] The hash table is generated based on each of the sub-packet hash values.

[0095] Specifically, the image to be upgraded refers to the data package or program that needs to be downloaded and written to the device storage via streaming upgrade. The image to be upgraded is part of the upgrade package and is the main body of the firmware or software update content.

[0096] The image header (image_header) is a field in the header of the upgrade package, which includes relevant information about the image to be upgraded.

[0097] Figure 5 This is a flow chart of obtaining the hash value of the hash table provided by the embodiment of the present application. Figure 5 As shown, the image to be upgraded is divided into subpacket sizes and a hash table is generated using a hash algorithm. The hash table stores the subpacket hash values of each subpacket downloaded during the upgrade process. The hash value of the hash table is calculated to obtain the hash value of the hash table (subpack_hash_table_hash).

[0098] The upgrade package verification method provided in the embodiment of the present application further calculates the hash table hash value of the hash table after obtaining the hash table, so that the hash table can be verified by the hash table hash value, thereby ensuring the credibility of the hash table and improving the credibility of the sub-package verification.

[0099] In some embodiments, when the packet header verification fails, the hash value matching of the hash table fails, or the sub-packet hash value matching of the current sub-packet fails, the upgrade is stopped and a prompt message indicating the stop of the upgrade is generated.

[0100] Specifically, the upgrade stop prompt is a message displayed by the terminal when a verification or matching failure is detected during the upgrade process. This prompt is to inform relevant personnel that the upgrade failed to complete successfully. The prompt information may include possible reasons for the verification or matching failure and subsequent action suggestions.

[0101] If the packet header verification fails, the hash table hash value fails to match, or the sub-packet hash value of the current sub-packet fails to match, it indicates that the current verification / matching data may have been tampered with. Continuing the upgrade may introduce security risks. Therefore, when any data verification / match fails, the upgrade process is immediately stopped and a prompt message is generated to stop the upgrade, thereby reducing the upgrade risk. Data transmission can be terminated in time, freeing up allocated resources to ensure system stability.

[0102] Figure 6This is the second flow chart of the upgrade package verification method provided in the embodiment of the present application, such as Figure 6 As shown, "Yes" indicates successful verification / matching, and "No" indicates failed verification. If the packet header verification fails, the hash table hash value fails to match, or the sub-packet hash value of the current sub-packet fails to match, the upgrade will be stopped.

[0103] The upgrade package verification method provided in the embodiment of the present application will stop the upgrade when the packet header verification fails, the hash table hash value matches fail, or the sub-packet hash value matches of the current sub-packet fail, so as to prevent tampered data from posing a security risk to the upgrade and improve the security of the upgrade.

[0104] In some embodiments, if the subpackage hash value of the current subpackage fails to match, pausing the upgrade and downloading a new current subpackage again;

[0105] Matching the sub-package hash value of the new current sub-package with the sub-package hash value of the new current sub-package in the hash table;

[0106] If the match is successful, continue the upgrade.

[0107] Specifically, the failure to match the subpackage hash value of the current subpackage may be caused by network abnormalities or matching abnormalities, and is not necessarily caused by tampering with the current subpackage. Therefore, when the subpackage hash value of the current subpackage fails to match, you can pause the upgrade first, then re-download the new current subpackage, and match the subpackage hash value of the new current subpackage with the subpackage hash value of the new current subpackage in the hash table again. If the match is successful at this time, you can continue to upgrade; if the match fails at this time, stop the upgrade.

[0108] You can obtain relevant information about the sub-packet that currently fails to match, such as locating the specific tampered sub-packet index.

[0109] Similarly, packet header verification failure or hash table hash value match failure may also be caused by network anomalies or verification anomalies. Therefore, if a verification / match fails, you can pause the upgrade, then re-download the new packet header or hash table, and verify / match the new packet header or hash table again. If the verification / match is successful, you can continue the upgrade; if the verification / match fails, stop the upgrade.

[0110] The upgrade package verification method provided in the embodiment of the present application re-downloads a new sub-package and re-matches it when the sub-package hash value matches fail, and continues the upgrade when the re-match succeeds, which can improve the upgrade efficiency.

[0111] To facilitate better implementation of the upgrade package verification method provided in the embodiment of the present application, the embodiment of the present application also provides a device based on the above upgrade package verification method. The meanings of the terms are the same as those in the above upgrade package verification method. For specific implementation details, please refer to the description in the method embodiment.

[0112] See also Figure 7 , Figure 7 This is a schematic diagram of the structure of the upgrade package verification device provided in an embodiment of the present application, wherein the upgrade package verification device may include an acquisition module 710, a verification module 720, a matching module 730, a download module 740 and a confirmation module 750, wherein:

[0113] An acquisition module 710 is configured to acquire a header of an upgrade package to be upgraded;

[0114] Verification module 720, configured to verify the packet header and, if the packet header verification succeeds, obtain a hash value of a hash table carried in the packet header, where the hash value is a hash value of a hash table of the upgrade package, where the hash table records a sub-packet hash value of each sub-packet of the upgrade package;

[0115] A matching module 730 is configured to obtain the hash table and match the obtained hash value of the hash table with the hash value of the hash table in the packet header;

[0116] A download module 740 is configured to, if the match succeeds, stream-download the upgrade package to obtain a current subpackage, and match the subpackage hash value of the downloaded current subpackage with the subpackage hash value of the current subpackage in the hash table;

[0117] The confirmation module 750 is used to confirm that the current sub-package has not been rewritten when the match is successful. In some embodiments, the upgrade package verification device also includes a generation module, which is specifically used to:

[0118] Splitting the image to be upgraded in the upgrade package into multiple subpackages;

[0119] Generate a subpacket hash value for each of the subpackets based on a hash algorithm;

[0120] The hash table is generated based on each of the sub-packet hash values.

[0121] In some embodiments, the verification module 720 is specifically configured to:

[0122] Parsing the packet header to obtain a field indicating the size of the packet header;

[0123] Reading the header data of the packet header based on the field;

[0124] Extracting the certificate chain and digital signature of the packet header from the packet header data;

[0125] The certificate chain and the digital signature are verified.

[0126] In some embodiments, verifying the certificate chain and the digital signature includes:

[0127] Verifying the certificate chain based on the root certificate and key; and

[0128] The digital signature is verified based on the header hash value in the digital signature.

[0129] In some embodiments, the upgrade package verification device further includes a signature module, which is specifically configured to:

[0130] Obtaining the packet header hash value based on a hash algorithm;

[0131] The packet header hash value is digitally signed, and the digital signature and the certificate chain are appended to the packet header.

[0132] In some embodiments, the upgrade package verification device further includes a stop module, which is specifically configured to:

[0133] In the case where the packet header verification fails, the hash value matching of the hash table fails, or the sub-packet hash value matching of the current sub-packet fails, the upgrade is stopped and a prompt message indicating the stop of the upgrade is generated.

[0134] In some embodiments, the upgrade package verification device further includes a pause module, which is specifically configured to:

[0135] If the subpackage hash value of the current subpackage fails to match, suspend the upgrade and download a new current subpackage again;

[0136] Matching the sub-package hash value of the new current sub-package with the sub-package hash value of the new current sub-package in the hash table;

[0137] If the match is successful, continue the upgrade.

[0138] It should be noted here that the upgrade package verification device provided in the embodiment of the present application can implement all the method steps implemented in the above-mentioned upgrade package verification method embodiment, and can achieve the same technical effect. The parts and beneficial effects of this embodiment that are the same as those in the method embodiment will not be described in detail here.

[0139] The embodiment of the present application also provides a server, such as Figure 8 As shown, it shows a schematic diagram of the structure of the server involved in the embodiment of the present application, specifically:

[0140] The server may include one or more processing core processors 810, one or more computer-readable storage media memories 820, a power supply 830, an input unit 840, and other components. Those skilled in the art will appreciate that Figure 8 The server structure shown in the figure does not constitute a limitation to the server, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.

[0141] in:

[0142] Processor 810 is the server's control center, connecting various components of the server using various interfaces and circuits. By running or executing software programs and / or modules stored in memory 820 and accessing data stored in memory 820, it performs various server functions and processes data, thereby providing overall server monitoring. Optionally, processor 810 may include one or more processing cores; preferably, processor 810 may integrate an application processor and a modem processor, with the application processor primarily handling operations such as storage media, user interfaces, and application programs, while the modem processor primarily handles wireless communications. It is understood that the modem processor may not be integrated into processor 810.

[0143] The memory 820 can be used to store software programs and modules. The processor 810 executes various functional applications and data processing by running the software programs and modules stored in the memory 820. The memory 820 may mainly include a program storage area and a data storage area, wherein the program storage area may store operating storage media, applications required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the server, etc. In addition, the memory 820 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 device. Accordingly, the memory 820 may also include a memory controller to provide the processor 810 with access to the memory 820.

[0144] The server also includes a power supply 830 for supplying power to various components. Preferably, the power supply 830 can be logically connected to the processor 810 via a power management storage medium, thereby enabling management of charging, discharging, and power consumption through the power management storage medium. The power supply 830 can also include one or more DC or AC power supplies, a recharge storage medium, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.

[0145] The server may further include an input unit 840, which may be configured to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.

[0146] Although not shown, the server may further include a display unit, etc., which will not be described in detail here. Specifically, in this embodiment, the processor 810 in the server will load the executable files corresponding to one or more application processes into the memory 820 according to the following instructions, and the processor 810 will run the application stored in the memory 820 to implement various functions as follows:

[0147] Get the header of the upgrade package to be upgraded;

[0148] Verify the packet header, and if the packet header verification succeeds, obtain a hash value of a hash table carried in the packet header, where the hash value of the hash table is a hash value of a hash table of the upgrade package, where the hash table records a sub-packet hash value of each sub-packet of the upgrade package;

[0149] Obtaining the hash table, and matching the obtained hash value of the hash table with the hash value in the packet header;

[0150] If the match is successful, streaming download the upgrade package to obtain the current subpackage, and matching the subpackage hash value of the downloaded current subpackage with the subpackage hash value of the current subpackage in the hash table;

[0151] If the match is successful, it is confirmed that the current sub-packet has not been rewritten.

[0152] Those skilled in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be accomplished by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.

[0153] To this end, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which is loaded by a processor to execute the steps of any of the upgrade package verification methods provided in the embodiments of the present application. For example, the computer program loaded by the processor may execute the following steps:

[0154] Get the header of the upgrade package to be upgraded;

[0155] Verify the packet header, and if the packet header verification succeeds, obtain a hash value of a hash table carried in the packet header, where the hash value of the hash table is a hash value of a hash table of the upgrade package, where the hash table records a sub-packet hash value of each sub-packet of the upgrade package;

[0156] Obtaining the hash table, and matching the obtained hash value of the hash table with the hash value in the packet header;

[0157] If the match is successful, streaming download the upgrade package to obtain the current subpackage, and matching the subpackage hash value of the downloaded current subpackage with the subpackage hash value of the current subpackage in the hash table;

[0158] If the match is successful, it is confirmed that the current sub-packet has not been rewritten.

[0159] The specific implementation of the above operations / steps can be found in the previous embodiments and will not be repeated here.

[0160] The computer-readable storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0161] Since the computer program stored in the computer-readable storage medium can execute the steps in any upgrade package verification method provided in the embodiments of the present application, the beneficial effects that can be achieved by any upgrade package verification method provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.

[0162] The present application also provides a computer program product or computer program, which includes computer instructions stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the electronic device to perform the methods provided in various optional implementations of the above embodiments.

[0163] The above is a detailed introduction to the upgrade package verification method, device, server and storage medium provided in the embodiments of the present application. Specific examples are used in this application to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, based on the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

Claims

1. A method for verifying an upgrade package, characterized in that: include: Get the header of the upgrade package to be upgraded; Verify the packet header, and if the packet header verification succeeds, obtain a hash value of a hash table carried in the packet header, where the hash value of the hash table is a hash value of a hash table of the upgrade package, where the hash table records a sub-packet hash value of each sub-packet of the upgrade package; Obtaining the hash table, and matching the obtained hash value of the hash table with the hash value in the packet header; If the match is successful, streaming download the upgrade package to obtain the current subpackage, and matching the subpackage hash value of the downloaded current subpackage with the subpackage hash value of the current subpackage in the hash table; If the match is successful, it is confirmed that the current sub-packet has not been rewritten.

2. The upgrade package verification method according to claim 1, characterized in that: Before obtaining the header of the upgrade package to be upgraded, the method further includes: Splitting the image to be upgraded in the upgrade package into multiple subpackages; Generate a subpacket hash value for each of the subpackets based on a hash algorithm; The hash table is generated based on each of the sub-packet hash values.

3. The upgrade package verification method according to claim 1, characterized in that: The checking of the packet header includes: Parsing the packet header to obtain a field indicating the size of the packet header; Reading the header data of the packet header based on the field; Extracting the certificate chain and digital signature of the packet header from the packet header data; The certificate chain and the digital signature are verified.

4. The upgrade package verification method according to claim 3, characterized in that: The verifying the certificate chain and the digital signature includes: Verifying the certificate chain based on the root certificate and key; and The digital signature is verified based on the header hash value in the digital signature.

5. The upgrade package verification method according to claim 4, characterized in that: Before verifying the certificate chain based on the root certificate and the key, the method further includes: Obtaining the packet header hash value based on a hash algorithm; The packet header hash value is digitally signed, and the digital signature and the certificate chain are appended to the packet header.

6. The upgrade package verification method according to any one of claims 1 to 5, characterized in that: In the case where the packet header verification fails, the hash value matching of the hash table fails, or the sub-packet hash value matching of the current sub-packet fails, the upgrade is stopped and a prompt message indicating the stop of the upgrade is generated.

7. The upgrade package verification method according to any one of claims 1 to 5, characterized in that: If the subpackage hash value of the current subpackage fails to match, suspend the upgrade and download a new current subpackage again; Matching the sub-package hash value of the new current sub-package with the sub-package hash value of the new current sub-package in the hash table; If the match is successful, continue the upgrade.

8. An upgrade package verification device, characterized in that: include: An acquisition module is used to obtain the header of the upgrade package to be upgraded; a verification module, configured to verify the packet header and, if the packet header verification succeeds, obtain a hash value of a hash table carried in the packet header, wherein the hash value of the hash table is a hash value of a hash table of the upgrade package, wherein the hash table records a sub-packet hash value of each sub-packet of the upgrade package; A matching module, configured to obtain the hash table and match the obtained hash value of the hash table with the hash value of the hash table in the packet header; a download module, configured to, if the match is successful, stream-download the upgrade package to obtain the current subpackage, and match the subpackage hash value of the downloaded current subpackage with the subpackage hash value of the current subpackage in the hash table; The confirmation module is used to confirm that the current sub-packet has not been rewritten when the matching is successful.

9. A server, characterized in that: It includes a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the steps in the upgrade package verification method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that A computer program is stored thereon, and the computer program is loaded by a processor to execute the steps in the upgrade package verification method according to any one of claims 1 to 7.

Citation Information

Cited By

  • USB flash disk firmware security upgrading method and device and storage medium

    CN120744941A