WO2024082560A1 - 固件升级方法、设备、服务器、终端设备及存储介质 - Google Patents

固件升级方法、设备、服务器、终端设备及存储介质 Download PDF

Info

Publication number
WO2024082560A1
WO2024082560A1 PCT/CN2023/085613 CN2023085613W WO2024082560A1 WO 2024082560 A1 WO2024082560 A1 WO 2024082560A1 CN 2023085613 W CN2023085613 W CN 2023085613W WO 2024082560 A1 WO2024082560 A1 WO 2024082560A1
Authority
WO
WIPO (PCT)
Prior art keywords
sub
upgrade
packages
terminal device
upgrade package
Prior art date
Application number
PCT/CN2023/085613
Other languages
English (en)
French (fr)
Inventor
张榕佐
赵凯
关红涛
李涛
Original Assignee
京东方科技集团股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 京东方科技集团股份有限公司 filed Critical 京东方科技集团股份有限公司
Publication of WO2024082560A1 publication Critical patent/WO2024082560A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/50Monitoring users, programs or devices to maintain the integrity of platforms, e.g. of processors, firmware or operating systems
    • G06F21/57Certifying or maintaining trusted computer platforms, e.g. secure boots or power-downs, version controls, system software checks, secure updates or assessing vulnerabilities
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • GPHYSICS
    • G16INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
    • G16YINFORMATION AND COMMUNICATION TECHNOLOGY SPECIALLY ADAPTED FOR THE INTERNET OF THINGS [IoT]
    • G16Y30/00IoT infrastructure
    • G16Y30/10Security thereof

Definitions

  • the present invention relates to the technical field of firmware upgrade, and in particular to a firmware upgrade method, device, server, terminal device and storage medium.
  • IoT Internet of Things
  • the present invention provides a firmware upgrade method, device, server, terminal device and storage medium, which can effectively avoid security risks in the firmware upgrade process.
  • a firmware upgrade method applied to a server side includes: obtaining a target firmware upgrade package; receiving an identification code of a target terminal device; splitting the target firmware upgrade package into sub-upgrade packages based on the identification code of the target terminal device; storing the sub-upgrade packages and/or sending the sub-upgrade packages to the target terminal device.
  • the firmware upgrade method applied to the server side also includes obtaining the size of the sub-upgrade package through the identification code of the target terminal device, and determining the number of split sub-upgrade packages based on the size of the sub-upgrade package.
  • the firmware upgrade method applied to the server side also includes determining a download address for the target terminal device to download the sub-upgrade package based on the identification code and the default modifiable address of the sub-upgrade package.
  • the firmware upgrade method applied to the server side also includes obtaining the sequence identification of the sub-upgrade package through the identification code of the target terminal device, determining whether to change the sequence of the sub-upgrade packages based on the sequence identification of the sub-upgrade package, in response to determining not to change the sequence of the sub-upgrade packages, numbering the sub-upgrade packages according to the initial sequence of the sub-upgrade packages, in response to determining to change the sequence of the sub-upgrade packages, changing the sequence of the sub-upgrade packages, and numbering the sub-upgrade packages according to the changed sequence of the sub-upgrade packages.
  • each of the sub-upgrade packages includes a sub-upgrade package header, and the sub-upgrade package header includes the serial number of the sub-upgrade package.
  • the sub-upgrade package header also includes at least one of an identification code of the target terminal device and the number of sub-upgrade packages split from the target firmware upgrade package.
  • determining whether to change the order of the sub-upgrade packages based on the sequence identifier of the sub-upgrade packages includes: identifying the numerical value indicated by the sequence identifier, and determining whether to change the order of the sub-upgrade packages based on the numerical value indicated by the sequence identifier.
  • determining whether to change the order of sub-upgrade packages based on the numerical value indicated by the sequence identifier includes determining whether to change the order of sub-upgrade packages based on whether the numerical value indicated by the sequence identifier is a first predetermined numerical value.
  • determining whether to change the order of sub-upgrade packages based on the value indicated by the sequence identifier includes: taking the modulus of the value indicated by the sequence identifier by a second predetermined value to obtain a remainder, wherein the second predetermined value is a natural number greater than or equal to 2, and determining whether to change the order of the sub-upgrade packages based on the remainder.
  • the second predetermined value is 2, wherein determining whether to change the order of the sub-upgrade packages based on the value indicated by the sequence identifier includes determining whether to change the order of the sub-upgrade packages based on the parity of the value indicated by the sequence identifier.
  • the firmware upgrade method is based on the sequence.
  • the identification of changing the sequence of the sub-upgrade packages includes: identifying a numerical value indicated by the sequence identifier, and changing the sequence of the sub-upgrade packages based on the numerical value indicated by the sequence identifier.
  • a firmware upgrade method applied to a server side wherein the sequence identifier includes data of a predetermined number of bits, and the numerical value indicated by the identification sequence identifier includes the numerical value indicated by the identification data
  • changing the sub-upgrade package sequence includes: dividing the sub-upgrade packages into sub-upgrade package groups, each sub-upgrade package group includes a specific number of sub-upgrade packages adjacent to each other in an initial sequence, wherein the specific number is the maximum numerical value that can be indicated by the data of the predetermined number of bits plus 1, and exchanging the order of two sub-upgrade packages in each sub-upgrade package group whose initial sequences differ by the numerical value indicated by the data.
  • changing the order of sub-upgrade packages includes: dividing the sub-upgrade packages into sub-upgrade package groups, each sub-upgrade package group includes a specific number of sub-upgrade packages that are adjacent in initial order, wherein the specific number is predetermined at the server, and exchanging the order of two sub-upgrade packages in each sub-upgrade package group whose initial order differs by a value less than the specific number.
  • firmware upgrade method applied to the server side also includes generating a matrix according to the number of sub-upgrade packages and arranging the sub-upgrade packages in the matrix, wherein changing the order of the sub-upgrade packages includes translating the sub-upgrade packages in the matrix according to the sequence identifier.
  • generating a matrix according to the number of sub-upgrade packages includes determining whether to generate an odd-dimensional matrix or an even-dimensional matrix according to the number of sub-upgrade packages.
  • the method further includes filling the matrix with one or more of a garbled package, an empty package and a repeated sub-upgrade package.
  • the sequence identifier indicates one or more of the number of translations of the sub-upgrade package in the matrix, the direction in which the sub-upgrade package moves out, and the clockwise or counterclockwise rotation of the sub-upgrade package in the matrix.
  • firmware upgrade method applied to the server side it also includes determining the translation method of the sub-upgrade package according to the sequence number of the sub-upgrade package in the matrix and the dimension of the matrix.
  • the firmware upgrade method applied to the server side also includes storing and/or sending the header of the target firmware upgrade package to the target terminal device, wherein the header of the target firmware upgrade package includes one or more of the identification code of the target terminal device, the number and number of sub-upgrade packages, the firmware upgrade key and/or integrity verification information.
  • a firmware upgrade method for a terminal device includes: obtaining a firmware upgrade instruction; sending an identification code of a target terminal device; downloading a sub-upgrade package from a server; and splicing the sub-upgrade package into a target firmware upgrade package based on the identification code of the target terminal device.
  • the firmware upgrade method applied to the terminal device also includes downloading the header of the firmware upgrade package from the server, and performing through the secure boot program: in response to all sub-upgrade packages and the firmware upgrade package header being downloaded to the terminal device, determining whether to change the order of the downloaded sub-upgrade packages based on the sequence identifier in the identification code of the terminal device; performing security or integrity verification on the downloaded sub-upgrade packages; in response to the downloaded sub-upgrade packages passing the security or integrity verification, running the target firmware spliced by the sub-upgrade packages.
  • obtaining the firmware upgrade instruction includes obtaining the firmware upgrade instruction and the security verification key by leaving the wide area network; downloading the sub-upgrade package from the server includes obtaining the firmware upgrade package and the firmware upgrade package security key via the wide area network; and performing security verification on the downloaded sub-upgrade package includes determining whether the security verification key matches the firmware upgrade package security key.
  • a firmware upgrade device which is applied to a server, and includes: a firmware upgrade package acquisition device, used to acquire a target firmware upgrade package; a receiving device, used to receive an identification code of a target terminal device; a splitting device, used to split the target firmware upgrade package into sub-upgrade packages based on the identification code of the target terminal device; a storage/sending device, used to store and/or send the sub-upgrade packages to the target terminal device.
  • a firmware upgrade device which is applied to a terminal device, and includes: a firmware upgrade instruction acquisition device, used to acquire a firmware upgrade instruction; a receiving device, used to send an identification code of a target terminal device; a downloading/receiving device, used to download/receive a sub-upgrade package; and a splicing device, used to splice the sub-upgrade packages into a target firmware upgrade package based on the identification code of the target terminal device.
  • a server which includes a memory and one or more processors, wherein a computer program is stored in the memory, and when the computer program is executed by the one or more processors, the above-mentioned firmware upgrade method applied to the server is implemented.
  • a terminal device which includes a memory and one or more processors, wherein a computer program is stored in the memory, and when the computer program is executed by the one or more processors, the above-mentioned firmware upgrade method applied to the terminal device is implemented.
  • a method for secure booting for a terminal device, which includes: in response to all sub-upgrade packages and firmware upgrade package headers being downloaded to the terminal device, based on the terminal device.
  • the sequence identifier in the identification code of the terminal device determines whether to change the order of the downloaded sub-upgrade packages; performs security or integrity verification on the downloaded sub-upgrade packages; in response to the downloaded sub-upgrade packages passing the security or integrity verification, runs the target firmware spliced by the sub-upgrade packages.
  • a security verification method for a target terminal device includes: obtaining firmware upgrade instructions and a security verification key in a manner away from a wide area network; obtaining a firmware upgrade package and a firmware upgrade package security key via the wide area network; and determining whether the security verification key matches the firmware upgrade package security key.
  • obtaining a firmware upgrade package via a wide area network includes downloading a sub-upgrade package from a server, wherein the method further includes: sending an identification code of a target terminal device; and based on the identification code of the target terminal device, splicing the sub-upgrade packages into a target firmware upgrade package.
  • the security verification method of an embodiment of the present disclosure also includes downloading the header of the firmware upgrade package from the server, and performing through a secure boot program: in response to all sub-upgrade packages and the firmware upgrade package header being downloaded to the target terminal device, determining whether to change the order of the downloaded sub-upgrade packages based on the sequence identifier in the identification code of the target terminal device; performing security or integrity verification on the downloaded sub-upgrade packages; in response to the downloaded sub-upgrade packages passing the security or integrity verification, running the target firmware spliced by the sub-upgrade packages.
  • FIG1 is a flow chart of a firmware upgrade method applied to a server according to an embodiment of the present disclosure
  • FIG2 is a flowchart of a firmware upgrade method applied to a terminal device according to an embodiment of the present disclosure
  • FIG. 3 is a flow chart of a firmware upgrade method applied to a server according to an embodiment of the present disclosure
  • FIG. 4 is a flowchart of a firmware upgrade method applied to a terminal device according to an embodiment of the present disclosure
  • 5A-5C are schematic diagrams of a server transforming a sub-upgrade package sequence clockwise in an odd-dimensional matrix with a shift direction being left according to an embodiment of the present disclosure
  • FIG5D is a schematic diagram of the inverse process of the data packet translation process according to an embodiment of the present disclosure.
  • FIG. 6 is a flow chart of determining a shifting method of a data packet in an odd-numbered matrix according to an embodiment of the present disclosure
  • FIG. 7 is a flow chart of the inverse process of the data packet translation process according to an embodiment of the present disclosure.
  • FIG. 8 is a flowchart of determining the number of times the server needs to continue executing the translation performed to restore the sub-upgrade package sequence according to an embodiment of the present disclosure
  • 9A-9D are schematic diagrams of a manner in which a server translates a data packet within an odd-dimensional matrix according to different shift-out directions according to an embodiment of the present disclosure
  • FIG. 10 is a schematic diagram of a server according to an embodiment of the present disclosure changing the order of sub-upgrade packages based on a sequence identifier including an indication that the removal direction is left and counterclockwise;
  • FIG. 11 is a schematic diagram of a server transforming the sub-upgrade package sequence clockwise in an even-dimensional matrix with the shift direction being left according to an embodiment of the present disclosure
  • FIG12 is a flow chart of determining a translation method of a data packet in an even-dimensional matrix according to an embodiment of the present disclosure
  • 13A-13D are schematic diagrams describing the manner in which a server translates a data packet within an even-dimensional matrix according to different shift-out directions according to an embodiment of the present disclosure
  • FIG14 is a firmware upgrade device for a server according to an embodiment of the present disclosure.
  • FIG15 is a firmware upgrade device for a terminal device according to an embodiment of the present disclosure.
  • FIG16 is a flowchart of secure booting of a target terminal device according to an embodiment of the present disclosure
  • FIG. 17 is a flowchart of off-network and on-network combined security verification for a target terminal device according to an embodiment of the present disclosure.
  • controller or “control unit” refers to any device, system, or part thereof that controls at least one operation. Such a controller may be implemented with hardware, or a combination of hardware and software and/or firmware. The functionality associated with any particular controller may be centralized or distributed, whether local or remote.
  • the phrase "at least one,” when used with a list of items, means that different combinations of one or more of the listed items may be used, and only one item in the list may be required. For example, "at least one of A, B, C” includes any one of the following combinations: A, B, C, A and B, A and C, B and C, A and B and C.
  • the Internet of Things is a technology that uses various devices and technologies such as information sensors, radio frequency identification technology, global positioning system, infrared sensor, laser scanner, etc. to collect any objects or processes that need to be monitored, connected, and interacted in real time, collect various required information such as sound, light, heat, electricity, mechanics, chemistry, biology, location, etc., and realize ubiquitous connection between things and things, things and people through various possible network access, and realize intelligent perception, identification and management of objects and processes.
  • the Internet of Things is an information carrier based on the Internet, traditional telecommunications networks, etc. It allows all ordinary physical objects that can be independently addressed to form an interconnected network. Unlike traditional network security, IoT security is the product of the integration of network security and other engineering disciplines.
  • IoT security Compared with simple data, server, network infrastructure and information security, the connotation of IoT security is richer. Moreover, IoT security also needs to include direct or distributed monitoring and control of the state of networked physical systems. There are a large number of terminal devices in the IoT system, a large part of which are single-chip microcomputer devices with limited computing power and storage resources. In this device environment with severely limited resources, traditional operating system-based security management solutions such as firewalls and app stores cannot guarantee the security of devices during upgrades.
  • firmware upgrades can be performed through the application store. Although the source of the upgrade data packet is legal and encryption is also present during the transmission process, the entire upgrade process is carried out as a whole, whether it is a complete package or a differential package. Moreover, the firmware upgrade package and upgrade process are the same for each terminal device when performing the same firmware upgrade. Security risks in the upgrade process cannot be effectively avoided. In other cases, firmware upgrades can be performed by downloading firmware upgrade packages in APK format from the web page. Since it involves the user's subjective judgment and choice of risks, it is also difficult to effectively avoid security risks in the firmware upgrade process.
  • the embodiments of the present invention provide a firmware upgrade method, apparatus, server, terminal device and storage medium, which can effectively avoid security risks in the firmware upgrade process. Since different devices may have different identification codes, and thus the sub-upgrade packages and firmware upgrade processes of different devices may be different, a single device may be hacked. The attack cannot leak information about other devices, and it is difficult to observe patterns in the network and interfere with the firmware upgrade of terminal devices on a large scale. The difficulty of cracking the system is proportional to the number of terminal devices, which is especially suitable for large-scale sensor and controller networks, and for military and factory-side scenarios.
  • FIG. 1 is a flow chart of a firmware upgrade method applied to a server according to an embodiment of the present disclosure.
  • the server obtains the target firmware upgrade package.
  • a firmware upgrade package made by a developer can be obtained.
  • the upgraded firmware will add or rewrite the existing firmware on the device so that it can operate with maximum efficiency and security again. For example, if there is a fault that needs to be resolved or a new security patch is created, the currently installed firmware will no longer apply. For devices that frequently access the Internet or need to continuously update security features, firmware upgrades may be very frequent.
  • the firmware upgrade package can be regarded as a whole file, which is debugged and tested by the developer when making the firmware upgrade package.
  • step S102 the server receives the identification code of the target terminal device.
  • the server receives the identification code of the target terminal device from the target terminal device.
  • the target terminal device may refer to a terminal device to be upgraded, and the terminal device may be any terminal device in the Internet of Things, for example, various information sensors, radio frequency identification devices, global positioning systems, infrared sensors, laser scanners, computers, etc.
  • the identification code may refer to an SN (serial number) code of a pre-configured terminal device.
  • the firmware upgrade packages in the related technology are all made into a unified upgrade package file. Therefore, when performing firmware upgrades on batches of terminal devices, the firmware upgrade package and upgrade process for each terminal device performing the same firmware upgrade are the same. Once the firmware upgrade package is monitored during transmission (download), the entire firmware upgrade package may be easily leaked or even tampered with, making it impossible to effectively guarantee the security of terminal devices with the same firmware upgrade requirements during firmware upgrades.
  • each terminal device is provided with an identification code configured with a certain degree of customization, and at least some fields in the identification code are configured with upgrade information.
  • the identification code is customized for each terminal device. Since the configurations of the identification codes of terminal devices with the same firmware upgrade requirements are different or not completely the same, the specific forms of unpacking and transmission (downloading) are not all the same. Therefore, even if the information of a single terminal device is leaked, it will not cause security problems for all terminal devices in the entire system.
  • the upgrade information includes at least one of the size of the sub-upgrade package, the sequence identifier of the sub-upgrade package, and the download address offset of the sub-upgrade package.
  • the size of each sub-upgrade package when transmitting the sub-upgrade package for example, 7 bits can be used to transmit the size of the sub-upgrade package; the sequence identifier of the sub-upgrade package is used to distinguish whether to change the order of the sub-upgrade packages and how to change the order of the sub-upgrade packages, so as to change the transmission order of the split sub-upgrade packages, increase the complexity of the transmission process, and avoid the leakage of the entire firmware upgrade package or even tampering when being monitored.
  • the sequence identifier of the sub-upgrade package can be set for different terminal devices, which can be set randomly or according to a certain rule, and this embodiment does not limit it.
  • the identification code in Table 1 includes a header field, a sequence identifier of the sub-upgrade package, a size of the sub-upgrade package, a download address offset of the sub-upgrade package, and a tail field.
  • the positions of the sequence identifier of the sub-upgrade package, the size of the sub-upgrade package, and the download address offset of the sub-upgrade package in the identification code are only schematic, and they can be located in the identification code in different orders.
  • the total number of bits of the identification code and various upgrade information, header fields, tail fields, and other bytes (or bits) can be determined according to the actual identification code configuration rules.
  • the header field and the tail field can refer to the header field and the tail field settings in the SN in the related technology to identify the basic information of the corresponding terminal device, and the header field and the tail field can also be customized.
  • the header field and the tail field can also be omitted, that is, the identification code is only configured with the upgrade information.
  • Step S103 the server splits the target firmware upgrade package into sub-upgrade packages based on the identification code of the target terminal device.
  • the server performs unpacking, storage or transmission during the firmware upgrade process. When unpacking, it may be necessary to input the identification number of the terminal device to be upgraded or the server automatically unpacks the firmware upgrade package according to the identification number of the terminal device.
  • the server may split the target firmware upgrade package into a number of sub-upgrade packages based on the size of the target firmware upgrade package and the size of the sub-upgrade package in the identification code of the target terminal device.
  • the server may split the target firmware upgrade package into a number of sub-upgrade packages based on the size of the target firmware upgrade package and the size of the predetermined sub-upgrade package or based on other mechanisms.
  • the server may split the target firmware upgrade package into a number of sub-upgrade packages based on the size of the sub-upgrade package in the identification code of the target terminal device.
  • the sequence identifier determines whether to change the sequence of each sub-upgrade package and how to change the sequence of each sub-upgrade package.
  • the server stores and/or sends the sub-upgrade package to the target terminal device.
  • the server can store each sub-upgrade package file in the server and wait for the target terminal device to be sent when the firmware is upgraded. Alternatively or additionally, when the current target terminal device is in the firmware upgrade, the sub-upgrade package file is sent to the target terminal device.
  • the server can first store several split sub-upgrade packages, and start sending the sub-upgrade package to the target terminal device when the terminal device requests it. Alternatively or additionally, the server can automatically send it to the target terminal device.
  • several split sub-upgrade packages can be stored and sent to the target terminal device at the same time to achieve backup.
  • the server can determine the address for storing the sub-upgrade package based on the identification code of the target terminal device, so that the terminal device can download the sub-upgrade package from the address.
  • the server can receive the identification code sn001 of the terminal device from the terminal device.
  • the server stores the sub-upgrade package in PROTOCOL://HOSTNAME/PATH/sn001 based on the default modifiable address PROTOCOL://HOSTNAME/PATH/SN and the identification code sn001 of the target terminal device.
  • the target terminal device can download the sub-upgrade package from the address PROTOCOL://HOSTNAME/PATH/sn001.
  • the specific form of the above address is exemplary and not restrictive.
  • the server can store the sub-upgrade package at a predetermined address so that the terminal device can download the sub-upgrade package from the predetermined address.
  • FIG2 is a flowchart of a firmware upgrade method applied to a terminal device according to an embodiment of the present disclosure.
  • the terminal device may be various IoT terminal devices, for example, smart sensors (such as sensors for collecting ambient environment data such as temperature, humidity, vibration, pressure, liquid level, etc.), smart home devices (such as smart sockets, smart lights, smart speakers, smart washing machines, smart refrigerators, smart air purifiers, etc.), smart wearable devices (such as smart watches, sports bracelets, smart glasses, etc.), smart transportation equipment (such as smart street lights, smart cars, smart parking lots, etc.), smart health care equipment (such as smart blood pressure monitors, smart health bracelets, smart call machines), smart industrial equipment (such as CNC machine tools, industrial robots), etc.
  • the above terminal devices may be implemented using embedded technology or other technologies.
  • the terminal device obtains a firmware upgrade instruction.
  • the firmware upgrade instruction is sent by a broadcast device that is off the wide area network or is triggered by a preset button of the terminal device.
  • the broadcast device that is off the wide area network can be, for example, a handheld broadcast device.
  • the broadcast device that is off the wide area network can be implemented using short-range wireless communications such as Bluetooth, Bluetooth LE, ZigBee, radio frequency identification (RFID), UWB, 60GHz, Wi-Fi, WiMAX, or wired communications such as USB. Since the broadcast device is off the wide area network, the terminal device can be used to connect to the wireless network. The use of a wide area network, not using a wide area network can effectively avoid security risks during transmission through a wide area network.
  • the terminal device can also preset buttons, for example, physical buttons such as toggle buttons, slide buttons, buttons, and specific areas displayed on the touch screen, so as to trigger firmware upgrade instructions and implement an upgrade strategy that coordinates off-grid and on-grid.
  • the firmware upgrade instruction can be sent by the server to the terminal device through the wide area network.
  • the broadcast device sends the firmware upgrade instruction
  • the preset button of the terminal device triggers the firmware upgrade instruction
  • the server sends the firmware upgrade instruction through the wide area network.
  • step S202 the terminal device sends the identification code of the target terminal device.
  • the terminal device can obtain the identification code of the target terminal device from the storage area of the flash chip of the terminal device.
  • the identification code of the target terminal device has been described in step S102 of FIG. 1 and will not be repeated here.
  • step S203 the terminal device receives (downloads) the sub-upgrade package.
  • the terminal device can download the sub-upgrade package from the server.
  • the identification code may also include a storage address offset, but this is not necessary.
  • the terminal device stores the sub-upgrade package in a storage address of a flash memory of the terminal device determined based on the modifiable storage address and the storage address offset. This enables partitioned storage of the sub-upgrade package in the terminal device.
  • the storage address offset of the sub-upgrade package is used to determine the storage address of the sub-upgrade package in the terminal device to achieve partitioned storage of the sub-upgrade package in the terminal device.
  • the sub-upgrade package is stored in a flash chip of the terminal device, and partitioned storage of the sub-upgrade package in the terminal device is achieved by dividing different storage areas in the flash chip.
  • the sub-upgrade package can be stored in the terminal device in partitions.
  • the terminal device can determine the address of the sub-upgrade package downloaded from the server based on the identification code of the terminal device and the default modifiable download address read from the flash chip of the terminal device according to the download address offset. For example, in the example of Table 2, the terminal device can obtain the download address offset address_offset001 of the target terminal device based on the identification code read from the address 00000000 of the flash chip.
  • the terminal device can read the modifiable address PROTOCOL://HOSTNAME/PATH/SN from the address 0000000F of the flash chip based on address_offset001, and determine to download the sub-upgrade package stored in the server from PROTOCOL://HOSTNAME/PATH/sn001 according to the identification code sn001 of the terminal device and the modifiable address PROTOCOL://HOSTNAME/PATH/SN.
  • the specific form of the above address is exemplary and not restrictive.
  • the terminal device can download the sub-upgrade package from a predetermined address.
  • the sub-upgrade packages are spliced into the target firmware upgrade package.
  • the terminal device may determine whether to change the order of each sub-upgrade package received and how to change the order of each sub-upgrade package based on the sequence identifier of the sub-upgrade package in the identification code of the target terminal device, so as to further splice the sub-upgrade packages into the target firmware upgrade package.
  • splicing may refer to reading the sub-upgrade packages from the storage area of the target terminal device in sequence.
  • the sub-upgrade packages are spliced into the target firmware upgrade package. After the upgrade packages are spliced into the target firmware upgrade package, a soft restart is also performed.
  • FIG. 3 is a flow chart of a firmware upgrade method applied to a server according to an embodiment of the present disclosure.
  • step S301 the server obtains a target firmware upgrade package.
  • the parts of step S301 in FIG3 similar to step S101 in FIG1 are not described again here.
  • step S302 the server receives the identification code of the target terminal device.
  • step S302 in FIG3 and step S102 in FIG1 are not described again here.
  • step S303 the server determines whether to perform a sequence transformation on the sub-upgrade package based on the identification code of the target terminal device. When it is determined that the sub-upgrade package is to be transformed in sequence, the process proceeds to S304. In S304, the server splits the target firmware upgrade package into sub-upgrade packages, performs a sequence transformation, and numbers the sub-upgrade packages. When it is determined that the sub-upgrade package is not to be transformed in sequence, the process proceeds to S305. In S304, the server splits the target firmware upgrade package into sub-upgrade packages, does not perform a sequence transformation, and numbers the sub-upgrade packages. In one embodiment, the sub-upgrade packages on the server are numbered 0001, 0002, 0003, 0004, 0005.
  • the numbering is written in sequence, which indicates the transmission order of each sub-upgrade package.
  • the header of each sub-upgrade package may include the number of the sub-upgrade package.
  • the header of each sub-upgrade package may also include the identification code of the target terminal device and the number of sub-upgrade packages.
  • the sequence identifier may be binary data, but the binary data is only exemplary, and in other embodiments, the sequence identifier may be another form of identifier.
  • step S303 determines whether to transform the order of each sub-upgrade package when splitting the target firmware upgrade package into a plurality of sub-upgrade packages, based on whether the value corresponding to the binary data of the preset number of bits is a predetermined value (e.g., 0).
  • a specific rule for changing the order may be that, in S304, a number of sub-upgrade packages are divided into a number of pairs of adjacent sub-upgrade packages, and the order of the two sub-upgrade packages in each pair of adjacent sub-upgrade packages is swapped. After the order of the sub-upgrade packages is changed according to this rule, the difficulty of the firmware upgrade package being monitored, leaked, and tampered with during transmission (downloading) of the firmware upgrade package is significantly increased, thereby improving the security of the firmware upgrade.
  • the preset number of bits is 1, then the binary data includes 0 or 1, and the corresponding value is also 0 or 1. Then, in step S303, when the value corresponding to the binary data corresponding to the sequence identifier in the identification code of the current terminal device is 0, the target firmware upgrade package is split into a plurality of sub-upgrade packages while the order of the sub-upgrade packages remains unchanged, and the binary data corresponding to the sequence identifier in the identification code of the current terminal device is When the corresponding value is 1, the target firmware upgrade package is split into several sub-upgrade packages and the sub-upgrade packages need to be sequentially transformed. Alternatively, the opposite setting to the above can be made.
  • the order of adjacent sub-upgrade packages can be exchanged to achieve the order transformation of the sub-upgrade packages. Therefore, the order transformation of each sub-upgrade package is performed according to the numerical value corresponding to the binary data of the preset number of bits, including: dividing a number of sub-upgrade packages into a number of pairs of adjacent sub-upgrade packages; and exchanging the order of two sub-upgrade packages in each pair of adjacent sub-upgrade packages.
  • the binary data when the preset number of bits is 1, the binary data includes 0 or 1, and when the numerical value corresponding to the binary data corresponding to the sequence identifier in the identification code of the current terminal device is 1, it is determined that each sub-upgrade package is sequentially transformed. At this time, the sub-upgrade packages obtained by splitting the target firmware upgrade package are divided into a number of pairs of adjacent sub-upgrade packages, and the order of the two sub-upgrade packages in each pair is exchanged. When the numerical value corresponding to the binary data corresponding to the sequence identifier in the identification code of the current terminal device is 0, there is no need to perform this order exchange operation, and the original order can be maintained.
  • the preset number of bits is 2, and the binary data includes 00, 01, 10, 11, and the corresponding values are 0, 1, 2, 3.
  • the target firmware upgrade package is split into several sub-upgrade packages while the order of each sub-upgrade package remains unchanged, and when the value corresponding to the binary data 01, 10 or 11 corresponding to the sequence identifier in the identification code of the current terminal device is 1, 2, 3, the target firmware upgrade package is split into several sub-upgrade packages while the order of each sub-upgrade package needs to be changed.
  • a setting different from the above setting can be made.
  • step S303 can also determine whether to perform a sequential transformation of the sub-upgrade packages based on the parity of the numerical value corresponding to the binary data of a preset number of bits. Therefore, based on the numerical value corresponding to the binary data of a preset number of bits, it is determined whether to perform a sequential transformation of each sub-upgrade package while splitting the target firmware upgrade package into a number of sub-upgrade packages, including: if the numerical value corresponding to the binary data of a preset number of bits is an even number, it is determined that the target firmware upgrade package is split into a number of sub-upgrade packages while the order of each sub-upgrade package remains unchanged; if the numerical value corresponding to the binary data of a preset number of bits is an odd number, it is determined that the target firmware upgrade package is split into a number of sub-upgrade packages while the order of each sub-upgrade package remains unchanged; if the numerical value corresponding to the binary data of a preset number of bits is an even number, it is determined that the numerical value corresponding
  • the target firmware upgrade package is split into a number of sub-upgrade packages while the order of each sub-upgrade package remains unchanged; if the numerical value corresponding to the binary data of a preset number of bits is an even number, it is determined that the target firmware upgrade package is split into a number of sub-upgrade packages while the order of each sub-upgrade package is transformed.
  • the preset number of bits is 1, it is determined based on the parity whether to transform the order of the sub-upgrade package.
  • the process of changing the order of the sub-upgrade packages is similar to the process of determining whether to change the order of the sub-upgrade packages according to whether the order identifier is 0 or 1.
  • step S303 can also determine whether to perform a sequence transformation of the sub-upgrade packages according to the modulus of the value corresponding to the binary data of the preset number of digits and the predetermined value. Therefore, the modulus of the predetermined value according to the value corresponding to the binary data of the preset number of digits determines whether to perform a sequence transformation of each sub-upgrade package while splitting the target firmware upgrade package into a plurality of sub-upgrade packages, including: if the modulus of the predetermined value according to the value corresponding to the binary data of the preset number of digits is one of one or more specific values, it is determined that the sequence of each sub-upgrade package remains unchanged while splitting the target firmware upgrade package into a plurality of sub-upgrade packages; if the modulus of the predetermined value according to the value corresponding to the binary data of the preset number of digits is not one or more specific values, it is determined that the sequence of each sub-upgrade package remains unchanged while splitting the target firmware upgrade package into a pluralit
  • the modulus of the predetermined value according to the value corresponding to the binary data of the preset number of digits is one or more specific values, it is determined that the sequence of each sub-upgrade package remains unchanged while splitting the target firmware upgrade package into a plurality of sub-upgrade packages; if the modulus of the predetermined value according to the value corresponding to the binary data of the preset number of digits is not one or more specific values, it is determined that the sequence of each sub-upgrade package remains unchanged while splitting the target firmware upgrade package into a plurality of sub-upgrade packages.
  • the modulus of the predetermined value based on the value corresponding to the binary data of the preset number of bits is a specific value (e.g., 0), and it can be determined whether to perform a sequence transformation of each sub-upgrade package when the target firmware upgrade package is split into a plurality of sub-upgrade packages.
  • the preset value is 2
  • the process of determining whether to perform a sequence transformation of the sub-upgrade packages based on the modulus of the predetermined value based on the value corresponding to the binary data of the preset number of bits is similar to the process of determining whether to transform the sequence of the sub-upgrade packages based on parity.
  • step S304 sequentially transforming each sub-upgrade package according to the numerical value corresponding to the binary data of the preset number of bits, includes: dividing the sub-upgrade package into a plurality of sub-upgrade package groups, each sub-upgrade package group includes a specific number of sub-upgrade packages, and the specific number is the numerical value corresponding to the maximum binary data of the preset number of bits plus 1; and sequentially exchanging two sub-upgrade packages in each sub-upgrade package group whose order differs by the numerical value corresponding to the binary data of the preset number of bits.
  • the target firmware upgrade package is split into several sub-upgrade packages while the order of each sub-upgrade package remains unchanged and no exchange is required.
  • the identification code of the current terminal device When the value corresponding to the binary data 01, 10 or 11 corresponding to the sequence identifier is 1, 2, or 3, the target firmware upgrade package is split into several sub-upgrade packages and the sub-upgrade packages need to be sequentially transformed.
  • the specific method of sequential transformation is: divide the several sub-upgrade packages into several groups of sub-upgrade packages, each group contains 4 (i.e., the value 3+1 corresponding to the maximum binary data), wherein the first group includes the 0th package, the 1st package, the 2nd package, and the 3rd package, and exchange the order of the two sub-upgrade packages that differ by 2 bits in order, i.e., the 0th package is exchanged with the 2nd package, and the 1st package is exchanged with the 3rd package.
  • the process of grouping the sub-upgrade packages according to the value corresponding to the maximum binary data of the preset number of bits plus 1, and transforming the order of the sub-upgrade packages according to the value corresponding to the maximum binary data of the preset number of bits is similar to the process of dividing the sub-upgrade packages into several pairs of adjacent sub-upgrade packages and transforming the order of the sub-upgrade packages by exchanging the order of the two sub-upgrade packages in each pair of adjacent sub-upgrade packages.
  • the cases where the preset number of bits is 3, 4, ... N bits are not given one by one in this embodiment. The more the preset number of bits and/or the more complicated the exchange sequence is, the higher the complexity of transmission (downloading) during the firmware upgrade process.
  • the above embodiments associate the determination of whether to transform and the transformation method with the preset number of bits of the sequence identifier.
  • the present disclosure is not limited to this.
  • the binary data includes 0 or 1
  • the corresponding value is also 0 or 1.
  • step S303 when the value corresponding to the binary data corresponding to the sequence identifier in the identification code of the current terminal device is 0, the target firmware upgrade package is split into several sub-upgrade packages while the order of each sub-upgrade package remains unchanged, and when the value corresponding to the binary data corresponding to the sequence identifier in the identification code of the current terminal device is 1, the target firmware upgrade package is split into several sub-upgrade packages while each sub-upgrade package needs to be sequentially transformed.
  • the transformation method can be to divide the sub-upgrade package into several sub-upgrade package groups, each sub-upgrade package group includes a certain number of sub-upgrade packages, and the number is the number previously predetermined by the server and the target terminal device (greater than or equal to 2); and the order of two sub-upgrade packages in each group of sub-upgrade packages is exchanged, the order difference is the number minus 1 (or the order difference is less than the number of other values, such as the order difference is less than the number minus 2, etc.).
  • the transformation method of the sub-upgrade package sequence for target terminal devices with different remainders can be set between the server and the target terminal device. For example, when the remainder is 0, the sub-upgrade package sequence may not be transformed. When the remainder is 1, the sub-upgrade package may be divided into a plurality of pairs of adjacent sub-upgrade packages, and the order of the two sub-upgrade packages in each pair of adjacent sub-upgrade packages may be swapped.
  • each sub-upgrade package can be divided into several groups of sub-upgrade packages, each group contains 3 (i.e., the remainder plus 1) sub-upgrade packages, and the order of two sub-upgrade packages that differ by 2 (i.e., the remainder) bits in order are swapped.
  • the present disclosure is not limited thereto.
  • the server generates a header of the target firmware upgrade package.
  • the header of the target firmware upgrade package may include one or more of the identification code of the target terminal device, the number and serial number of the sub-upgrade packages, the firmware upgrade key and/or the integrity verification information.
  • the firmware upgrade key and/or the integrity verification information may be used by the terminal device for security verification in the secure boot process.
  • the server stores and/or sends the sub-upgrade package and the info package to the target terminal device.
  • the info package is equivalent to a data packet that provides a header of the target firmware upgrade package.
  • FIG. 4 is a flowchart of a firmware upgrade method applied to a terminal device according to an embodiment of the present disclosure.
  • step S401 the terminal device obtains a firmware upgrade instruction.
  • step S401 in FIG4 and step S201 in FIG2 are not described again here.
  • step S402 the terminal device sends the identification code of the target terminal device.
  • step S402 in FIG4 and step S202 in FIG2 are not described again here.
  • the terminal device downloads the info package.
  • the terminal device obtains one or more of the identification code of the target terminal device, the number of sub-upgrade packages, the firmware upgrade key and/or integrity verification information through the downloaded info package. For example, it can be verified whether the identification code of the target terminal device in the info package is consistent with the identification code of the terminal device.
  • the sub-upgrade package split based on the upgrade information sent by the server is downloaded. If the identification code of the terminal device obtained is inconsistent with the identification code in the packet header sent by the server, the current firmware upgrade instruction may be illegal and the download operation is not performed.
  • the server can send GET information (info package containing header information) to the terminal device.
  • the GET information can include the terminal device's identification code SN, the sub-upgrade package quantity of the split sub-upgrade package, and can also include the sub-upgrade package number and integrity check value, such as md5 value, and security verification information such as firmware upgrade key.
  • security verification information such as firmware upgrade key.
  • more quantities and types of security verification information can be set according to security requirements to achieve security verification of terminal devices and improve the security of firmware upgrades.
  • the packet header may also include a firmware upgrade key and/or integrity verification information to verify the firmware upgrade key and/or integrity verification information carried in the firmware upgrade instruction, thereby improving security. All nature.
  • the info package sent by the server is downloaded and stored in the tmp partition preset by the terminal device for calling the information therein during the upgrade process.
  • a packet-by-packet request and packet-by-packet transmission download method may be adopted, and when each sub-upgrade package is downloaded, it may be determined whether the last sub-upgrade package has been downloaded according to the information provided by the packet header. Therefore, in some implementations, the method further includes: determining whether the last sub-upgrade package has been downloaded according to the number of sub-upgrade packages in the packet header.
  • the terminal device determines whether to sequentially transform the sub-upgrade packages based on the identification code.
  • the process proceeds to S405.
  • the terminal device downloads the sub-upgrade packages.
  • the terminal device confirms whether the sub-upgrade package currently being downloaded is the last upgrade package.
  • the process proceeds to S405.
  • the terminal device changes the order of the sub-upgrade packages.
  • the process proceeds to S408.
  • the terminal device downloads the sub-upgrade packages.
  • the terminal device confirms whether the sub-upgrade package currently being downloaded is the last upgrade package. When the sub-upgrade package currently being downloaded is not the last upgrade package, the process proceeds to S408. When the sub-upgrade package currently being downloaded is the last upgrade package, the process proceeds to S410. At S410, the terminal device does not change the order of the sub-upgrade packages.
  • the terminal device downloads the sub-upgrade package, it first determines whether to change the sequence of the sub-upgrade package based on the sequence identifier. If the sequence of the sub-upgrade package needs to be changed, the sequence of the sub-upgrade package is changed back to the original sequence, and then the sub-upgrade packages are spliced into the original firmware upgrade package; if the sequence of the sub-upgrade package does not need to be changed, the sub-upgrade packages are directly spliced into the original firmware upgrade package.
  • the terminal device assembles the sub-upgrade packages into a target firmware upgrade package.
  • 5A-5C are diagrams of servers in an odd-dimensional matrix clockwise, Schematic diagram of the order of sub-upgrade packages with the shift direction being left.
  • the sequence identifier in the identification code may include data of a preset number of digits indicating at least one of the number of translations, the direction of movement, and the direction of rotation.
  • the sequence identifier includes data of a preset number of digits indicating one or two of the number of translations, the direction of movement, and the direction of rotation, the remaining parts of the number of translations, the direction of movement, and the direction of rotation may be predetermined in advance between the terminal device and the server.
  • the number of translations may be 1, 2, 3, or more.
  • the direction of movement refers to the translation direction of the sub-upgrade package or data packet moved out of the matrix when the sub-upgrade package or other data packet is translated.
  • the direction of movement may be up, down, left, right, or other directions.
  • the direction of rotation may be clockwise or counterclockwise. For example, when the number of translations is 2, the direction of movement is left, and the direction of rotation is clockwise, it may be thought that all data packets in the matrix are translated 2 times, and the direction of movement of the data moved out of the matrix each time is left, and the direction of rotation of the data packet in the matrix is clockwise.
  • the number of translations indicated by the sequence identifier in the identification code is not 0, the order of transforming the sub-upgrade package can be determined.
  • the server generates a matrix according to the number N of sub-upgrade packages into which the target upgrade package is split. In one embodiment, the server determines the dimension of the generated matrix according to the number N of sub-upgrade packages into which the target upgrade package is split. T is calculated according to the following formula:
  • roundup() means rounding up.
  • the 17 sub-upgrade packages cannot just fill the 5-dimensional matrix, and interference packages (garbled code packages, empty packages, or repeated use of one or more of the 17 sub-upgrade packages) can be used to fill the matrix until the matrix is filled.
  • the sequence identifier includes data of a preset number of bits indicating that the number of translations K is 1, the direction of shifting is left, and the direction of rotation is clockwise.
  • the matrix is as shown in FIG5B .
  • the data packet shifted out of the matrix is filled into the empty position in the middle of FIG5B , and the matrix after translation is shown in FIG5C .
  • the matrix of FIG5C is the matrix of FIG5A after being translated to the left and clockwise once.
  • FIG6 is a flow chart of determining a shifting manner of data packets in an odd-numbered matrix according to an embodiment of the present disclosure.
  • ) means taking the maximum value of
  • the translation mode of the data packet in the matrix can be determined by the following conditions:
  • condition 1 if condition 1 is met, the process proceeds to S604, and the coordinates of the data packet are changed to: The X value is reduced by 1, and the Y value remains unchanged; if condition 1 is not satisfied, the process proceeds to S605.
  • the data packets satisfying condition 1 correspond to the data packets shifted to the left, ie, the data packets included in the dashed area 1 .
  • the data packets satisfying condition 2 correspond to the data packets shifted upward, ie, the data packets included in the dashed area 2 .
  • condition three if condition three is satisfied, the process proceeds to S608, and the coordinates of the data packet are changed as follows: the X value is increased by 1, and the Y value remains unchanged; if condition three is not satisfied, the process proceeds to S609.
  • the data packets satisfying condition three correspond to the data packets shifted to the right, ie, the data packets included in the dashed area 3 .
  • condition four if condition four is satisfied, the process proceeds to S610, and the coordinates of the data packet are changed as follows: the X value remains unchanged, and the Y value is increased by 1.
  • the data packets satisfying condition four correspond to the data packets shifted downward, that is, the data packets included in the dashed area 4 .
  • the data packet in addition to being moved into the matrix, can be translated in four ways within the matrix: up, down, left, and right.
  • the translation mode of the data packet can be determined by elimination.
  • the selection and execution order of conditions 1 to 4 in FIG6 are merely exemplary.
  • the server After the server performs K translations on all the data packets in the matrix, it uses P_new in the translated matrix as the data packet number S in the matrix and sends it to the target terminal device. During the sending process, the order of the sub-upgrade packets is disrupted and mixed with interference packets, which greatly increases the difficulty of cracking.
  • the target terminal device can determine the manner (e.g., the direction of movement and clockwise or counterclockwise) and the number of times the received data packet is translated by the server based on the sequence identifier in the identification code read from the flash.
  • the target terminal device can obtain the total number of data packets (e.g., including sub-upgrade packets and interference packets) sent by the server and included in the matrix generated by the server, and the dimension of the matrix generated by the target terminal device based on the number of sub-upgrade packets included in the info packet.
  • the info packet may include the total number of data packets (e.g., including sub-upgrade packets and interference packets) included in the matrix generated by the server, and the target terminal device can generate the dimension of the matrix based on the total number (i.e., the root mean square of the total number).
  • the determination of the dimension of the generated matrix by the target terminal device based on the number of sub-upgrade packets is similar to the description of Figures 5A-5C, and will not be repeated here.
  • the target terminal device can restore the order of the sub-upgrade packages based on the reverse process of the server's translation process of the data packets in the matrix.
  • FIG5D is a schematic diagram of the inverse process of the data packet translation process according to an embodiment of the present disclosure.
  • FIG. 7 is a flowchart of the inverse process of the data packet translation process according to an embodiment of the present disclosure.
  • the sub-upgrade package with the original serial number P_new can be determined in the matrix according to the new serial number P_new.
  • the method of calculating the number of layers is the same as that described in step S602 of FIG. 6 , and will not be repeated here.
  • Take the new sequence number P_new 12 of the data packet located at the center of FIG. 7A as an example.
  • the K value is reduced by 1, and the K value after reduction by 1 is 0.
  • the translation mode of the data packet in the matrix can be determined by the following conditions:
  • the data packets satisfying condition 1 correspond to the data packets shifted to the right, ie, the data packets included in the dashed area 1 .
  • the data packets satisfying condition 2 correspond to the data packets shifted upward, ie, the data packets included in the dashed area 4 .
  • condition three if condition three is met, the process proceeds to S710 , and the coordinates of the data packet are changed as follows: the X value is reduced by 1, and the Y value remains unchanged; if condition three is not met, the process proceeds to S711 .
  • the data packets satisfying condition three correspond to the data packets shifted to the left, ie, the data packets included in the dashed area 3 .
  • condition four if condition four is satisfied, the process proceeds to S712, and the coordinates of the data packet are changed as follows: the X value remains unchanged, and the Y value is increased by 1.
  • the data packets satisfying condition four correspond to the data packets shifted downward, that is, the data packets included in the dashed area 2 .
  • the data packet in addition to being moved out of the matrix, can be translated in four ways within the matrix: up, down, left, and right.
  • the translation mode of the data packet can be determined by elimination.
  • FIG7 shows only three of the four conditions except the preprocessing condition. The selection and execution order of conditions one to three in FIG7 are merely exemplary.
  • the matrix can be restored from FIG. 5C to FIG. 5A.
  • the sequence numbers of the sub-upgrade packages in the matrix are the same as the original sequence of the sub-upgrade packages. According to the sequence numbers of the sub-upgrade packages in the restored matrix and the number of sub-upgrade packages, the sub-upgrade packages with the restored sequence can be obtained.
  • the target terminal device can restore the order of the sub-upgrade packages by continuing to execute the server's translation process of the data packets in the matrix.
  • FIG8 is a flowchart of determining the number of times the translation performed by the server needs to be continued to be executed to restore the sequence of sub-upgrade packages according to an embodiment of the present disclosure.
  • the layer number of the sub-upgrade package with the original serial number P_original in the matrix can be determined according to the original serial number P_original.
  • the determination method is similar to the process described above with reference to FIG. 6, and the description is not repeated.
  • the R value is increased by 1, and the R value after the increase is equal to 1.
  • S802 - S813 are similar to S602 - S613 in FIG6 , and description thereof will not be repeated.
  • the R at the end indicates the number of times the translation performed by the server needs to be continued to restore the sub-upgrade package sequence.
  • 9A-9D are schematic diagrams of the manner in which a server translates a data packet within an odd-dimensional matrix according to different shift-out directions according to an embodiment of the present disclosure.
  • the layer number Layer of each data packet can be determined according to the sequence number P of each data packet. Referring to the first and second layers of FIG5A , when the moving direction is left and rotating clockwise, the movement mode of the data packet in any layer of the matrix is shown in FIG9A .
  • conditions 1 to 5 for determining the moving direction of a data packet described with reference to FIG. 6 can be obtained.
  • 9B is used to describe the movement of data packets in any layer of the matrix when the moving direction is right and the rotation is clockwise.
  • the movement mode of the data packet is the same as that described with reference to FIG. 9A , and will not be described again here.
  • the conditions for the server to determine the movement direction of the data packet in the matrix when the moving direction is right and clockwise can be obtained. For the sake of brevity, the specific conditions are not described again.
  • 9C describes the movement of data packets in any layer of the matrix when the moving direction is upward and the rotation is clockwise.
  • the movement mode of the data packet is the same as that described with reference to FIG. 9A , and will not be described again here.
  • the conditions for the server to determine the movement direction of the data packet in the matrix when the moving direction is upward and rotating clockwise can be obtained. No more describing the specific conditions.
  • 9D describes the movement of data packets in any layer of the matrix when the moving direction is downward and the rotation is clockwise.
  • the movement mode of the data packet is the same as that described with reference to FIG. 9A , and will not be described again here.
  • the conditions for the server to determine the movement direction of the data packet in the matrix when the moving direction is downward and rotating clockwise can be obtained. For the sake of brevity, the specific conditions are not described again.
  • FIG. 10 is a schematic diagram of a server according to an embodiment of the present disclosure changing the order of sub-upgrade packages based on a sequence identifier including an indication that the removal direction is left, counterclockwise.
  • the process of determining the layer in which the data packet is located is the same as the process in FIG5A .
  • the description is not repeated.
  • the process of the server changing the order of the sub-upgrade packages based on the sequence identifier including the indication that the moving direction is left and counterclockwise is similar to the process of the server changing the order of the sub-upgrade packages based on the sequence identifier including the indication that the moving direction is left and clockwise in FIG6 .
  • the translation mode of the data packet in the matrix can be obtained.
  • the packets moved out of the matrix are always placed back at the center (n+1,n+1) of the odd-dimensional matrix.
  • the server can change the order of the sub-upgrade packages by translating the data packets in the matrix in a moving direction such as left, right, up, and down, and in a rotating direction such as clockwise and counterclockwise according to the sequence identifier in the identification code. Accordingly, the target terminal can restore the order of the sub-upgrade packages by the reverse process of the process of the server translating the data packets in the matrix according to the sequence identifier in the identification code.
  • FIG11 is a schematic diagram showing a server according to an embodiment of the present disclosure transforming the order of sub-upgrade packages in a clockwise manner with the shift direction being left within an even-dimensional matrix.
  • interference packages garbled code packages, empty packages, or repeated use of one or more of the 14 sub-upgrade packages
  • the sequence identifier includes data of a preset number of bits indicating that the number of translations K is 1, the direction of the shift is left, and the direction of rotation is clockwise.
  • the data packet at coordinates (1, 4) is shifted out of the matrix to the left, and the data packet is rotated clockwise within the matrix.
  • the data packet shifted out of the matrix is shifted to the position (n, n) that will be vacated in the middle of FIG11 .
  • FIG. 12 is a flowchart of determining a shifting method of a data packet in an even-dimensional matrix according to an embodiment of the present disclosure.
  • the translation mode of the data packet in the matrix can be determined by the following conditions:
  • condition 1 if condition 1 is satisfied, the process proceeds to S1204, and the coordinates of the data packet are changed as follows: the X value is reduced by 1, and the Y value remains unchanged; if condition 1 is not satisfied, the process proceeds to S1205.
  • the data packets satisfying condition 1 correspond to the data packets shifted to the left, that is, the data packets included in the dashed area 1 .
  • condition 2 if condition 2 is met, the process proceeds to S1206, and the coordinates of the data packet are changed. The X value remains unchanged, and the Y value decreases by 1. If the second condition is not met, the process proceeds to S1207.
  • the data packets satisfying condition 2 correspond to the data packets shifted upward, that is, the data packets included in the dashed area 2 .
  • condition three if condition three is met, the process proceeds to S1208, and the coordinates of the data packet are changed as follows: the X value is increased by 1, and the Y value remains unchanged; if condition three is not met, the process proceeds to S1209.
  • the data packets satisfying condition three correspond to the data packets shifted to the right, ie, the data packets included in the dashed area 3 .
  • condition four if condition four is satisfied, the process proceeds to S1210, and the coordinates of the data packet are changed as follows: the X value remains unchanged, and the Y value increases by 1.
  • the data packets satisfying condition four correspond to the data packets shifted downward, that is, the data packets included in the dotted area 4 .
  • the data packet in addition to being moved into the matrix, can be translated in four ways within the matrix: up, down, left, and right.
  • the translation mode of the data packet can be determined by elimination.
  • the selection and execution order of conditions 1 to 4 in FIG. 12 are merely exemplary.
  • the server After the server performs K translations on all the data packets in the matrix, it uses P_new in the translated matrix as the number of the data packet in the matrix and sends it to the target terminal device. During the sending process, the order of the sub-upgrade packets is disrupted and mixed with interference packets, which greatly increases the difficulty of cracking.
  • 13A-13D are schematic diagrams describing the manner in which a server according to an embodiment of the present disclosure translates data packets within an even-dimensional matrix according to different shift-out directions.
  • the layer number Layer of each data packet can be determined according to the sequence number P of each data packet. Referring to the first and second layers of Figure 11, when the moving direction is left and rotating clockwise, the movement mode of the data packet in any layer of the matrix is shown in Figure 13A.
  • conditions 1 to 5 for determining the moving direction of a data packet described with reference to FIG. 12 can be obtained.
  • the packet that was moved out of the matrix is placed back at coordinates (n, n).
  • 13B is used to describe the movement of data packets in any layer of the matrix when the moving direction is right and the rotation is clockwise.
  • the movement mode of the data packet is the same as that described with reference to FIG. 13A, and will not be described again here.
  • the conditions for the server to determine the movement direction of the data packet in the matrix when the moving direction is right and clockwise can be obtained. For the sake of brevity, the specific conditions are not described again.
  • 13C describes the movement of data packets in any layer of the matrix when the moving direction is upward and rotating clockwise.
  • the movement mode of the data packet is the same as that described with reference to FIG. 13A, and will not be described again here.
  • the conditions for the server to determine the movement direction of the data packet in the matrix when the moving direction is upward and rotating clockwise can be obtained. For the sake of brevity, the specific conditions are not described again.
  • 13D describes the movement of data packets in any layer of the matrix when the moving direction is downward and rotating clockwise.
  • the movement mode of the data packet is the same as described with reference to FIG. 13A, and will not be described again here.
  • the conditions for the server to determine the movement direction of the data packet in the matrix when the moving direction is downward and rotating clockwise can be obtained.
  • the specific conditions are not described again.
  • the order of the sub-upgrade packages can be changed by translating the matrix within the matrix of even dimensions to achieve counterclockwise rotation.
  • the detailed process will not be described.
  • the target terminal device can restore the order of the sub-upgrade packages based on the reverse process of the server's translation process of the data packets in the matrix. In one embodiment, the target terminal device can restore the order of the sub-upgrade packages by continuing to execute the server's translation process of the data packets in the matrix.
  • FIG. 14 is a firmware upgrade device for a server according to an embodiment of the present disclosure.
  • 1400 is a firmware upgrade device for a server.
  • the firmware upgrade device 1400 may include a firmware upgrade package acquisition device 1410 for acquiring a target firmware upgrade package.
  • the firmware upgrade device 1400 may include a receiving device 1420 for receiving the identification of the target terminal device. Other code.
  • the firmware upgrade device 1400 may include a splitting device 1430 for splitting the target firmware upgrade package into sub-upgrade packages based on the identification code of the target terminal device.
  • the firmware upgrade device 1400 may include a storage/sending device 1440 for storing and/or sending the sub-upgrade package to a target terminal device.
  • FIG. 15 is a firmware upgrade device for a terminal device according to an embodiment of the present disclosure.
  • 1500 is a firmware upgrade device for a target terminal device.
  • the firmware upgrade device 1500 may include a firmware upgrade instruction acquisition device 1510 for acquiring a firmware upgrade instruction.
  • the firmware upgrade device 1500 may include a sending device 1520 for sending an identification code of a target terminal device.
  • the firmware upgrade device 1500 may include a downloading/receiving device 1530 for downloading/receiving a sub-upgrade package.
  • the firmware upgrade device 1500 may include a splicing device 1540 for splicing sub-upgrade packages into a target firmware upgrade package based on the identification code of the target terminal device.
  • FIG. 16 is a flowchart of secure booting of a target terminal device according to an embodiment of the present disclosure.
  • the terminal device After the terminal device soft restarts, the terminal device runs a secure boot program.
  • the process proceeds to S1603, where the information in the tmp partition preset by the terminal device is obtained and parsed to determine whether to change the order of the sub-upgrade packages.
  • S1603-S1605 the process of determining whether to change the order of the sub-upgrade packages and how to change the order of the sub-upgrade packages is similar to the description of the corresponding part above, and will not be repeated.
  • the target firmware may be security verified based on the firmware upgrade key and/or integrity verification information included in the firmware upgrade instruction.
  • the integrity verification information is, for example, an md5 value, or other integrity verification information, which is not limited in this embodiment.
  • the info package sent to the target terminal device may also include a firmware upgrade key and/or integrity verification information.
  • the target firmware is security verified based on the firmware upgrade key and/or integrity verification information, when the firmware upgrade key carried by the info package and sent to the terminal device is consistent with the firmware upgrade key in the firmware upgrade instruction, and/or the integrity verification information of the terminal device is consistent with the firmware upgrade key in the firmware upgrade instruction. If the integrity verification information in the instruction is consistent, the security verification is passed. If the security verification fails, the process ends. If the security verification passes, the process proceeds to S1607.
  • the firmware upgrade package can be run.
  • the firmware upgrade package can be copied to the run address and jumped to the run address to run the upgraded target firmware.
  • the firmware upgrade package can be run directly from the corresponding partition in the flash.
  • the startup information of the target firmware can be modified to be upgraded.
  • the security of firmware upgrade can be further improved on the basis of splitting the sub-upgrade packages and transmitting and downloading them in a sequentially transformed manner, and the integrity check of the firmware and the configuration operation of secure boot can be implemented to ensure the legitimacy of the firmware.
  • FIG. 17 is a flowchart of off-network and on-network combined security verification for a target terminal device according to an embodiment of the present disclosure.
  • the target terminal device can obtain the firmware upgrade instruction and the security verification key by being separated from the wide area network.
  • the target terminal device can obtain the firmware upgrade instruction and the security verification key from the broadcasting device separated from the wide area network in the form of broadcasting or point-to-point communication.
  • the broadcasting device separated from the wide area network can be, for example, a handheld broadcasting device.
  • the target terminal device can obtain the download base address from the broadcasting device separated from the wide area network.
  • the target terminal device can obtain the download address of the firmware upgrade package based on the default modifiable address, download base address, and identification code.
  • the broadcasting device separated from the wide area network can be realized by short-range wireless communication such as Bluetooth, Bluetooth LE, ZigBee, radio frequency identification (RFID), UWB, 60GHz, Wi-Fi, WiMAX, or wired communication such as USB. Since the broadcasting device is separated from the wide area network, not using the wide area network can well avoid the security risks during transmission through the wide area network.
  • short-range wireless communication such as Bluetooth, Bluetooth LE, ZigBee, radio frequency identification (RFID), UWB, 60GHz, Wi-Fi, WiMAX, or wired communication such as USB.
  • the target terminal device may obtain the firmware upgrade package and the firmware upgrade package security key via the wide area network.
  • the target terminal device may determine whether the security verification key matches the firmware upgrade package security key. For example, the target terminal device may determine whether the security verification key obtained by leaving the wide area network matches the firmware upgrade package security key obtained via the wide area network. If they match, the firmware upgrade package is confirmed to be safe, otherwise risk information is reported.
  • the process of the target terminal device obtaining the firmware upgrade package may be similar to the above-mentioned terminal device firmware upgrade process based on the identification code and the secure boot process for the target terminal device, and will not be repeated here.

Landscapes

  • Engineering & Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computing Systems (AREA)
  • Stored Programmes (AREA)

Abstract

一种固件升级方法、设备、服务器、终端设备及存储介质,其中,固件升级方法包括,获取目标固件升级包;接收目标终端设备的识别码;基于所述目标终端设备的识别码,将所述目标固件升级包拆分成子升级包;将所述子升级包进行存储和/或将所述子升级包发送至目标终端设备。

Description

固件升级方法、设备、服务器、终端设备及存储介质
本申请要求于2022年10月21日递交的第202211295975.2号中国专利申请的优先权,在此全文引用上述中国专利申请公开的内容以作为本申请的一部分。
技术领域
本发明涉及固件升级技术领域,尤其涉及一种固件升级方法、设备、服务器、终端设备及存储介质。
背景技术
与传统意义上的网络安全不同,物联网(Internet of Things,简称IoT)安全是网络安全与其他工程学科相融合的产物。相比于单纯的数据、服务器、网络基础架构和信息安全,物联网安全的内涵要更加丰富。而且,物联网安全还需要包括对联网物理系统状态的直接或分布式的监测和控制。
物联网系统中存在大量的终端设备,其中很大一部分又是算力及存储资源有限的单片机设备。在这种资源严重受限的设备环境中,传统的基于操作系统的安全管理如防火墙、应用商店等解决方案是无法保证设备在升级中的安全问题的。
因此,本领域亟需一种安全的固件升级方案,来有效避免终端设备的固件升级过程中的安全风险。
发明内容
本发明提供一种固件升级方法、设备、服务器、终端设备及存储介质,能够有效避免固件升级过程中的安全风险。
根据本公开的实施例,提供了一种应用于服务器端的固件升级方法,其中,包括:获取目标固件升级包;接收目标终端设备的识别码;基于目标终端设备的识别码,将目标固件升级包拆分成子升级包;将子升级包进行存储和/或将子升级包发送至目标终端设备。
根据本公开的实施例的应用于服务器端的固件升级方法还包括,通过目标终端设备的识别码获得子升级包的大小,基于子升级包的大小,确定拆分的子升级包的数量。
根据本公开的实施例的应用于服务器端的固件升级方法,还包括,基于子升级包的识别码和默认可修改地址,确定目标终端设备下载子升级包的下载地址。
根据本公开的实施例的应用于服务器端的固件升级方法,还包括,通过目标终端设备的识别码获得子升级包的顺序标识,基于子升级包的顺序标识,确定是否变换子升级包顺序,响应于确定不变换子升级包顺序,按照子升级包的初始顺序对子升级包进行编号,响应于确定变换子升级包顺序,变换子升级包顺序,按照子升级包的变换后的顺序对子升级包进行编号。
根据本公开的实施例的应用于服务器端的固件升级方法,其中,子升级包中的每一个包括子升级包包头,子升级包包头包括子升级包的编号。
根据本公开的实施例的应用于服务器端的固件升级方法,其中,子升级包包头还包括目标终端设备的识别码以及目标固件升级包所拆分的子升级包的数量中的至少一个。
根据本公开的实施例的应用于服务器端的固件升级方法,其中,基于子升级包的顺序标识,确定是否变换子升级包顺序包括:识别顺序标识指示的数值,基于顺序标识指示的数值确定是否变换子升级包顺序。
根据本公开的实施例的应用于服务器端的固件升级方法,其中,基于顺序标识指示的数值确定是否变换子升级包顺序包括基于顺序标识指示的数值是否为第一预定数值确定是否变换子升级包顺序。
根据本公开的实施例的应用于服务器端的固件升级方法,其中,基于顺序标识指示的数值确定是否变换子升级包顺序包括:将顺序标识指示的数值对第二预定数值取余,获得余数,其中,第二预定数值为大于等于2的自然数,基于余数,确定是否变换子升级包顺序。
根据本公开的实施例的应用于服务器端的固件升级方法,其中,第二预定数值为2,其中,基于顺序标识指示的数值确定是否变换子升级包顺序包括基于顺序标识指示的数值的奇偶性确定是否变换子升级包顺序。
根据本公开的实施例的应用于服务器端的固件升级方法,其中,基于顺序 标识变换子升级包顺序包括:识别顺序标识指示的数值,基于顺序标识指示的数值变换子升级包顺序。
根据本公开的实施例的应用于服务器端的固件升级方法,其中,顺序标识包括预定位数的数据,识别顺序标识指示的数值包括识别数据指示的数值,其中,变换子升级包顺序包括:将子升级包划分为子升级包组,每个子升级包组包括初始顺序相邻的特定数量的子升级包,其中,特定数量为预定位数的数据能够指示的最大数值加1,将每个子升级包组中初始顺序相差数据指示的数值的两个子升级包的顺序交换。
根据本公开的实施例的应用于服务器端的固件升级方法,其中,变换子升级包顺序包括:将子升级包划分为子升级包组,每个子升级包组包括初始顺序相邻的特定数量的子升级包,其中,特定数量在服务器处预先确定,将每个子升级包组中初始顺序相差小于特定数量的数值的两个子升级包的顺序交换。
根据本公开的实施例的应用于服务器端的固件升级方法,还包括,根据子升级包的数量生成矩阵,将子升级包在矩阵中排列,其中,变换子升级包顺序包括根据顺序标识在矩阵中平移子升级包。
根据本公开的实施例的应用于服务器端的固件升级方法,其中,根据子升级包的数量生成矩阵包括根据子升级包的数量确定生成奇数维度矩阵还是偶数维度矩阵。
根据本公开的实施例的应用于服务器端的固件升级方法,还包括使用乱码包、空包和重复的子升级包中的一个或多个填满矩阵。
根据本公开的实施例的应用于服务器端的固件升级方法,其中,顺序标识指示矩阵中的子升级包的平移次数、子升级包的移出方向、子升级包在矩阵中旋转的顺逆时针中的一个或多个。
根据本公开的实施例的应用于服务器端的固件升级方法,还包括,根据子升级包在矩阵中的序号以及矩阵的维度,确定子升级包的平移方式。
根据本公开的实施例的应用于服务器端的固件升级方法,还包括,将目标固件升级包的包头进行存储和/或发送至目标终端设备,其中,目标固件升级包的包头包括目标终端设备的识别码、子升级包的数量和编号、固件升级密钥和/或完整性验证信息中的一个或多个。
根据本公开的实施例,提供了一种应用于终端设备的固件升级方法,其 中,包括:获取固件升级指令;发送目标终端设备的识别码;从服务器下载子升级包;基于目标终端设备的识别码,将子升级包拼接成目标固件升级包。
根据本公开的实施例的应用于终端设备的固件升级方法,还包括,从服务器下载固件升级包的包头,以及通过安全引导程序进行:响应于全部子升级包和固件升级包包头下载到终端设备,基于终端设备的识别码中的顺序标识,确定是否变换下载的子升级包的顺序;对下载的子升级包进行安全性或完整性校验;响应于下载的子升级包通过安全性或完整性校验,运行通过子升级包拼接的目标固件。
根据本公开的实施例的应用于终端设备的固件升级方法,其中,获取固件升级指令包括通过脱离广域网的方式获取固件升级指令以及安全验证密钥;其中,从服务器下载子升级包包括经由广域网获得固件升级包以及固件升级包安全密钥;对下载的子升级包进行安全性校验包括确定安全验证密钥与固件升级包安全密钥是否匹配。
根据本公开的实施例,提供了一种固件升级设备,应用于服务器,其中,包括:固件升级包获取装置,用于获取目标固件升级包;接收装置,用于接收目标终端设备的识别码;拆分装置,用于基于目标终端设备的识别码,将目标固件升级包拆分成子升级包;存储/发送装置,用于将子升级包进行存储和/或发送至目标终端设备。
根据本公开的实施例,提供了一种固件升级设备,应用于终端设备,其中,包括:固件升级指令获取装置,用于获取固件升级指令;接收装置,用于发送目标终端设备的识别码;下载/接收装置,用于下载/接收子升级包;拼接装置,用于基于目标终端设备的识别码,将子升级包拼接成目标固件升级包。
根据本公开的实施例,提供了一种服务器,其中,包括存储器和一个或多个处理器,存储器上存储有计算机程序,计算机程序被一个或多个处理器执行时实现上述应用于服务器的固件升级方法。
根据本公开的实施例,提供了一种终端设备,其中,包括存储器和一个或多个处理器,存储器上存储有计算机程序,计算机程序被一个或多个处理器执行时实现上述应用于终端设备的固件升级方法。
根据本公开的实施例,提供了一种用于安全引导的方法,用于终端设备,其中,包括:响应于全部子升级包和固件升级包包头下载到终端设备,基于终 端设备的识别码中的顺序标识,确定是否变换下载的子升级包的顺序;对下载的子升级包进行安全性或完整性校验;响应于下载的子升级包通过安全性或完整性校验,运行通过子升级包拼接的目标固件。
根据本公开的实施例,提供了一种用于目标终端设备的安全验证方法,其中,包括:通过脱离广域网的方式获取固件升级指令以及安全验证密钥;经由广域网获得固件升级包以及固件升级包安全密钥;确定安全验证密钥与固件升级包安全密钥是否匹配。
根据本公开的实施例的安全验证方法,其中,经由广域网获得固件升级包包括从服务器下载子升级包,其中,方法还包括:发送目标终端设备的识别码;基于目标终端设备的识别码,将子升级包拼接成目标固件升级包。
根据本公开的实施例的安全验证方法,还包括,从服务器下载固件升级包的包头,以及通过安全引导程序进行:响应于全部子升级包和固件升级包包头下载到目标终端设备,基于目标终端设备的识别码中的顺序标识,确定是否变换下载的子升级包的顺序;对下载的子升级包进行安全性或完整性校验;响应于下载的子升级包通过安全性或完整性校验,运行通过子升级包拼接的目标固件。
附图说明
从以下结合附图的描述中,本公开的特定实施例的上述和其他方面、特征和优点将变得更加清晰,其中:
图1是根据本公开的实施例的应用于服务器的固件升级方法的流程图;
图2是根据本公开的实施例的应用于终端设备的固件升级方法的流程图;
图3是根据本公开的实施例的应用于服务器的固件升级方法的流程图;
图4是根据本公开的实施例的应用于终端设备的固件升级方法的流程图;
图5A-图5C是根据本公开的实施例的服务器在奇数维度矩阵内顺时针、移出方向为左变换子升级包顺序的示意图;
图5D是根据本公开的实施例的数据包的平移过程的逆过程的示意图;
图6是根据本公开的实施例的确定奇数矩阵中的数据包的平移方式的流程图;
图7是根据本公开的实施例的数据包的平移过程的逆过程的流程图;
图8是根据本公开的实施例的确定恢复子升级包顺序需要继续执行服务器执行的平移的次数的流程图;
图9A-图9D是根据本公开的实施例的服务器根据不同移出方向在奇数维度矩阵内平移数据包的方式的示意图;
图10是根据本公开的实施例的服务器基于包括指示移出方向为左,逆时针的顺序标识来变换子升级包顺序的示意图;
图11是根据本公开的实施例的服务器在偶数维度矩阵内顺时针、移出方向为左变换子升级包顺序的示意图;
图12是根据本公开的实施例的确定偶数维度矩阵中的数据包的平移方式的流程图;
图13A-图13D是描述根据本公开的实施例的服务器根据不同移出方向在偶数维度矩阵内平移数据包的方式的示意图;
图14是根据本公开的实施例的用于服务器的固件升级设备;
图15是根据本公开的实施例的用于终端设备的固件升级设备;
图16是根据本公开的实施例的用于目标终端设备的安全引导的流程图;
图17是根据本公开的实施例的用于目标终端设备的离网与联网结合的安全验证的流程图。
具体实施方式
在进行下面的详细描述之前,阐述贯穿本专利文件使用的某些单词和短语的定义可能是有利的。术语“包括”和“包含”及其派生词是指包括但不限于。术语“控制器”或“控制单元”是指控制至少一个操作的任何设备、系统或其一部分。这种控制器可以用硬件、或者硬件和软件和/或固件的组合来实施。与任何特定控制器相关联的功能可以是集中式的或分布式的,无论是本地的还是远程的。短语“至少一个”,当与项目列表一起使用时,意指可以使用所列项目中的一个或多个的不同组合,并且可能只需要列表中的一个项目。例如,“A、B、C中的至少一个”包括以下组合中的任意一个:A、B、C、A和B、A和C、B和C、A和B和C。
贯穿本专利文件提供了其他特定单词和短语的定义。本领域普通技术人员应该理解,在许多情况下,即使不是大多数情况下,这种定义也适用于这样 定义的单词和短语的先前和将来使用。
以下结合附图描述本专利文档中的本公开的原理的各种实施例仅作为说明,并且不应以任何方式解释为限制本公开的范围。本领域技术人员将理解,本公开的原理可以在任何适当布置的系统或设备中实施。在一些情况下,说明书描述的动作可以按不同的顺序执行,并且仍然可以达到期望结果。此外,附图描绘的过程不一定要求所示的特定顺序或依次顺序来达到期望结果。在特定实施方式中,多任务和并行处理可能是有利的。
物联网(Internet of Thing,简称IoT)是通过各种信息传感器、射频识别技术、全球定位系统、红外感应器、激光扫描器等各种装置与技术,实时采集任何需要监控、连接、互动的物体或过程,采集其声、光、热、电、力学、化学、生物、位置等各种需要的信息,通过各类可能的网络接入,实现物与物、物与人的泛在连接,实现对物品和过程的智能化感知、识别和管理。物联网是一个基于互联网、传统电信网等的信息承载体,它让所有能够被独立寻址的普通物理对象形成互联互通的网络。与传统意义上的网络安全不同,物联网安全是网络安全与其他工程学科相融合的产物。相比于单纯的数据、服务器、网络基础架构和信息安全,物联网安全的内涵要更加丰富。而且,物联网安全还需要包括对联网物理系统状态的直接或分布式的监测和控制。物联网系统中存在大量的终端设备,其中很大一部分又是算力及存储资源有限的单片机设备。在这种资源严重受限的设备环境中,传统的基于操作系统的安全管理如防火墙、应用商店等解决方案是无法保证设备在升级中的安全问题的。
以Android系统的终端设备为例,一些情形中可通过应用商店进行固件升级,尽管升级数据包的源头合法且传输过程中也存在加密处理,但无论是完整包还是差分包均是以整体的形式进行整个升级过程,且每个终端设备进行相同固件升级时的固件升级包及升级过程均相同,无法有效避免升级过程中的安全风险,另一些情形中可通过网页下载APK格式的固件升级包进行固件升级,由于涉及用户对风险的主观判断和选择,同样难以有效避免固件升级过程中的安全风险。
本发明实施例提供一种固件升级方法、装置、服务器、终端设备及存储介质,能够有效避免固件升级过程中的安全风险,由于不同设备可能具有不同的识别码,进而不同设备的子升级包和固件升级过程可能不同,单一设备被黑客 攻击无法泄漏其他设备信息,很难在网络中观察出规律并大范围干扰终端设备的固件升级。系统的破解难度和终端设备数量成正比,尤其适用于大范围的传感器和控制器网络,适用于军用和工厂端场景。
图1是根据本公开的实施例的应用于服务器的固件升级方法的流程图。
在步骤S101,服务器获取目标固件升级包。例如,可以获得开发人员制作的固件升级包。当开发人员开发了升级的固件,升级的固件会添加或重写设备上的现有固件,使其再次以最高效率和安全性操作。例如,如果存在需要解决的故障或创建了新的安全补丁,则当前安装的固件将不再适用。对于经常访问互联网或需要不断更新安全功能的设备,固件升级可能非常频繁。在实际应用中,可以将固件升级包看作整体文件,由开发人员在制作固件升级包时调试并测试完成。
在步骤S102,服务器接收目标终端设备的识别码。例如,服务器从目标终端设备接收其识别码。
目标终端设备可以指待升级的终端设备,终端设备可以是物联网中的任一终端设备,例如,各种信息传感器、射频识别设备、全球定位系统、红外感应器、激光扫描器、电脑等。
一些实现方式中,识别码可以指预先配置终端设备的SN(序列号,Serial Number)码,相关技术中的固件升级包都是制作成统一的升级包文件,因此,在对批量终端设备进行固件升级时,每个终端设备进行相同固件升级时的固件升级包及升级过程均相同,一旦固件升级包传输(下载)过程中被监听,易使整个固件升级包泄露甚至被篡改,使得同样固件升级需求的终端设备在进行固件升级时的安全性无法得到有效保证。
本实施例中所采用的固件升级的安全机制中,每个终端设备都设置有配置具有一定定制性的识别码,在识别码中的至少部分字段配置有升级信息,针对每个终端设备进行识别码的定制,由于具有相同固件升级需求的终端设备的识别码的配置不同或者不完全相同,使得拆包传输(下载)的具体形式不是全部一致,因而即使单个终端设备的信息泄露,也不会带来整个系统所有终端设备的安全问题。
在一些实现方式中,升级信息包括子升级包的大小、子升级包的顺序标识、子升级包的下载地址偏移量中的至少一个。其中,子升级包的大小是拆分 子升级包时每个子升级包的大小,例如可以用7比特来传输子升级包的大小;子升级包的顺序标识用于区分是否变换各子升级包的顺序以及如何变换各子升级包的顺序,以变换拆分后的子升级包的传输顺序,提升传输过程中的复杂度,避免被监听时泄露整个固件升级包甚至被篡改,实际中可以根据为不同的终端设备设置子升级包的顺序标识,可以随机设置,也可以按照一定规律设置,本实施例不做限定。
识别码的组成示例如表1所示:
表1
表1中的识别码,包括头部字段、子升级包的顺序标识、子升级包的大小、子升级包的下载地址偏移量和尾部字段。子升级包的顺序标识、子升级包的大小、子升级包的下载地址偏移量在识别码中的位置仅是示意性的,并且其可以以不同的顺序位于识别码中。可以根据实际的标识码配置规则确定标识码的总位数以及各种升级信息、头部字段、尾部字段等字节(或位数)。其中,头部字段、尾部字段可以参考相关技术中的SN中的头部字段、尾部字段设置,来标识对应的终端设备的基本信息,也可以自定义设置头部字段、尾部字段,在一些情况下还可以省略头部字段、尾部字段,即:识别码仅以升级信息来配置。
步骤S103,服务器基于目标终端设备的识别码,将目标固件升级包拆分成子升级包。由服务器进行固件升级过程中的拆包存储或传输。在拆包时可能需要输入待升级的终端设备的识别号或者服务器自动根据终端设备的识别号进行固件升级包的拆包。在一个实施例中,服务器可以基于目标固件升级包的大小和目标终端设备的识别码中的子升级包的大小,将目标固件升级包拆分成若干数量的子升级包。可替代地,服务器可以基于目标固件升级包的大小和预定子升级包的大小或基于其他机制,将目标固件升级包拆分成若干子升级包。在一个实施例中,服务器可以基于目标终端设备的识别码中的子升级包的 顺序标识确定是否变换各子升级包的顺序以及如何变换各子升级包的顺序。
在步骤S104,服务器将子升级包进行存储和/或发送至目标终端设备。服务器将可以将各子升级包文件存储在服务器中等待目标终端设备固件升级时发送。可替代或附加地,在当前目标终端设备处于固件升级时,将子升级包文件发送给目标终端设备。在实际应用中,服务器可以先将拆分的若干子升级包进行存储,在终端设备请求时开始发送子升级包至目标终端设备。可替代或附加地,服务器可以自动发送至目标终端设备。在一个实施例中,可以在将拆分的若干子升级包同时进行存储和发送至目标终端设备,以实现备份。在一个实施例中,服务器可以基于目标终端设备的识别码确定存储子升级包的地址,以供终端设备从该地址下载子升级包。例如,服务器可以从终端设备接收终端设备的识别码sn001。服务器基于默认的可修改的地址PROTOCOL://HOSTNAME/PATH/SN以及目标终端设备的识别码sn001,将子升级包存储在PROTOCOL://HOSTNAME/PATH/sn001。目标终端设备可以从地址PROTOCOL://HOSTNAME/PATH/sn001下载子升级包。上述地址的具体形式是示例性的,而非限制性的。可替代地,服务器可以将子升级包存储在预定地址,以供终端设备从预定地址下载子升级包。
图2是根据本公开的实施例的应用于终端设备的固件升级方法的流程图。终端设备可以是各种物联网终端设备,例如,智能传感器(诸如,用于收集例如温度、湿度、振动、压力、液位等周围环境数据的传感器)、智能家居设备(诸如,智能插座、智能电灯、智能音响、智能洗衣机、智能冰箱、智能空气净化器等)、智能穿戴设备(诸如,智能手表、运动手环、智能眼镜等)、智能交通设备(诸如,智能路灯、智能汽车、智能停车场等)、智能医疗保健设备(诸如,智能血压计、智能健康手环、智能叫号机)、智能工业设备(诸如,数控机床、工业机器人)等。可以以嵌入式技术或者其他技术实现上述终端设备。
在步骤S201,终端设备获取固件升级指令。在一些实现方式中,固件升级指令由脱离广域网的广播设备发送或者由终端设备的预设按键触发。脱离广域网的广播设备例如可以是手持广播设备。可以使用诸如蓝牙、蓝牙LE、ZigBee、射频识别(RFID)、UWB、60GHz、Wi-Fi、WiMAX等短程无线通信或者USB等有线通信方式实现脱离广域网的广播设备。由于广播设备是脱离 广域网的,不使用广域网能够很好地避免通过广域网传输时的安全风险。终端设备还可以预设按键,例如,诸如拨动按键、滑动按键、按钮等物理按键以及在触摸屏上显示的特定区域,以便触发固件升级指令,实现离网和联网相配合的升级策略。在一个实施例中,固件升级指令可以由服务器通过广域网,向终端设备发送。在实际应用中,可以根据固件升级的需求,选择广播设备发送固件升级指令、终端设备的预设按键触发固件升级指令、服务器通过广域网发送固件升级指令中的一个或多个。
在步骤S202,终端设备发送目标终端设备的识别码。例如,终端设备可以从终端设备的flash芯片的存储区域获得目标终端设备的识别码。已经在图1的步骤S102中对目标终端设备的识别码进行了描述,此处不再重复描述。
在步骤S203,终端设备接收(下载)子升级包。在一个实施例中,终端设备可以从服务器下载子升级包。
在一个实施例中,识别码还可以包括存储地址偏移量,但这不是必须的。例如,终端设备将子升级包存储到基于可修改存储地址和存储地址偏移量确定的终端设备的闪存(flash)的存储地址中。从而实现子升级包在终端设备中的分区存储。子升级包的存储地址偏移量用于确定子升级包在终端设备中的存储地址,以实现子升级包在终端设备中分区存储。实际应用中子升级包存储于终端设备的flash芯片,通过在flash芯片划分不同的存储区域,实现子升级包在终端设备中分区存储。
终端设备flash芯片的存储区域划分示例,如表2所示:
表2

可以看出,通过在flash芯片划分不同的存储区域,实现子升级包在终端设备中分区存储。
在一个实施例中,终端设备可以基于终端设备的识别码以及根据下载地址偏移量从终端设备的flash芯片读取的默认的可修改下载地址,确定从服务器下载子升级包的地址。例如,在表2的示例中,终端设备可以基于从flash芯片的00000000地址读取的识别码,获得目标终端设备的下载地址偏移量address_offset001。并且终端设备可以基于address_offset001从flash芯片的地址0000000F读取可修改的地址PROTOCOL://HOSTNAME/PATH/SN,根据终端设备的识别码sn001以及可修改的地址PROTOCOL://HOSTNAME/PATH/SN,确定从PROTOCOL://HOSTNAME/PATH/sn001下载服务器存储的子升级包。上述地址的具体形式是示例性的,而非限制性的。可替代地,终端设备可以从预定地址下载子升级包。
在步骤S204,基于目标终端设备的识别码,将子升级包拼接成目标固件升级包。例如,终端设备可以基于目标终端设备的识别码中的子升级包的顺序标识,确定是否变换接收的各子升级包的顺序以及如何变换各子升级包的顺序,从而进一步将子升级包拼接成目标固件升级包。在一个实施例中,拼接可以指按顺序从目标终端设备的存储区域读取子升级包。在一些实施例中,将子 升级包拼接成目标固件升级包之后,还进行软重启。
图3是根据本公开的实施例的应用于服务器的固件升级方法的流程图。
在步骤S301,服务器获取目标固件升级包。图3的步骤S301与图1的步骤S101相似的部分,在此不再重复描述。
在步骤S302,服务器接收目标终端设备的识别码。图3的步骤S302与图1的步骤S102相似的部分,在此不再重复描述。
在步骤S303,服务器基于目标终端设备的识别码确定是否将子升级包进行顺序变换。当确定将子升级包进行顺序变换时,流程行进到S304。在S304,服务器将目标固件升级包拆分成子升级包,执行顺序变换,并将子升级包编号。当确定将子升级包不进行顺序变换时,流程行进到S305。在S304,服务器将目标固件升级包拆分成子升级包,不执行顺序变换,并将子升级包编号。在一个实施例中,服务器上各子升级包的编号为0001,0002,0003,0004,0005。无论各子升级包的顺序是否经过变换,编号均为按顺序编写,其指示了各子升级包的传输顺序。在一个实施例中,每个子升级包的包头可以包括子升级包的编号。在一个实施例中,每个子升级包的包头还可以包括目标终端设备的识别码和子升级包的数量。
在一个实施例中,顺序标识可以是二进制数据。但二进制数据仅仅是示例性的,在其他实施例中,顺序标识可以是其他形式的标识。
在一些实现方式中,步骤S303,根据预设位数的二进制数据对应的数值是否为预定数值(例如,0),来确定在将目标固件升级包拆分成若干子升级包的同时是否将各子升级包进行顺序变换。通过顺序标识来确定并在拆分时调整子升级包的顺序,可以提升固件升级包的传输(下载)的安全性。
例如,一种具体的变换顺序规则可以是,在S304,将若干子升级包划分为若干对相邻的子升级包,将每对相邻的子升级包中的两个子升级包的顺序交换,以此规则变换子升级包的顺序后,使得固件升级包的传输(下载)固件升级包时的被监听而泄露和篡改的难度明显增大,提升了固件升级的安全性。
一个示例中,预设位数为1,则二进制数据包括0或1,对应的数值也是0或1,进而,步骤S303,当前终端设备的识别码中顺序标识对应的二进制数据对应的数值为0时,将目标固件升级包拆分成若干子升级包的同时各子升级包的顺序不变,而当前终端设备的识别码中顺序标识对应的二进制数据对 应的数值为1时,将目标固件升级包拆分成若干子升级包的同时需要将各子升级包进行顺序变换。可替代地,可以作与上述相反的设定。
在预设位数为1位的一些实现方式中,在S304,可以将相邻的子升级包交换顺序,以实现子升级包的顺序变换。因此,根据预设位数的二进制数据对应的数值将各子升级包进行顺序变换,包括:将若干子升级包划分为若干对相邻的子升级包;以及将每对相邻的子升级包中的两个子升级包的顺序交换。继续前面的示例,预设位数为1,则二进制数据包括0或1,当前终端设备的识别码中顺序标识对应的二进制数据对应的数值为1时,确定将各子升级包进行顺序变换,此时,将对目标固件升级包拆分所得的若干子升级包划分为若干对相邻的子升级包,每一对中的两个子升级包的顺序交换。而当前终端设备的识别码中顺序标识对应的二进制数据对应的数值为0时,则无需作此顺序交换操作,保持原始顺序即可。
另一个示例中,预设位数为2,则二进制数据包括00、01、10、11,对应的数值是0、1、2、3,进而,步骤S303,当前终端设备的识别码中顺序标识对应的二进制数据00对应的数值为0时,将目标固件升级包拆分成若干子升级包的同时各子升级包的顺序不变,而当前终端设备的识别码中顺序标识对应的二进制数据01、10或11对应的数值为1、2、3时,将目标固件升级包拆分成若干子升级包的同时需要将各子升级包进行顺序变换。可替代地,可以作与上述设定不同的设定。
在一些实现方式中,步骤S303,还可以根据预设位数的二进制数据对应的数值的奇偶性来确定是否进行子升级包的顺序变换。因此,根据预设位数的二进制数据对应的数值,确定在将目标固件升级包拆分成若干子升级包的同时是否将各子升级包进行顺序变换,包括:若预设位数的二进制数据对应的数值为偶数,确定将目标固件升级包拆分成若干子升级包的同时各子升级包的顺序不变;若预设位数的二进制数据对应的数值为奇数,确定将目标固件升级包拆分成若干子升级包的同时将各子升级包进行顺序变换。可替代地,若预设位数的二进制数据对应的数值为奇数,确定将目标固件升级包拆分成若干子升级包的同时各子升级包的顺序不变;若预设位数的二进制数据对应的数值为偶数,确定将目标固件升级包拆分成若干子升级包的同时将各子升级包进行顺序变换。当预设位数为1位时,根据奇偶性确定是否变换子升级包的顺 序的过程与根据顺序标识为0还是为1来确定是否变换子升级包的顺序的过程类似。
在一些实现方式中,步骤S303,还可以根据预设位数的二进制数据对应的数值对预定数值取余来确定是否进行子升级包的顺序变换。因此,根据预设位数的二进制数据对应的数值对预定数值取余,确定在将目标固件升级包拆分成若干子升级包的同时是否将各子升级包进行顺序变换,包括:若根据预设位数的二进制数据对应的数值对预定数值取余为一个或多个特定数值中的一个,确定将目标固件升级包拆分成若干子升级包的同时各子升级包的顺序不变;若根据预设位数的二进制数据对应的数值对预定数值取余不是一个或多个特定数值,确定将目标固件升级包拆分成若干子升级包的同时将各子升级包进行顺序变换。可替代地,若根据预设位数的二进制数据对应的数值对预定数值取余为一个或多个特定数值,确定将目标固件升级包拆分成若干子升级包的同时将各子升级包进行顺序变换;若根据预设位数的二进制数据对应的数值对预定数值取余不是一个或多个特定数值,确定将目标固件升级包拆分成若干子升级包的同时各子升级包的顺序不变。例如,当预设数值为3时,根据预设位数的二进制数据对应的数值对预定数值取余为特定数值(例如,0),可以确定在将目标固件升级包拆分成若干子升级包的同时是否将各子升级包进行顺序变换。当预设数值为2时,根据预设位数的二进制数据对应的数值对预定数值取余来确定是否进行子升级包的顺序变换的过程与根据奇偶性确定是否变换子升级包的顺序的过程类似。
在一些实现方式中,可以将根据预设位数的二进制数据对应的数值确定顺序交换的规则。因此,步骤S304,根据预设位数的二进制数据对应的数值将各子升级包进行顺序变换,包括:将子升级包划分为若干子升级包组,每个子升级包组中包括特定数量子升级包,该特定数量为预设位数的最大二进制数据对应的数值加1;以及将每组子升级包中顺序相差该预设位数的二进制数据对应的数值的两个子升级包的顺序交换。
继续前面的示例中,预设位数为2时,二进制数据包括00、01、10、11,2位的最大二进制数据对应的数值是3,进而,当前终端设备的识别码中顺序标识对应的二进制数据00对应的数值为0时,将目标固件升级包拆分成若干子升级包的同时各子升级包的顺序不变,无需交换。但当前终端设备的识别码 中顺序标识对应的二进制数据01、10或11对应的数值为1、2、3时,将目标固件升级包拆分成若干子升级包的同时需要将各子升级包进行顺序变换。以顺序标识对应的二进制数据为10为例,对应的数值为2,此时进行顺序变换的具体方式是:将若干子升级包划分为若干组子升级包,每一组中包含4(即:最大二进制数据对应的数值3+1)个子升级包,其中第一组包括第0包、第1包、第2包、第3包,将顺序上相差2位的两个子升级包的顺序交换,即:第0包与第2包交换,第1包与第3包交换。在预设位数为1的情况下,根据预设位数的最大二进制数据对应的数值加1进行子升级包进行分组、并根据预设位数的最大二进制数据对应的数值对子升级包的顺序进行变换的过程,与将子升级包划分为若干对相邻的子升级包、以及将每对相邻的子升级包中的两个子升级包的顺序交换来对子升级包的顺序进行变换的过程类似。基于相似的原理,预设位数为3位、4位……N位的情形,本实施例中不再一一举例,预设位数越多和/或交换顺序的规律越复杂,固件升级过程中的传输(下载)复杂度越高。
虽然上述部分实施例将确定是否变换以及变换的方式与顺序标识的预设位数相关联。但本公开不限于此。例如,在预设位数为1的实施例中,二进制数据包括0或1,对应的数值也是0或1,进而,步骤S303,当前终端设备的识别码中顺序标识对应的二进制数据对应的数值为0时,将目标固件升级包拆分成若干子升级包的同时各子升级包的顺序不变,而当前终端设备的识别码中顺序标识对应的二进制数据对应的数值为1时,将目标固件升级包拆分成若干子升级包的同时需要将各子升级包进行顺序变换。但变换方式可以是将子升级包划分为若干子升级包组,每个子升级包组中包括某个数量子升级包,该数量为服务器与目标终端设备先前预定的数量(大于等于2);以及将每组子升级包中顺序相差该数量减1(或者顺序相差小于该数量的其他数值,例如顺序相差小于该数量减2等)的两个子升级包的顺序交换。例如,在根据预设位数的二进制数据对应的数值对预定数值取余来确定是否进行子升级包的顺序变换的实施例中,可以在服务器和目标终端设备之间分别设定对不同余数的目标终端设备的子升级包顺序的变换方式。例如,当余数为0时,可以不变换子升级包顺序。在余数为1时,可以将子升级包划分为若干对相邻的子升级包、以及将每对相邻的子升级包中的两个子升级包的顺序交换。在 余数为2时,可以将若干子升级包划分为若干组子升级包,每一组中包含3(即,余数加1)个子升级包,将顺序上相差2(即,余数)位的两个子升级包的顺序交换。但本公开不限于此。
在S306,服务器生成目标固件升级包的包头。目标固件升级包的包头可以包括目标终端设备的识别码、子升级包的数量和编号、固件升级密钥和/或完整性验证信息中的一个或多个。固件升级密钥和/或完整性验证信息可以供终端设备在安全引导流程中安全验证使用。
在S307,服务器将子升级包以及info包进行存储和/或发送至目标终端设备。info包相当于提供目标固件升级包的包头的数据包。图3的S307中与图1的S104相似的部分不再重复描述。
图4是根据本公开的实施例的应用于终端设备的固件升级方法的流程图。
在S401,终端设备获取固件升级指令。图4的步骤S401与图2的步骤S201相似的部分,在此不再重复描述。
在S402,终端设备发送目标终端设备的识别码。图4的步骤S402与图2的步骤S202相似的部分,在此不再重复描述。
在S403,终端设备下载info包。终端设备通过下载的info包获得目标终端设备的识别码、子升级包的数量、固件升级密钥和/或完整性验证信息中的一个或多个。例如,可以验证info包中的目标终端设备的识别码和本终端设备的识别码是否一致。在终端设备的识别码与服务器发送的info包中的识别码一致的情况下,执行下载服务器发送的基于升级信息拆分的子升级包。在获取的终端设备的识别码与服务器发送的包头中的识别码不一致,则当前固件升级指令可能非法,不执行下载操作。
服务器可以发送给终端设备GET信息(含包头信息的info包)。GET信息可以包括终端设备的识别码SN,拆分的子升级包的子升级包数量quantity,还可以包含拆分的子升级包的编号以及完整性校验值,例如md5值,以及固件升级密钥等安全验证信息,在实际应用中,可以根据安全需求,设置更多数量及种类的安全验证信息,以实现终端设备的安全验证,提升固件升级的安全性。
一些情况下,包头还可以包括固件升级密钥和/或完整性验证信息,以与固件升级指令中携带的固件升级密钥和/或完整性验证信息进行验证,提升安 全性。
服务器发送的info包经下载,存储至终端设备预设的tmp分区中,供升级过程中调用其中信息。
下载服务器发送的基于升级信息拆分的子升级包的过程中,可以采用逐包请求逐包传输下载的方式,并在每下载一个子升级包的情况下,可以根据包头提供的信息确定是否下载完最后一个子升级包。因此,在一些实现方式中,本方法还包括:根据包头中的子升级包的数量,确定是否下载完最后一个子升级包。
由于子升级包的数量和编号是确定的,在顺序下载每一子升级包的时候,根据该子升级包的编号即可判断是传输完所有的子升级包。
在S404,终端设备基于识别码确定是否将子升级包进行顺序变换。
当确定将子升级包进行顺序变换时,流程行进到S405。在S405,终端设备下载子升级包。在S406,终端设备确认当前下载的子升级包是否为最后一个升级包。当当前下载的子升级包不是最后一个升级包时,流程进行到S405。当当前下载的子升级包是最后一个升级包时,流程进行到S407。在S407,终端设备变换子升级包的顺序。
当确定不将子升级包进行顺序变换时,流程行进到S408。在S408,终端设备下载子升级包。在S409,终端设备确认当前下载的子升级包是否为最后一个升级包。当当前下载的子升级包不是最后一个升级包时,流程进行到S408。当当前下载的子升级包是最后一个升级包时,流程进行到S410。在S410,终端设备不变换子升级包的顺序。
因此,终端设备在下载完子升级包时,先基于顺序标识确定是否将子升级包进行顺序变换,若需要将子升级包进行顺序变换,则将子升级包的顺序变换回原始顺序,再将各子升级包拼接成原始的固件升级包;若不需要将子升级包进行顺序变换,则直接将各子升级包拼接成原始的固件升级包即可。
在S411,终端设备将子升级包拼接成目标固件升级包。
在S404,终端设备基于识别码确定是否将子升级包进行顺序变换的过程以及,以及在S406,终端设备变换子升级包的顺序以将变换后的顺序拼接为初始顺序的过程与图3的303步骤和304步骤类似,在此不再重复描述。
图5A-图5C是根据本公开的实施例的服务器在奇数维度矩阵内顺时针、 移出方向为左变换子升级包顺序的示意图。
图5A-图5C中服务器基于目标终端设备的识别码拆分子升级包的过程与关于3描述的过程相似,不再重复描述。
在一个实施例中,标识码中的顺序标识可以包括分别指示平移次数、移出方向、旋转方向中的至少一个的预设位数的数据。当顺序标识包括分别指示平移次数、移出方向、旋转方向中的一个或两个的预设位数的数据时,平移次数、移出方向、旋转方向中的剩余部分可以在终端设备和服务器之间提前预定。取决于需要,平移次数可以是1次、2次、3次或更多。移出方向是指子升级包或其他数据包在平移时,从矩阵移出的子升级包或数据包的平移方向。取决于需要,移出方向可以是上、下、左、右或其他方向。取决于需要,旋转方向可以是顺时针旋转方向或逆时针旋转方向。例如,当平移次数为2,移出方向为左,旋转方向为顺时针时,可能以为将矩阵内的所有数据包平移2次,并且每次被移出矩阵的数据的移出方向为向左,数据包在矩阵内的旋转方向为顺时针。当标识码中的顺序标识指示的平移次数不为0时,可以确定变换子升级包的顺序。
服务器根据目标升级包被拆分的子升级包数量N,生成矩阵。在一个实施例中,服务器根据目标升级包被拆分的子升级包数量N,确定生成的矩阵的维数。根据以下公式计算T:
其中,roundup()表示向上取整。
将T进行对2的取余运算,当余数为0时,使用偶数维数的矩阵。当余数为1时,使用奇数维数的矩阵。
接下来参照图5A描述使用奇数维数的矩阵变换子升级包的顺序的方式。
假设子升级包共有N=17个。根据等式(1),T=5,将T对2取余为1,因此可以确定生成奇数维数的矩阵。在生成奇数维数的矩阵时,通过以下等式确定矩阵的维数:
根据等式(2),n=2,则奇数矩阵的维度为:2n+1=5。也即,在子升级包N=17个的情况下,生成如图5A所示的5维矩阵。如图5A所示,子升级包 初始编号S为1-17的17个子升级包从左至右,自动换行地在矩阵中进行排列。上述排列方式仅仅是示例性的,并且可以使用其他排列方式。矩阵从左至右、从上至下的每个位置分别具有原始序号P_original。如图5A所示,17个子升级包无法刚好填满5维矩阵,可以使用干扰包(乱码包、空包、或者重复使用17个子升级包中的一个或多个)来填充矩阵,直到矩阵被填满。
假设顺序标识包括指示平移次数K为1、移出方向为左、旋转方向为顺时针的预设位数的数据。如图5A所示,坐标(1,5)的数据包(P_original=21)被向左移出矩阵、数据包在矩阵内呈顺时针旋转。坐标(1,5)的数据包被向左移出矩阵后,矩阵为图5B所示。然后,将移出矩阵的数据包填充到图5B中间空出的位置,平移后的矩阵如图5C所示。图5C的矩阵是图5A的矩阵向左、顺时针平移1次之后的矩阵。
图6是根据本公开的实施例的确定奇数矩阵中的数据包的平移方式的流程图。
参照图5A和参照图6描述确定矩阵中的每一个数据包在矩阵内的平移方式的过程。针对矩阵中的一个数据包执行以下流程。
在S601,确定平移次数K是否为0。平移次数K=1,流程进行到S602。
在S602,可以根据原始序号P_original确定原始序号P_original的数据包(该数据包为子升级包)在矩阵中所处的层数。以位于图5A中心的数据包的原始序号P_original=13作为示例。
P_original/(2n+1)=(Y-1)……X      (3)
其中,(Y-1)为商,X为余数。等式(3)示出了根据子升级包的原始序号P_original=13确定子升级包在矩阵中的坐标(X,Y)=(3,3)。
Layer=max(|X-n-1|,|Y-n-1|)        (4)
其中,max(|X-n-1|,|Y-n-1|)表示取|X-n-1|和|Y-n-1|两者中的最大值。根据等式(4)可以计算出原始序号P_original=13的数据包在矩阵中所处的层数为Layer=0。同时,将K值减1,即K’=K-1,K’=0,K=K’。
在向左平移的情况下,根据数据包在矩阵中所处于的层数以及数据包在矩阵中的坐标,确定数据包在矩阵内的平移方式可以由以下条件进行:
条件一:数据包的坐标Y=(n+1)+Layer。
在S603,如果满足条件一,则流程行进到S604,数据包的坐标的改变为: 将X值减1,Y值不变;如果不满足条件一,则流程行进到S605。
在图5A中,满足条件一的数据包对应于向左平移的数据包,即,虚线区域1中包括的数据包。
条件二:数据包的坐标X=n+1-Layer并且n+1-Layer<Y<n+1+Layer。
在S605,如果满足条件二,则流程行进到S606,数据包的坐标的改变为:X值不变,将Y值减1;如果不满足条件二,则流程行进到S607。
在图5A中,满足条件二的数据包对应于向上平移的数据包,即,虚线区域2中包括的数据包。
条件三:数据包的坐标Y=n+1-Layer并且n+1-Layer<=X<n+1+Layer。
在S607,如果满足条件三,则流程行进到S608,数据包的坐标的改变为:将X值加1,Y值不变;如果不满足条件三,则流程行进到S609。
在图5A中,满足条件三的数据包对应于向右平移的数据包,即,虚线区域3中包括的数据包。
条件四:数据包的坐标Y=n+1-Layer并且n+1-Layer<=X<n+1+Layer,
在S609,如果满足条件四,则流程行进到S610,数据包的坐标的改变为:X值不变,将Y值加1。
在图5A中,满足条件四的数据包对应于向下平移的数据包,即,虚线区域4中包括的数据包。
本领域技术人员应该理解,由于在本实施例中,除了移入矩阵之外,数据包在矩阵内平移方式为上下左右四种,在获得以上四个条件中的三个的情况下,可以通过排除法,确定数据包的平移方式。图6中对条件一-条件四的选择以及执行顺序仅仅是示例性的。
条件五:移动后的数据包的坐标X=0。
在S611,如果满足条件五,则流程行进到S612,数据包的坐标的改变为:X=n+1,Y=n+1,然后流程从S612行进到S613。如果不满足条件五,则流程直接行进到S613。
如图5A所示,原始序号P_original=13的数据包符合条件一,位于矩阵中的虚线区域1中,原始序号P_original=13的数据包的平移方式为向左平移。平移后的原始序号P_original=13的数据包的新序号为P_new=X+(Y-1)(2n+1)=12,如图5C所示。原始序号P_original=21的数据包符合条件一, 位于矩阵中的虚线区域1中,原始序号P_original=21的数据包的平移方式为向左平移。平移后的原始序号P_original=21的数据包的坐标为(0,5),符合条件五,原始序号P_original=21的数据包的坐标改变为(3,3),因此平移后的原始序号P_original=21的数据包的新序号为P_new=X+(Y-1)(2n+1)=13,如图5C所示。
流程继续行进到S601,当前K=0,流程结束。
通过对矩阵中的每个数据包重复上述图6的过程,可以获得矩阵内所有数据包的平移方式。
以上为平移次数为1时,服务器对矩阵内数据包的平移方式。本领域技术人员基于图5A-图5C和图6可以理解平移更多次的过程。
服务器对矩阵内的所有数据包执行K次平移之后,以平移后的矩阵内的P_new作为矩阵内数据包的编号S,向目标终端设备发送。在发送的过程中,子升级包的顺序被打乱,并且混合有干扰包,这极大地增加了破解难度。
目标终端设备可以基于从flash读取的识别码中的顺序标识,确定接收的数据包被服务器平移的方式(例如,移出方向以及顺逆时针)以及次数。目标终端设备可以基于info包中包括的子升级包的数量,获得服务器发送的、在服务器生成的矩阵中包括的数据包(例如,包括子升级包以及干扰包)的总数量,以及目标终端设备生成的矩阵的维数。可替代或附加地,info包中可以包括在服务器生成的矩阵中包括的数据包(例如,包括子升级包以及干扰包)的总数量,目标终端设备可以基于总数量生成矩阵的维数(即,总数量的均方根)。目标终端设备基于子升级包的数量确定生成的矩阵的维度与关于图5A-图5C的描述相似,在此不再重复描述。
在一个实施例中,目标终端设备可以基于服务器对矩阵中的数据包的平移过程的逆过程,恢复子升级包的顺序。
图5D是根据本公开的实施例的数据包的平移过程的逆过程的示意图。
图7是根据本公开的实施例的数据包的平移过程的逆过程的流程图。
参照图5A-图5D以及图7描述针对矩阵中的每一个数据包的平移过程的逆过程。针对矩阵中的一个数据包执行以下过程。
在S701,确定平移次数K是否为0。平移次数K=1,流程进行到S702。
在S702,可以根据新序号P_new确定原始序号P_new的子升级包在矩阵 中所处的层数。计算层数的方式与图6的步骤S602中的描述相同,在此不再重复描述。以位于图7A中心的数据包的新序号P_new=12作为示例。新序号P_new=12确定子升级包在矩阵中的坐标(X,Y)=(2,3)。P_new=12的数据包在矩阵中所处的层数为Layer=1。同时,将K值减1,减1后的K值为0。
在向左平移的情况下,根据数据包在矩阵中所处于的层数以及数据包在矩阵中的坐标,确定数据包在矩阵内的平移方式可以由以下条件进行:
预处理条件:数据包的坐标X=n+1并且Y=n+1。
在S703,如果满足预处理条件,则流程行进到S704,数据包的坐标的改变为:X=0,Y=2n+1,流程行进到S705;如果不满足预处理条件,则流程直接行进到S705。
条件一:数据包的坐标Y=Layer+n+1,X<n+1+Layer;或者X=n+1-Layer并且Y=n+1+Layer-1。
在S705,如果满足条件一,则流程行进到S706,数据包的坐标的改变为:将X值加1,Y值不变;如果不满足条件一,则流程行进到S707。
在图5D中,满足条件一的数据包对应于向右平移的数据包,即,虚线区域1中包括的数据包。
条件二:数据包的坐标X=n+1+Layer并且Y<n+1-Layer。
在S707,如果满足条件二,则流程行进到S708,数据包的坐标的改变为:X值不变,将Y值减1;如果不满足条件二,则流程行进到S709。
在图5D中,满足条件二的数据包对应于向上平移的数据包,即,虚线区域4中包括的数据包。
条件三:数据包的坐标Y=n+1-Layer并且n+1-Layer<X<n+1+Layer。
在S709,如果满足条件三,则流程行进到S710,数据包的坐标的改变为:将X值减1,Y值不变;如果不满足条件三,则流程行进到S711。
在图5D中,满足条件三的数据包对应于向左平移的数据包,即,虚线区域3中包括的数据包。
条件四:数据包的坐标X=n+1-Layer,Y>n+1+Layer-1。
在S711,如果满足条件四,则流程行进到S712,数据包的坐标的改变为:X值不变,将Y值加1。
在图5D中,满足条件四的数据包对应于向下平移的数据包,即,虚线区域2中包括的数据包。
本领域技术人员应该理解,由于在本实施例中,除了移出矩阵之外,数据包在矩阵内平移方式为上下左右四种,在获得四个条件中的三个的情况下,可以通过排除法,确定数据包的平移方式。图7为了简洁,除了预处理条件以外,仅示出了四个条件中的三个。图7中对条件一-条件三的选择以及执行顺序仅仅是示例性的。
如图5D所示,新序号P_new=12的数据包符合条件一,新序号P_new=12的数据包的平移方式为向右移动,坐标改变为(3,3)。流程行进到S713,P=13。
流程继续行进到S701,当前K=0,流程结束。
通过对矩阵中的每个数据包重复上述图7的过程,可以将矩阵从图5C恢复至图5A。在图5A中,子升级包在矩阵中的序号与子升级包原始的顺序相同。根据子升级包在恢复的矩阵中的序号以及子升级包的数量,可以获得顺序被恢复的子升级包。
以上为平移次数为1时,目标终端设备对矩阵内数据包的移动方式。本领域技术人员基于图5D和图7可以理解恢复平移更多次的过程。
在一个实施例中,目标终端设备可以通过继续执行服务器对矩阵中的数据包的平移过程来恢复子升级包的顺序。
上文已经参照图5A-图5C和图6描述了服务器对矩阵中的数据包的平移过程,在此不再重复描述。
图8是根据本公开的实施例的确定恢复子升级包顺序需要继续执行服务器执行的平移的次数的流程图。
假设初始序号为P_original的数据包经过图6所述的平移之后,新序号为P_new。可以通过图8的流程计算出需要继续执行多少次服务器执行的平移,可以恢复子升级包顺序。
在S801,确定P_original是否等于P_new。如果不相等,则流程进行到S802。
在S802,可以根据原始序号P_original确定原始序号P_original的子升级包在矩阵中所处的层数。确定方式与上述参照图6描述的过程相似,不再重复描述。同时,将R值加1,加1后的R值等于1。
S802-S813与图6的S602-S613相似,不再重复描述。
流程继续行进到S801,继续执行流程,直到P_new=P_original,流程结束,结束时的R指示恢复子升级包顺序需要继续执行服务器执行的平移的次数。
图9A-图9D是根据本公开的实施例的服务器根据不同移出方向在奇数维度矩阵内平移数据包的方式的示意图。
在一个实施例中,可以根据各个数据包的序号P确定数据包所在的层数Layer。参照图5A的第1层和第2层,移出方向为左、顺时针旋转时,矩阵中任一层中的数据包的移动方式如图9A所示。
在区域1中,数据包的移动方式为向左移动,数据包的坐标改变为:X值减1,Y值不变。
在区域2中,数据包的移动方式为向上移动,数据包的坐标改变为:X值不变,Y值减1。
在区域3中,数据包的移动方式为向右移动,数据包的坐标改变为:X值加1,Y值不变。
在区域4中,数据包的移动方式为向下移动,数据包的坐标改变为:X值不变,Y值加1。
基于图9A的层中对不同移动方向的区域的划分,可以获得参照图6描述确定数据包移动方向的条件一-条件五。
参照图9B描述移出方向为右、顺时针旋转时,矩阵中任一层中的数据包的移动方式。
区域1-区域4中,数据包的移动方式与参照图9A描述的相同,这里不再重复描述。基于图9B的层中对不同移动方向的区域的划分,可以获得在移出方向为右、顺时针旋转时服务器确定矩阵内的数据包移动方向的条件,为了简洁,不再描述具体条件。
参照图9C描述移出方向为上、顺时针旋转时,矩阵中任一层中的数据包的移动方式。
区域1-区域4中,数据包的移动方式与参照图9A描述的相同,这里不再重复描述。基于图9C的层中对不同移动方向的区域的划分,可以获得在移出方向为上、顺时针旋转时服务器确定矩阵内的数据包移动方向的条件,为了简 洁,不再描述具体条件。
参照图9D描述移出方向为下、顺时针旋转时,矩阵中任一层中的数据包的移动方式。
区域1-区域4中,数据包的移动方式与参照图9A描述的相同,这里不再重复描述。基于图9D的层中对不同移动方向的区域的划分,可以获得在移出方向为下、顺时针旋转时服务器确定矩阵内的数据包移动方向的条件,为了简洁,不再描述具体条件。
图10是根据本公开的实施例的服务器基于包括指示移出方向为左,逆时针的顺序标识来变换子升级包顺序的示意图。
图10中,确定数据包所处于的层的过程与图5A中的该过程相同。不再重复描述。服务器基于包括指示移出方向为左,逆时针的顺序标识来变换子升级包顺序的过程与图6中服务器基于包括指示移出方向为左,顺时针的顺序标识来变换子升级包顺序的过程类似。通过调整条件一-条件五,可以获得矩阵内的数据包的平移方式。
在奇数维度矩阵中移动数据包时,被移出矩阵的数据包,总是被放回到奇数维度矩阵的中心(n+1,n+1)处。
参照图9A-图10,服务器可以根据识别码中的顺序标识以诸如左、右、上、下的移出方向,诸如顺时针、逆时针的旋转方向平移矩阵内的数据包,变换子升级包的顺序。相应地,目标终端可以根据识别码中的顺序标识,通过服务器平移矩阵内的数据包的过程的逆过程,恢复子升级包的顺序。
图11示出了根据本公开的实施例的服务器在偶数维度矩阵内顺时针、移出方向为左变换子升级包顺序的示意图。
假设子升级包共有N=14个。根据等式(1),T=4,将T对2取余为0,因此可以确定生成偶数维数的矩阵。在生成偶数维数的矩阵时,通过以下等式确定矩阵的维数:
根据等式(5),n=2,则偶数矩阵的维度为:2n=4。也即,在子升级包N=14个的情况下,生成如图11所示的4维矩阵。如图11所示,子升级包初始编号S为1-14的14个子升级包从左至右,自动换行地在矩阵中进行排列。矩 阵从左至右、从上至下的每个位置分别具有原始序号P_original。如图11所示,14个子升级包无法刚好填满4维矩阵,可以使用干扰包(乱码包、空包、或者重复使用14个子升级包中的一个或多个)来填充矩阵,直到矩阵被填满。
假设顺序标识包括指示平移次数K为1、移出方向为左、旋转方向为顺时针的预设位数的数据。如图11所示,坐标(1,4)的数据包被向左移出矩阵、数据包在矩阵内呈顺时针旋转。坐标(1,4)的数据包被向左移出矩阵后,将移出矩阵的数据包平移到图11中间将会空出的位置(n,n)处。
图12是根据本公开的实施例的确定偶数维度矩阵中的数据包的平移方式的流程图。
参照图11和参照图12描述确定数据包在矩阵内的平移方式的过程。
在S1201,确定平移次数K是否为0。平移次数K=1,流程进行到S1202。
在S1202,可以根据原始序号P_original确定原始序号P_original的子升级包在矩阵中所处的层数。以位于图11的数据包的原始序号P_original=13作为示例。
P_original/(2n)=(Y-1)……X       (6)
其中,(Y-1)为商,X为余数。等式(3)示出了根据子升级包的原始序号P_original=6确定子升级包在矩阵中的坐标(X,Y)=(2,2)。
Layer=|max(X-n-0.5,Y-n-0.5)|+0.5      (7)
其中,max(,)表示取最大值。根据等式(6)可以计算出原始序号P_original=6的数据包在矩阵中所处的层数为Layer=0。同时,K值减1,减1后的K值等于0。
在向左平移的情况下,根据数据包在矩阵中所处于的层数以及数据包在矩阵中的坐标,确定数据包在矩阵内的平移方式可以由以下条件进行:
条件一:数据包的坐标Y=n+Layer。
在S1203,如果满足条件一,则流程行进到S1204,数据包的坐标的改变为:X值减1,Y值不变;如果不满足条件一,则流程行进到S1205。
在图11中,满足条件一的数据包对应于向左平移的数据包,即,虚线区域1中包括的数据包。
条件二:数据包的坐标X=n-Layer并且Y<n-Layer。
在S1205,如果满足条件二,则流程行进到S1206,数据包的坐标的改变 为:X值不变,Y值减1;如果不满足条件二,则流程行进到S1207。
在图11中,满足条件二的数据包对应于向上平移的数据包,即,虚线区域2中包括的数据包。
条件三:数据包的坐标Y=n+1-Layer并且X<n+Layer。
在S1207,如果满足条件三,则流程行进到S1208,数据包的坐标的改变为:X值加1,Y值不变;如果不满足条件三,则流程行进到S1209。
在图5A中,满足条件三的数据包对应于向右平移的数据包,即,虚线区域3中包括的数据包。
条件四:数据包的坐标X=n+Laye r并且Y<n+Layer,
在S1209,如果满足条件四,则流程行进到S1210,数据包的坐标的改变为:X值不变,Y值加1。
在图11中,满足条件四的数据包对应于向下平移的数据包,即,虚线区域4中包括的数据包。
本领域技术人员应该理解,由于在本实施例中,除了移入矩阵之外,数据包在矩阵内平移方式为上下左右四种,在获得以上四个条件中的三个的情况下,可以通过排除法,确定数据包的平移方式。图12中对条件一-条件四的选择以及执行顺序仅仅是示例性的。
条件五:移动后的数据包的坐标X=0。
在S1211,如果满足条件五,则流程行进到S1212,数据包的坐标的改变为:X=n,Y=n,然后流程从S1212行进到S1213。如果不满足条件五,则流程直接行进到S1213。
如图11所示,原始序号P_original=6的数据包符合条件三,位于矩阵中的虚线区域3中,原始序号P_original=6的数据包的平移方式为向右平移。平移后的原始序号P_original=6的数据包的新序号为P_new=X+2n(Y-1)=7,如图5C所示。原始序号P_original=13的数据包符合条件一,位于矩阵中的虚线区域1中,原始序号P_original=13的数据包的平移方式为向左平移。平移后的原始序号P_original=13的数据包的坐标为(0,4),符合条件五,原始序号P_original=13的数据包的坐标改变为(2,2),因此平移后的原始序号P_original=13的数据包的新序号为P_new=X+2n(Y-1)=6。
流程继续行进到S1201,当前K=0,流程结束。
通过对矩阵中的每个数据包重复上述图12的过程,可以获得矩阵内所有数据包的平移方式。
以上为平移次数为1时,服务器对矩阵内数据包的平移方式。本领域技术人员基于图11和图12可以理解平移更多次的过程。
服务器对矩阵内的所有数据包执行K次平移之后,以平移后的矩阵内的P_new作为矩阵内数据包的编号,向目标终端设备发送。在发送的过程中,子升级包的顺序被打乱,并且混合有干扰包,这极大地增加了破解难度。
图13A-图13D是描述根据本公开的实施例的服务器根据不同移出方向在偶数维度矩阵内平移数据包的方式的示意图。
在一个实施例中,可以根据各个数据包的序号P确定数据包所在的层数Layer。参照图11的第1层和第2层,移出方向为左、顺时针旋转时,矩阵中任一层中的数据包的移动方式如图13A所示。
在区域1中,数据包的移动方式为向左移动,数据包的坐标改变为:X值减1,Y值不变。
在区域2中,数据包的移动方式为向上移动,数据包的坐标改变为:X=X值不变,Y值减1。
在区域3中,数据包的移动方式为向右移动,数据包的坐标改变为:X值加1,Y值不变。
在区域4中,数据包的移动方式为向下移动,数据包的坐标改变为:X值不变,Y值加1。
基于图13A的层中对不同移动方向的区域的划分,可以获得参照图12描述确定数据包移动方向的条件一-条件五。
在图13A中,移出矩阵的数据包被放回到坐标(n,n)处。
参照图13B描述移出方向为右、顺时针旋转时,矩阵中任一层中的数据包的移动方式。
区域1-区域4中,数据包的移动方式与参照图13A描述的相同,这里不再重复描述。基于图13B的层中对不同移动方向的区域的划分,可以获得在移出方向为右、顺时针旋转时服务器确定矩阵内的数据包移动方向的条件,为了简洁,不再描述具体条件。
在图13B中,移出矩阵的数据包被放回到坐标(n+1,n+1)处。
参照图13C描述移出方向为上、顺时针旋转时,矩阵中任一层中的数据包的移动方式。
区域1-区域4中,数据包的移动方式与参照图13A描述的相同,这里不再重复描述。基于图13C的层中对不同移动方向的区域的划分,可以获得在移出方向为上、顺时针旋转时服务器确定矩阵内的数据包移动方向的条件,为了简洁,不再描述具体条件。
在图13C中,移出矩阵的数据包被放回到坐标(n+1,n)处。
参照图13D描述移出方向为下、顺时针旋转时,矩阵中任一层中的数据包的移动方式。
区域1-区域4中,数据包的移动方式与参照图13A描述的相同,这里不再重复描述。基于图13D的层中对不同移动方向的区域的划分,可以获得在移出方向为下、顺时针旋转时服务器确定矩阵内的数据包移动方向的条件,为了简洁,不再描述具体条件。
在图13D中,移出矩阵的数据包被放回到坐标(n,n+1)处。
此外,还可以通过在偶数维度的矩阵内平移矩阵,以实现逆时针旋转来变换子升级包的顺序。为了简洁,不再描述其详细过程。
在一个实施例中,目标终端设备可以基于服务器对矩阵中的数据包的平移过程的逆过程,恢复子升级包的顺序。在一个实施例中,目标终端设备可以通过继续执行服务器对矩阵中的数据包的平移过程来恢复子升级包的顺序。
以上描述了通过平移矩阵内的数据包,以旋转的形式变换子升级包的顺序的实施例。除了上面描述的通过左、右、上、下移出方向,顺时针、逆时针旋转,不同的平移次数在奇数或偶数维度的矩阵内平移数据包来变换/恢复子升级包的顺序,受益于本公开的本领域技术人员还可以以不旋转而平移的方式或其他平移方式在矩阵内移动数据包来变换/恢复子升级包的顺序。这些都在本公开的设想之内。
图14是根据本公开的实施例的用于服务器的固件升级设备。
如图14所示,1400是用于服务器的固件升级设备。
固件升级设备1400可以包括固件升级包获取装置1410,用于获取目标固件升级包。
固件升级设备1400可以包括接收装置1420,用于接收目标终端设备的识 别码。
固件升级设备1400可以包括拆分装置1430,用于基于目标终端设备的识别码,将目标固件升级包拆分成子升级包。
固件升级设备1400可以包括存储/发送装置1440,用于将子升级包进行存储和/或发送至目标终端设备。
图15是根据本公开的实施例的用于终端设备的固件升级设备。
如图15所示,1500是用于目标终端设备的固件升级设备。
固件升级设备1500可以包括固件升级指令获取装置1510,用于获取固件升级指令。
固件升级设备1500可以包括发送装置1520,用于发送目标终端设备的识别码。
固件升级设备1500可以包括下载/接收装置1530,用于下载/接收子升级包。
固件升级设备1500可以包括拼接装置1540,用于基于目标终端设备的识别码,将子升级包拼接成目标固件升级包。
图16是根据本公开的实施例的用于目标终端设备的安全引导的流程图。
终端设备软重启之后,终端设备运行安全引导程序。
在S1601,确定固件的升级信息是否为已升级。如果是,流程行进到S1602,启动目标固件。
如果否,流程行进到S1603,获取终端设备预设的tmp分区中的信息并解析,确定是否变换子升级包顺序。S1603-S1605中,确定是否变换子升级包顺序以及如何变换子升级包顺序的过程与上文相应部分的描述相似,不再重复描述。
在S1606,确定目标固件安全验证是否通过。可以根据固件升级指令中包含固件升级密钥和/或完整性验证信息对目标固件进行安全验证。在一些实现方式中,完整性验证信息例如是md5值,也可以是其他完整性验证信息,本实施例不做唯一限定。发送给目标终端设备的info包中也可以包括固件升级密钥和/或完整性验证信息。基于固件升级密钥和/或完整性验证信息进行目标固件的安全验证,在由info包携带发送至终端设备的固件升级密钥与固件升级指令中的固件升级密钥一致,和/或终端设备的完整性验证信息与固件升级 指令中的完整性验证信息一致的情况下,安全验证通过。如果安全验证未通过,流程结束。如果安全验证通过,流程行进到S1607。
在S1607,可以运行固件升级包。在一个实施例中,可以将固件升级包拷贝至运行地址并跳至该运行地址,即可运行升级后的目标固件。在一个实施例中,可以直接从flash中的相应分区运行固件升级包。
在S1607,可以修改目标固件的启动信息为已升级
通过上述安全引导流程,可以在拆分子升级包并对子升级包进行顺序变换的传输下载基础上,进一步提升固件升级的安全,实现固件的完整性校验和安全启动的配置操作,保证固件合法性。
图17是根据本公开的实施例的用于目标终端设备的离网与联网结合的安全验证的流程图。
在S1701,目标终端设备可以通过脱离广域网的方式获取固件升级指令以及安全验证密钥。目标终端设备可以从脱离广域网的广播设备以广播或者点对点通信的形式获得固件升级指令以及安全验证密钥。脱离广域网的广播设备例如可以是手持广播设备。在一个实施例中,目标终端设备可以从脱离广域网的广播设备获得下载基地址。目标终端设备可以基于默认的可修改地址、下载基地址、识别码获得固件升级包的下载地址。可以使用诸如蓝牙、蓝牙LE、ZigBee、射频识别(RFID)、UWB、60GHz、Wi-Fi、WiMAX等短程无线通信或者USB等有线通信方式实现脱离广域网的广播设备。由于广播设备是脱离广域网的,不使用广域网能够很好地避免通过广域网传输时的安全风险。
在S1702,目标终端设备可以经由广域网获得固件升级包以及固件升级包安全密钥。
在S1703,目标终端设备可以确定安全验证密钥与固件升级包安全密钥是否匹配。例如,目标终端设备可以确定通过脱离广域网的方式获得的安全验证密钥与经由广域网获得固件升级包安全密钥是否匹配。如果匹配,则确认固件升级包是安全的,否则报告风险信息。
目标终端设备获得固件升级包的过程可以与上述基于识别码的终端设备固件升级过程以及用于目标终端设备的安全引导过程相似,这里不再重复描述。
文本和附图仅作为示例提供,以帮助理解本公开。它们不应被解释为以任 何方式限制本公开的范围。尽管已经提供了某些实施例和示例,但是基于本文所公开的内容,对于本领域技术人员而言清晰的是,在不脱离本公开的范围的情况下,可以对所示的实施例和示例进行改变。
尽管已经用示例性实施例描述了本公开,但是可以向本领域技术人员建议各种改变和修改。本公开旨在涵盖落入所附权利要求范围内的这种改变和修改。
本发明中的任何描述都不应被理解为暗示任何特定的元件、步骤或功能是必须包括在权利要求范围内的必要元素。专利主题的范围仅由权利要求限定。

Claims (30)

  1. 一种应用于服务器端的固件升级方法,其特征在于,包括:
    获取目标固件升级包;
    接收目标终端设备的识别码;
    基于所述目标终端设备的识别码,将所述目标固件升级包拆分成子升级包;
    将所述子升级包进行存储和/或将所述子升级包发送至目标终端设备。
  2. 根据权利要求1所述的固件升级方法,其特征在于,所述方法还包括,
    通过所述目标终端设备的识别码获得子升级包的大小,
    基于所述子升级包的大小,确定拆分的子升级包的数量。
  3. 根据权利要求1所述的固件升级方法,其特征在于,所述方法还包括,
    基于子升级包的识别码和默认的可修改地址,确定目标终端设备下载子升级包的下载地址。
  4. 根据权利要求1所述的固件升级方法,其特征在于,所述方法还包括,
    通过所述目标终端设备的识别码获得子升级包的顺序标识,
    基于所述子升级包的顺序标识,确定是否变换子升级包顺序,
    响应于确定不变换子升级包顺序,按照子升级包的初始顺序对子升级包进行编号,
    响应于确定变换子升级包顺序,变换子升级包顺序,按照子升级包的变换后的顺序对子升级包进行编号。
  5. 根据权利要求4所述的固件升级方法,其特征在于,所述子升级包中的每一个包括子升级包包头,所述子升级包包头包括子升级包的编号。
  6. 根据权利要求5所述的固件升级方法,其特征在于,所述子升级包包头还包括目标终端设备的识别码以及目标固件升级包所拆分的子升级包的数 量中的至少一个。
  7. 根据权利要求4所述的固件升级方法,其特征在于,基于所述子升级包的顺序标识,确定是否变换子升级包顺序包括:
    识别所述顺序标识指示的数值,
    基于所述顺序标识指示的数值确定是否变换子升级包顺序。
  8. 根据权利要求7所述的固件升级方法,其特征在于,基于所述顺序标识指示的数值确定是否变换子升级包顺序包括基于所述顺序标识指示的数值是否为第一预定数值确定是否变换子升级包顺序。
  9. 根据权利要求7所述的固件升级方法,其特征在于,基于所述顺序标识指示的数值确定是否变换子升级包顺序包括:
    将所述顺序标识指示的数值对第二预定数值取余,获得余数,其中,第二预定数值为大于等于2的自然数,
    基于余数,确定是否变换子升级包顺序。
  10. 根据权利要求9所述的固件升级方法,其特征在于,所述第二预定数值为2,其中,基于所述顺序标识指示的数值确定是否变换子升级包顺序包括基于所述顺序标识指示的数值的奇偶性确定是否变换子升级包顺序。
  11. 根据权利要求4所述的固件升级方法,其特征在于,基于所述顺序标识变换子升级包顺序包括:
    识别顺序标识指示的数值,
    基于所述顺序标识指示的数值变换子升级包顺序。
  12. 根据权利要求11所述的固件升级方法,其特征在于,所述顺序标识包括预定位数的数据,识别顺序标识指示的数值包括识别数据指示的数值,
    其中,变换子升级包顺序包括:
    将子升级包划分为子升级包组,每个子升级包组包括初始顺序相邻的特 定数量的子升级包,其中,所述特定数量为预定位数的数据能够指示的最大数值加1,
    将每个子升级包组中初始顺序相差所述数据指示的数值的两个子升级包的顺序交换。
  13. 根据权利要求4所述的固件升级方法,其特征在于,变换所述子升级包顺序包括:
    将子升级包划分为子升级包组,每个子升级包组包括初始顺序相邻的特定数量的子升级包,其中,所述特定数量在服务器处预先确定,
    将每个子升级包组中初始顺序相差小于特定数量的数值的两个子升级包的顺序交换。
  14. 根据权利要求4所述的固件升级方法,其特征在于,所述方法还包括,根据子升级包的数量生成矩阵,
    将子升级包在矩阵中排列,
    其中,变换子升级包顺序包括根据顺序标识在矩阵中平移子升级包。
  15. 根据权利要求14所述的固件升级方法,其特征在于,根据所述子升级包的数量生成矩阵包括根据子升级包的数量确定生成奇数维度矩阵还是偶数维度矩阵。
  16. 根据权利要求15所述的固件升级方法,其特征在于,所述方法还包括使用乱码包、空包和重复的子升级包中的一个或多个填满矩阵。
  17. 根据权利要求14所述的固件升级方法,其特征在于,所述顺序标识指示矩阵中的子升级包的平移次数、子升级包的移出方向、子升级包在矩阵中旋转的顺逆时针中的一个或多个。
  18. 根据权利要求17所述的固件升级方法,其特征在于,所述方法还包括,根据子升级包在矩阵中的序号以及矩阵的维度,确定子升级包的平移方 式。
  19. 根据权利要求1所述的固件升级方法,其特征在于,所述方法还包括,将目标固件升级包的包头进行存储和/或发送至目标终端设备,
    其中,所述目标固件升级包的包头包括目标终端设备的识别码、子升级包的数量和编号、固件升级密钥和/或完整性验证信息中的一个或多个。
  20. 一种应用于终端设备的固件升级方法,其特征在于,包括:
    获取固件升级指令;
    发送目标终端设备的识别码;
    从服务器下载子升级包;
    基于目标终端设备的识别码,将子升级包拼接成目标固件升级包。
  21. 根据权利要求20所述的固件升级方法,其特征在于,所述方法还包括,从服务器下载固件升级包的包头,以及通过安全引导程序进行:
    响应于全部子升级包和固件升级包包头下载到终端设备,基于终端设备的识别码中的顺序标识,确定是否变换下载的子升级包的顺序;
    对下载的子升级包进行安全性或完整性校验;
    响应于下载的子升级包通过安全性或完整性校验,运行通过子升级包拼接的目标固件。
  22. 根据权利要求21所述的固件升级方法,其特征在于,获取所述固件升级指令包括通过脱离广域网的方式获取固件升级指令以及安全验证密钥;
    其中,从服务器下载所述子升级包包括经由广域网获得固件升级包以及固件升级包安全密钥;
    对下载的子升级包进行安全性校验包括确定安全验证密钥与固件升级包安全密钥是否匹配。
  23. 一种固件升级设备,应用于服务器,其特征在于,包括:
    固件升级包获取装置,用于获取目标固件升级包;
    接收装置,用于接收目标终端设备的识别码;
    拆分装置,用于基于所述目标终端设备的识别码,将所述目标固件升级包拆分成子升级包;
    存储/发送装置,用于将所述子升级包进行存储和/或将所述子升级包发送至目标终端设备。
  24. 一种固件升级设备,应用于终端设备,其特征在于,包括:
    固件升级指令获取装置,用于获取固件升级指令;
    接收装置,用于发送目标终端设备的识别码;
    下载/接收装置,用于从服务器下载/接收子升级包;
    拼接装置,用于基于所述目标终端设备的识别码,将所述子升级包拼接成目标固件升级包。
  25. 一种服务器,其特征在于,包括存储器和一个或多个处理器,所述存储器上存储有计算机程序,所述计算机程序被所述一个或多个处理器执行时实现如权利要求1至19中任一项所述的方法。
  26. 一种终端设备,其特征在于,包括存储器和一个或多个处理器,所述存储器上存储有计算机程序,所述计算机程序被所述一个或多个处理器执行时实现如权利要求20-22所述的方法。
  27. 一种用于安全引导的方法,用于终端设备,其特征在于,包括:
    响应于全部子升级包和固件升级包包头下载到终端设备,基于终端设备的识别码中的顺序标识,确定是否变换下载的子升级包的顺序;
    对下载的子升级包进行安全性或完整性校验;
    响应所述于下载的子升级包通过安全性或完整性校验,运行通过子升级包拼接的目标固件。
  28. 一种用于目标终端设备的安全验证方法,其特征在于,包括:
    通过脱离广域网的方式获取固件升级指令以及安全验证密钥;
    经由广域网获得固件升级包以及固件升级包安全密钥;
    确定所述安全验证密钥与所述固件升级包安全密钥是否匹配。
  29. 根据权利要求28所述的安全验证方法,其特征在于,经由广域网获得固件升级包包括经由广域网从服务器下载子升级包,其中,所述方法还包括:
    发送目标终端设备的识别码;
    基于所述目标终端设备的识别码,将所述子升级包拼接成目标固件升级包。
  30. 根据权利要求29所述的安全验证方法,其特征在于,所述方法还包括,从服务器下载固件升级包的包头,以及通过安全引导程序进行:
    响应于全部子升级包和固件升级包包头下载到目标终端设备,基于所述目标终端设备的识别码中的顺序标识,确定是否变换下载的子升级包的顺序;
    对下载的子升级包进行安全性或完整性校验;
    响应于下载的子升级包通过安全性或完整性校验,运行通过子升级包拼接的目标固件。
PCT/CN2023/085613 2022-10-21 2023-03-31 固件升级方法、设备、服务器、终端设备及存储介质 WO2024082560A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211295975.2 2022-10-21
CN202211295975.2A CN117951706A (zh) 2022-10-21 2022-10-21 一种固件升级方法、装置、服务器、终端设备及存储介质

Publications (1)

Publication Number Publication Date
WO2024082560A1 true WO2024082560A1 (zh) 2024-04-25

Family

ID=90736776

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/085613 WO2024082560A1 (zh) 2022-10-21 2023-03-31 固件升级方法、设备、服务器、终端设备及存储介质

Country Status (2)

Country Link
CN (1) CN117951706A (zh)
WO (1) WO2024082560A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008757A (zh) * 2019-04-09 2019-07-12 江南大学 一种物联网终端固件更新中数据保护方法及系统
CN112445507A (zh) * 2019-09-05 2021-03-05 阿里巴巴集团控股有限公司 一种设备的升级方法和装置
US20210216637A1 (en) * 2020-01-10 2021-07-15 Beijing Xiaomi Mobile Software Co., Ltd. Firmware upgrade method and device, and storage medium
CN113141263A (zh) * 2020-01-02 2021-07-20 广东博智林机器人有限公司 一种升级方法、装置、系统和存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110008757A (zh) * 2019-04-09 2019-07-12 江南大学 一种物联网终端固件更新中数据保护方法及系统
CN112445507A (zh) * 2019-09-05 2021-03-05 阿里巴巴集团控股有限公司 一种设备的升级方法和装置
CN113141263A (zh) * 2020-01-02 2021-07-20 广东博智林机器人有限公司 一种升级方法、装置、系统和存储介质
US20210216637A1 (en) * 2020-01-10 2021-07-15 Beijing Xiaomi Mobile Software Co., Ltd. Firmware upgrade method and device, and storage medium

Also Published As

Publication number Publication date
CN117951706A (zh) 2024-04-30

Similar Documents

Publication Publication Date Title
CN110912707B (zh) 基于区块链的数字证书处理方法、装置、设备及存储介质
CN109739604B (zh) 页面渲染方法、装置、服务器及存储介质
KR102242221B1 (ko) 서비스 데이터 처리 방법 및 디바이스, 및 서비스 처리 방법 및 디바이스
CN107967316A (zh) 一种数据同步方法、设备及计算机可读存储介质
CN109656538A (zh) 应用程序的生成方法、装置、系统、设备和介质
CN111201754A (zh) 用于提供区块链的环节的密码学保护的和经过滤的以及经排序的交易数据集的集合的设备
CN108830720A (zh) 智能合约运行方法、装置、系统和计算机可读存储介质
CN104346184A (zh) 应用打包装置及方法
CN107168749A (zh) 一种编译方法、装置、设备和计算机可读存储介质
CN108306844B (zh) 用于服务器与客户端之间的api通信的方法
CN106873960A (zh) 一种应用软件的更新方法和设备
CN111597567B (zh) 数据处理方法、装置、节点设备及存储介质
CN112887451B (zh) 域名解析方法、装置及计算机设备
CN111492355A (zh) 用于控制和/或监控装置的方法和控制系统
CN103607376A (zh) 一种兼容协议的方法及装置
WO2024082560A1 (zh) 固件升级方法、设备、服务器、终端设备及存储介质
CN107111495A (zh) 用于虚拟和接口方法调用的装置和方法
CN113077260A (zh) 基于区块链的数据访问方法、装置及电子设备
CN110780915B (zh) 一种数据处理方法、装置和存储介质
CN109086059B (zh) 代码加载更新方法、装置及服务器
CN112003736B (zh) 一种多节点配置信息确定方法、装置及存储介质
CN112650710B (zh) 数据迁移的发送方法及装置、存储介质、电子装置
CN106325958A (zh) 代码下载方法和编译服务器
CN112437010A (zh) 服务功能聚合树的嵌入方法、装置、电子设备及存储介质
JP2007272909A (ja) 集計システム