WO2021147668A1 - 一种软件升级方法及设备 - Google Patents

一种软件升级方法及设备 Download PDF

Info

Publication number
WO2021147668A1
WO2021147668A1 PCT/CN2021/070365 CN2021070365W WO2021147668A1 WO 2021147668 A1 WO2021147668 A1 WO 2021147668A1 CN 2021070365 W CN2021070365 W CN 2021070365W WO 2021147668 A1 WO2021147668 A1 WO 2021147668A1
Authority
WO
WIPO (PCT)
Prior art keywords
encrypted
patch
patch file
code segment
terminal device
Prior art date
Application number
PCT/CN2021/070365
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 华为技术有限公司
Priority to EP21743687.2A priority Critical patent/EP4086757A4/en
Publication of WO2021147668A1 publication Critical patent/WO2021147668A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/60Software deployment
    • G06F8/65Updates
    • G06F8/658Incremental updates; Differential updates
    • 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
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/606Protecting data by securing the transmission between two devices or processes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F8/00Arrangements for software engineering
    • G06F8/70Software maintenance or management
    • G06F8/71Version control; Configuration management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/10Protecting distributed programs or content, e.g. vending or licensing of copyrighted material ; Digital rights management [DRM]
    • G06F21/12Protecting executable software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2221/00Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/21Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/2107File encryption
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2221/00Indexing scheme relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/21Indexing scheme relating to G06F21/00 and subgroups addressing additional information or applications relating to security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F2221/2115Third party

Definitions

  • This application relates to the field of communication technology, and in particular to a software upgrade method and equipment.
  • terminal devices With the development of communication technology and the ever-increasing service demands of users, the services that can be realized by terminal devices become more and more diversified. Examples of some terminal devices are: mobile phones, tablet computers, smart home devices, wearable devices, Internet of Things (IoT) devices, Internet of Vehicles devices, etc.
  • IoT Internet of Things
  • the software developer After the software developer develops the patch file, it submits the patch file to the Over the Air (OTA) server.
  • the OTA server determines the current version of the application software in the terminal device through interaction with the terminal device, and then the OTA server adds the patch file updated by the current version of the application software to the OTA data package (compressed package) and sends it to the terminal device side.
  • the terminal device can upgrade the local application software according to the patch file downloaded from the OTA server.
  • the terminal device when there are multiple patch files in the OTA server that are newer than the current version in the terminal device, the terminal device usually requires multiple OTA download processes to download these patch files from the OTA server. . In addition, after the terminal device downloads these patch files, they need to be installed in sequence according to the version order of the patch files. In summary, the traditional OTA upgrade process takes a long time and has an impact on the working efficiency of the terminal device.
  • This application provides a software upgrade method and equipment to solve the problem of long time-consuming traditional software upgrade process.
  • an embodiment of the present application provides a software upgrade method, which is applied to a software development device, and the method includes the following steps:
  • the software development device generates a patch file of the target application software and a corresponding version number of the patch file, wherein the patch file includes a first code segment, and the first code segment includes a first code segment identifier and first code content
  • the software development device encrypts the patch file, including: the software development device encrypts the first code content according to the first security key; the software development device encrypts the first code content according to the first operation key , Encrypting the first code segment identifier and the first code content encrypted by the first security key; wherein the first operation key is different from the first security key; the software The development device sends the encrypted patch file and the version number corresponding to the patch file to the upgrade server.
  • the software development device uses different keys to encrypt the first code segment identifier and the first code content respectively.
  • the upgrade server is encrypting the patch file.
  • the method further includes: the software development device obtains the identification offset value of the target application software; the software development device offsets the first code segment identification according to the identification offset value.
  • the software development device can perform identification offset processing on the first code segment identification of the patch file to ensure the security of the first code segment identification in the patch file.
  • the patch file further includes a patch header, where the patch header is used to indicate the target application software; the software development device encrypts the patch file, and further The method includes: the software development device encrypts the patch header according to the first security key.
  • the software development device can encrypt the patch header of the patch file, thereby ensuring the security of the patch header.
  • the patch file includes at least one of the first code segment; the first code segment is a line of first code, and the first code segment is identified as the line number of the first code .
  • an embodiment of the present application provides a software upgrade method, which is applied to an upgrade server, and the method includes the following steps:
  • the upgrade server stores the encrypted patch file of the target application software and the version number corresponding to the patch file; wherein, the encrypted patch file contains the encrypted first code segment, and the encrypted first code segment is passed
  • the first operation key is obtained by encrypting the first code segment identifier and the first code content encrypted by the first security key, the first operation key is different from the first security key;
  • the upgrade The server receives the patch download request of the target application software from the terminal device; the upgrade server determines the current version number of the target application software installed in the terminal device according to the patch download request, and the terminal device performs The target version number of the target application software upgrade; the upgrade server determines the intermediate patch file from the locally stored encrypted patch file of the target application software according to the current version number and the target version number, Wherein, the intermediate patch file is an encrypted patch file with a version number greater than the current version number and less than or equal to the target version number; when there are multiple intermediate patch files, the upgrade server is based on the second The operation key is used to decrypt each intermediate patch file.
  • the decryption includes decrypting the encrypted first code segment contained in each intermediate patch file to obtain the first code of the first code segment of each intermediate patch file Segment identification and the first code content encrypted by the first security key; the upgrade server according to the version number corresponding to the plurality of intermediate patch files, the first code segment contained in each decrypted intermediate patch file
  • the first code segment identifier is used to merge the decrypted intermediate patch files to obtain the merged patch file of the target application software;
  • the merged patch file contains the updated first code segment, and the updated
  • the first code segment includes the first code content encrypted by the first security key and the updated first code segment identifier;
  • the upgrade server encrypts the merged patch file according to the first operation key,
  • the method includes: encrypting the updated first code segment in the merged patch file according to the first operation key; and the upgrade server sends the encrypted merged patch file to the terminal device.
  • the upgrade server can splice and merge multiple intermediate patch files that meet the upgrade requirements of the target application software of the terminal device.
  • the terminal device can only download and install the combined patch file once.
  • the target application software is upgraded from the current version number to the target version number. Obviously, this method can significantly shorten the time consumed by the terminal device to upgrade the software, and can improve the efficiency of the terminal device software upgrade.
  • the upgrade server performs an identification of the first code segment contained in the first code segment of each decrypted intermediate patch file according to the version numbers corresponding to the plurality of intermediate patch files.
  • Merging the multiple intermediate patch files to obtain the merged patch file of the target application software includes:
  • the upgrade server sorts the decrypted intermediate patch files according to the sequence of the stored version numbers corresponding to the multiple intermediate patch files to obtain a file sequence, wherein the version number is the first after decryption
  • the intermediate patch file is located at the first position of the file sequence, and the decrypted intermediate patch file with the last version number is located at the end of the file sequence;
  • the upgrade server contains the first code segment according to each decrypted intermediate patch file
  • the first code segment is identified by sequentially merging each decrypted intermediate patch file in the order of the file sequence to obtain the merged patch file.
  • This design can ensure the accuracy of the merged patch file generated by the upgrade server, that is, the effect of installing the merged patch file on the terminal device is the same as the effect of installing the multiple intermediate patch files in sequence according to the sequence of version numbers.
  • the encrypted patch file further includes an encrypted patch header, and the encrypted patch header is encrypted by the first security key; the merged patch file It also contains the encrypted patch header.
  • the upgrade server determining the current version number of the target application software installed in the terminal device and the target version number for the terminal device to upgrade the target application software includes:
  • the upgrade server obtains, from the patch download request, the current version number of the target application software installed in the terminal device, and the target version number for the terminal device to upgrade the target application software.
  • the terminal device can send its own upgrade requirements for the target application software through a patch download request.
  • the encrypted patch file contains at least one encrypted first code segment; the encrypted first code segment is an encrypted line of the first code, and the first code segment Identified as the line number of the first code; the merged patch file contains at least one updated first code segment.
  • an embodiment of the present application provides a software upgrade method, which is applied to a terminal device, and the method includes the following steps:
  • the terminal device sends a patch download request of the target application software to the upgrade server; the terminal device receives the encrypted merged patch file of the target application software from the upgrade server, wherein the encrypted merged patch file is
  • the upgrade server is generated by merging multiple intermediate patch files of the target application software, the encrypted merged patch file contains an encrypted first code segment, and the encrypted first code segment is passed through the first Obtained by encrypting a first code segment with an operation key, the first code segment including the first code segment identifier and the first code content encrypted by the first security key; the first operation key and the The first security key is different; the terminal device decrypts the encrypted merged patch file to obtain the merged patch file, including: the terminal device performs the encrypted first operation key on the encrypted first Decrypt a code segment to obtain the first code segment; the terminal device decrypts the first code content contained in the first code segment encrypted by the first security key according to the second security key, Obtain the first code content; the terminal device upgrades the installed target application software according to the first code segment identifier contained in the
  • the upgrade server can splice and merge multiple intermediate patch files that meet the upgrade requirements of the target application software of the terminal device, so that the terminal device can only download and install the combined patch file once.
  • the target application software is upgraded from the current version number to the target version number. Obviously, this method can significantly shorten the time consumed by the terminal device to upgrade the software, and can improve the efficiency of the terminal device software upgrade.
  • the encrypted merged patch file further includes an encrypted patch header, and the encrypted patch header is encrypted by a first security key;
  • the decryption processing of the encrypted merged patch file further includes: the terminal device decrypts the encrypted patch header in the encrypted merged patch file according to the second security key to obtain Patch the head.
  • the terminal device uses the first code segment contained in the first code segment in the merged patch file.
  • Code segment identification and first before upgrading the installed target application software, the method further includes: the terminal device obtains the identification offset value of the target application software; the terminal device according to the identification offset value Offset the first code segment identifier included in the first code segment in the merged patch file.
  • the software development device in order to ensure the security of the first code segment identifier in the patch file, after the software development device generates the patch file, it offsets the first code segment identifier in the patch file. Therefore, here is to ensure The terminal device can successfully install the merged patch file. Therefore, the terminal device also needs to offset the first code segment identifier in the merged patch file to restore to the original fetch of the first code segment identifier. value. It should be noted that the identification offset processing performed by the software development device and the terminal device is a reciprocal operation.
  • the software development device adds the identifier offset value based on the value of the first code segment identifier in the patch file, then the software development device merges the value of the first code segment identifier in the patch file On the basis of, subtract the mark offset value.
  • the patch download request includes the current version number of the target application software installed in the terminal device, and the target version number of the target application software upgrade performed by the terminal device.
  • the terminal device can send its own upgrade requirements for the target application software through a patch download request.
  • the encrypted merged patch file contains at least one encrypted first code segment; the encrypted first code segment is an encrypted line of the first code, and the first code
  • the segment identifier is the line number of the first code.
  • an embodiment of the present application provides a software upgrade method, which is applied to a software development device, and the method includes the following steps:
  • the software development device generates a patch file of the target application software and a corresponding version number of the patch file, wherein the patch file includes a first code segment, and the first code segment includes a first code segment identifier and first code content
  • the software development device encrypts the patch file, including: the software development device encrypts the first code content according to the first security key; the software development device encrypts the first code content according to the first operation key , Encrypt the first code segment identifier; wherein, the first operation key is different from the first security key; the software development device sends the encrypted patch file and the The version number corresponding to the patch file.
  • the software development device uses different keys to encrypt the first code segment identifier and the first code content respectively.
  • the upgrade server is encrypting the patch file.
  • the method further includes: the software development device obtains the target application software The identifier offset value of the; the software development device offsets the first code segment identifier according to the identifier offset value.
  • the software development device can perform identification offset processing on the first code segment identification of the patch file to ensure the security of the first code segment identification in the patch file.
  • the patch file further includes a patch header, where the patch header is used to indicate the target application software; the software development device encrypts the patch file, and further The method includes: the software development device encrypts the patch header according to the first security key.
  • the software development device can encrypt the patch header of the patch file, thereby ensuring the security of the patch header.
  • the patch file includes at least one of the first code segment; the first code segment is a line of first code, and the first code segment is identified as the line number of the first code .
  • the embodiments of the present application provide a software upgrade method, which is applied to an upgrade server, and the method includes the following steps:
  • the upgrade server stores the encrypted patch file of the target application software and the version number corresponding to the patch file; wherein the encrypted patch file includes a first code segment, and the first code segment includes the encrypted first code
  • a security key is obtained by encrypting the content of the first code, and the first operation key is different from the first security key;
  • the upgrade server receives the patch download request of the target application software from the terminal device;
  • the upgrade server determines the current version number of the target application software installed in the terminal device according to the patch download request, and the target version number for the terminal device to upgrade the target application software;
  • the upgrade server determines the current version number of the target application software installed in the terminal device according to the patch download request;
  • the current version number and the target version number determine an intermediate patch file from a locally stored encrypted patch file of the target application software, where the intermediate patch file has a version number greater than the current version number, And is less than or equal to the target version number;
  • the upgrade server decrypts each intermediate patch file according to the second operation key, and the decryption It includes decrypting the encrypted first code segment identifier contained in the first code segment of each intermediate patch file to obtain the first code segment identifier contained in the first code segment of each intermediate patch file;
  • the upgrade server can splice and merge multiple intermediate patch files that meet the upgrade requirements of the target application software of the terminal device.
  • the terminal device can only download and install the combined patch file once.
  • the target application software is upgraded from the current version number to the target version number. Obviously, this method can significantly shorten the time consumed by the terminal device to upgrade the software, and can improve the efficiency of the terminal device software upgrade.
  • the upgrade server performs an identification of the first code segment contained in the first code segment of each decrypted intermediate patch file according to the version numbers corresponding to the plurality of intermediate patch files.
  • Merging the multiple intermediate patch files to obtain the merged patch file of the target application software includes:
  • the upgrade server sorts the decrypted intermediate patch files according to the sequence of the stored version numbers corresponding to the multiple intermediate patch files to obtain a file sequence, wherein the version number is the first after decryption
  • the intermediate patch file is located at the first position of the file sequence, and the decrypted intermediate patch file with the last version number is located at the end of the file sequence;
  • the upgrade server contains the first code segment according to each decrypted intermediate patch file
  • the first code segment is identified by sequentially merging each decrypted intermediate patch file in the order of the file sequence to obtain the merged patch file.
  • This design can ensure the accuracy of the merged patch file generated by the upgrade server, that is, the effect of installing the merged patch file on the terminal device is the same as the effect of installing the multiple intermediate patch files in sequence according to the sequence of version numbers.
  • the encrypted patch file further includes an encrypted patch header, and the encrypted patch header is encrypted by the first security key; the merged patch file It also contains the encrypted patch header.
  • the upgrade server determining the current version number of the target application software installed in the terminal device and the target version number for the terminal device to upgrade the target application software includes:
  • the upgrade server obtains, from the patch download request, the current version number of the target application software installed in the terminal device, and the target version number for the terminal device to upgrade the target application software.
  • the terminal device can send its own upgrade requirements for the target application software through a patch download request.
  • the encrypted patch file contains at least one encrypted first code segment; the encrypted first code segment is an encrypted line of the first code, and the first code segment Identified as the line number of the first code; the merged patch file contains at least one updated first code segment.
  • an embodiment of the present application provides a software upgrade method, which is applied to a terminal device, and the method includes the following steps:
  • the terminal device sends a patch download request of the target application software to the upgrade server; the terminal device receives the encrypted merged patch file of the target application software from the upgrade server, wherein the encrypted merged patch file is
  • the upgrade server is generated by merging multiple target patch files of the target application software, the encrypted merged patch file includes a first code segment, and the first code segment includes an encrypted first code segment identifier And the encrypted first code content, the encrypted first code segment identifier is obtained by encrypting the first code segment by the first operation key, and the encrypted first code content is obtained through the first security Obtained by encrypting the content of the first code by a key, the first operation key is different from the first security key; the terminal device decrypts the encrypted merged patch file to obtain the merged patch file,
  • the method includes: the terminal device decrypts the encrypted first code segment identifier according to the second operation key to obtain the first code segment identifier; the terminal device decrypts the encrypted first code segment identifier according to the second security key Decrypt the first code content of
  • the upgrade server can splice and merge multiple intermediate patch files that meet the upgrade requirements of the target application software of the terminal device, so that the terminal device can only download and install the combined patch file once.
  • the target application software is upgraded from the current version number to the target version number. Obviously, this method can significantly shorten the time consumed by the terminal device to upgrade the software, and can improve the efficiency of the terminal device software upgrade.
  • the encrypted merged patch file further includes an encrypted patch header, and the encrypted patch header is encrypted by a first security key;
  • the terminal device Decrypting the encrypted merged patch file further includes: the terminal device decrypts the encrypted patch header of the encrypted merged patch file according to the second security key to obtain the patch header Department.
  • the terminal device uses the first code segment contained in the first code segment in the merged patch file.
  • the code segment identifier and the first code content further include: the terminal device obtains the identifier offset value of the target application software; the terminal device according to the The identifier offset value is used to offset the first code segment identifier included in the first code segment in the merged patch file.
  • the software development device in order to ensure the security of the first code segment identifier in the patch file, after the software development device generates the patch file, it offsets the first code segment identifier in the patch file. Therefore, here is to ensure The terminal device can successfully install the merged patch file. Therefore, the terminal device also needs to offset the first code segment identifier in the merged patch file to restore to the original fetch of the first code segment identifier. value. It should be noted that the identification offset processing performed by the software development device and the terminal device is a reciprocal operation.
  • the software development device adds the identifier offset value based on the value of the first code segment identifier in the patch file, then the software development device merges the value of the first code segment identifier in the patch file On the basis of, subtract the mark offset value.
  • the patch download request includes the current version number of the target application software installed in the terminal device, and the target version number of the target application software upgrade performed by the terminal device.
  • the terminal device can send its own upgrade requirements for the target application software through a patch download request.
  • the encrypted merged patch file contains at least one first code segment; the first code segment is a line of first code, and the first code segment is identified as a part of the first code Line number.
  • an embodiment of the present application provides a software development device, including a unit for executing each step in the first or fourth aspect above.
  • an embodiment of the present application provides an upgrade server, including a unit for executing each step in the second or fifth aspect above.
  • an embodiment of the present application provides a terminal device, including a unit for executing each step in the third or sixth aspect above.
  • an embodiment of the present application provides a software development device, including at least one processing element and at least one storage element, wherein the at least one storage element is used to store programs and data, and the at least one processing element is used to execute the application.
  • a software development device including at least one processing element and at least one storage element, wherein the at least one storage element is used to store programs and data, and the at least one processing element is used to execute the application.
  • an embodiment of the present application provides an upgrade server, including at least one processing element and at least one storage element, wherein the at least one storage element is used to store programs and data, and the at least one processing element is used to execute the application.
  • an embodiment of the present application provides a terminal device, including at least one processing element and at least one storage element, wherein the at least one storage element is used to store programs and data, and the at least one processing element is used to execute the present application.
  • a terminal device including at least one processing element and at least one storage element, wherein the at least one storage element is used to store programs and data, and the at least one processing element is used to execute the present application.
  • an embodiment of the present application provides a software upgrade system, including a software development device, an upgrade server, and a terminal device.
  • the software development device has the function of executing the method provided in the first aspect of the present application.
  • the upgrade server has the function of executing the method provided in the second aspect of this application, the terminal device has the function of executing the method provided in the third aspect of this application; or the software development device has the function of executing the method provided in the fourth aspect of this application
  • the upgrade server has the function of executing the method provided by the fifth aspect of the present application, and the terminal device has the function of executing the method provided by the sixth aspect of the present application.
  • the embodiments of the present application also provide a computer program that, when the computer program runs on a computer, causes the computer to execute the method provided in any one of the first to sixth aspects.
  • the embodiments of the present application also provide a computer-readable storage medium in which a computer program is stored.
  • the computer program is executed by a computer, the computer is caused to execute the above-mentioned The method provided by any one of the first to sixth aspects.
  • an embodiment of the present application also provides a chip, which is used to read a computer program stored in a memory and execute the method provided in any one of the first to sixth aspects.
  • an embodiment of the present application also provides a chip system, which includes a processor, and is configured to support a computer device to implement the method provided in any one of the first to sixth aspects.
  • the chip system further includes a memory, and the memory is used to store necessary programs and data of the computer device.
  • the chip system can be composed of chips, or it can include chips and other discrete devices.
  • FIG. 1 is an architecture diagram of a software upgrade system provided by an embodiment of the application
  • FIG. 2 is a flowchart of a software upgrade method provided by an embodiment of the application
  • FIG. 3 is a diagram of an example of generating a patch file provided by an embodiment of the application.
  • FIG. 4A is an example diagram of the first method of encrypting a patch file provided by an embodiment of the application.
  • FIG. 4B is a second example diagram of encrypting a patch file provided by an embodiment of the application.
  • FIG. 4C is a third example diagram of encrypting a patch file provided by an embodiment of the application.
  • FIG. 4D is a fourth example diagram of encrypting a patch file provided by an embodiment of the application.
  • FIG. 5A is a schematic diagram of a method for merging patch files according to an embodiment of the application.
  • 5B is a schematic diagram of another method for merging patch files according to an embodiment of the application.
  • FIG. 6A is a schematic diagram of a process of encrypting the line number of a merged patch file according to an embodiment of the application
  • 6B is a schematic diagram of another process of encrypting the line number of a merged patch file provided by an embodiment of the application;
  • FIG. 7A is a schematic diagram of the first process of decrypting a merged patch file provided by an embodiment of the application.
  • FIG. 7B is a schematic diagram of the second process of decrypting the merged patch file provided by an embodiment of the application.
  • FIG. 7C is a schematic diagram of the third process of decrypting the merged patch file provided by an embodiment of the application.
  • FIG. 7D is a schematic diagram of the fourth process of decrypting the merged patch file provided by an embodiment of the application.
  • FIG. 7E is a schematic diagram of the fifth process of decrypting the merged patch file provided by an embodiment of the application.
  • FIG. 7F is a schematic diagram of the sixth process of decrypting the merged patch file provided by an embodiment of the application.
  • FIG. 8 is a communication flowchart between a software development device and an upgrade server provided by an embodiment of the application
  • FIG. 9 is a communication flowchart between an upgrade server and a terminal device according to an embodiment of the application.
  • FIG. 10 is another communication flowchart between an upgrade server and a terminal device according to an embodiment of the application.
  • FIG. 11 is a structural diagram of a communication device provided by an embodiment of this application.
  • FIG. 12 is a structural diagram of a communication device provided by an embodiment of this application.
  • the present application provides a software upgrade method and device, which are used to shorten the time consumed by the terminal device for software upgrade.
  • the method and the device are based on the same technical idea. Since the principles of the method and the device to solve the problem are similar, the implementation of the device and the method can be referred to each other, and the repetition will not be repeated.
  • the software development device after the software development device encrypts the patch file generated each time, it sends the encrypted patch file and the corresponding version number to the upgrade server for storage; the upgrade server can apply the target application according to the terminal device
  • the upgrade server decrypts the encrypted first code segment identifier in each intermediate patch file, And according to the version number and the first code segment identifier in each intermediate patch file, the multiple intermediate patch files are merged to obtain a merged patch file, and the merged patch file is encrypted and sent to the terminal device, so that the The terminal device may perform a software upgrade of the target application software according to the merged patch file.
  • the upgrade server may splice and merge multiple intermediate patch files that meet the upgrade requirements of the target application software of the terminal device, so that the terminal device can only download and install the merged patch file once.
  • the target application software is upgraded from the current version number to the target version number.
  • this method can obviously shorten the time consumed by the terminal device to upgrade the software, and can improve the efficiency of the terminal device software upgrade.
  • the software development device uses different keys to respectively encrypt the first code segment identifier and the first code content. In this way, the upgrade server is performing the process of encrypting the patch file. During the merging process, only the encrypted first code segment identifier can be decrypted, but the encrypted first code content cannot be decrypted. Therefore, this method can ensure the security of the code content in the patch file.
  • Terminal equipment is a device that can provide users with various service functions such as voice, video, shooting, and data connectivity by installing application software.
  • the terminal equipment may also be called user equipment (UE), mobile station (mobile station, MS), mobile terminal (mobile terminal, MT), and so on.
  • the terminal device may be a handheld device with a wireless connection function, a vehicle-mounted device, and the like.
  • some examples of terminal devices are: mobile phones (mobile phones), tablets, notebook computers, palmtop computers, mobile internet devices (MID), smart point of sale (POS), wearable devices, Virtual reality (VR) equipment, augmented reality (AR) equipment, wireless terminals in industrial control, wireless terminals in self-driving, and remote medical surgery
  • Wireless terminals in smart grids wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, and various Class smart meters (smart water meters, smart electricity meters, smart gas meters), smart cars in the Internet of Vehicles, onboard units (OBU), roadside units (RSU), roadside equipment (roadside equipment) , RSE), remote communication science box (telematics box, T-Box), electronic control unit (electronic control unit, ECU), etc.
  • OBU onboard units
  • RSU roadside units
  • RSE roadside equipment
  • the application can provide users with corresponding service functions.
  • the terminal device can run the application by installing the application software of the application to realize the service function of the application.
  • the terminal device needs to install the camera application software and run the camera application to provide the user with the shooting service function.
  • the terminal device needs to install WeChat application software or QQ application software and run the WeChat application or QQ application to provide the user with the chat service function.
  • application software of the application can be developed by the supplier of the terminal device or by the application supplier, which is not limited in this application.
  • Software development equipment is the equipment used by software designers to develop patch files for application software.
  • the software development equipment may belong to an application supplier or a terminal equipment supplier capable of installing application software. This application does not limit the form of the software development equipment.
  • the software development equipment may be a computer, a server, or other equipment.
  • the upgrade server is a third-party device that can store patch files of application software and provide patch file download services for terminal devices.
  • the upgrade server may be an OTA server, etc., a cloud server, etc.
  • the upgrade server can establish a connection with the software development device, thereby obtaining a patch file newly developed by the software development device, and store the patch file according to the corresponding version number.
  • the upgrade server may establish a connection with the terminal device to obtain the terminal device's upgrade requirements for application software, thereby selecting multiple patch files of the application software corresponding to the upgrade requirements, and combining the selected multiple patch files The splicing and merging are performed and sent to the terminal device so that the terminal device can upgrade the application software.
  • Code segment used to identify a piece of code. This application does not limit the length of the code contained in the code segment.
  • the code segment may include one line of code or multiple lines of code.
  • the code segment includes a line of code as an example for description.
  • the code segment is identified as the line number of the line of code.
  • Multiple refers to two or more.
  • At least one refers to one or more.
  • Figure 1 shows the software upgrade system architecture to which the software upgrade method provided in this application is applicable.
  • the system includes terminal equipment, upgrade servers, software development equipment, and so on.
  • the software development equipment is used to develop application software and a patch file of the application software, and determine the version number of the developed patch file.
  • the software development equipment may belong to an application supplier or a terminal equipment supplier, which is not limited in this application.
  • the upgrade server after establishing a connection with the software development device, receives the patch file of the application software sent by the software development device, and stores the patch file according to the version number of each patch file.
  • the upgrade server may also establish a connection with a terminal device, and through interaction with the terminal device, determine the terminal device's upgrade requirement for application software, so as to select a plurality of corresponding intermediate applications of the application software according to the upgrade requirement. Patch file, and merge the selected multiple intermediate patch files to generate a merged patch file and send it to the terminal device, so that the terminal device can upgrade the application software according to the merged patch file.
  • the upgrade server may also be referred to as an OTA server.
  • the terminal device can provide users with corresponding services by running application software.
  • the terminal device can download the patch file of the application software from the upgrade server to upgrade the installed application software.
  • the expression form of the terminal device is also different, as shown in the figure.
  • the terminal device may be a mobile phone, a tablet computer, etc.
  • terminal devices can be mobile Internet devices, wearable devices, various wireless terminals in industry or smart homes.
  • the terminal device may be a vehicle, OBU, RSU, RSE, ECU, etc.
  • the terminal device can establish a communication connection with the upgrade server through a mobile communication network (including an access network and a core network) to perform communication interaction.
  • the terminal device may also establish a communication connection with the upgrade server through the mobile communication network through at least one relay device to perform communication interaction.
  • the terminal device is an ECU in a V2X communication scenario, as shown in the figure, the ECU may sequentially pass through the following relay devices: domain controller (DC), gateway (gateway, GW), and T-Box, finally connected to the upgrade server.
  • DC domain controller
  • GW gateway
  • T-Box T-Box
  • the upgrade server may establish a communication connection with the software development device through a traditional Internet protocol (IP) network to perform communication interaction.
  • IP Internet protocol
  • the architecture shown in Figure 2 can be applied to a variety of communication scenarios, for example, the fifth generation (The 5th Generation, 5G) communication system, the future sixth generation communication system and other evolving communication systems, long-term evolution (Long Term Evolution, LTE) communication system, vehicle to everything (V2X), long-term evolution-Internet of Vehicles (LTE-vehicle, LTE-V), vehicle to vehicle (V2V), Internet of Vehicles, machine Communication (Machine Type Communications, MTC), Internet of Things (IoT), Long Term Evolution-Machine to Machine (LTE-Machine to Machine, LTE-M), Machine to Machine (M2M) and other communication scenarios
  • this application is not limited.
  • the current version number of the target application software installed in the terminal device is The target version number. That is, the version number of the patch file is the version number of the application software after the patch file is installed. In other words, the patch file and the application software actually share a version numbering mechanism.
  • an embodiment of the present application provides a software upgrade method.
  • the method can be applied to the software upgrade system as shown in FIG. 1.
  • the following describes the method provided by the embodiment of the present application in detail with reference to the flowchart shown in FIG. 2.
  • a code segment is a line of code (in the embodiments of this application, the code may also be referred to as software code) as an example for specific description, at this time the code segment identifier is the line number . It should also be noted that this embodiment does not constitute a limitation on the software upgrade method provided in this application.
  • the software development device generates a patch file of the target application software and a corresponding version number of the patch file, where the patch file includes at least one line of software code, and each line of software code includes a line number and code content.
  • the patch file of the version number is generated by the software development device based on the software code of the previous version of the target application software.
  • the patch file further includes a patch header, and the patch header is used to indicate the target application software.
  • the patch header may also include a version number corresponding to the patch file, etc. information.
  • the software development equipment needs to add the line: xxxx between line 2 and line 3 on the basis of the target application software with the version number of V1, to generate the target application software with the version number of V2, then the software development The device can generate the patch file P1 with the version number V2, so that the terminal device installed with the target application software of the version number V1 can upgrade the target application software to V2 by downloading and installing the patch file P1 (as shown in the figure).
  • the software development equipment can generate the patch file P2 with the version number V3, so that the terminal device installed with the target application software of the version number V2 can upgrade the target application software to V3 by downloading and installing the patch file P2 (e.g. Shown in the picture).
  • the software development equipment When the software development equipment needs to delete the second line on the basis of the target application software with the version number V3 to generate the target application software with the version number V4, the software development equipment can generate the patch file with the version number V4 P3. In this way, the terminal device installed with the target application software of the version number V3 can upgrade the target application software to V4 by downloading and installing the patch file P3 (as shown in the figure).
  • each line of software code of each target application software file contains two parts: line number and code content.
  • Each patch file also contains at least one line of software code (patch body), and each line of software code also contains two parts: line number (not only contains the line identification, but also contains instructions for adding or deleting) and the code content; each patch file It also includes a patch header, and the patch header may contain information indicating the target application software (for example, the file name of the target application software, or the identifier of the target application software).
  • the first security key and the first operation key are both generated by the software development device for the target application software, and the first security key is used to verify the target application software.
  • the code content in each patch file of is encrypted, and the first operation key is used to encrypt the line number/software code in each patch file of the target application software.
  • the software upgrade system may use two encryption methods to encrypt the patch file of the target application software: a symmetric encryption method and an asymmetric encryption method.
  • the first implementation manner uses a symmetric encryption method to encrypt the patch file.
  • the system may use various symmetric encryption methods such as an advanced encryption standard (AES) algorithm to encrypt the patch file.
  • AES advanced encryption standard
  • the software development equipment manages and maintains the first security key and the first operation key, and notifies the first operation key to the software server, and sends the first security key to the software server.
  • the key (optionally, the first operation key) is notified to the terminal device.
  • the second implementation manner the system uses an asymmetric encryption method to encrypt the patch file.
  • the software development equipment manages and maintains a security key pair (first security key, second security key) and operation key pair (first operation key, second operation key) .
  • the second security key is used for other devices to decrypt the code content in the patch file
  • the second operation key is used for other devices to decrypt the line number in the patch file. Therefore, the software development device may notify the software server of the second operation key (optionally, also including the first operation key), and send the second security key (optionally, The second operation key is also included) to notify the terminal device.
  • the software development device may, but is not limited to, encrypt the patch file through the following two implementation manners.
  • the first implementation manner the software development device uses the first security key to encrypt the code content contained in each line of the software code in the patch file; the software development device uses the first operation secret Key to encrypt the line number contained in each line of software code in the patch file.
  • the software development device uses the first security key to encrypt the patch header of the patch file.
  • the software development device may use the first security key to encrypt the code content contained in each line of the software code in the patch header and the patch body, and use the first security key.
  • the operation key encrypts the line number contained in each line of software code in the patch body, and finally obtains the encrypted patch file P1.
  • the specific encryption process can be referred to as shown in Figure 4A.
  • the software development device may also check the content of each line of software code in the patch body. Before encrypting the line number, use the following steps to offset the line number:
  • the software development device offsets the line number contained in each line of software code according to the line number offset value. For example, the software development device may add (or subtract) the line number offset value to the line number contained in each line of software code.
  • each target application software corresponds to a line number offset value
  • the line number offset value may be a random number.
  • the line number offset value may be sent along with the patch file.
  • the line number offset value may be saved in the header of the patch file.
  • the software development equipment first offsets the line number contained in each line of software code in the patch file P1, and adjusts the line number "3+" to "259 +”; Then use the first security key to encrypt the code content contained in the patch header and each line of software code in the patch body, and use the first arithmetic key to encrypt the line number contained in each line of software code in the patch body Encryption, and finally get the encrypted patch file P1.
  • the specific encryption process can be referred to as shown in Figure 4B.
  • the second implementation manner the software development device uses the first security key to encrypt the code content of each line of software code in the patch file; the software development device uses the first operation key , Encrypting the line number in the patch file and the code content encrypted with the first security key.
  • the software development device uses the first security key to encrypt the patch header of the patch file.
  • the software development device may use the first security key to encrypt the code content contained in each line of software code in the patch header and the patch body, and then use the first security key.
  • An operation key encrypts the line number contained in each line of software code in the patch body and the encrypted code content, and finally obtains the encrypted patch file P1.
  • the specific encryption process can be referred to as shown in Figure 4C.
  • the software development device may also offset the line number before encrypting the line number contained in each line of software code in the patch body.
  • the specific steps refer to the description of offsetting the row number in the first implementation manner, which is not repeated here.
  • the software development equipment first offsets the line number contained in each line of software code in the patch file P1, and adjusts the line number "3+" to "259 +”; Then use the first security key to encrypt the code content of each line of software code in the patch header and the patch body, and then use the first operation key to encrypt the line number and line number of each line of software code in the patch body
  • the encrypted code content is encrypted, and the encrypted patch file P1 is finally obtained.
  • the specific encryption process can be referred to as shown in Figure 4D.
  • the software development device can use different keys to respectively encrypt the line number and code content in each line of software code in the patch file, so that when the patch file is sent to the upgrade server, the upgrade server Only the encrypted line number in each line of software code can be decrypted, but the code content in each line of software code cannot be decrypted. Therefore, this method can also ensure the security of the code content in the patch file.
  • the software development device sends the encrypted patch file and the version number corresponding to the patch file (or the encrypted patch file) to the upgrade server.
  • the upgrade server receives the encrypted patch file and the corresponding version number of the target application software from the software development device.
  • the software development device may send the information of the target application software and the installation condition information of the patch file to the upgrade server together.
  • the installation condition information of the patch file may, but is not limited to, include: restriction conditions on the hardware and/or software of the terminal device.
  • the software development device and the upgrade server may communicate with each other through an established transport layer security channel.
  • the transport layer security channel may be a transport layer security protocol (Transport Layer Security, TLS) channel or a secure socket layer protocol (Secure Sockets Layer, SSL) channel.
  • the upgrade server stores the received encrypted patch file and the version number corresponding to the patch file.
  • the upgrade server After the upgrade server also receives the information of the target application software and the installation condition information of the patch file, it also saves the information.
  • the upgrade server may push the new version number to the terminal device; or the upgrade server may periodically or periodically send the new version number to the terminal device. Push the new version number.
  • the terminal device sends a patch download request of the target application software to the upgrade server.
  • the upgrade server receives the patch download request of the target application software from the terminal device.
  • the upgrade server determines the upgrade requirements of the terminal device, that is, determines the current version number of the target application software installed in the terminal device, and the target version of the terminal device to upgrade the target application software No.
  • the upgrade server may, but is not limited to, determine the terminal device upgrade requirement in the following manner:
  • the upgrade server may determine whether the terminal device installs the target application software, the hardware and/or software information of the terminal device, and the current version number through communication interaction with the terminal device; Then, the upgrade server may determine the target version number according to information such as the version number of the saved patch file, the installation condition information of the patch file, and the like.
  • the upgrade server may obtain the current version number from the patch download request, or determine the current version number through communication interaction with the terminal device; then the upgrade server saves the latest version number The version number is used as the target version number.
  • the upgrade server selects multiple intermediate patch files from the locally stored encrypted patch files of the target application software according to the current version number and the target version number, where each intermediate patch file The corresponding version number is greater than the current version number and less than or equal to the target version number.
  • the system can encrypt the patch file by using a symmetric encryption method or an asymmetric encryption method. Therefore, in this step, the following two embodiments can also be included correspondingly.
  • the first implementation manner the system uses a symmetric encryption method to encrypt the patch file.
  • the second operation key is the same as the first operation key.
  • the second implementation manner the system uses an asymmetric encryption method to encrypt the patch file.
  • the second operation key is the same as the first operation key.
  • the second operation key is received by the upgrade server from the software development device.
  • the manner in which the upgrade server decrypts the encrypted line number is related to the implementation manner in which the software development device encrypts the patch file. Therefore, correspondingly, the upgrade server may also, but is not limited to, decrypt the encrypted line number in the intermediate patch file through the following two implementation manners.
  • the first implementation manner when the software development device performs encryption processing on each patch file through the above first implementation manner, as shown in FIG. 4A or FIG. 4B.
  • the upgrade server uses the second operation key to decrypt the encrypted line number contained in each line of software code of each intermediate patch file.
  • the second implementation manner when the software development device performs encryption processing on each patch file through the above second implementation manner, as shown in FIG. 4C or FIG. 4D.
  • the upgrade server uses the second operation key to decrypt the encrypted line number and the encrypted software content contained in each line of the software code of each intermediate patch file.
  • the upgrade server merges the multiple decrypted intermediate patch files according to the version number corresponding to the multiple intermediate patch files and the line number of each line of software code in each decrypted intermediate patch file. Obtain a merged patch file of the target application software; wherein the merged patch file contains at least one line of software code, and each line of software code contains a line number and encrypted code content.
  • the upgrade server may adopt the following steps to realize the merging of the multiple decrypted intermediate patch files:
  • the upgrade server sorts the multiple decrypted intermediate patch files according to the order of the stored version numbers corresponding to the multiple intermediate patch files to obtain a file sequence, where the version number is decrypted first The latter intermediate patch file is located at the first position of the file sequence, and the decrypted intermediate patch file with the last version number is located at the end of the file sequence;
  • the upgrade server merges each decrypted intermediate patch file according to the line number of each line of software code in each decrypted intermediate patch file in the order of the file sequence to obtain the merged patch file .
  • each intermediate patch file contains an encrypted patch header
  • the generated merged patch file also contains the encrypted patch header (that is, the encrypted patch header of one of the target patch files)
  • the patch header of is copied into the merged patch file).
  • the upgrade server may first generate an empty merged patch file; and then copy the first decrypted intermediate patch file in the file sequence to the merged patch file.
  • the upgrade server then merges the second decrypted intermediate patch file with the merged patch file, which specifically includes the following steps:
  • the upgrade server copies the line of software code to an appropriate position in the merged patch file to ensure that the lines in the merged patch file
  • the numbers are arranged in ascending order. For example, if the line number of a certain line of software code in the second decrypted intermediate patch file is "2", then this line of software code is copied to the merged patch file before the line number is "3"; If the line number of a certain line of software code in the two decrypted intermediate patch files is "4", then this line of software code is copied to the merged patch file after the line number is "3".
  • the line numbers of the original software code in the merged patch file other than the software code are adjusted as follows:
  • the upgrade server sequentially determines each line of software code in the second decrypted intermediate patch file copied in the merged patch file in the order of line numbers from small to large, if the line number in the line of software code contains a delete instruction " -", then the line number of each line of the original software code after the line of software code is subtracted by 1; if the line number of the line of software code contains the increase instruction "+”, then each line of the original software code after the line of software code is added 1.
  • the upgrade server determines whether there are two adjacent lines of software code that meet the following offset conditions in the merged patch file after the line number of the original software code is adjusted: the line number is the same, the code content is the same, and the line number of one of the lines is Contains the delete instruction "-", and the line number of the other line contains the increase instruction "+”. If it exists, the upgrade server deletes these two lines of software code (that is, the two adjacent lines of software code cancel each other out).
  • the upgrade server obtains the next decrypted intermediate patch file from the file sequence, and continues to merge with the merged patch file according to the above steps, until all the decrypted intermediate patch files in the file sequence are merged Merged into the merged patch file.
  • the description is continued by taking the three patch files P1, P2, and P3 in FIG. 3 as examples.
  • the upgrade server determines that these three patch files are intermediate patch files, and then uses the second calculation The key decrypts the encrypted line number and the encrypted software content contained in each line of the software code of each intermediate patch file to obtain the three decrypted patch files shown in (1) in FIG. 5A.
  • the upgrade server uses the merging method shown in (2) in Figure 5A to merge the three decrypted intermediate patch files:
  • the upgrade server generates an empty merged patch file, and copies a line of software code in P1 into the merged patch file; then, the upgrade server adds each line of software code in P2 to the line number of each line of software code in P2.
  • the line of software code is copied to the appropriate position in the merged patch file, as shown in the temporary merged patch file temp1 in (2) in Figure 5A; because the first line of software code of P2 is added to the merged patch file
  • the line number "258-" contains the delete instruction "-".
  • the upgrade server reduces the line number of the original software code in the merged patch file after the line of software code by 1, that is, the original software line number "259+”
  • the line number in the code becomes "258+", as shown in the temporary merged patch file temp2 in (2) in Figure 5A;
  • the upgrade server copies each line of software code in P3 to the merged patch file After the original software code with the line number "258+” in the appropriate position in Figure 5A, the temporary merged patch file temp3 in (2) in Figure 5A; due to the newly added line number of the P3 software code "258- "Contains the delete instruction "-".
  • the upgrade server decrements the line number of the original software code after this line of software code by 1, that is, the line number in the original software code with the line number "260+” becomes “259+” ", as shown in the temporary merged patch file temp4 in (2) in Figure 5A; since the second and third lines of software code adjacent to the merged patch file temp4 at this time meet the offset condition, the software The server deletes these two lines of software code, and finally obtains the merged patch file P1_3 after merging P1, P2, and P3.
  • the header of the merged patch file is the same as that of any one of the patch files P1-P3 saved by the upgrade server.
  • the patch header is the same.
  • the description is continued by taking the three patch files P1, P2, and P3 in FIG. 3 as examples.
  • the upgrade server determines that these three patch files are intermediate patch files, and then uses the second calculation The key decrypts the encrypted line number and the encrypted software content contained in each line of the software code of each intermediate patch file to obtain the three decrypted patch files shown in (1) in FIG. 5B.
  • the upgrade server uses the merging method shown in (2) in FIG. 5B to merge the three decrypted target patch files:
  • the upgrade server generates an empty merged patch file, and copies a line of software code in P1 into the merged patch file; then, the upgrade server adds each line of software code in P2 to the line number of each line of software code in P2.
  • the line software code is copied to the appropriate position in the merged patch file, as shown in the temporary merged patch file temp1 in (2) in Figure 5B; because the first line of software code of P2 is newly added in the merged patch file
  • the line number "2-" contains the delete instruction "-".
  • the upgrade server decrements the line number of the original software code in the merged patch file after the line of software code by 1, that is, the original software line number "3+”
  • the line number in the code becomes "2+", as shown in the temporary merged patch file temp2 in (2) in Figure 5B;
  • the upgrade server copies each line of software code in P3 to the merged patch file After the original software code with the line number "2+” in the appropriate position in Figure 5B, as shown in the temporary merged patch file temp3 in (2) in Figure 5B; due to the newly added line number of the P3 software code "2- "Contains the delete instruction "-”, therefore, the upgrade server decrements the line number of the original software code after the line of software code by 1, that is, the line number in the original software code with the line number "4+” becomes "3+” ", as shown in the temporary merged patch file temp4 in (2) in Figure 5B; at this time, the adjacent second and third lines of software code in the merged patch file temp4 meet the offset condition, therefore, the software The server
  • the header of the merged patch file is the same as that of any one of the patch files P1-P3 saved by the upgrade server.
  • the patch header is the same.
  • the upgrade server can offset some software codes that meet the offset conditions, which can reduce the data volume of the merged patch file. , To improve the transmission efficiency of the merged patch file. Compared with the traditional method in which the upgrade server needs to send multiple intermediate patch files to the terminal device, this solution can upgrade the terminal device to the target version number by sending a combined patch file, which can simplify the transfer of patches to the terminal device.
  • the file process significantly improves the transmission efficiency of patch files.
  • the upgrade server sends the merged patch file to the terminal device.
  • the terminal device receives the merged patch file of the target application software from the upgrade server.
  • the upgrade server may send the upgrade patch file in two ways.
  • the upgrade server may obtain the merged patch file and before sending the merged patch file to the terminal device, the upgrade server The line number in each line of software code in the merged patch file can be encrypted again.
  • the upgrade server may encrypt the line numbers in the merged patch file in two implementation manners.
  • the first implementation manner the software development device encrypts the patch file through the first implementation manner shown in FIG. 4A or FIG. 4B, and the upgrade server uses the second operation key when executing S208, In the case of decrypting the encrypted line number contained in each line of software code of each intermediate patch file.
  • the upgrade server uses the first operation key to encrypt the line number contained in each line of software code in the merged patch file.
  • the upgrade server may Extract the line number contained in each line of software code in the merged patch file, then use the first operation key to encrypt the extracted line number, and apply each encrypted line number to the merged patch file Replace the corresponding line number in to obtain the merged patch file P1_3 after the line number encryption process.
  • the second implementation manner the software development device encrypts the patch file through the second implementation manner shown in FIG. 4C or FIG. 4D, and the upgrade server uses the second operation key when executing S208, When decrypting the encrypted line number and encrypted software content contained in each line of software code of each intermediate patch file.
  • the upgrade server uses the first operation key to encrypt the line number and the encrypted software content contained in each line of the software code in the merged patch file.
  • the upgrade server may Extract each line of software code in the merged patch file, and then use the first operation key to encrypt each line of the extracted software code, and encrypt each line of software code and the original patch header to form a line number after encryption The processed merged patch file P1_3.
  • the upgrade server may directly send the merged patch file obtained by the merge to the terminal device.
  • the upgrade server and the terminal device may establish a transport layer security channel for communication interaction.
  • the transport layer security channel may be a TLS channel or an SSL channel.
  • the upgrade server may establish a transport layer security channel with the intermediate device to safely transmit the merged patch file to Terminal Equipment.
  • the ECU needs to pass through the domain controller, GW, and T-Box to connect to the upgrade server, then the upgrade server can establish a transport layer security channel with the T-Box , And then send the merged patch file to the T-Box through the transport layer security channel, and then the T-Box transmits the merged patch file to the ECU through the GW and the domain controller.
  • the process of decrypting the merged patch file by the terminal device is also different.
  • the decryption process of the terminal device which is related to the encryption process of the upgrade server and the software development device, may include the following implementation modes.
  • the first implementation manner the software development device encrypts the patch file through the implementation manner shown in FIG. 4A, and the upgrade server uses the second operation key to encrypt the encrypted line in each target patch file When the number is decrypted, and the upgrade server uses the first operation key to encrypt the line number contained in each line of software code in the merged patch file.
  • the terminal device uses the following steps to decrypt the encrypted merged patch file:
  • the terminal device uses the second security key to decrypt the encrypted code content contained in each line of the software code in the encrypted merged patch file.
  • the terminal device uses the second operation key to decrypt the encrypted line number contained in each line of the software code in the encrypted merged patch file.
  • the terminal device can use the second security key to decrypt the encrypted patch header to obtain "APP1"; the terminal device can use the second operation key to determine the content of each line of software code The encrypted line number is decrypted to obtain line numbers "2-" and "3+”; the terminal device can use the second security key to decrypt the encrypted code content contained in each line of software code to obtain the code content "Bbbb" and "yyyy”; then the terminal device will decrypt the patch header, line number and code content obtained by decryption to form the decrypted merged patch file P1_3.
  • the second implementation manner the software development device encrypts the patch file in the implementation manner shown in FIG. 4B, and the upgrade server uses the second operation key to encrypt the encrypted line in each target patch file When the number is decrypted, and the upgrade server uses the first operation key to encrypt the line number contained in each line of software code in the merged patch file.
  • the terminal device uses the following steps to decrypt the encrypted merged patch file:
  • the terminal device uses the second security key to decrypt the encrypted code content contained in each line of the software code in the encrypted merged patch file.
  • the terminal device uses the second operation key to decrypt the encrypted line number contained in each line of the software code in the encrypted merged patch file.
  • the terminal device uses the following steps to perform row offset processing on the row numbers in the merged patch file:
  • the terminal device offsets the line number contained in each line of software code in the merged patch file according to the line number offset value.
  • the row offset processing performed by the terminal device and the row offset processing performed by the software development device are mutually inverse. For example, the terminal device subtracts (or adds) the line number offset value from the line number contained in each line of software code.
  • the terminal device may obtain the line number offset value from the decrypted patch header in the merged patch file, or obtain the stored line number offset value of the target application software.
  • the content is decrypted to obtain code content "bbbb" and "yyyy”; then the terminal device will decrypt the patch header, line number, and code content obtained by decryption to form a decrypted merged patch file P1_3'; finally, the terminal device According to z, the line number contained in each line of software code is offset (line number minus z) to obtain the final decrypted merged patch file P1_3.
  • the third implementation manner the software development device encrypts the patch file in the implementation manner shown in FIG. 4C, and the upgrade server uses the second operation key to encrypt the encrypted line in each target patch file When the number and encrypted software content are decrypted, and the upgrade server uses the first operation key to encrypt the line number and the encrypted software content contained in each line of the software code in the merged patch file.
  • the terminal device uses the following steps to decrypt the encrypted merged patch file:
  • the terminal device uses the second operation key to decrypt each line of software code (including the encrypted line number and the encrypted code content) in the encrypted merged patch file.
  • the terminal device uses the second security key to decrypt the encrypted code content contained in each line of the software code in the encrypted merged patch file.
  • the terminal device uses the second security key to decrypt the encrypted patch header.
  • the terminal device can use the second security key to decrypt the encrypted patch header to obtain "APP1"; the terminal device can use the second operation key to decrypt each line of software code , Obtain the line number and the corresponding encrypted code content; the terminal device can use the second security key to decrypt the encrypted code content contained in each line of software code to obtain the code content "bbbb" and "yyyy”; Then the terminal device will decrypt the patch header, line number and code content to form the decrypted merged patch file P1_3.
  • the fourth implementation manner the software development device encrypts the patch file in the implementation manner shown in FIG. 4D, and the upgrade server uses the second operation key to encrypt the encrypted line in each target patch file When the number and encrypted software content are decrypted, and the upgrade server uses the first operation key to encrypt the line number and the encrypted software content contained in each line of the software code in the merged patch file.
  • the terminal device uses the following steps to decrypt the encrypted merged patch file:
  • E1 The terminal device uses the second operation key to decrypt each line of software code (including the encrypted line number and the encrypted code content) in the encrypted merged patch file.
  • the terminal device uses the second security key to decrypt the encrypted code content contained in each line of the software code in the encrypted merged patch file.
  • E4 The terminal device performs line offset processing on the line numbers in the merged patch file, which is the same as step C4, and will not be repeated here.
  • z Offset processing line number minus z
  • the decryption process of the terminal device which is related to the encryption process of the upgrade server and the software development device, may include the following implementation modes.
  • the first implementation manner the software development device encrypts the patch file through the implementation manner shown in FIG. 4A, and the upgrade server uses the second operation key to encrypt the encrypted line in each target patch file No. in case of decryption.
  • the terminal device uses the following steps to decrypt the merged patch file:
  • the terminal device uses the second security key to decrypt the encrypted code content contained in each line of the software code in the merged patch file.
  • the terminal device uses the second security key to decrypt the encrypted patch header in the merged patch file.
  • the terminal device can use the second security key to decrypt the encrypted patch header to obtain "APP1"; the terminal device can use the second security key to determine the content of each line of software code
  • the encrypted code content is decrypted to obtain code content "bbbb" and "yyyy”; then the terminal device will decrypt the patch header, code content, and line number obtained by decryption to form the decrypted merged patch file P1_3.
  • the second implementation manner the software development device encrypts the patch file in the implementation manner shown in FIG. 4B, and the upgrade server uses the second operation key to encrypt the encrypted line in each target patch file No. in case of decryption.
  • the terminal device uses the following steps to decrypt the merged patch file:
  • the terminal device uses the second security key to decrypt the encrypted code content contained in each line of the software code in the merged patch file.
  • the terminal device uses the second security key to decrypt the encrypted patch header in the merged patch file.
  • step C3 The terminal device performs line offset processing on the line numbers in the merged patch file, which is the same as step C4, and will not be repeated here.
  • the encrypted code content contained in each line of the software code is decrypted to obtain the code content "bbbb" and "yyyy”; then the terminal device will decrypt the patch header, code content, and line number obtained by the decryption to form the decrypted code content
  • the third implementation manner the software development device encrypts the patch file in the implementation manner shown in FIG. 4C, and the upgrade server uses the second operation key to encrypt the encrypted line in each target patch file Number and encrypted software content in case of decryption.
  • the process of decrypting the merged patch file by the terminal device is the same as that in the first embodiment, and will not be repeated here.
  • the fourth implementation manner the software development device encrypts the patch file through the implementation manner shown in FIG. 4D, and the upgrade server uses the second operation key to encrypt the encrypted line in each target patch file Number and encrypted software content in case of decryption.
  • the process of decrypting the merged patch file by the terminal device is the same as that in the first embodiment, and will not be repeated here.
  • S212 The terminal device upgrades the installed target application software according to the line number and code content contained in each line of software code in the merged patch file.
  • the terminal device may install the merged patch file to merge the merged patch file into the file of the target application software, thereby upgrading the target application software to the target version number.
  • For the process of the terminal device merging the merged patch file into the file of the target application software refer to (2) in FIG. 5A or (2) in FIG. 5B, which will not be repeated here.
  • the embodiment of the present application provides a software upgrade method.
  • the upgrade server can merge multiple target patch files.
  • the terminal device can download and install the combined patch file only once to achieve the target application software. Upgrade from the current version number to the target version number. Obviously, this method can significantly shorten the time consumed by the terminal device to upgrade the software, and can improve the efficiency of the terminal device software upgrade.
  • the software development equipment uses different keys to respectively encrypt the line number and code content in each line of software code. In this way, the upgrade server can only encrypt each line of software. The encrypted line number in the code is decrypted, but the code content in each line of software code cannot be decrypted. Therefore, this method can also ensure the security of the code content in the patch file.
  • the embodiment of the present application also provides a communication process between the software development device and the upgrade server, so as to realize that the software development device sends the patch file and its corresponding version number to the upgrade server.
  • the communication process will be described in detail below with reference to FIG. 8.
  • the software development device before the software development device communicates with the upgrade server, the software development device maintains its own key pair (public key K S_pub , private key K S_priv ), and saves the upgrade server
  • the software development device and the upgrade server may first establish a transport layer security channel (TSL channel or SSL channel), so that the two can communicate through the transport layer security channel during communication and interaction.
  • TSL channel transport layer security channel
  • the software development device After generating the patch file of the target application file, the software development device generates a notification message, where the notification message is used to notify that a new patch file has been prepared in the software development device.
  • the notification message includes the message freshness N determined by the software development device for this notification.
  • the software development device After the software development device encrypts the notification message using the public key K OTA_pub of the upgrade server, it sends the encrypted notification message to the upgrade server.
  • the upgrade server After receiving the encrypted notification message, the upgrade server uses its own private key K OTA_priv to decrypt the encrypted notification message, obtain the notification message, and obtain N from the notification message. The upgrade server stores N to facilitate subsequent verification.
  • the upgrade server generates a patch download request containing N. Wherein, the patch download request is used to request the software development device to send a patch file. After the upgrade server encrypts the patch download request using the public key K S_pub of the software development device, it sends the encrypted patch download request to the software development device.
  • the software development device After receiving the encrypted patch download request, the software development device uses its own private key K S_priv to decrypt the encrypted patch download request, obtains the patch download request, and obtains N from the patch download request. .
  • the software development device encapsulates the patch file, version number, and N into a patch file data package, and uses the public key K OTA_pub of the upgrade server to encrypt the patch file data package, and the encrypted patch
  • the file data package is sent to the upgrade server.
  • the upgrade server After receiving the encrypted patch file data package, the upgrade server uses its own private key K OTA_priv to decrypt the encrypted patch file data package to obtain the patch file, version number, and N therein. Then, the upgrade server checks the N obtained in the patch file data package with the N obtained in S802, and when it is determined that the two are exactly the same, the upgrade server saves the patch file and the version number in its own database middle.
  • the embodiment of the present application also provides a communication process between the upgrade server and the terminal device, so that the terminal device can download the merged patch file from the software development device, as shown in FIGS. 9 and 10 .
  • FIG. 9 is described by taking a scenario where the terminal device does not pass through other relay devices and connects to the upgrade server as an example.
  • the upgrade server before the upgrade server communicates with the terminal device, the upgrade server maintains its own key pair (public key K OTA_pub , private key K OTA_priv ), and saves the public key of the terminal device.
  • Key K UE_pub ;
  • the upgrade server maintains its own key pair (public key K UE_pub and private key K UE_priv ), and stores the public key K OTA_pub of the upgrade server.
  • the upgrade server and the terminal device may first establish a transport layer security channel (TSL channel or SSL channel), so that when the two communicate and interact, they can transmit through the transport layer security channel.
  • TSL channel transport layer security channel
  • the upgrade server generates a notification message after receiving a new patch file of the target application software from the software development device, or generates the notification message periodically or periodically.
  • the notification message is used to notify that a new patch file is ready in the upgrade server.
  • the notification message includes the message freshness N determined by the upgrade server for this notification.
  • the upgrade server encrypts the notification message using the public key K UE_pub of the terminal device, and then sends the encrypted notification message to the terminal device.
  • the terminal device After receiving the encrypted notification message, the terminal device uses its own private key K UE_priv to decrypt the encrypted notification message, obtain the notification message, and obtain N from the notification message. The terminal device stores N to facilitate subsequent verification.
  • the terminal device generates a patch download request containing N.
  • the patch download request is used to request the upgrade server to send a patch file.
  • the terminal device encrypts the patch download request using the public key K OTA_pub of the upgrade server, and sends the encrypted patch download request to the upgrade server.
  • the patch download request includes the current version number of the target application software installed by the terminal device, and the target version number of the target application software upgrade performed by the terminal device.
  • the upgrade server After receiving the encrypted patch download request, the upgrade server uses its own private key K OTA_priv to decrypt the encrypted patch download request to obtain the patch download request, and obtain it from the patch download request N, and the current version number and the target version number.
  • the upgrade server selects multiple target patch files from the patch files of the target application software stored in a local database according to the current version number and the target version number, and then merges the multiple target patch files To generate a merged patch file.
  • the upgrade server For the process of generating the merged patch file by the upgrade server, reference may be made to the description in S208-S210 in the embodiment shown in FIG. 2, which will not be repeated here.
  • the upgrade server encapsulates the merged patch file and N into a patch file data package, and uses the public key K UE_pub of the terminal device to encrypt the patch file data package, and finally the encrypted patch file The data packet is sent to the terminal device.
  • the terminal device After receiving the encrypted patch file data package, the terminal device uses its own private key K UE_priv to decrypt the encrypted patch file data package to obtain the merged patch file and N therein. Then, the terminal device checks the N obtained from the patch file data package with the N obtained in S902, and when it is determined that the two are exactly the same, the terminal device installs the merged patch file, thereby applying the target The software is upgraded to the target version number.
  • FIG. 10 illustrates a scenario where the terminal device is an ECU, and the ECU is connected to the upgrade server via other relay devices (DC, GW, and T_Box) as an example.
  • DC DC, GW, and T_Box
  • the upgrade server before the upgrade server communicates with the terminal device, the upgrade server maintains its own key pair (public key K OTA_pub , private key K OTA_priv ), and saves the public key of the T_Box K TBox_pub ;
  • the upgrade server maintains its own key pair (public key K TBox_pub , private key K TBox_priv ), and stores the public key K OTA_pub of the upgrade server.
  • the upgrade server and the T_Box can first establish a transport layer security channel (TSL channel or SSL channel), so that the two can communicate through the transport layer security channel during communication and interaction.
  • TSL channel transport layer security channel
  • the T_Box and the GW also store a symmetric key K TBox_GW for encrypting and decrypting messages transmitted between the T_Box and the GW; the GW and the DC store a symmetric key
  • the key K GW_DC is used to encrypt and decrypt messages transmitted between the GW and the DC; the DC and the ECU store a symmetric key K DC_ECU , which is used to compare the difference between the DC and the ECU. Encryption and decryption of messages transmitted between.
  • the upgrade server generates a notification message after receiving the new patch file of the target application software from the software development device, or generates the notification message periodically or periodically.
  • the notification message is used to notify that a new patch file is ready in the upgrade server.
  • the notification message includes the message freshness N determined by the upgrade server for this notification.
  • the upgrade server uses the public key K TBox_pub of the T_Box to encrypt the notification message, and then sends the encrypted notification message to the T_Box.
  • the T_Box After receiving the encrypted notification message, the T_Box uses its own private key K TBox_priv to decrypt the encrypted notification message to obtain the notification message, and obtain N from the notification message. The T_Box stores N to facilitate subsequent verification.
  • the T_Box generates a patch download request containing N. Wherein, the patch download request is used to request the upgrade server to send a patch file.
  • the T_Box encrypts the patch download request using the public key K OTA_pub of the upgrade server, and sends the encrypted patch download request to the upgrade server.
  • the patch download request includes the current version number of the target application software that has been installed by the T_Box, and the target version number of the target application software upgrade performed by the T_Box.
  • the upgrade server After receiving the encrypted patch download request, the upgrade server uses its private key K OTA_priv to decrypt the encrypted patch download request to obtain the patch download request, and obtain N from it, and The current version number and the target version number.
  • the upgrade server selects multiple target patch files from the patch files of the target application software stored in a local database according to the current version number and the target version number, and then merges the multiple target patch files To generate a merged patch file.
  • K OTA_priv the private key
  • the upgrade server selects multiple target patch files from the patch files of the target application software stored in a local database according to the current version number and the target version number, and then merges the multiple target patch files To generate a merged patch file.
  • the upgrade server encapsulates the merged patch file and N into a patch file data package, and uses the public key K TBox_pub of the T_Box to encrypt the patch file data package, and finally the encrypted patch file data package Send to the T_Box.
  • the T_Box After receiving the encrypted patch file data package, the T_Box uses its own private key K TBox_priv to decrypt the patch file data package to obtain the merged patch file and N therein. Then, the T_Box checks the N obtained from the patch file data package and the N obtained in S902, and determines that the two are identical.
  • T_Box encrypts the merged patch file using the symmetric key K TBox_GW, and sends the encrypted merged patch file to the GW.
  • the GW After receiving the encrypted merged patch file, the GW uses the symmetric key K TBox_GW to decrypt the encrypted merged patch file to obtain the merged patch file; and then uses the symmetric key K GW_DC to pair The merged patch file is encrypted, and the encrypted merged patch file is sent to the DC.
  • the DC After receiving the encrypted merged patch file, the DC uses the symmetric key K GW_DC to decrypt the encrypted merged patch file to obtain the merged patch file; and then uses the symmetric key K DC_ECU to The merged patch file is encrypted, and the encrypted merged patch file is sent to the ECU.
  • the ECU After receiving the encrypted merged patch file, the ECU uses the symmetric key K DC_ECU to decrypt the encrypted merged patch file to obtain the merged patch file; then the terminal device installs the The patch files are merged to upgrade the target application software to the target version number.
  • the DC After receiving the decrypted upgrade result notification, the DC uses the symmetric key K DC_ECU to decrypt the upgrade result notification to obtain the upgrade result notification; and then uses the symmetric key K GW_DC to perform the upgrade
  • the result notification is encrypted, and the encrypted upgrade result notification is sent to the GW.
  • the GW After receiving the decrypted upgrade result notification, the GW decrypts the upgrade result notification using the symmetric key K GW_DC to obtain the upgrade result notification; then uses the symmetric key K TBox_GW to perform the upgrade
  • the result notification is encrypted, and the encrypted upgrade result notification is sent to T_Box.
  • the T_Box After receiving the decrypted upgrade result notification, the T_Box decrypts the upgrade result notification using the symmetric key KTBox_GW to obtain the upgrade result notification; then uses the public key K OTA_puk of the upgrade server to pair The upgrade result notification is encrypted, and the encrypted upgrade result notification is sent to the upgrade server.
  • the upgrade server After receiving the encrypted upgrade result notification, the upgrade server uses its own private key K OTA_priv to decrypt the upgrade result notification to obtain the upgrade result notification.
  • an embodiment of the present application also provides a communication device.
  • the structure of the device is shown in FIG. 11 and includes a communication unit 1101 and a processing unit 1102.
  • the communication device 1100 can be applied to a software development device, a software server, or a terminal device in the software upgrade system shown in FIG. 1, and can implement the software upgrade method provided in the above embodiments and examples.
  • the communication unit 1101 is used for receiving and sending data.
  • the communication unit 1101 may also be called a physical interface, a communication module, a communication interface, and an input/output interface.
  • the communication device 1100 may be connected to a network cable or a cable through the communication unit, and then establish a physical connection with other devices.
  • the communication unit 1101 may also be referred to as a transceiver, which may be implemented by a mobile communication module and/or a wireless communication module.
  • the mobile communication module can provide wireless communication solutions including 2G/3G/4G/5G, etc., which are applied to the terminal device.
  • the mobile communication module may include at least one antenna, at least one filter, switch, power amplifier, low noise amplifier (LNA), etc.
  • the terminal device can access the mobile communication network through the mobile communication module, and then access the forwarding device in the calculation network through the mobile communication network.
  • the wireless communication module can provide applications on terminal devices including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (bluetooth, BT), and global navigation satellite systems ( Global navigation satellite system, GNSS), frequency modulation (frequency modulation, FM), near field communication technology (near field communication, NFC) and other wireless communication solutions.
  • WLAN wireless local area networks
  • Bluetooth blue, BT
  • GNSS global navigation satellite systems
  • frequency modulation frequency modulation, FM
  • NFC near field communication technology
  • the wireless communication module 160 may include at least one antenna, one or more devices of at least one communication processing module.
  • the terminal device can access the wireless communication network through the wireless communication module, and then access the forwarding device in the arithmetic network through the wireless communication network.
  • processing unit 1102 when the communication device 1100 is applied to software development equipment will be introduced below.
  • the processing unit 1102 is configured to generate a patch file of the target application software and a corresponding version number of the patch file, wherein the patch file includes a first code segment, and the first The code segment includes the first code segment identifier and the first code content; encrypting the patch file includes: encrypting the first code content according to the first security key; and encrypting the first code content according to the first operation key The first code segment identifier and the first code content encrypted by the first security key are encrypted; wherein, the first operation key is different from the first security key; the communication unit 1101 sends the encrypted patch file and the version number corresponding to the patch file to the upgrade server.
  • processing unit 1102 is further configured to:
  • the identifier offset value offsets the identifier of the first code segment.
  • the patch file further includes a patch header, where the patch header is used to indicate the target application software; the processing unit 1102, when encrypting the patch file, also uses At:
  • the patch file includes at least one of the first code segments; the first code segment is a line of first code, and the first code segment is identified as a line number of the first code.
  • the processing unit 1102 is configured to generate a patch file of the target application software and a corresponding version number of the patch file, wherein the patch file includes a first code segment, and the first The code segment includes the first code segment identifier and the first code content; encrypting the patch file includes: encrypting the first code content according to the first security key; and encrypting the first code content according to the first operation key
  • the first code segment identifier is encrypted; wherein, the first operation key is different from the first security key; the encrypted patch file and the patch are sent to the upgrade server through the communication unit 1101 The version number corresponding to the file.
  • processing unit 1102 is further configured to:
  • the identifier offset value of the target application software is obtained; according to the identifier offset value, the first code segment identifier is biased shift.
  • the patch file further includes a patch header, where the patch header is used to indicate the target application software
  • the processing unit 1102 is further configured to: when performing encryption processing on the patch file:
  • processing unit 1102 when the communication device 1100 is applied to an upgrade server will be introduced below.
  • the processing unit 1102 is configured to:
  • the encrypted patch file contains the encrypted first code segment, and the encrypted first code segment is passed through the first Obtained by encrypting a first code segment identifier and a first code content encrypted by a first security key by an arithmetic key, the first arithmetic key is different from the first security key;
  • the target version number determines an intermediate patch file from the locally stored encrypted patch file of the target application software, where the intermediate patch file has a version number greater than the current version The encrypted patch file whose number is less than or equal to the target version number;
  • each intermediate patch file is decrypted according to the second operation key.
  • the decryption includes decrypting the encrypted first code segment contained in each intermediate patch file to obtain each intermediate patch file.
  • the first code segment identifier of the first code segment of an intermediate patch file and the first code content encrypted by the first security key;
  • the merged patch file contains the updated first code segment, and the updated first code segment includes the first code content encrypted by the first security key and the update The first code segment identification after;
  • Encrypting the merged patch file according to the first operation key includes: encrypting the updated first code segment in the merged patch file according to the first operation key;
  • the encrypted merged patch file is sent to the terminal device through the communication unit 1101.
  • the processing unit 1102 based on the version numbers corresponding to the plurality of intermediate patch files, and the first code segment identifier contained in the first code segment of each decrypted intermediate patch file, perform the identification of all the decrypted intermediate patch files.
  • the multiple intermediate patch files are merged to obtain the merged patch file of the target application software, it is specifically used for:
  • the decrypted intermediate patch files are sorted to obtain a file sequence, where the decrypted intermediate patch file with the first version number is located at The decrypted intermediate patch file with the first position of the file sequence and the last version number is located at the end of the file sequence;
  • each decrypted intermediate patch file is merged in sequence in the order of the file sequence to obtain the merged patch file.
  • the encrypted patch file further includes an encrypted patch header, and the encrypted patch header is encrypted by the first security key; the merged patch file also includes all Describe the encrypted patch header.
  • the processing unit 1102 when determining the current version number of the target application software installed in the terminal device, and the target version number for the terminal device to upgrade the target application software, specifically use At:
  • the encrypted patch file contains at least one encrypted first code segment; the encrypted first code segment is an encrypted line of the first code, and the first code segment is identified as the Line number of the first code; the merged patch file contains at least one updated first code segment.
  • processing unit 1102 is configured to:
  • the encrypted patch file includes a first code segment, and the first code segment includes an encrypted first code segment identifier And the encrypted first code content;
  • the encrypted first code segment identifier is obtained by encrypting the first code segment identifier by the first operation key, and the encrypted first code content is obtained through the first security Obtained by encrypting the content of the first code by a key, the first operation key is different from the first security key;
  • the target version number determines an intermediate patch file from the locally stored encrypted patch file of the target application software, where the intermediate patch file has a version number greater than the current version The encrypted patch file whose number is less than or equal to the target version number;
  • each intermediate patch file When there are multiple intermediate patch files, decrypt each intermediate patch file according to the second operation key, and the decryption includes the encrypted first code contained in the first code segment of each intermediate patch file
  • the segment identifier is decrypted to obtain the first code segment identifier contained in the first code segment of each intermediate patch file;
  • the merged patch file includes an updated first code segment, and the updated first code segment includes the first code content encrypted by the first security key And the updated first code segment identifier;
  • Encrypting the merged patch file according to the first operation key includes: encrypting the updated first code segment identifier in the merged patch file according to the first operation key;
  • the encrypted merged patch file is sent to the terminal device through the communication unit 1101.
  • the processing unit 1102 based on the version numbers corresponding to the plurality of intermediate patch files, and the first code segment identifier contained in the first code segment of each decrypted intermediate patch file, perform the identification of all the decrypted intermediate patch files.
  • the multiple intermediate patch files are merged to obtain the merged patch file of the target application software, it is specifically used for:
  • the decrypted intermediate patch files are sorted to obtain a file sequence, where the decrypted intermediate patch file with the first version number is located at The decrypted intermediate patch file with the first position of the file sequence and the last version number is located at the end of the file sequence;
  • each decrypted intermediate patch file is merged in sequence in the order of the file sequence to obtain the merged patch file.
  • the encrypted patch file further includes an encrypted patch header, and the encrypted patch header is encrypted by the first security key;
  • the merged patch file also contains the encrypted patch header.
  • the processing unit 1102 when determining the current version number of the target application software installed in the terminal device, and the target version number for the terminal device to upgrade the target application software, specifically use At:
  • the encrypted patch file contains at least one encrypted first code segment; the encrypted first code segment is an encrypted line of the first code, and the first code segment is identified as the Line number of the first code; the merged patch file contains at least one updated first code segment.
  • the following describes specific functions of the processing unit 1102 when the communication device 1100 is applied to a terminal device.
  • the processing unit 1102 is configured to:
  • the encrypted merged patch file of the target application software is received from the upgrade server through the communication unit 1101, wherein the encrypted merged patch file is a plurality of intermediate files of the upgrade server to the target application software.
  • a patch file is generated by merging, the encrypted merged patch file contains an encrypted first code segment, and the encrypted first code segment is obtained by encrypting the first code segment with a first operation key,
  • the first code segment includes a first code segment identifier and first code content encrypted by a first security key; the first operation key is different from the first security key;
  • Decrypting the encrypted merged patch file to obtain the merged patch file includes: decrypting the encrypted first code segment according to the second operation key to obtain the first code segment; 2. a security key, decrypting the first code content encrypted by the first security key contained in the first code segment to obtain the first code content;
  • the encrypted merged patch file further includes an encrypted patch header, and the encrypted patch header is encrypted by the first security key; the processing unit 1102 is performing the encryption on the encrypted patch header.
  • the latter merged patch file is decrypted, it is also used to:
  • processing unit 1102 is further configured to:
  • the encrypted merged patch file is decrypted, according to the first code segment identifier and the first code content contained in the first code segment in the merged patch file, the target installed Before the application software is upgraded, the identification offset value of the target application software is obtained; according to the identification offset value, the first code segment identification included in the first code segment in the merged patch file is biased shift.
  • the patch download request includes the current version number of the target application software installed in the terminal device, and the target version number of the target application software upgrade performed by the terminal device.
  • the encrypted merged patch file includes at least one encrypted first code segment; the encrypted first code segment is an encrypted line of the first code, and the first code segment is identified as State the line number of the first code.
  • processing unit 1102 is configured to:
  • the encrypted merged patch file is the target application software's multiple targets of the upgrade server Patch file is generated by merging, the encrypted merged patch file includes a first code segment, the first code segment includes the encrypted first code segment identifier and the encrypted first code content, the encrypted first code segment
  • the first code segment identifier is obtained by encrypting the first code segment by the first operation key
  • the encrypted first code content is obtained by encrypting the first code content by the first security key.
  • An operation key is different from the first security key;
  • Decrypting the encrypted merged patch file to obtain the merged patch file includes: decrypting the encrypted first code segment identifier according to the second operation key to obtain the first code segment identifier; Two security keys, decrypt the encrypted first code content to obtain the first code content;
  • the encrypted merged patch file further includes an encrypted patch header, and the encrypted patch header is encrypted by the first security key; the processing unit 1102 is performing the encryption on the encrypted patch header.
  • the latter merged patch file is decrypted, it is also used to:
  • processing unit 1102 is further configured to:
  • the identification offset value of the target application software is acquired; according to the identification offset value, the first code segment included in the first code segment in the merged patch file is identified Offset.
  • the patch download request includes the current version number of the target application software installed in the terminal device, and the target version number of the target application software upgrade performed by the terminal device.
  • the encrypted merged patch file includes at least one first code segment; the first code segment is a line of first code, and the first code segment is identified as a line number of the first code.
  • each function in each embodiment of the present application can be integrated into one processing unit, or it can exist alone physically, or two or more units can be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solution of the present application essentially or the part that contributes to the existing technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , Including a number of instructions to enable a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code .
  • the present application also provides a communication device, which can be applied to a software development device, a software server, or a terminal device in the software upgrade system as shown in FIG. 1, which can implement the above embodiments
  • the software upgrade method provided in the example has the function of the communication device shown in FIG. 11.
  • the communication device 1200 includes: a communication module 1201, a processor 1202, and a memory 1203. Wherein, the communication module 1201, the processor 1202, and the memory 1203 are connected to each other.
  • the communication module 1201, the processor 1202, and the memory 1203 are connected to each other through a bus 1204.
  • the bus 1204 may be a peripheral component interconnect standard (PCI) bus or an extended industry standard architecture (EISA) bus, etc.
  • PCI peripheral component interconnect standard
  • EISA extended industry standard architecture
  • the bus can be divided into an address bus, a data bus, a control bus, and so on. For ease of presentation, only one thick line is used in FIG. 12 to represent it, but it does not mean that there is only one bus or one type of bus.
  • the communication module 1201 is used to receive and send data, and realize communication and interaction with other devices.
  • the communication module 1201 may be implemented through a physical interface.
  • the communication module 1201 may also be implemented by a transceiver.
  • the processor 1202 is used to implement the software development device, software server, or terminal device to implement the software upgrade method provided in the above embodiments.
  • the processor 1202 is used to implement the software development device, software server, or terminal device to implement the software upgrade method provided in the above embodiments.
  • the memory 1203 is used to store program instructions and data.
  • the program instructions may include program code, and the program code includes computer operation instructions.
  • the memory 1203 may include a random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
  • the processor 1202 executes the program instructions stored in the memory 1203, and uses the data stored in the memory 1203 to implement the above-mentioned functions, thereby realizing the software upgrade method provided in the above-mentioned embodiment.
  • the memory 1203 in FIG. 12 of the present application may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memory.
  • the non-volatile memory can be read-only memory (Read-Only Memory, ROM), programmable read-only memory (Programmable ROM, PROM), erasable programmable read-only memory (Erasable PROM, EPROM), and electrically available Erase programmable read-only memory (Electrically EPROM, EEPROM) or flash memory.
  • the volatile memory may be a random access memory (Random Access Memory, RAM), which is used as an external cache.
  • RAM random access memory
  • SRAM static random access memory
  • DRAM dynamic random access memory
  • DRAM synchronous dynamic random access memory
  • DDR SDRAM Double Data Rate Synchronous Dynamic Random Access Memory
  • Enhanced SDRAM, ESDRAM Enhanced Synchronous Dynamic Random Access Memory
  • Synchronous Link Dynamic Random Access Memory Synchronous Link Dynamic Random Access Memory
  • DR RAM Direct Rambus RAM
  • the embodiments of the present application also provide a computer program, which when the computer program runs on a computer, causes the computer to execute the software upgrade method provided in the above embodiments.
  • the embodiments of the present application also provide a computer-readable storage medium in which a computer program is stored.
  • the computer program When the computer program is executed by a computer, the computer executes the software provided in the above embodiment. Upgrade method.
  • the storage medium may be any available medium that can be accessed by a computer. Take this as an example but not limited to: computer readable media may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage media or other magnetic storage devices, or can be used to carry or store instructions or data in the form of structure The desired program code and any other medium that can be accessed by the computer.
  • an embodiment of the present application also provides a chip, which is used to read a computer program stored in a memory to implement the software upgrade method provided in the above embodiment.
  • the embodiments of the present application provide a chip system that includes a processor for supporting a computer device to implement functions related to the software development equipment, software server, or terminal equipment in the above embodiments.
  • the chip system further includes a memory, and the memory is used to store programs and data necessary for the computer device.
  • the chip system can be composed of chips, or include chips and other discrete devices.
  • the embodiments of the present application provide a software upgrade method and device.
  • the software development equipment After the software development equipment encrypts the patch file generated each time, it sends the encrypted patch file and the corresponding version number to the upgrade server for storage; the upgrade server can store the target application software according to the terminal device's upgrade requirements for the target application software.
  • the patch file of the target application software a plurality of intermediate patch files are determined; then, the upgrade server decrypts the encrypted first code segment identifier in each intermediate patch file, and according to the version number and each intermediate patch file In the first code segment, the multiple intermediate patch files are merged to obtain a merged patch file, and the merged patch file is encrypted and sent to the terminal device, so that the terminal device can perform processing according to the merged patch file.
  • the software upgrade of the target application software After the software development equipment encrypts the patch file generated each time, it sends the encrypted patch file and the corresponding version number to the upgrade server for storage; the upgrade server can store the target application software according to the terminal device's upgrade requirements
  • the upgrade server may splice and merge multiple intermediate patch files that meet the upgrade requirements of the target application software of the terminal device, so that the terminal device can only download and install the merged patch file once.
  • the target application software is upgraded from the current version number to the target version number.
  • this method can obviously shorten the time consumed by the terminal device to upgrade the software, and can improve the efficiency of the terminal device software upgrade.
  • the software development device uses different keys to respectively encrypt the first code segment identifier and the first code content. In this way, the upgrade server is performing the process of encrypting the patch file. During the merging process, only the encrypted first code segment identifier can be decrypted, but the encrypted first code content cannot be decrypted. Therefore, this method can ensure the security of the code content in the patch file.
  • this application can be provided as methods, systems, or computer program products. Therefore, this application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, this application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing equipment to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including the instruction device.
  • the device implements the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.
  • These computer program instructions can also be loaded on a computer or other programmable data processing equipment, so that a series of operation steps are executed on the computer or other programmable equipment to produce computer-implemented processing, so as to execute on the computer or other programmable equipment.
  • the instructions provide steps for implementing the functions specified in one process or multiple processes in the flowchart and/or one block or multiple blocks in the block diagram.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • General Health & Medical Sciences (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • Multimedia (AREA)
  • Technology Law (AREA)
  • Stored Programmes (AREA)

Abstract

一种软件升级方法及设备,可用于智能车领域的车载设备升级,在上述方法中,升级服务器可以将满足终端设备的目标应用软件的升级需求的多个中间补丁文件进行拼接合并,这样,终端设备可以仅下载和安装一次合并补丁文件即可实现目标应用软件从当前版本号升级至目标版本号,显然,该方法可以明显的缩短终端设备进行软件升级消耗的时间,可以提高终端设备软件升级效率。

Description

一种软件升级方法及设备
相关申请的交叉引用
本申请要求在2020年01月23日提交中国专利局、申请号为202010077050.5、申请名称为“一种软件升级方法及设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及通信技术领域,尤其涉及一种软件升级方法及设备。
背景技术
随着通信技术的发展和用户日益增长的业务需求,终端设备能够实现的业务越来越多样化。一些终端设备的举例为:手机、平板电脑、智能家居设备、可穿戴设备、物联网(Internet of things,IoT)设备、车联网设备等。
这些终端设备实现的功能和操作是由加载到内部的应用软件实现的。然而,在软件开发阶段,由于软件设计人员考虑不全面或程序功能不完善,在软件发行后,软件开发商需要经常对应用软件进行升级,通常这些升级是以补丁文件的形式发布出去的。其中,补丁文件中包含对应用软件中局部修改的代码。
当软件开发商开发出补丁文件后,将补丁文件提交给空中下载(Over the air,OTA)服务器。OTA服务器通过与终端设备的交互,确定终端设备中应用软件的当前版本,然后OTA服务器将应用软件的当前版本更新的补丁文件添加至OTA数据包(压缩包)发送至终端设备侧。最后,终端设备可以根据从OTA服务器下载的补丁文件对本地的应用软件进行升级。
然而,由于OTA数据包的空间限制,当OTA服务器中比终端设备中的当前版本更新的补丁文件有多个时,终端设备通常需要多个OTA下载过程,从所述OTA服务器中下载这些补丁文件。另外,终端设备下载这些补丁文件后,需要按照补丁文件的版本顺序依次安装。综上所述,传统的OTA升级过程耗时较长对终端设备的工作效率产生的影响。
发明内容
本申请提供了一种软件升级方法及设备,用以解决传统的软件升级过程耗时较长的问题。
第一方面,本申请实施例提供了一种软件升级方法,该方法应用于软件开发设备,该方法包括以下步骤:
软件开发设备生成目标应用软件的补丁文件和所述补丁文件的对应的版本号,其中,所述补丁文件包含第一代码段,所述第一代码段包含第一代码段标识和第一代码内容;所述软件开发设备对所述补丁文件进行加密处理,包括:所述软件开发设备根据第一安全密钥,对所述第一代码内容进行加密;所述软件开发设备根据第一运算密钥,对所述第一代码段标识和通过第一安全密钥加密后的所述第一代码内容进行加密;其中,所述第一运算密钥与所述第一安全密钥不同;所述软件开发设备向升级服务器发送加密后的所述补丁文 件和所述补丁文件对应的版本号。
通过以上方法,所述软件开发设备在对每个补丁文件进行加密的过程中,使用不同的密钥分别对第一代码段标识和第一代码内容进行加密,这样,所述升级服务器在对补丁文件进行合并过程中可以仅对加密后的第一代码段标识进行解密,而无法对加密后的第一代码内容进行解密,因此,该方法可以保证补丁文件中代码内容的安全性。
在一种可能的设计中,在所述软件开发设备根据第一运算密钥,对所述第一代码段标识和通过第一安全密钥加密后的所述第一代码内容进行加密之前,所述方法还包括:所述软件开发设备获取所述目标应用软件的标识偏移值;所述软件开发设备根据所述标识偏移值,对所述第一代码段标识进行偏移。
通过以上设计,所述软件开发设备可以对所述补丁文件的第一代码段标识进行标识偏移处理,以保证补丁文件中第一代码段标识的安全性。
在一种可能的设计中,所述补丁文件中还包含补丁头部,其中,所述补丁头部用于指示所述目标应用软件;所述软件开发设备对所述补丁文件进行加密处理,还包括:所述软件开发设备根据所述第一安全密钥,对所述补丁头部进行加密。
通过以上设计,所述软件开发设备可以对所述补丁文件的补丁头部进行加密,从而保证所述补丁头部的安全性。
在一种可能的设计中,所述补丁文件包含至少一个所述第一代码段;所述第一代码段为一行第一代码,所述第一代码段标识为所述第一代码的行号。
第二方面,本申请实施例提供了一种软件升级方法,该方法应用于升级服务器,该方法包括以下步骤:
升级服务器存储目标应用软件加密后的补丁文件和所述补丁文件对应的版本号;其中,所述加密后的补丁文件包含加密后的第一代码段,所述加密后的第一代码段是通过第一运算密钥对第一代码段标识和通过第一安全密钥加密后的第一代码内容进行加密得到的,所述第一运算密钥与所述第一安全密钥不同;所述升级服务器从终端设备接收所述目标应用软件的补丁下载请求;所述升级服务器根据所述补丁下载请求确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号;所述升级服务器根据所述当前版本号和所述目标版本号,从本地存储的所述目标应用软件的加密后的补丁文件中,确定中间补丁文件,其中,所述中间补丁文件为版本号大于所述当前版本号,且小于或等于所述目标版本号的加密后的补丁文件;当所述中间补丁文件为多个,所述升级服务器根据第二运算密钥,对每个中间补丁文件进行解密,所述解密包括对每个中间补丁文件包含的加密后的第一代码段进行解密,得到每个中间补丁文件的第一代码段的第一代码段标识和通过第一安全密钥加密后的第一代码内容;所述升级服务器根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件中的第一代码段包含的第一代码段标识,对解密后的所述多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件;所述合并补丁文件包含更新后的第一代码段,所述更新后的第一代码段包括对通过第一安全密钥加密后的第一代码内容和更新后的第一代码段标识;所述升级服务器根据所述第一运算密钥对所述合并补丁文件进行加密,包括:根据所述第一运算密钥对所述合并补丁文件中更新后的第一代码段进行加密;所述升级服务器向所述终端设备发送加密后的所述合并补丁文件。
通过该方法,所述升级服务器可以将满足终端设备的所述目标应用软件的升级需求的 多个中间补丁文件进行拼接合并,这样,所述终端设备可以仅下载和安装一次合并补丁文件即可实现目标应用软件从当前版本号升级至目标版本号,显然,该方法可以明显的缩短终端设备进行软件升级消耗的时间,可以提高终端设备软件升级效率。
在一种可能的设计中,所述升级服务器根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件的第一代码段包含的第一代码段标识,对解密后的所述多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件,包括:
所述升级服务器根据存储的所述多个中间补丁文件对应的版本号的先后顺序,对解密后的所述多个中间补丁文件进行排序,得到文件序列,其中,版本号最先的解密后的中间补丁文件位于所述文件序列的首位,版本号最后的解密后的中间补丁文件位于所述文件序列的末位;所述升级服务器根据每个解密后的中间补丁文件中的第一代码段包含的第一代码段标识,按照所述文件序列的顺序依次将每个解密后的中间补丁文件进行合并,得到所述合并补丁文件。
该设计可以保证所述升级服务器生成的合并补丁文件的准确性,即所述终端设备安装所述合并补丁文件的效果与按照版本号的先后顺序依次安装所述多个中间补丁文件的效果相同。
在一种可能的设计中,所述加密后的补丁文件中还包含加密后的补丁头部,所述加密后的补丁头部是通过所述第一安全密钥加密的;所述合并补丁文件中还包含所述加密后的补丁头部。
在一种可能的设计中,所述升级服务器确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号,包括:
所述升级服务器从所述补丁下载请求中获取所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
通过该设计,所述终端设备可以通过补丁下载请求发送自身对所述目标应用软件的升级需求。
在一种可能的设计中,所述加密后的补丁文件包含至少一个加密后的第一代码段;所述加密后的第一代码段为加密后的一行第一代码,所述第一代码段标识为所述第一代码的行号;所述合并补丁文件包含至少一个更新后的第一代码段。
第三方面,本申请实施例提供了一种软件升级方法,该方法应用于终端设备,该方法包括以下步骤:
终端设备向所述升级服务器发送目标应用软件的补丁下载请求;所述终端设备从所述升级服务器接收所述目标应用软件的加密后的合并补丁文件,其中,所述加密后的合并补丁文件是所述升级服务器对所述目标应用软件的多个中间补丁文件进行合并生成的,所述加密后的合并补丁文件包含加密后的第一代码段,所述加密后的第一代码段是通过第一运算密钥对第一代码段进行加密得到的,所述第一代码段包含第一代码段标识和通过第一安全密钥加密后的第一代码内容;所述第一运算密钥与所述第一安全密钥不同;所述终端设备对所述加密后的合并补丁文件进行解密处理,得到合并补丁文件,包括:所述终端设备根据第二运算密钥,对所述加密后的第一代码段进行解密,得到所述第一代码段;所述终端设备根据第二安全密钥,对所述第一代码段包含的通过第一安全密钥加密后的第一代码内容进行解密,得到第一代码内容;所述终端设备根据所述合并补丁文件中的所述第一代码段包含的第一代码段标识和所述第一代码内容,对已安装的所述目标应用软件进行升级。
通过该方法,所述升级服务器可以将满足终端设备的所述目标应用软件的升级需求的多个中间补丁文件进行拼接合并,这样,所述终端设备可以仅下载和安装一次合并补丁文件即可实现目标应用软件从当前版本号升级至目标版本号,显然,该方法可以明显的缩短终端设备进行软件升级消耗的时间,可以提高终端设备软件升级效率。
在一种可能的设计中,所述加密后的合并补丁文件中还包含加密后的补丁头部,所述加密后的补丁头部是通过第一安全密钥加密的;所述终端设备对所述加密后的合并补丁文件进行解密处理,还包括:所述终端设备根据所述第二安全密钥,对所述加密后的合并补丁文件中的所述加密后的补丁头部进行解密,得到补丁头部。
在一种可能的设计中,在所述终端设备对所述加密后的合并补丁文件进行解密处理之后,在所述终端设备根据所述合并补丁文件中的所述第一代码段包含的第一代码段标识和第一,对已安装的所述目标应用软件进行升级之前,还包括:所述终端设备获取所述目标应用软件的标识偏移值;所述终端设备根据所述标识偏移值,对所述合并补丁文件中所述第一代码段包含的所述第一代码段标识进行偏移。
通过该设计,由于为了保证补丁文件内第一代码段标识的安全性,软件开发设备在生成补丁文件后,通过对补丁文件中的第一代码段标识进行偏移处理,因此,此处为了保证所述终端设备能够成功安装所述合并补丁文件,因此,所述终端设备也需要对所述合并补丁文件中的第一代码段标识进行偏移处理,以还原到第一代码段标识的原取值。需要注意的是,所述软件开发设备和所述终端设备进行的标识偏移处理为互逆的操作。例如若所述软件开发设备在补丁文件中第一代码段标识的取值的基础上,增加所述标识偏移值,则所述软件开发设备在合并补丁文件中第一代码段标识的取值的基础上,减去所述标识偏移值。
在一种可能的设计中,所述补丁下载请求中包含所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
通过该设计,所述终端设备可以通过补丁下载请求发送自身对所述目标应用软件的升级需求。
在一种可能的设计中,所述加密后的合并补丁文件包含至少一个加密后的第一代码段;所述加密后的第一代码段为加密后的一行第一代码,所述第一代码段标识为所述第一代码的行号。
第四方面,本申请实施例提供了一种软件升级方法,该方法应用于软件开发设备,该方法包括以下步骤:
软件开发设备生成目标应用软件的补丁文件和所述补丁文件的对应的版本号,其中,所述补丁文件包含第一代码段,所述第一代码段包含第一代码段标识和第一代码内容;所述软件开发设备对所述补丁文件进行加密处理,包括:所述软件开发设备根据第一安全密钥,对所述第一代码内容进行加密;所述软件开发设备根据第一运算密钥,对所述第一代码段标识进行加密;其中,所述第一运算密钥与所述第一安全密钥不同;所述软件开发设备向升级服务器发送加密后的所述补丁文件和所述补丁文件对应的所述版本号。
通过以上方法,所述软件开发设备在对每个补丁文件进行加密的过程中,使用不同的密钥分别对第一代码段标识和第一代码内容进行加密,这样,所述升级服务器在对补丁文件进行合并过程中可以仅对加密后的第一代码段标识进行解密,而无法对加密后的第一代码内容进行解密,因此,该方法可以保证补丁文件中代码内容的安全性。
在一种可能的设计中,在所述软件开发设备根据第一运算密钥,对所述第一代码段标 识进行加密之前,所述方法还包括:所述软件开发设备获取所述目标应用软件的标识偏移值;所述软件开发设备根据所述标识偏移值,对所述第一代码段标识进行偏移。
通过以上设计,所述软件开发设备可以对所述补丁文件的第一代码段标识进行标识偏移处理,以保证补丁文件中第一代码段标识的安全性。
在一种可能的设计中,所述补丁文件中还包含补丁头部,其中,所述补丁头部用于指示所述目标应用软件;所述软件开发设备对所述补丁文件进行加密处理,还包括:所述软件开发设备根据所述第一安全密钥,对所述补丁头部进行加密。
通过以上设计,所述软件开发设备可以对所述补丁文件的补丁头部进行加密,从而保证所述补丁头部的安全性。
在一种可能的设计中,所述补丁文件包含至少一个所述第一代码段;所述第一代码段为一行第一代码,所述第一代码段标识为所述第一代码的行号。
第五方面,本申请实施例提供了一种软件升级方法,该方法应用于升级服务器,该方法包括以下步骤:
升级服务器存储目标应用软件的加密后的补丁文件和所述补丁文件对应的版本号;其中,所述加密后的补丁文件包含第一代码段,所述第一代码段包含加密后的第一代码段标识和加密后的第一代码内容;所述加密后的第一代码段标识是通过第一运算密钥对第一代码段标识加密得到的,所述加密后的第一代码内容是通过第一安全密钥对第一代码内容加密得到的,所述第一运算密钥与所述第一安全密钥不同;所述升级服务器从终端设备接收所述目标应用软件的补丁下载请求;所述升级服务器根据所述补丁下载请求确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号;所述升级服务器根据所述当前版本号和所述目标版本号,从本地存储的所述目标应用软件的加密后的补丁文件中,确定中间补丁文件,其中,所述中间补丁文件为版本号大于所述当前版本号,且小于或等于所述目标版本号的加密后的补丁文件;当所述中间补丁文件为多个时,所述升级服务器根据第二运算密钥,对每个中间补丁文件进行解密,所述解密包括对每个中间补丁文件的第一代码段包含的加密后的第一代码段标识进行解密,得到每个中间补丁文件的第一代码段包含的第一代码段标识;所述升级服务器根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件中的第一代码段包含的第一代码段标识,对解密后的所述多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件;其中,所述合并补丁文件包含更新后的第一代码段,所述更新后的第一代码段包括对通过第一安全密钥加密后的第一代码内容和更新后的第一代码段标识;所述升级服务器根据所述第一运算密钥对所述合并补丁文件进行加密,包括:根据所述第一运算密钥对所述合并补丁文件中更新后的第一代码段标识进行加密;所述升级服务器向所述终端设备发送加密后的所述合并补丁文件。
通过该方法,所述升级服务器可以将满足终端设备的所述目标应用软件的升级需求的多个中间补丁文件进行拼接合并,这样,所述终端设备可以仅下载和安装一次合并补丁文件即可实现目标应用软件从当前版本号升级至目标版本号,显然,该方法可以明显的缩短终端设备进行软件升级消耗的时间,可以提高终端设备软件升级效率。
在一种可能的设计中,所述升级服务器根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件的第一代码段包含的第一代码段标识,对解密后的所述多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件,包括:
所述升级服务器根据存储的所述多个中间补丁文件对应的版本号的先后顺序,对解密后的所述多个中间补丁文件进行排序,得到文件序列,其中,版本号最先的解密后的中间补丁文件位于所述文件序列的首位,版本号最后的解密后的中间补丁文件位于所述文件序列的末位;所述升级服务器根据每个解密后的中间补丁文件中的第一代码段包含的第一代码段标识,按照所述文件序列的顺序依次将每个解密后的中间补丁文件进行合并,得到所述合并补丁文件。
该设计可以保证所述升级服务器生成的合并补丁文件的准确性,即所述终端设备安装所述合并补丁文件的效果与按照版本号的先后顺序依次安装所述多个中间补丁文件的效果相同。
在一种可能的设计中,所述加密后的补丁文件中还包含加密后的补丁头部,所述加密后的补丁头部是通过所述第一安全密钥加密的;所述合并补丁文件中还包含所述加密后的补丁头部。
在一种可能的设计中,所述升级服务器确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号,包括:
所述升级服务器从所述补丁下载请求中获取所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
通过该设计,所述终端设备可以通过补丁下载请求发送自身对所述目标应用软件的升级需求。
在一种可能的设计中,所述加密后的补丁文件包含至少一个加密后的第一代码段;所述加密后的第一代码段为加密后的一行第一代码,所述第一代码段标识为所述第一代码的行号;所述合并补丁文件包含至少一个更新后的第一代码段。
第六方面,本申请实施例提供了一种软件升级方法,该方法应用于终端设备,该方法包括以下步骤:
终端设备向所述升级服务器发送目标应用软件的补丁下载请求;所述终端设备从所述升级服务器接收所述目标应用软件的加密后的合并补丁文件,其中,所述加密后的合并补丁文件是所述升级服务器对所述目标应用软件的多个目标补丁文件进行合并生成的,所述加密后的合并补丁文件包含第一代码段,所述第一代码段包含加密后的第一代码段标识和加密后的第一代码内容,所述加密后的第一代码段标识是通过第一运算密钥对第一代码段进行加密得到的,所述加密后的第一代码内容是通过第一安全密钥对第一代码内容加密得到的,所述第一运算密钥与所述第一安全密钥不同;所述终端设备对所述加密后的合并补丁文件进行解密处理,得到合并补丁文件,包括:所述终端设备根据第二运算密钥,对所述加密后的第一代码段标识进行解密,得到第一代码段标识;所述终端设备根据第二安全密钥,对所述加密后的第一代码内容进行解密,得到第一代码内容;所述终端设备根据所述合并补丁文件中的所述第一代码段包含的第一代码段标识和所述第一代码内容,对已安装的所述目标应用软件进行升级。
通过该方法,所述升级服务器可以将满足终端设备的所述目标应用软件的升级需求的多个中间补丁文件进行拼接合并,这样,所述终端设备可以仅下载和安装一次合并补丁文件即可实现目标应用软件从当前版本号升级至目标版本号,显然,该方法可以明显的缩短终端设备进行软件升级消耗的时间,可以提高终端设备软件升级效率。
在一种可能的设计中,所述加密后的合并补丁文件还包含加密后的补丁头部,所述加 密后的补丁头部是通过第一安全密钥加密的;所述终端设备对所述加密后的合并补丁文件进行解密处理,还包括:所述终端设备根据所述第二安全密钥,对所述加密后的合并补丁文件的所述加密后的补丁头部进行解密,得到补丁头部。
在一种可能的设计中,在所述终端设备对所述加密后的合并补丁文件进行解密处理之后,在所述终端设备根据所述合并补丁文件中的所述第一代码段包含的第一代码段标识和所述第一代码内容,对已安装的所述目标应用软件进行升级之前,还包括:所述终端设备获取所述目标应用软件的标识偏移值;所述终端设备根据所述标识偏移值,对所述合并补丁文件中所述第一代码段包含的所述第一代码段标识进行偏移。
通过该设计,由于为了保证补丁文件内第一代码段标识的安全性,软件开发设备在生成补丁文件后,通过对补丁文件中的第一代码段标识进行偏移处理,因此,此处为了保证所述终端设备能够成功安装所述合并补丁文件,因此,所述终端设备也需要对所述合并补丁文件中的第一代码段标识进行偏移处理,以还原到第一代码段标识的原取值。需要注意的是,所述软件开发设备和所述终端设备进行的标识偏移处理为互逆的操作。例如若所述软件开发设备在补丁文件中第一代码段标识的取值的基础上,增加所述标识偏移值,则所述软件开发设备在合并补丁文件中第一代码段标识的取值的基础上,减去所述标识偏移值。
在一种可能的设计中,所述补丁下载请求中包含所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
通过该设计,所述终端设备可以通过补丁下载请求发送自身对所述目标应用软件的升级需求。
在一种可能的设计中,所述加密后的合并补丁文件包含至少一个第一代码段;所述第一代码段为一行第一代码,所述第一代码段标识为所述第一代码的行号。
第七方面,本申请实施例提供了一种软件开发设备,包括用于执行以上第一或第四方面中各个步骤的单元。
第八方面,本申请实施例提供了一种升级服务器,包括用于执行以上第二或第五方面中各个步骤的单元。
第九方面,本申请实施例提供了一种终端设备,包括用于执行以上第三或第六方面中各个步骤的单元。
第十方面,本申请实施例提供了一种软件开发设备,包括至少一个处理元件和至少一个存储元件,其中该至少一个存储元件用于存储程序和数据,该至少一个处理元件用于执行本申请以上第一或第四方面提供的方法。
第十一方面,本申请实施例提供了一种升级服务器,包括至少一个处理元件和至少一个存储元件,其中该至少一个存储元件用于存储程序和数据,该至少一个处理元件用于执行本申请以上第二或第五方面提供的方法。
第十二方面,本申请实施例提供了一种终端设备,包括至少一个处理元件和至少一个存储元件,其中该至少一个存储元件用于存储程序和数据,该至少一个处理元件用于执行本申请以上第三或第六方面提供的方法。
第十三方面,本申请实施例提供了一种软件升级系统,包括软件开发设备、升级服务器和终端设备,其中,所述软件开发设备具有执行本申请第一方面提供的方法的功能,所述升级服务器具有执行本申请第二方面提供的方法的功能,所述终端设备具有执行本申请第三方面提供的方法的功能;或者所述软件开发设备具有执行本申请第四方面提供的方法 的功能,所述升级服务器具有执行本申请第五方面提供的方法的功能,所述终端设备具有执行本申请第六方面提供的方法的功能。
第十四方面,本申请实施例还提供了一种计算机程序,当所述计算机程序在计算机上运行时,使得所述计算机执行上述第一至第六方面中任一方面提供的方法。
第十五方面,本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机程序,当所述计算机程序被计算机执行时,使得所述计算机执行上述第一至第六方面中任一方面提供的方法。
第十六方面,本申请实施例还提供了一种芯片,所述芯片用于读取存储器中存储的计算机程序,执行上述第一至第六方面中任一方面提供的方法。
第十七方面,本申请实施例还提供了一种芯片系统,该芯片系统包括处理器,用于支持计算机装置实现上述第一至第六方面中任一方面提供的方法。在一种可能的设计中,所述芯片系统还包括存储器,所述存储器用于保存该计算机装置必要的程序和数据。该芯片系统可以由芯片构成,也可以包含芯片和其他分立器件。
附图说明
图1为本申请实施例提供的一种软件升级系统的架构图;
图2为本申请实施例提供的一种软件升级方法的流程图;
图3为本申请实施例提供的一种补丁文件的生成示例图;
图4A为本申请实施例提供的第一种对补丁文件加密的示例图;
图4B为本申请实施例提供的第二种对补丁文件加密的示例图;
图4C为本申请实施例提供的第三种对补丁文件加密的示例图;
图4D为本申请实施例提供的第四种对补丁文件加密的示例图;
图5A为本申请实施例提供的一种对补丁文件进行合并的方法示意图;
图5B为本申请实施例提供的另一种对补丁文件进行合并的方法示意图;
图6A为本申请实施例提供的一种对合并补丁文件的行号进行加密的过程示意图;
图6B为本申请实施例提供的另一种对合并补丁文件的行号进行加密的过程示意图;
图7A为本申请实施例提供的第一种对合并补丁文件进行解密的过程示意图;
图7B为本申请实施例提供的第二种对合并补丁文件进行解密的过程示意图;
图7C为本申请实施例提供的第三种对合并补丁文件进行解密的过程示意图;
图7D为本申请实施例提供的第四种对合并补丁文件进行解密的过程示意图;
图7E为本申请实施例提供的第五种对合并补丁文件进行解密的过程示意图;
图7F为本申请实施例提供的第六种对合并补丁文件进行解密的过程示意图;
图8为本申请实施例提供的一种软件开发设备与升级服务器之间的通信流程图;
图9为本申请实施例提供的一种升级服务器与终端设备之间的通信流程图;
图10为本申请实施例提供的另一种升级服务器与终端设备之间的通信流程图;
图11为本申请实施例提供的一种通信装置的结构图;
图12为本申请实施例提供的一种通信设备的结构图。
具体实施方式
本申请提供一种软件升级方法及设备,用以缩短终端设备进行软件升级消耗的时间。其中,方法和设备是基于同一技术构思的,由于方法及设备解决问题的原理相似,因此设备与方法的实施可以相互参见,重复之处不再赘述。
在本申请实施例提供的方案中,软件开发设备将每次生成的补丁文件进行加密后,将加密后的补丁文件以及对应的版本号发送给升级服务器保存;升级服务器可以根据终端设备对目标应用软件的升级需求,在本地存储的所述目标应用软件的补丁文件中,确定多个中间补丁文件;然后,所述升级服务器对每个中间补丁文件中加密后的第一代码段标识进行解密,并根据版本号和每个中间补丁文件中第一代码段标识,对所述多个中间补丁文件进行合并,得到合并补丁文件,并将该合并补丁文件加密后发送给终端设备,以使所述终端设备可以根据所述合并补丁文件进行所述目标应用软件的软件升级。
在上述方案中,所述升级服务器可以将满足终端设备的所述目标应用软件的升级需求的多个中间补丁文件进行拼接合并,这样,所述终端设备可以仅下载和安装一次合并补丁文件即可实现目标应用软件从当前版本号升级至目标版本号,显然,该方法可以明显的缩短终端设备进行软件升级消耗的时间,可以提高终端设备软件升级效率。另外,所述软件开发设备在对每个补丁文件进行加密的过程中,使用不同的密钥分别对第一代码段标识和第一代码内容进行加密,这样,所述升级服务器在对补丁文件进行合并过程中可以仅对加密后的第一代码段标识进行解密,而无法对加密后的第一代码内容进行解密,因此,该方法可以保证补丁文件中代码内容的安全性。
以下,对本申请中的部分用语进行解释说明,以便于本领域技术人员理解。
1)、终端设备,是一种能够通过安装应用软件,向用户提供相应的语音、视频、拍摄、数据连通性等各种服务功能的设备。终端设备又可以称为用户设备(user equipment,UE)、移动台(mobile station,MS)、移动终端(mobile terminal,MT)等。
例如,终端设备可以为具有无线连接功能的手持式设备、车载设备等。目前,一些终端设备的举例为:手机(mobile phone)、平板电脑、笔记本电脑、掌上电脑、移动互联网设备(mobile internet device,MID)、智能销售终端(point of sale,POS)、可穿戴设备,虚拟现实(virtual reality,VR)设备、增强现实(augmented reality,AR)设备、工业控制(industrial control)中的无线终端、无人驾驶(self driving)中的无线终端、远程手术(remote medical surgery)中的无线终端、智能电网(smart grid)中的无线终端、运输安全(transportation safety)中的无线终端、智慧城市(smart city)中的无线终端、智慧家庭(smart home)中的无线终端、各类智能仪表(智能水表、智能电表、智能燃气表)、车联网中的智能汽车、车载单元(on board unit,OBU)、路侧单元(road side unit,RSU)、路侧设备(road side equipment,RSE)、远程通信科学盒子(telematics box,T-Box)、电子控制单元(electronic control unit,ECU)等。
2)、应用,能够为用户提供对应的服务功能。终端设备可以通过安装该应用的应用软件,从而运行该应用,实现该应用的服务功能。例如,具有提供拍摄服务功能的相机应用,终端设备需要安装相机应用软件,并运行相机应用时,即可以向用户提供拍摄服务功能。又例如,具有提供聊天服务功能的微信应用或QQ应用等,终端设备需要安装微信应用软件或QQ应用软件,并运行微信应用或QQ应用,即可以向用户提供聊天服务功能。
需要说明的是,应用的应用软件可以由终端设备的供应商开发,或者由应用供应商开 发,本申请对此不作限定。
由于之前软件设计人员考虑不全面或程序功能不完善,或者是随着用户对应用的服务需求的不断增加,软件设计人员通常在应用软件发现后,还需要开发应用软件的补丁文件以对应用软件进行升级,从而修补应用软件的漏洞或扩展应用功能。
3)、软件开发设备,是软件设计人员针对应用软件开发补丁文件的设备。其中,所述软件开发设备可以属于应用供应商或能够安装应用软件的终端设备供应商。本申请不限定所述软件开发设备的形式,例如,所述软件开发设备可以为计算机、服务器等设备。
4)、升级服务器,是能够存储应用软件的补丁文件,并为终端设备提供补丁文件下载服务的第三方设备。可选的,所述升级服务器可以为OTA服务器等、云服务器等。
所述升级服务器可以与软件开发设备建立连接,从而获取软件开发设备新开发的补丁文件,并根据对应的版本号对补丁文件进行存储。另外,所述升级服务器可以与终端设备建立连接,从而获取终端设备对应用软件的升级需求,从而根据该升级需求选择对应的所述应用软件的多个补丁文件,并将选择的多个补丁文件进行拼接合并,发送给终端设备,以使所述终端设备可以进行应用软件的升级。
5)代码段,用于标识一段代码。本申请不对所述代码段中包含的代码的长度进行限定。所述代码段中可以包含一行代码,也可以包含多行代码。本申请以下实施例中以所述代码段包含一行代码为例进行说明。另外,需要注意的是,当所述代码段为一行代码时,所述代码段标识为该行代码的行号。
6)、多个,是指两个或两个以上。
7)、至少一个,是指一个或多个。
8)、“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。
另外,需要理解的是,在本申请的描述中,“第一”、“第二”等词汇,仅用于区分描述的目的,而不能理解为指示或暗示相对重要性,也不能理解为指示或暗示顺序。
下面结合附图对本申请实施例进行具体说明。
图1示出了本申请提供的软件升级方法适用的软件升级系统架构。参阅图1所示,该系统中包含终端设备、升级服务器、软件开发设备等。
所述软件开发设备,用于开发应用的应用软件,以及开发该应用软件的补丁文件,并确定开发的补丁文件的版本号。可选的,所述软件开发设备可以属于应用供应商或终端设备供应商,本申请对此不作限定。
所述升级服务器,在与软件开发设备建立连接后,接收软件开发设备发送的应用软件的补丁文件,并根据每个补丁文件的版本号存储该补丁文件。所述升级服务器还可以与终端设备建立连接,并通过与所述终端设备的交互,确定所述终端设备对应用软件的升级需求,从而根据该升级需求选择对应的所述应用软件的多个中间补丁文件,并将选择的多个中间补丁文件进行拼接合并,生成合并补丁文件发送给终端设备,以使所述终端设备可以根据该合并补丁文件进行应用软件的升级。所述升级服务器还可以称为OTA服务器。
所述终端设备,可以通过运行应用软件,为用户提供相应服务。所述终端设备可以从所述升级服务器下载应用软件的补丁文件,对已经安装的应用软件进行升级。
根据不同的应用场景,所述终端设备的表现形式也不同,如图所示。示例性的,在传统的移动通信场景中,终端设备可以是手机、平板电脑等。在物联网(internet of things,IoT)通信场景中,终端设备可以是移动互联网设备、可穿戴设备、工业中或智能家居中的各种无线终端。在车联网或车到万物(vehicle to everything,V2X)通信场景中,终端设备可以是车辆、OBU、RSU、RSE、ECU等。
需要说明的是,在本申请提供的系统中,终端设备可以通过移动通信网络(包括接入网和核心网)与所述升级服务器建立通信连接,进行通信交互。所述终端设备也可以通过至少一个中继设备,在通过所述移动通信网络与所述升级服务器建立通信连接,进行通信交互。例如,当所述终端设备为V2X通信场景中的ECU时,如图中所示,所述ECU可以依次通过以下中继设备:域控制器(domain controller,DC),网关(gateway,GW)和T-Box,最终连接升级服务器。
所述升级服务器可以通过传统的互联网协议(internet protocol,IP)网络与所述软件开发设备建立通信连接,进行通信交互。
另外,图2所示的架构可以应用到多种通信场景中,例如,第五代(The 5th Generation,5G)通信系统、未来的第六代通信系统和演进的其他通信系统、长期演进(Long Term Evolution,LTE)通信系统、车到万物(vehicle to everything,V2X)、长期演进-车联网(LTE-vehicle,LTE-V)、车到车(vehicle to vehicle,V2V)、车联网、机器类通信(Machine Type Communications,MTC)、物联网(internet of things,IoT)、长期演进-机器到机器(LTE-machine to machine,LTE-M)、机器到机器(machine to machine,M2M)等通信场景中,本申请对此不作限定。
另外,需要注意的是,在本申请各个实施例中,所述终端设备安装目标应用的目标版本号的补丁文件后,所述终端设备中已安装的所述目标应用软件的当前版本号即为该目标版本号。即补丁文件的版本号即为安装该补丁文件后应用软件的版本号,换句话说,补丁文件和应用软件实际上是共用一个版本号编号机制。
为了缩短软件升级系统中的终端设备进行软件升级消耗的时间,本申请实施例提供了一种软件升级方法。其中,所述方法可以适用于如图1所示的软件升级系统中。下面参阅图2所示的流程图对本申请实施例提供的方法进行详细介绍。为了便于说明和举例,在以下实施例中,以一个代码段为一行代码(在本申请实施例中,代码还可以称为软件代码)为例进行具体说明,此时代码段标识即为行号。还需要说明的是,该实施例并不构成对本申请提供的软件升级方法的限定。
S201:软件开发设备生成目标应用软件的补丁文件和所述补丁文件的对应的版本号,其中,所述补丁文件中包含至少一行软件代码,每行软件代码中包含行号和代码内容。
其中,该版本号的补丁文件是所述软件开发设备基于前一版本的目标应用软件的软件代码生成的。
可选的,所述补丁文件中还包含补丁头部,所述补丁头部用于指示所述目标应用软件,可选的,所述补丁头部还可以包含所述补丁文件对应的版本号等信息。
下面参阅图3为例,对补丁文件的生成过程进行说明。假设目标应用软件的文件名为APP1。
当软件开发设备需要在版本号为V1的目标应用软件的基础上,在第2行和第3行之 间增加行:xxxx,以生成版本号为V2的目标应用软件时,则所述软件开发设备可以生成版本号为V2的补丁文件P1,这样,安装有版本号V1的目标应用软件的终端设备可以通过下载并安装补丁文件P1,将目标应用软件升级到V2(如图中所示)。
当软件开发设备需要在版本号为V2的目标应用软件的基础上,删除第2行,并在第4行和第5行之间增加行:yyyy,以生成版本号为V3的目标应用软件时,则所述软件开发设备可以生成版本号为V3的补丁文件P2,这样,安装有版本号V2的目标应用软件的终端设备可以通过下载并安装补丁文件P2,将目标应用软件升级到V3(如图中所示)。
当软件开发设备需要在版本号为V3的目标应用软件的基础上,删除第2行,以生成版本号为V4的目标应用软件时,则所述软件开发设备可以生成版本号为V4的补丁文件P3,这样,安装有版本号V3的目标应用软件的终端设备可以通过下载并安装补丁文件P3,将目标应用软件升级到V4(如图中所示)。
如图中所示,每个目标应用软件的文件的每行软件代码中包含两部分:行号和代码内容。每个补丁文件也包含至少一行软件代码(补丁本体),且每行软件代码也包含两部分:行号(不仅包含行的标识还包含代表增加指示或删除指示)和代码内容;每个补丁文件还包括补丁头部,所述补丁头部中可以包含指示所述目标应用软件的信息(例如所述目标应用软件的文件名,或所述目标应用软件的标识)。
S202:所述软件开发设备对所述补丁文件进行加密处理。
在本申请实施例中,第一安全密钥和第一运算密钥均为所述软件开发设备针对所述目标应用软件生成的,其中所述第一安全密钥用于对所述目标应用软件的每个补丁文件中的代码内容进行加密,所述第一运算密钥用于对所述目标应用软件的每个补丁文件中的行号/软件代码进行加密。
需要说明的是,在本申请实施例中,软件升级系统可以采用两种加密方式对所述目标应用软件的补丁文件进行加密:对称加密方式和非对称加密方式。
第一种实施方式:所述系统采用对称加密方式对补丁文件进行加密。可选的,所述系统可以采用高级加密标准(advanced encryption standard,AES)算法等各种对称加密方式,对补丁文件进行加密。
在本实施方式中,所述软件开发设备管理维护所述第一安全密钥和所述第一运算密钥,并将所述第一运算密钥通知给软件服务器,将所述第一安全密钥(可选的,还包括所述第一运算密钥)通知给终端设备。
第二种实施方式:所述系统采用非对称加密方式对补丁文件进行加密。
在本实施例方式中,所述软件开发设备管理维护有安全密钥对(第一安全密钥、第二安全密钥)和运算密钥对(第一运算密钥,第二运算密钥)。
其中,所述第二安全密钥用于其他设备对补丁文件中的代码内容进行解密,第二运算密钥用于其他设备对补丁文件中的行号进行解密。因此,所述软件开发设备可以将所述第二运算密钥(可选的,还包括所述第一运算密钥)通知给软件服务器,并将所述第二安全密钥(可选的,还包括所述第二运算密钥)通知给终端设备。
可选的,在执行S202时,所述软件开发设备可以但不限于通过以下两种实现方式,对所述补丁文件进行加密处理。
第一种实现方式:所述软件开发设备使用所述第一安全密钥,对所述补丁文件中的每行软件代码包含的代码内容进行加密;所述软件开发设备使用所述第一运算密钥,对所述 补丁文件中的每行软件代码包含的行号进行加密。
当所述补丁文件中还包含补丁头部时,所述软件开发设备使用所述第一安全密钥,对所述补丁文件的补丁头部进行加密。
示例性的,以图3中的补丁文件P1为例,所述软件开发设备可以使用第一安全密钥对补丁头部和补丁本体中每行软件代码包含的代码内容进行加密,并使用第一运算密钥对补丁本体中每行软件代码包含的行号进行加密,最终得到加密后的补丁文件P1。具体加密过程可以参阅图4A所示。
可选的,为了保证升级服务器无法确定补丁文件中每行软件代码变更的具体行号,保证补丁文件中行号的安全性,所述软件开发设备还可以在对补丁本体中每行软件代码包含的行号进行加密之前,采用以下步骤对行号进行偏移:
所述软件开发设备获取所述目标应用软件的行号偏移值;
所述软件开发设备根据所述行号偏移值,对每行软件代码包含的行号进行偏移。例如,所述软件开发设备可以将每行软件代码包含的行号加上(或减去)所述行号偏移值。
其中,每个目标应用软件对应一个行号偏移值,该行号偏移值可以是为一个随机数。所述行号偏移值可以跟随所述补丁文件发送,例如,所述行号偏移值可以保存到补丁文件头部。
示例性的,继续图3中的补丁文件P1为例,所述软件开发设备先对补丁文件P1中每行软件代码包含的行号进行行偏移,将行号“3+”调整为“259+”;然后再使用第一安全密钥对补丁头部和补丁本体中每行软件代码包含的代码内容进行加密,并使用第一运算密钥对补丁本体中每行软件代码包含的行号进行加密,最终得到加密后的补丁文件P1。具体加密过程可以参阅图4B所示。
第二种实现方式:所述软件开发设备使用所述第一安全密钥,对所述补丁文件中的每行软件代码的代码内容进行加密;所述软件开发设备使用所述第一运算密钥,对所述补丁文件中的行号和使用所述第一安全密钥加密后的代码内容进行加密。
当所述补丁文件中还包含补丁头部时,所述软件开发设备使用所述第一安全密钥,对所述补丁文件的补丁头部进行加密。
示例性的,继续以图3中的补丁文件P1为例,所述软件开发设备可以使用第一安全密钥对补丁头部和补丁本体中每行软件代码包含的代码内容进行加密,然后使用第一运算密钥对补丁本体中每行软件代码包含的行号和加密后的代码内容进行加密,最终得到加密后的补丁文件P1。具体加密过程可以参阅图4C所示。
可选的,为了保证补丁文件中行号的安全性,所述软件开发设备还可以在对补丁本体中每行软件代码包含的行号进行加密之前,对行号进行偏移。具体步骤可以参考第一种实现方式中对行号进行偏移的描述,此处不再赘述。
示例性的,继续图3中的补丁文件P1为例,所述软件开发设备先对补丁文件P1中每行软件代码包含的行号进行行偏移,将行号“3+”调整为“259+”;然后再使用第一安全密钥对补丁头部和补丁本体中每行软件代码包含的代码内容进行加密,再使用第一运算密钥对补丁本体中每行软件代码包含的行号和加密后的代码内容进行加密,最终得到加密后的补丁文件P1。具体加密过程可以参阅图4D所示。
通过步骤S202,所述软件开发设备可以使用不同的密钥分别对补丁文件中的每行软件代码中的行号和代码内容进行加密,这样,当补丁文件发送到升级服务器后,所述升级服 务器可以仅对每行软件代码中的加密行号进行解密,而无法对每行软件代码中的代码内容进行解密,因此,该方法还可以保证补丁文件中代码内容的安全性。
S203:所述软件开发设备向升级服务器发送所述加密后的补丁文件和所述补丁文件(或所述加密后的补丁文件)对应的所述版本号。所述升级服务器从所述软件开发设备接收所述目标应用软件的所述加密后的补丁文件和对应的版本号。
在一种实施方式中,所述软件开发设备可以将所述目标应用软件的信息,以及所述补丁文件的安装条件信息等信息一起发送给升级服务器。其中,所述补丁文件的安装条件信息可以但不限于包括:对终端设备的硬件和/或软件的限制条件。
可选的,在本申请实施例中,所述软件开发设备和所述升级服务器之间可以通过建立的传输层安全通道,以进行通信交互。示例性的,所述传输层安全通道可以为传输层安全协议(Transport Layer Security,TLS)通道或安全套接层协议(Secure Sockets Layer,SSL)通道。
S204:所述升级服务器存储接收到的所述加密后的补丁文件和所述补丁文件对应的所述版本号。
当所述升级服务器还接收到所述目标应用软件的信息,以及所述补丁文件的安装条件信息等信息后,也对这些信息进行保存。
可选的,所述升级服务器在接收到新的版本号的加密后的补丁文件后,可以向终端设备进行推送该新的版本号;或者所述升级服务器可以定期或周期性的向终端设备进行推送该新的版本号。
S205:终端设备向所述升级服务器发送目标应用软件的补丁下载请求。所述升级服务器从终端设备接收所述目标应用软件的补丁下载请求。
S206:所述升级服务器确定所述终端设备的升级需求,即确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
可选的,所述升级服务器可以但不限于通过以下方式确定所述终端设备升级需求:
方式一:当所述终端设备发送的所述补丁下载请求中包含所述当前版本号和所述目标版本号时,所述升级服务器从所述补丁下载请求中获取所述当前版本号和所述目标版本号。
方式二:所述升级服务器可以通过与所述终端设备的通信交互,确定所述终端设备是否安装所述目标应用软件、所述终端设备的硬件和/或软件信息,以及所述当前版本号;然后所述升级服务器可以根据保存的补丁文件的版本号、所述补丁文件的安装条件信息等信息,确定所述目标版本号。
方式三:所述升级服务器可以从所述补丁下载请求中获取所述当前版本号,或者通过与所述终端设备的通信交互,确定所述当前版本号;然后所述升级服务器将保存的最新的版本号作为所述目标版本号。
S207:所述升级服务器根据所述当前版本号和所述目标版本号,从本地存储的所述目标应用软件的加密后的补丁文件中,选择多个中间补丁文件,其中,每个中间补丁文件对应的版本号大于所述当前版本号,且小于或等于所述目标版本号。
S208:所述升级服务器根据第二运算密钥,对每个中间补丁文件进行解密。
通过以上S202中所述软件开发设备对所述补丁文件进行加密处理的具体描述可知,所述系统可以采用对称加密方式或非对称加密方式对补丁文件进行加密。因此,在本步骤 中,也可以对应包含以下两种实施方式。
第一种实施方式:所述系统采用对称加密方式对补丁文件进行加密。
在该实施方式中,所述第二运算密钥与所述第一运算密钥相同。
第二种实施方式:所述系统采用非对称加密方式对补丁文件进行加密。
在该实施方式中,所述第二运算密钥与所述第一运算密钥相同。
其中,所述第二运算密钥为所述升级服务器从所述软件开发设备接收的。
另外,所述升级服务器对加密后的行号进行解密的方式与所述软件开发设备对补丁文件进行加密的实现方式相关。因此,对应的,所述升级服务器也可以但不限于通过以下两种实现方式,对中间补丁文件中的加密后的行号进行解密。
第一种实现方式:当所述软件开发设备通过以上第一种实现方式,对每个补丁文件进行加密处理的情况下,如图4A或图4B所示。
所述升级服务器使用所述第二运算密钥,对每个中间补丁文件的每行软件代码包含的加密后的行号进行解密。
第二种实现方式:当所述软件开发设备通过以上第二种实现方式,对每个补丁文件进行加密处理的情况下,如图4C或图4D所示。
所述升级服务器使用所述第二运算密钥,对每个中间补丁文件的每行软件代码包含的加密后的行号和加密后的软件内容进行解密。
S209:所述升级服务器根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件中每行软件代码的行号,对所述解密后的多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件;其中,所述合并补丁文件中包含至少一行软件代码,每行软件代码中包含行号和加密后的代码内容。
可选的,所述升级服务器可以采用以下步骤,实现对所述解密后的多个中间补丁文件的合并:
A1:所述升级服务器根据存储的所述多个中间补丁文件对应的版本号的先后顺序,对所述多个解密后的中间补丁文件进行排序,得到文件序列,其中,版本号最先的解密后的中间补丁文件位于所述文件序列的首位,版本号最后的解密后的中间补丁文件位于所述文件序列的末位;
A2:所述升级服务器根据每个解密后的中间补丁文件中每行软件代码的行号,按照所述文件序列的顺序依次将每个解密后的中间补丁文件进行合并,得到所述合并补丁文件。
需要说明的是,当每个中间补丁文件中包含加密后的补丁头部时,生成的所述合并补丁文件中也还包含所述加密后的补丁头部(即将其中一个目标补丁文件的加密后的补丁头部复制到所述合并补丁文件中)。
在一种实施方式中,所述升级服务器在执行上述步骤A2时,可以通过以下方法实现:
所述升级服务器可以先生成一个空的合并补丁文件;然后将所述文件序列中首个解密后的中间补丁文件复制到所述合并补丁文件中。
所述升级服务器再将第二个解密后的中间补丁文件与所述合并补丁文件进行合并,具体包括以下步骤:
所述升级服务器根据第二个解密后的中间补丁文件中每行软件代码的行号,将该行软件代码复制到所述合并补丁文件中的适当位置,以确保所述合并补丁文件中的行号是按照从小到大的顺序排列的。例如,第二个解密后的中间补丁文件中的某一行软件代码的行号 为“2”,则将该行软件代码复制到所述合并补丁文件中行号为“3”之前;若所述第二个解密后的中间补丁文件中的某一行软件代码的行号为“4”,则将该行软件代码复制到所述合并补丁文件中行号为“3”之后。若所述第二个解密后的中间补丁文件中的某一行的软件代码的行号为“4”,且所述合并补丁文件中也存在行号为“4”的软件代码,则将第二个解密后的中间补丁文件中的该行软件代码复制到所述合并补丁文件中行号为“4”的软件代码之后。
当所述升级服务器将第二个解密后的中间补丁文件中所有软件代码均复制到所述合并补丁文件之后,需要对所述合并补丁文件中除所述第二个解密后的中间补丁文件中的软件代码以外的所述合并补丁文件中的原软件代码(未复制第二个解密后的中间补丁文件的所有软件代码之前所述合并补丁文件中包含的软件代码)的行号进行如下调整:
所述升级服务器按照行号从小到大的顺序依次确定所述合并补丁文件中复制的所述第二个解密后的中间补丁文件中每一行软件代码,若该行软件代码中行号包含删除指示“-”,则将该行软件代码之后的每行原软件代码的行号减1;若该行软件代码中行号包含增加指示“+”,则将该行软件代码之后的每行原软件代码加1。
然后所述升级服务器确定原软件代码的行号调整后的所述合并补丁文件中是否存在满足以下抵消条件的相邻两行软件代码:行号相同、代码内容相同,且其中一行的行号中包含删除指示“-”,另一行的行号中包含增加指示“+”。若存在,则所述升级服务器删除这两行软件代码(即将该相邻两行软件代码相互抵消)。
所述升级服务器从所述文件序列中获取下一个解密后的中间补丁文件,并按照以上步骤,继续与所述合并补丁文件进行合并,直至将所述文件序列中所有的解密后的中间补丁文件合并到所述合并补丁文件中。
示例性的,继续以图3中的三个补丁文件P1、P2和P3为例进行说明。参阅图5A所示,假设软件开发设备侧采用如图4D所示的加密方法对每个补丁文件进行加密的,那么所述升级服务器确定这三个补丁文件为中间补丁文件后,使用第二运算密钥对每个中间补丁文件的每行软件代码包含的加密后的行号和加密后的软件内容进行解密,得到图5A中的(1)中所示的3个解密后的补丁文件。然后所述升级服务器采用图5A中的(2)所示的合并方法,将解密后的三个中间补丁文件进行合并:
所述升级服务器生成一个空的合并补丁文件,将P1中的一行软件代码复制到该合并补丁文件中;然后,所述升级服务器按照P2中的每行软件代码的行号,将P2中的每行软件代码复制到所述合并补丁文件中的适当位置,如图5A中的(2)中的临时的合并补丁文件temp1所示;由于合并补丁文件中新增的P2的第一行软件代码的行号“258-”包含删除指示“-”,因此,所述升级服务器将该行软件代码之后的合并补丁文件中的原软件代码的行号减1,即将行号“259+”的原软件代码中的行号变为“258+”,如图5A中的(2)中的临时的合并补丁文件temp2所示;所述升级服务器将P3中的每行软件代码复制到所述合并补丁文件中的适当位置行号为“258+”的原软件代码之后,如图5A中的(2)中的临时的合并补丁文件temp3所示;由于新增的P3的软件代码的行号“258-”包含删除指示“-”,因此,所述升级服务器将该行软件代码之后的原软件代码的行号减1,即将行号“260+”的原软件代码中的行号变为“259+”,如图5A中的(2)中的临时的合并补丁文件temp4所示;由于此时合并补丁文件temp4中相邻的第二行和第三行软件代码满足抵消条件,因此,所述软件服务器将这两行软件代码删除,最终得到将P1、P2和P3合并后的合并补丁 文件P1_3。
需要说明的是,虽然图5A中的(2)未示出所述合并补丁文件的补丁头部,但该合并补丁文件的头部与所述升级服务器保存的P1-P3中任一个补丁文件的补丁头部相同。
示例性的,继续以图3中的三个补丁文件P1、P2和P3为例进行说明。参阅图5B所示,假设软件开发设备侧采用如图4C所示的加密方法对每个补丁文件进行加密的,那么所述升级服务器确定这三个补丁文件为中间补丁文件后,使用第二运算密钥对每个中间补丁文件的每行软件代码包含的加密后的行号和加密后的软件内容进行解密,得到图5B中的(1)中所示的3个解密后的补丁文件。然后所述升级服务器采用图5B中的(2)所示的合并方法,将解密后的三个目标补丁文件进行合并:
所述升级服务器生成一个空的合并补丁文件,将P1中的一行软件代码复制到该合并补丁文件中;然后,所述升级服务器按照P2中的每行软件代码的行号,将P2中的每行软件代码复制到所述合并补丁文件中的适当位置,如图5B中的(2)中的临时的合并补丁文件temp1所示;由于合并补丁文件中新增的P2的第一行软件代码的行号“2-”包含删除指示“-”,因此,所述升级服务器将该行软件代码之后的合并补丁文件中的原软件代码的行号减1,即将行号“3+”的原软件代码中的行号变为“2+”,如图5B中的(2)中的临时的合并补丁文件temp2所示;所述升级服务器将P3中的每行软件代码复制到所述合并补丁文件中的适当位置行号为“2+”的原软件代码之后,如图5B中的(2)中的临时的合并补丁文件temp3所示;由于新增的P3的软件代码的行号“2-”包含删除指示“-”,因此,所述升级服务器将该行软件代码之后的原软件代码的行号减1,即将行号“4+”的原软件代码中的行号变为“3+”,如图5B中的(2)中的临时的合并补丁文件temp4所示;由于此时合并补丁文件temp4中相邻的第二行和第三行软件代码满足抵消条件,因此,所述软件服务器将这两行软件代码删除,最终得到将P1、P2和P3合并后的合并补丁文件P1_3。
需要说明的是,虽然图5B中的(2)未示出所述合并补丁文件的补丁头部,但该合并补丁文件的头部与所述升级服务器保存的P1-P3中任一个补丁文件的补丁头部相同。
通过以上描述可知,所述升级服务器在将解密后的所述多个中间补丁文件进行合并的过程中,可以对一些满足抵消条件的软件代码抵消掉,这样可以减少所述合并补丁文件的数据量,提高所述合并补丁文件的传输效率。相对于传统方法中所述升级服务器需要向终端设备发送多个中间补丁文件的方案,本方案可以通过发送一个合并补丁文件即可实现将终端设备升级到目标版本号,可以简化向终端设备传输补丁文件的过程,显著提高补丁文件的传输效率。
S210:所述升级服务器向所述终端设备发送所述合并补丁文件。所述终端设备从所述升级服务器接收所述目标应用软件的合并补丁文件。
需要说明的是,在本申请实施例中,所述升级服务器可以通过两种方式发送所述升级补丁文件。
方式一:为了保证所述合并补丁文件在传输过程中行号的安全性,所述升级服务器可以在得到所述合并补丁文件,在向所述终端设备发送所述合并补丁文件之前,所述升级服务器可以再次对所述合并补丁文件中的每行软件代码中的行号进行加密处理。
与S208对应的,所述升级服务器可以通过两种实现方式对所述合并补丁文件中的行号进行加密处理。
第一种实现方式:在所述软件开发设备通过如图4A或图4B所示的第一种实现方式对 补丁文件进行加密,所述升级服务器在执行S208时使用所述第二运算密钥,对每个中间补丁文件的每行软件代码包含的加密后的行号进行解密的情况下。
所述升级服务器使用所述第一运算密钥,对所述合并补丁文件中每行软件代码中包含的行号进行加密。
示例性的,假设所述软件开发设备通过图4A或图4B所示的实现方式对补丁文件进行加密,所述升级服务器得到的合并补丁文件为P1_3,参阅图6A所示,所述升级服务器可以提取所述合并补丁文件中的每行软件代码中包含的行号,然后使用所述第一运算密钥对提取的行号进行加密,并将每个加密后的行号对所述合并补丁文件中的相应的行号进行替换,得到行号加密处理后的合并补丁文件P1_3。
第二种实现方式:在所述软件开发设备通过如图4C或图4D所示的第二种实现方式对补丁文件进行加密,所述升级服务器在执行S208时使用所述第二运算密钥,对每个中间补丁文件的每行软件代码包含的加密后的行号和加密后的软件内容进行解密的情况下。
所述升级服务器使用所述第一运算密钥,对所述合并补丁文件中每行软件代码包含的行号和加密后的软件内容进行加密。
示例性的,假设所述软件开发设备通过图4A或图4B所示的实现方式对补丁文件进行加密,所述升级服务器得到的合并补丁文件为P1_3,参阅图6B所示,所述升级服务器可以提取所述合并补丁文件中的每行软件代码,然后使用所述第一运算密钥对提取的每行软件代码进行加密,并根据加密后的每行软件代码和原补丁头部组成行号加密处理后的合并补丁文件P1_3。
方式二:为了提高终端设备接收到所述合并补丁文件的解密速度,提高终端设备的升级效率,所述升级服务器可以直接将合并得到的所述合并补丁文件发送给终端设备。
可选的,在本申请实施例中,所述升级服务器和所述终端设备之间可以通过建立传输层安全通道,进行通信交互。示例性的,所述传输层安全通道可以为TLS通道或SSL通道。
需要说明的是,当所述终端设备还需要通过其他中间设备连接所述升级服务器的情况下,所述升级服务器可以与中间设备建立传输层安全通道,以将所述合并补丁文件安全的传输给终端设备。例如图1中所示的终端设备ECU,所述ECU需要通过域控制器、GW、T-Box,才能连接所述升级服务器,那么所述升级服务器可以与所述T-Box建立传输层安全通道,然后通过所述传输层安全通道将所述合并补丁文件发送给所述T-Box,然后所述T-Box在通过GW、域控制器将该合并补丁文件传输到ECU。
S211:所述终端设备对接收到的合并补丁文件进行解密处理。
根据所述升级服务器在S210中对所述合并补丁文件的发送不同,所述终端设备对所述合并补丁文件进行解密的过程也不同。
方式一:在所述升级服务器在向所述终端设备发送所述合并补丁文件之前,所述升级服务器对所述合并补丁文件中的每行软件代码中的行号进行加密处理的情况下。
所述终端设备的解密处理过程,与所述升级服务器和所述软件开发设备的加密过程的相关,可以包含以下几种实现方式。
第一种实现方式:在所述软件开发设备通过如图4A所示的实现方式对补丁文件进行加密,所述升级服务器使用所述第二运算密钥对每个目标补丁文件中加密后的行号进行解密,且所述升级服务器使用第一运算密钥对合并补丁文件中每行软件代码中包含的行号进 行加密的情况下。
所述终端设备使用以下步骤,对加密后的合并补丁文件进行解密处理:
B1:所述终端设备使用第二安全密钥对所述加密后的合并补丁文件中的每行软件代码包含的加密后的代码内容进行解密。
B2:所述终端设备使用所述第二运算密钥对所述加密后的合并补丁文件中的每行软件代码包含的加密后的行号进行解密。
B3:当所述加密后的合并补丁文件中还包含加密后的补丁头部时,所述终端设备使用所述第二安全密钥对所述加密后的补丁头部进行解密。
示例性的,假设所述终端设备接收到的加密后的合并补丁文件为P1_3,如图7A中的左侧所示。参阅图7A所示,所述终端设备可以使用第二安全密钥对加密后的补丁头部进行解密,得到“APP1”;所述终端设备可以使用第二运算密钥对每行软件代码包含的加密后的行号进行解密,得到行号“2-”和“3+”;所述终端设备可以使用第二安全密钥对每行软件代码包含的加密后的代码内容进行解密,得到代码内容“bbbb”和“yyyy”;然后所述终端设备将解密得到的补丁头部、行号和代码内容,组成解密后的合并补丁文件P1_3。
第二种实现方式:在所述软件开发设备通过如图4B所示的实现方式对补丁文件进行加密,所述升级服务器使用所述第二运算密钥对每个目标补丁文件中加密后的行号进行解密,且所述升级服务器使用第一运算密钥对合并补丁文件中每行软件代码中包含的行号进行加密的情况下。
所述终端设备使用以下步骤,对加密后的合并补丁文件进行解密处理:
C1:所述终端设备使用第二安全密钥对所述加密后的合并补丁文件中的每行软件代码包含的加密后的代码内容进行解密。
C2:所述终端设备使用所述第二运算密钥对所述加密后的合并补丁文件中的每行软件代码包含的加密后的行号进行解密。
C3:当所述加密后的合并补丁文件中还包含加密后的补丁头部时,所述终端设备使用所述第二安全密钥对所述加密后的补丁头部进行解密。
C4:所述终端设备使用以下步骤对所述合并补丁文件中的行号进行行偏移处理:
所述终端设备获取所述目标应用软件的行号偏移值;
所述终端设备根据所述行号偏移值,对所述合并补丁文件中每行软件代码包含的行号进行偏移。其中,所述终端设备进行行偏移处理与所述软件开发设备进行的行偏移处理互逆。例如,所述终端设备将每行软件代码包含的行号减去(或加上)所述行号偏移值。
其中,所述终端设备可以从所述合并补丁文件中解密后的补丁头部中获取所述行号偏移值,或者获取存储的所述目标应用软件的行号偏移值。
示例性的,假设所述终端设备接收到的加密后的合并补丁文件为P1_3,如图7B中的左侧所示。参阅图7B所示,所述终端设备可以使用第二安全密钥对加密后的补丁头部进行解密,得到“APP1:z(z=256)”;所述终端设备可以使用第二运算密钥对每行软件代码包含的加密后的行号进行解密,得到行号“258-”和“259+”;所述终端设备可以使用第二安全密钥对每行软件代码包含的加密后的代码内容进行解密,得到代码内容“bbbb”和“yyyy”;然后所述终端设备将解密得到的补丁头部、行号和代码内容,组成解密后的合并补丁文件P1_3’;最后,所述终端设备根据z对每行软件代码包含的行号进行偏移处理 (行号减去z),得到最终的解密后的合并补丁文件P1_3。
第三种实现方式:在所述软件开发设备通过如图4C所示的实现方式对补丁文件进行加密,所述升级服务器使用所述第二运算密钥对每个目标补丁文件中加密后的行号和加密后的软件内容进行解密,且所述升级服务器使用第一运算密钥对合并补丁文件中每行软件代码中包含的行号和加密后的软件内容进行加密的情况下。
所述终端设备使用以下步骤,对加密后的合并补丁文件进行解密处理:
D1:所述终端设备使用所述第二运算密钥对所述加密后的合并补丁文件中的每行软件代码(包含加密后的行号和加密后的代码内容)进行解密。
D2:所述终端设备使用第二安全密钥对所述加密后的合并补丁文件中的每行软件代码包含的加密后的代码内容进行解密。
D3:当所述加密后的合并补丁文件中还包含加密后的补丁头部时,所述终端设备使用所述第二安全密钥对所述加密后的补丁头部进行解密。
示例性的,假设所述终端设备接收到的加密后的合并补丁文件为P1_3,如图7C中的左侧所示。参阅图7C所示,所述终端设备可以使用第二安全密钥对加密后的补丁头部进行解密,得到“APP1”;所述终端设备可以使用第二运算密钥对每行软件代码进行解密,得到行号和对应的加密后的代码内容;所述终端设备可以使用第二安全密钥对每行软件代码包含的加密后的代码内容进行解密,得到代码内容“bbbb”和“yyyy”;然后所述终端设备将解密得到的补丁头部、行号和代码内容,组成解密后的合并补丁文件P1_3。
第四种实现方式:在所述软件开发设备通过如图4D所示的实现方式对补丁文件进行加密,所述升级服务器使用所述第二运算密钥对每个目标补丁文件中加密后的行号和加密后的软件内容进行解密,且所述升级服务器使用第一运算密钥对合并补丁文件中每行软件代码中包含的行号和加密后的软件内容进行加密的情况下。
所述终端设备使用以下步骤,对加密后的合并补丁文件进行解密处理:
E1:所述终端设备使用所述第二运算密钥对所述加密后的合并补丁文件中的每行软件代码(包含加密后的行号和加密后的代码内容)进行解密。
E2:所述终端设备使用第二安全密钥对所述加密后的合并补丁文件中的每行软件代码包含的加密后的代码内容进行解密。
E3:当所述加密后的合并补丁文件中还包含加密后的补丁头部时,所述终端设备使用所述第二安全密钥对所述加密后的补丁头部进行解密。
E4:所述终端设备对所述合并补丁文件中的行号进行行偏移处理,同步骤C4,此处不再赘述。
示例性的,假设所述终端设备接收到的加密后的合并补丁文件为P1_3,如图7D中的左侧所示。参阅图7D所示,所述终端设备可以使用第二安全密钥对加密后的补丁头部进行解密,得到“APP1:z(z=256)”;所述终端设备可以使用第二运算密钥对每行软件代码进行解密,得到行号和对应的加密后的代码内容;所述终端设备可以使用第二安全密钥对每行软件代码包含的加密后的代码内容进行解密,得到代码内容“bbbb”和“yyyy”;然后所述终端设备将解密得到的补丁头部、行号和代码内容,组成解密后的合并补丁文件P1_3’;最后,所述终端设备根据z对每行软件代码包含的行号进行偏移处理(行号减去z),得到最终的解密后的合并补丁文件P1_3。
方式二:在所述升级服务器直接将合并得到的所述合并补丁文件发送给终端设备的情 况下。
所述终端设备的解密处理过程,与所述升级服务器和所述软件开发设备的加密过程的相关,可以包含以下几种实现方式。
第一种实现方式:在所述软件开发设备通过如图4A所示的实现方式对补丁文件进行加密,所述升级服务器使用所述第二运算密钥对每个目标补丁文件中加密后的行号进行解密的情况下。
所述终端设备使用以下步骤,对所述合并补丁文件进行解密处理:
F1:所述终端设备使用第二安全密钥对所述合并补丁文件中的每行软件代码包含的加密后的代码内容进行解密。
F2:当所述合并补丁文件中还包含加密后的补丁头部时,所述终端设备使用所述第二安全密钥对所述合并补丁文件中加密后的补丁头部进行解密。
示例性的,假设所述终端设备接收到的加密后的合并补丁文件为P1_3,如图7E中的左侧所示。参阅图7E所示,所述终端设备可以使用第二安全密钥对加密后的补丁头部进行解密,得到“APP1”;所述终端设备可以使用第二安全密钥对每行软件代码包含的加密后的代码内容进行解密,得到代码内容“bbbb”和“yyyy”;然后所述终端设备将解密得到的补丁头部和代码内容,以及行号,组成解密后的合并补丁文件P1_3。
第二种实现方式:在所述软件开发设备通过如图4B所示的实现方式对补丁文件进行加密,所述升级服务器使用所述第二运算密钥对每个目标补丁文件中加密后的行号进行解密的情况下。
所述终端设备使用以下步骤,对所述合并补丁文件进行解密处理:
F1:所述终端设备使用第二安全密钥对所述合并补丁文件中的每行软件代码包含的加密后的代码内容进行解密。
F2:当所述合并补丁文件中还包含加密后的补丁头部时,所述终端设备使用所述第二安全密钥对所述合并补丁文件中加密后的补丁头部进行解密。
F3:所述终端设备对所述合并补丁文件中的行号进行行偏移处理,同步骤C4,此处不再赘述。
示例性的,假设所述终端设备接收到的加密后的合并补丁文件为P1_3,如图7F中的左侧所示。参阅图7F所示,所述终端设备可以使用第二安全密钥对加密后的补丁头部进行解密,得到“APP1:z(z=256)”;所述终端设备可以使用第二安全密钥对每行软件代码包含的加密后的代码内容进行解密,得到代码内容“bbbb”和“yyyy”;然后所述终端设备将解密得到的补丁头部和代码内容,以及行号,组成解密后的合并补丁文件P1_3’;最后,所述终端设备根据z对每行软件代码包含的行号进行偏移处理(行号减去z),得到最终的解密后的合并补丁文件P1_3。
第三种实现方式:在所述软件开发设备通过如图4C所示的实现方式对补丁文件进行加密,所述升级服务器使用所述第二运算密钥对每个目标补丁文件中加密后的行号和加密后的软件内容进行解密的情况下。所述终端设备对所述合并补丁文件进行解密处理的过程与第一种实施方式中的相同,此处不再赘述。
第四种实现方式:在所述软件开发设备通过如图4D所示的实现方式对补丁文件进行加密,所述升级服务器使用所述第二运算密钥对每个目标补丁文件中加密后的行号和加密后的软件内容进行解密的情况下。所述终端设备对所述合并补丁文件进行解密处理的过程 与第一种实施方式中的相同,此处不再赘述。
S212:所述终端设备根据所述合并补丁文件中的每行软件代码包含的行号和代码内容,对已安装的所述目标应用软件进行升级。
所述终端设备可以安装所述合并补丁文件,以将所述合并补丁文件合并到所述目标应用软件的文件内,从而将所述目标应用软件升级到所述目标版本号。其中,所述终端设备将所述合并补丁文件合并到所述目标应用软件的文件的过程可以参考图5A中的(2)或图5B中的(2),此处不再赘述。
本申请实施例提供了一种软件升级方法,在上述方案中,升级服务器可以将多个目标补丁文件进行拼接合并,这样,终端设备可以仅下载和安装一次合并补丁文件即可实现将目标应用软件从当前版本号升级至目标版本号,显然,该方法可以明显的缩短终端设备进行软件升级消耗的时间,可以提高终端设备软件升级效率。另外,软件开发设备在对每个补丁文件进行加密的过程中,使用不同的密钥分别对每行软件代码中的行号和代码内容进行加密,这样,所述升级服务器可以仅对每行软件代码中的加密行号进行解密,而无法对每行软件代码中的代码内容进行解密,因此,该方法还可以保证补丁文件中代码内容的安全性。
基于图2所示的实施例,本申请实施例还提供了一种软件开发设备和升级服务器之间的通信过程,以实现软件开发设备向升级服务器发送补丁文件及其对应的版本号。下面参考图8,对该通信过程进行详细描述。
其中,在所述软件开发设备与所述升级服务器在进行通信之前,所述软件开发设备中维护有自身的密钥对(公钥K S_pub,私钥K S_priv),并保存有所述升级服务器的公钥K OTA_pub;所述升级服务器维护有自身的密钥对(公钥K OTA_pub,私钥K OTA_priv),并保存有所述软件开发设备的公钥K S_pub。另外在进行通信之前,所述软件开发设备与所述升级服务器可以先建立传输层安全通道(TSL通道或SSL通道),这样二者在进行通信交互时,可以通过该传输层安全通道传输。
S801:所述软件开发设备在生成目标应用文件的补丁文件之后,生成通知消息,所述通知消息用于通知所述软件开发设备中已经准备好新的补丁文件。其中,所述通知消息中包含所述软件开发设备针对本次通知确定的消息新鲜度N。所述软件开发设备使用所述升级服务器的公钥K OTA_pub对所述通知消息进行加密后,向所述升级服务器发送加密后的通知消息。
S802:所述升级服务器接收到加密后的通知消息后,使用自身的私钥K OTA_priv对所述加密后的通知消息进行解密,得到所述通知消息,并从该通知消息中获取N。所述升级服务器存储N,以便于进行后续校验。
S803:所述升级服务器生成包含N的补丁下载请求。其中,所述补丁下载请求用于请求所述软件开发设备发送补丁文件。所述升级服务器使用所述软件开发设备的公钥K S_pub对所述补丁下载请求进行加密后,向所述软件开发设备发送加密后的补丁下载请求。
S804:所述软件开发设备接收到加密后的补丁下载请求后,使用自身的私钥K S_priv对加密后的补丁下载请求进行解密,得到所述补丁下载请求,并从该补丁下载请求中获取N。
S805:所述软件开发设备将该补丁文件、版本号,以及N封装到补丁文件数据包,并使用所述升级服务器的公钥K OTA_pub对所述补丁文件数据包进行加密,将加密后的补丁文 件数据包发送给所述升级服务器。
S806:所述升级服务器接收到加密后的补丁文件数据包后,使用自身的私钥K OTA_priv对所述加密后的补丁文件数据包进行解密,得到其中的补丁文件、版本号,以及N。然后,所述升级服务器将从补丁文件数据包中获得的N与S802中获得的N进行校验,确定两者完全相同时,所述升级服务器将所述补丁文件和版本号保存到自身的数据库中。
基于图2所示的实施例,本申请实施例还提供了一种升级服务器和终端设备之间的通信过程,以实现终端设备从软件开发设备下载合并补丁文件,如图9和图10所示。
下面参考图9对该通信过程进行详细描述。其中,图9是以所述终端设备不经过其他中继设备,连接所述升级服务器的场景为例进行说明的。
其中,在所述升级服务器与所述终端设备在进行通信之前,所述升级服务器中维护有自身的密钥对(公钥K OTA_pub,私钥K OTA_priv),并保存有所述终端设备的公钥K UE_pub;所述升级服务器维护有自身的密钥对(公钥K UE_pub,私钥K UE_priv),并保存有所述升级服务器的公钥K OTA_pub。另外在进行通信之前,所述升级服务器与所述终端设备可以先建立传输层安全通道(TSL通道或SSL通道),这样二者在进行通信交互时,可以通过该传输层安全通道传输。
S901:所述升级服务器在从软件开发设备接收目标应用软件的新的补丁文件之后,生成通知消息,或者定期或周期性的生成所述通知消息。所述通知消息用于通知所述升级服务器中已经准备好新的补丁文件。其中,所述通知消息中包含所述升级服务器针对本次通知确定的消息新鲜度N。所述升级服务器使用所述终端设备的公钥K UE_pub对所述通知消息进行加密后,向所述终端设备发送加密后的通知消息。
S902:所述终端设备接收到加密后的通知消息后,使用自身的私钥K UE_priv对所述加密后的通知消息进行解密,得到所述通知消息,并从该通知消息中获取N。所述终端设备存储N,以便于进行后续校验。
S903:所述终端设备生成包含N的补丁下载请求。其中,所述补丁下载请求用于请求所述升级服务器发送补丁文件。所述终端设备使用所述升级服务器的公钥K OTA_pub对所述补丁下载请求进行加密,并向所述升级服务器发送所述加密后的补丁下载请求。所述补丁下载请求中包含所述终端设备已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
S904:所述升级服务器接收到加密后的补丁下载请求后,使用自身的私钥K OTA_priv对所述加密后的补丁下载请求进行解密,得到所述补丁下载请求,并从该补丁下载请求中获取N,以及所述当前版本号和所述目标版本号。所述升级服务器根据所述当前版本号和所述目标版本号,在本地数据库存储的所述目标应用软件的补丁文件中,选择多个目标补丁文件,再对所述多个目标补丁文件进行合并,生成合并补丁文件。其中,所述升级服务器生成所述合并补丁文件的过程可以参考图2所示的实施例中的S208-S210中的描述,此处不再赘述。
S905:所述升级服务器将该合并补丁文件,以及N封装到补丁文件数据包中,并使用所述终端设备的公钥K UE_pub对所述补丁文件数据包进行加密,最后将加密后的补丁文件数据包发送给所述终端设备。
S906:所述终端设备接收到加密后的补丁文件数据包后,使用自身的私钥K UE_priv对 所述加密后的补丁文件数据包进行解密,得到其中的合并补丁文件和N。然后,所述终端设备将从补丁文件数据包中获得的N与S902中获得的N进行校验,确定两者完全相同时,所述终端设备安装所述合并补丁文件,从而将所述目标应用软件升级到目标版本号。
下面参考图10对升级服务器和终端设备之间的通信过程进行描述。其中图10是以所述终端设备为ECU,所述ECU经过其他中继设备(DC、GW和T_Box),连接所述升级服务器的场景为例进行说明的。
其中,在所述升级服务器与所述终端设备在进行通信之前,所述升级服务器中维护有自身的密钥对(公钥K OTA_pub,私钥K OTA_priv),并保存有所述T_Box的公钥K TBox_pub;所述升级服务器维护有自身的密钥对(公钥K TBox_pub,私钥K TBox_priv),并保存有所述升级服务器的公钥K OTA_pub。另外在进行通信之前,所述升级服务器与所述T_Box可以先建立传输层安全通道(TSL通道或SSL通道),这样二者在进行通信交互时,可以通过该传输层安全通道传输。另外,所述T_Box和所述GW中还保存有对称密钥K TBox_GW,用于对所述T_Box和所述GW之间传输的消息进行加解密;所述GW和所述DC中保存有对称密钥K GW_DC,用于对所述GW和所述DC之间传输的消息进行加解密;所述DC和所述ECU中保存有对称密钥K DC_ECU,用于对所述DC和所述ECU之间传输的消息进行加解密。
S1001:所述升级服务器在从软件开发设备接收目标应用软件的新的补丁文件之后,生成通知消息,或者定期或周期性的生成所述通知消息。所述通知消息用于通知所述升级服务器中已经准备好新的补丁文件。其中,所述通知消息中包含所述升级服务器针对本次通知确定的消息新鲜度N。所述升级服务器使用所述T_Box的公钥K TBox_pub对所述通知消息进行加密后,向T_Box发送加密后的通知消息。
S1002:所述T_Box接收到所述加密后的通知消息后,使用自身的私钥K TBox_priv对所述加密后的通知消息进行解密,得到所述通知消息,并从该通知消息中获取N。所述T_Box存储N,以便于进行后续校验。
S1003:所述T_Box生成包含N的补丁下载请求。其中,所述补丁下载请求用于请求所述升级服务器发送补丁文件。所述T_Box使用所述升级服务器的公钥K OTA_pub对所述补丁下载请求进行加密,并向所述升级服务器发送所述加密后的补丁下载请求。所述补丁下载请求中包含所述T_Box已安装的所述目标应用软件的当前版本号,以及所述T_Box进行所述目标应用软件升级的目标版本号。
S1004:所述升级服务器接收到加密后的补丁下载请求后,使用自身的私钥K OTA_priv对所述加密后的补丁下载请求进行解密,得到所述补丁下载请求,并从中获取N,以及所述当前版本号和所述目标版本号。所述升级服务器根据所述当前版本号和所述目标版本号,在本地数据库存储的所述目标应用软件的补丁文件中,选择多个目标补丁文件,再对所述多个目标补丁文件进行合并,生成合并补丁文件。其中,所述升级服务器生成所述合并补丁文件的过程可以参考图2所示的实施例中的S208-S210中的描述,此处不再赘述。
S1005:所述升级服务器将该合并补丁文件,以及N封装到补丁文件数据包,并使用所述T_Box的公钥K TBox_pub对所述补丁文件数据包进行加密,最后将加密后的补丁文件数据包发送给所述T_Box。
S1006:所述T_Box接收到所述加密后的补丁文件数据包后,使用自身的私钥K TBox_priv对所述补丁文件数据包进行解密,得到其中的合并补丁文件和N。然后,所述T_Box将从 补丁文件数据包中获得的N与S902中获得的N进行校验,确定两者完全相同。
S1007:所述T_Box使用对称密钥K TBox_GW对所述合并补丁文件进行加密,并将加密后的所述合并补丁文件发送给GW。
S1008:所述GW接收到加密后的所述合并补丁文件后,使用对称密钥K TBox_GW对加密后的所述合并补丁文件进行解密,得到所述合并补丁文件;然后使用对称密钥K GW_DC对所述合并补丁文件进行加密,并将加密后的所述合并补丁文件发送给DC。
S1009:所述DC接收到加密后的所述合并补丁文件后,使用对称密钥K GW_DC对加密后的所述合并补丁文件进行解密,得到所述合并补丁文件;然后使用对称密钥K DC_ECU对所述合并补丁文件进行加密,并将加密后的所述合并补丁文件发送给ECU。
S1010:所述ECU接收到加密后的所述合并补丁文件后,使用对称密钥K DC_ECU对加密后的所述合并补丁文件进行解密,得到所述合并补丁文件;然后所述终端设备安装所述合并补丁文件,从而将所述目标应用软件升级到目标版本号。
S1011:所述ECU安装完成后,生成升级结果通知;并使用对称密钥K DC_ECU对所述升级结果通知进行加密,将加密后的升级结果通知发送给DC。
S1012:所述DC接收到解密后的所述升级结果通知后,使用对称密钥K DC_ECU对所述升级结果通知进行解密,得到所述升级结果通知;然后使用对称密钥K GW_DC对所述升级结果通知进行加密,将加密后的升级结果通知发送给GW。
S1013:所述GW接收到解密后的所述升级结果通知后,使用对称密钥K GW_DC对所述升级结果通知进行解密,得到所述升级结果通知;然后使用对称密钥K TBox_GW对所述升级结果通知进行加密,将加密后的升级结果通知发送给T_Box。
S1014:所述T_Box接收到解密后的所述升级结果通知后,使用对称密钥KTBox_GW对所述升级结果通知进行解密,得到所述升级结果通知;然后使用所述升级服务器的公钥K OTA_puk对所述升级结果通知进行加密,将加密后的升级结果通知发送给所述升级服务器。
所述升级服务器接收到所述加密后的所述升级结果通知后,使用自身的私钥K OTA_priv对所述升级结果通知进行解密,得到所述升级结果通知。
基于相同的技术构思,本申请实施例还提供了一种通信装置,该装置的结构如图11所示,包括通信单元1101和处理单元1102。所述通信装置1100可以应用于图1所示的软件升级系统中的软件开发设备、软件服务器,或终端设备,并可以实现以上实施例以及实例提供的软件升级方法。
其中,所述通信单元1101,用于接收和发送数据。
当所述通信装置1100应用于软件开发设备或软件服务器时,所述通信单元1101又可以称为物理接口、通信模块、通信接口、输入输出接口。所述通信装置1100可以通过该通信单元连接网线或电缆,进而与其他设备建立物理连接。
当所述通信装置1100应用于终端设备时,所述通信单元1101又可以称为收发器,可以通过移动通信模块和/或无线通信模块实现。
移动通信模块可以提供应用在所述终端设备上的包括2G/3G/4G/5G等无线通信的解决方案。移动通信模块可以包括至少一个天线、至少一个滤波器,开关,功率放大器,低噪声放大器(low noise amplifier,LNA)等。所述终端设备可以通过所述移动通信模块接入移动通信网络中,进而通过所述移动通信网络接入演算网络中的转发设备。
无线通信模块可以提供应用在终端设备上的包括无线局域网(wireless local area networks,WLAN)(如无线保真(wireless fidelity,Wi-Fi)网络),蓝牙(bluetooth,BT),全球导航卫星系统(global navigation satellite system,GNSS),调频(frequency modulation,FM),近距离无线通信技术(near field communication,NFC)等无线通信的解决方案。无线通信模块160可以包括至少一个天线、至少一个通信处理模块的一个或多个器件。所述终端设备可以通过所述无线通信模块接入无线通信网络中,进而通过所述无线通信网络接入演算网络中的转发设备。
下面对所述通信装置1100应用于软件开发设备时,所述处理单元1102的具体功能进行介绍。
在第一种实施方式中,所述处理单元1102,用于生成目标应用软件的补丁文件和所述补丁文件的对应的版本号,其中,所述补丁文件包含第一代码段,所述第一代码段包含第一代码段标识和第一代码内容;对所述补丁文件进行加密处理,包括:根据第一安全密钥,对所述第一代码内容进行加密;根据第一运算密钥,对所述第一代码段标识和通过第一安全密钥加密后的所述第一代码内容进行加密;其中,所述第一运算密钥与所述第一安全密钥不同;通过所述通信单元1101向升级服务器发送加密后的所述补丁文件和所述补丁文件对应的版本号。
可选的,所述处理单元1102,还用于:
在根据第一运算密钥,对所述第一代码段标识和通过第一安全密钥加密后的所述第一代码内容进行加密之前,获取所述目标应用软件的标识偏移值;根据所述标识偏移值,对所述第一代码段标识进行偏移。
可选的,所述补丁文件中还包含补丁头部,其中,所述补丁头部用于指示所述目标应用软件;所述处理单元1102,在对所述补丁文件进行加密处理时,还用于:
根据所述第一安全密钥,对所述补丁头部进行加密。
可选的,所述补丁文件包含至少一个所述第一代码段;所述第一代码段为一行第一代码,所述第一代码段标识为所述第一代码的行号。
在第二种实施方式中,所述处理单元1102,用于生成目标应用软件的补丁文件和所述补丁文件的对应的版本号,其中,所述补丁文件包含第一代码段,所述第一代码段包含第一代码段标识和第一代码内容;对所述补丁文件进行加密处理,包括:根据第一安全密钥,对所述第一代码内容进行加密;根据第一运算密钥,对所述第一代码段标识进行加密;其中,所述第一运算密钥与所述第一安全密钥不同;通过所述通信单元1101向升级服务器发送加密后的所述补丁文件和所述补丁文件对应的所述版本号。
可选的,所述处理单元1102,还用于:
在根据第一运算密钥,对所述第一代码段标识进行加密之前,获取所述目标应用软件的标识偏移值;根据所述标识偏移值,对所述第一代码段标识进行偏移。
可选的,所述补丁文件中还包含补丁头部,其中,所述补丁头部用于指示所述目标应用软件;
所述处理单元1102,在对所述补丁文件进行加密处理时,还用于:
根据所述第一安全密钥,对所述补丁头部进行加密。
下面对所述通信装置1100应用于升级服务器时,所述处理单元1102的具体功能进行 介绍。
在第一种实施方式中,所述处理单元1102,用于:
存储目标应用软件加密后的补丁文件和所述补丁文件对应的版本号;其中,所述加密后的补丁文件包含加密后的第一代码段,所述加密后的第一代码段是通过第一运算密钥对第一代码段标识和通过第一安全密钥加密后的第一代码内容进行加密得到的,所述第一运算密钥与所述第一安全密钥不同;
通过所述通信单元1101从终端设备接收所述目标应用软件的补丁下载请求;
根据所述补丁下载请求确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号;
根据所述当前版本号和所述目标版本号,从本地存储的所述目标应用软件的加密后的补丁文件中,确定中间补丁文件,其中,所述中间补丁文件为版本号大于所述当前版本号,且小于或等于所述目标版本号的加密后的补丁文件;
当所述中间补丁文件为多个,根据第二运算密钥,对每个中间补丁文件进行解密,所述解密包括对每个中间补丁文件包含的加密后的第一代码段进行解密,得到每个中间补丁文件的第一代码段的第一代码段标识和通过第一安全密钥加密后的第一代码内容;
根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件中的第一代码段包含的第一代码段标识,对解密后的所述多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件;所述合并补丁文件包含更新后的第一代码段,所述更新后的第一代码段包括对通过第一安全密钥加密后的第一代码内容和更新后的第一代码段标识;
根据所述第一运算密钥对所述合并补丁文件进行加密,包括:根据所述第一运算密钥对所述合并补丁文件中更新后的第一代码段进行加密;
通过所述通信单元1101向所述终端设备发送加密后的所述合并补丁文件。
可选的,所述处理单元1102,在根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件的第一代码段包含的第一代码段标识,对解密后的所述多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件时,具体用于:
根据存储的所述多个中间补丁文件对应的版本号的先后顺序,对解密后的所述多个中间补丁文件进行排序,得到文件序列,其中,版本号最先的解密后的中间补丁文件位于所述文件序列的首位,版本号最后的解密后的中间补丁文件位于所述文件序列的末位;
根据每个解密后的中间补丁文件中的第一代码段包含的第一代码段标识,按照所述文件序列的顺序依次将每个解密后的中间补丁文件进行合并,得到所述合并补丁文件。
可选的,所述加密后的补丁文件中还包含加密后的补丁头部,所述加密后的补丁头部是通过所述第一安全密钥加密的;所述合并补丁文件中还包含所述加密后的补丁头部。
可选的,所述处理单元1102,在确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号时,具体用于:
从所述补丁下载请求中获取所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
可选的,所述加密后的补丁文件包含至少一个加密后的第一代码段;所述加密后的第一代码段为加密后的一行第一代码,所述第一代码段标识为所述第一代码的行号;所述合并补丁文件包含至少一个更新后的第一代码段。
在第二种实施方式中,所述处理单元1102,用于:
存储目标应用软件的加密后的补丁文件和所述补丁文件对应的版本号;其中,所述加密后的补丁文件包含第一代码段,所述第一代码段包含加密后的第一代码段标识和加密后的第一代码内容;所述加密后的第一代码段标识是通过第一运算密钥对第一代码段标识加密得到的,所述加密后的第一代码内容是通过第一安全密钥对第一代码内容加密得到的,所述第一运算密钥与所述第一安全密钥不同;
通过所述通信单元1101从终端设备接收所述目标应用软件的补丁下载请求;
根据所述补丁下载请求确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号;
根据所述当前版本号和所述目标版本号,从本地存储的所述目标应用软件的加密后的补丁文件中,确定中间补丁文件,其中,所述中间补丁文件为版本号大于所述当前版本号,且小于或等于所述目标版本号的加密后的补丁文件;
当所述中间补丁文件为多个时,根据第二运算密钥,对每个中间补丁文件进行解密,所述解密包括对每个中间补丁文件的第一代码段包含的加密后的第一代码段标识进行解密,得到每个中间补丁文件的第一代码段包含的第一代码段标识;
根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件中的第一代码段包含的第一代码段标识,对解密后的所述多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件;其中,所述合并补丁文件包含更新后的第一代码段,所述更新后的第一代码段包括对通过第一安全密钥加密后的第一代码内容和更新后的第一代码段标识;
根据所述第一运算密钥对所述合并补丁文件进行加密,包括:根据所述第一运算密钥对所述合并补丁文件中更新后的第一代码段标识进行加密;
通过所述通信单元1101向所述终端设备发送加密后的所述合并补丁文件。
可选的,所述处理单元1102,在根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件的第一代码段包含的第一代码段标识,对解密后的所述多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件时,具体用于:
根据存储的所述多个中间补丁文件对应的版本号的先后顺序,对解密后的所述多个中间补丁文件进行排序,得到文件序列,其中,版本号最先的解密后的中间补丁文件位于所述文件序列的首位,版本号最后的解密后的中间补丁文件位于所述文件序列的末位;
根据每个解密后的中间补丁文件中的第一代码段包含的第一代码段标识,按照所述文件序列的顺序依次将每个解密后的中间补丁文件进行合并,得到所述合并补丁文件。
可选的,所述加密后的补丁文件中还包含加密后的补丁头部,所述加密后的补丁头部是通过所述第一安全密钥加密的;
所述合并补丁文件中还包含所述加密后的补丁头部。
可选的,所述处理单元1102,在确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号时,具体用于:
从所述补丁下载请求中获取所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
可选的,所述加密后的补丁文件包含至少一个加密后的第一代码段;所述加密后的第一代码段为加密后的一行第一代码,所述第一代码段标识为所述第一代码的行号;所述合并补丁文件包含至少一个更新后的第一代码段。
下面对所述通信装置1100应用于终端设备时,所述处理单元1102的具体功能进行介绍。
在第一种实施方式中,处理单元1102,用于:
通过所述通信单元1101向所述升级服务器发送目标应用软件的补丁下载请求;
通过所述通信单元1101从所述升级服务器接收所述目标应用软件的加密后的合并补丁文件,其中,所述加密后的合并补丁文件是所述升级服务器对所述目标应用软件的多个中间补丁文件进行合并生成的,所述加密后的合并补丁文件包含加密后的第一代码段,所述加密后的第一代码段是通过第一运算密钥对第一代码段进行加密得到的,所述第一代码段包含第一代码段标识和通过第一安全密钥加密后的第一代码内容;所述第一运算密钥与所述第一安全密钥不同;
对所述加密后的合并补丁文件进行解密处理,得到合并补丁文件,包括:根据第二运算密钥,对所述加密后的第一代码段进行解密,得到所述第一代码段;根据第二安全密钥,对所述第一代码段包含的通过第一安全密钥加密后的第一代码内容进行解密,得到第一代码内容;
根据所述合并补丁文件中的所述第一代码段包含的第一代码段标识和所述第一代码内容,对已安装的所述目标应用软件进行升级。
可选的,所述加密后的合并补丁文件还包含加密后的补丁头部,所述加密后的补丁头部是通过第一安全密钥加密的;所述处理单元1102,在对所述加密后的合并补丁文件进行解密处理时,还用于:
根据所述第二安全密钥,对所述加密后的合并补丁文件的所述加密后的补丁头部进行解密,得到补丁头部。
可选的,所述处理单元1102,还用于:
在对所述加密后的合并补丁文件进行解密处理之后,在根据所述合并补丁文件中的所述第一代码段包含的第一代码段标识和第一代码内容,对已安装的所述目标应用软件进行升级之前,获取所述目标应用软件的标识偏移值;根据所述标识偏移值,对所述合并补丁文件中所述第一代码段包含的所述第一代码段标识进行偏移。
可选的,所述补丁下载请求中包含所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
可选的,所述加密后的合并补丁文件包含至少一个加密后的第一代码段;所述加密后的第一代码段为加密后的一行第一代码,所述第一代码段标识为所述第一代码的行号。
在第二种实施方式中,处理单元1102,用于:
通过所述通信单元1101向所述升级服务器发送目标应用软件的补丁下载请求;
通过所述通信单元1101从所述升级服务器接收所述目标应用软件的加密后的合并补丁文件,其中,所述加密后的合并补丁文件是所述升级服务器对所述目标应用软件的多个目标补丁文件进行合并生成的,所述加密后的合并补丁文件包含第一代码段,所述第一代码段包含加密后的第一代码段标识和加密后的第一代码内容,所述加密后的第一代码段标识是通过第一运算密钥对第一代码段进行加密得到的,所述加密后的第一代码内容是通过第一安全密钥对第一代码内容加密得到的,所述第一运算密钥与所述第一安全密钥不同;
对所述加密后的合并补丁文件进行解密处理,得到合并补丁文件,包括:根据第二运 算密钥,对所述加密后的第一代码段标识进行解密,得到第一代码段标识;根据第二安全密钥,对所述加密后的第一代码内容进行解密,得到第一代码内容;
根据所述合并补丁文件中的所述第一代码段包含的第一代码段标识和所述第一代码内容,对已安装的所述目标应用软件进行升级。
可选的,所述加密后的合并补丁文件还包含加密后的补丁头部,所述加密后的补丁头部是通过第一安全密钥加密的;所述处理单元1102,在对所述加密后的合并补丁文件进行解密处理时,还用于:
根据所述第二安全密钥,对所述加密后的合并补丁文件的所述加密后的补丁头部进行解密,得到补丁头部。
可选的,所述处理单元1102,还用于:
在对所述加密后的合并补丁文件进行解密处理之后,在根据所述合并补丁文件中的所述第一代码段包含的第一代码段标识和所述第一代码内容,对已安装的所述目标应用软件进行升级之前,获取所述目标应用软件的标识偏移值;根据所述标识偏移值,对所述合并补丁文件中所述第一代码段包含的所述第一代码段标识进行偏移。
可选的,所述补丁下载请求中包含所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
可选的,所述加密后的合并补丁文件包含至少一个第一代码段;所述第一代码段为一行第一代码,所述第一代码段标识为所述第一代码的行号。
需要说明的是,本申请以上实施例中对模块的划分是示意性的,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)或处理器(processor)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
基于相同的技术构思,本申请还提供了一种通信设备,所述通信设备可以应用于如图1所示的软件升级系统中的软件开发设备、软件服务器,或终端设备,可以实现以上实施例以及实例提供的软件升级方法,具有图11所示的通信装置的功能。参阅图12所示,所述通信设备1200包括:通信模块1201、处理器1202以及存储器1203。其中,所述通信模块1201、所述处理器1202以及所述存储器1203之间相互连接。
可选的,所述通信模块1201、所述处理器1202以及所述存储器1203之间通过总线1204相互连接。所述总线1204可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。 所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图12中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
所述通信模块1201,用于接收和发送数据,实现与其他设备之间的通信交互。例如,当所述通信设备1200应用于软件开发设备、软件服务器时,所述通信模块1201可以通过物理接口实现。又例如,当所述通信设备1200应用于终端设备,所述通信模块1201还可以通过收发器实现。
所述处理器1202,用于实现软件开发设备、软件服务器,或终端设备实现以上实施例中提供的软件升级方法,具体功能可以参见以上软件升级方法中的描述,以及图11所示的实施例中对所述通信装置1100的具体功能描述,此处不再赘述。
所述存储器1203,用于存放程序指令和数据等。具体地,程序指令可以包括程序代码,该程序代码包括计算机操作指令。存储器1203可能包含随机存取存储器(random access memory,RAM),也可能还包括非易失性存储器(non-volatile memory),例如至少一个磁盘存储器。处理器1202执行存储器1203所存放的程序指令,并使用所述存储器1203中存储的数据,实现上述功能,从而实现上述实施例提供的软件升级方法。
可以理解,本申请图12中的存储器1203可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(Read-Only Memory,ROM)、可编程只读存储器(Programmable ROM,PROM)、可擦除可编程只读存储器(Erasable PROM,EPROM)、电可擦除可编程只读存储器(Electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(Random Access Memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的RAM可用,例如静态随机存取存储器(Static RAM,SRAM)、动态随机存取存储器(Dynamic RAM,DRAM)、同步动态随机存取存储器(Synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(Double Data Rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(Enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(Synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(Direct Rambus RAM,DR RAM)。应注意,本文描述的系统和方法的存储器旨在包括但不限于这些和任意其它适合类型的存储器。
基于以上实施例,本申请实施例还提供了一种计算机程序,当所述计算机程序在计算机上运行时,使得所述计算机执行以上实施例提供的软件升级方法。
基于以上实施例,本申请实施例还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,所述计算机程序被计算机执行时,使得计算机执行以上实施例提供的软件升级方法。
其中,存储介质可以是计算机能够存取的任何可用介质。以此为例但不限于:计算机可读介质可以包括RAM、ROM、EEPROM、CD-ROM或其他光盘存储、磁盘存储介质或者其他磁存储设备、或者能够用于携带或存储具有指令或数据结构形式的期望的程序代码并能够由计算机存取的任何其他介质。
基于以上实施例,本申请实施例还提供了一种芯片,所述芯片用于读取存储器中存储的计算机程序,实现以上实施例提供的软件升级方法。
基于以上实施例,本申请实施例提供了一种芯片系统,该芯片系统包括处理器,用于支持计算机装置实现以上实施例中软件开发设备、软件服务器,或终端设备所涉及的功能。在一种可能的设计中,所述芯片系统还包括存储器,所述存储器用于保存该计算机装置必 要的程序和数据。该芯片系统,可以由芯片构成,也可以包含芯片和其他分立器件。
综上所述,本申请实施例提供了一种软件升级方法及设备。软件开发设备将每次生成的补丁文件进行加密后,将加密后的补丁文件以及对应的版本号发送给升级服务器保存;升级服务器可以根据终端设备对目标应用软件的升级需求,在本地存储的所述目标应用软件的补丁文件中,确定多个中间补丁文件;然后,所述升级服务器对每个中间补丁文件中加密后的第一代码段标识进行解密,并根据版本号和每个中间补丁文件中第一代码段标识,对所述多个中间补丁文件进行合并,得到合并补丁文件,并将该合并补丁文件加密后发送给终端设备,以使所述终端设备可以根据所述合并补丁文件进行所述目标应用软件的软件升级。
在上述方案中,所述升级服务器可以将满足终端设备的所述目标应用软件的升级需求的多个中间补丁文件进行拼接合并,这样,所述终端设备可以仅下载和安装一次合并补丁文件即可实现目标应用软件从当前版本号升级至目标版本号,显然,该方法可以明显的缩短终端设备进行软件升级消耗的时间,可以提高终端设备软件升级效率。另外,所述软件开发设备在对每个补丁文件进行加密的过程中,使用不同的密钥分别对第一代码段标识和第一代码内容进行加密,这样,所述升级服务器在对补丁文件进行合并过程中可以仅对加密后的第一代码段标识进行解密,而无法对加密后的第一代码内容进行解密,因此,该方法可以保证补丁文件中代码内容的安全性。
本领域内的技术人员应明白,本申请的实施例可提供为方法、系统、或计算机程序产品。因此,本申请可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本申请是参照根据本申请的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。

Claims (27)

  1. 一种软件升级方法,其特征在于,包括:
    升级服务器存储目标应用软件加密后的补丁文件和所述补丁文件对应的版本号;其中,所述加密后的补丁文件包含加密后的第一代码段,所述加密后的第一代码段是通过第一运算密钥对第一代码段标识和通过第一安全密钥加密后的第一代码内容进行加密得到的,所述第一运算密钥与所述第一安全密钥不同;
    所述升级服务器从终端设备接收所述目标应用软件的补丁下载请求;
    所述升级服务器根据所述补丁下载请求确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号;
    所述升级服务器根据所述当前版本号和所述目标版本号,从本地存储的所述目标应用软件的加密后的补丁文件中,确定中间补丁文件,其中,所述中间补丁文件为版本号大于所述当前版本号,且小于或等于所述目标版本号的加密后的补丁文件;
    当所述中间补丁文件为多个,所述升级服务器根据第二运算密钥,对每个中间补丁文件进行解密,所述解密包括对每个中间补丁文件包含的加密后的第一代码段进行解密,得到每个中间补丁文件的第一代码段的第一代码段标识和通过第一安全密钥加密后的第一代码内容;
    所述升级服务器根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件中的第一代码段包含的第一代码段标识,对解密后的所述多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件;所述合并补丁文件包含更新后的第一代码段,所述更新后的第一代码段包括对通过第一安全密钥加密后的第一代码内容和更新后的第一代码段标识;
    所述升级服务器根据所述第一运算密钥对所述合并补丁文件进行加密,包括:根据所述第一运算密钥对所述合并补丁文件中更新后的第一代码段进行加密;
    所述升级服务器向所述终端设备发送加密后的所述合并补丁文件。
  2. 如权利要求1所述的方法,其特征在于,所述升级服务器根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件的第一代码段包含的第一代码段标识,对解密后的所述多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件,包括:
    所述升级服务器根据存储的所述多个中间补丁文件对应的版本号的先后顺序,对解密后的所述多个中间补丁文件进行排序,得到文件序列,其中,版本号最先的解密后的中间补丁文件位于所述文件序列的首位,版本号最后的解密后的中间补丁文件位于所述文件序列的末位;
    所述升级服务器根据每个解密后的中间补丁文件中的第一代码段包含的第一代码段标识,按照所述文件序列的顺序依次将每个解密后的中间补丁文件进行合并,得到所述合并补丁文件。
  3. 如权利要求1或2所述的方法,其特征在于,所述加密后的补丁文件还包含加密后的补丁头部,所述加密后的补丁头部是通过所述第一安全密钥加密的;
    所述合并补丁文件还包含所述加密后的补丁头部。
  4. 如权利要求1-3任一项所述的方法,其特征在于,所述升级服务器根据所述补丁下载请求确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备 进行所述目标应用软件升级的目标版本号,包括:
    所述升级服务器从所述补丁下载请求中获取所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
  5. 如权利要求1-4任一项所述的方法,其特征在于,所述加密后的补丁文件包含至少一个加密后的第一代码段;所述加密后的第一代码段为加密后的一行第一代码,所述第一代码段标识为所述第一代码的行号;
    所述合并补丁文件包含至少一个更新后的第一代码段。
  6. 一种软件升级方法,其特征在于,包括:
    终端设备向所述升级服务器发送目标应用软件的补丁下载请求;
    所述终端设备从所述升级服务器接收所述目标应用软件的加密后的合并补丁文件,其中,所述加密后的合并补丁文件是所述升级服务器对所述目标应用软件的多个中间补丁文件进行合并生成的,所述加密后的合并补丁文件包含加密后的第一代码段,所述加密后的第一代码段是通过第一运算密钥对第一代码段进行加密得到的,所述第一代码段包含第一代码段标识和通过第一安全密钥加密后的第一代码内容;所述第一运算密钥与所述第一安全密钥不同;
    所述终端设备对所述加密后的合并补丁文件进行解密处理,得到合并补丁文件,包括:所述终端设备根据第二运算密钥,对所述加密后的第一代码段进行解密,得到所述第一代码段;所述终端设备根据第二安全密钥,对所述第一代码段包含的通过第一安全密钥加密后的第一代码内容进行解密,得到第一代码内容;
    所述终端设备根据所述合并补丁文件中的所述第一代码段包含的第一代码段标识和所述第一代码内容,对已安装的所述目标应用软件进行升级。
  7. 如权利要求6所述的方法,其特征在于,所述加密后的合并补丁文件还包含加密后的补丁头部,所述加密后的补丁头部是通过第一安全密钥加密的;
    所述终端设备对所述加密后的合并补丁文件进行解密处理,还包括:
    所述终端设备根据所述第二安全密钥,对所述加密后的合并补丁文件的所述加密后的补丁头部进行解密,得到补丁头部。
  8. 如权利要求6或7所述的方法,其特征在于,在所述终端设备对所述加密后的合并补丁文件进行解密处理之后,在所述终端设备根据所述合并补丁文件中的所述第一代码段包含的第一代码段标识和第一代码内容,对已安装的所述目标应用软件进行升级之前,还包括:
    所述终端设备获取所述目标应用软件的标识偏移值;
    所述终端设备根据所述标识偏移值,对所述合并补丁文件中所述第一代码段包含的所述第一代码段标识进行偏移。
  9. 如权利要求6-8任一项所述的方法,其特征在于,所述补丁下载请求中包含所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
  10. 如权利要求6-9任一项所述的方法,其特征在于,所述加密后的合并补丁文件包含至少一个加密后的第一代码段;所述加密后的第一代码段为加密后的一行第一代码,所述第一代码段标识为所述第一代码的行号。
  11. 一种软件升级方法,其特征在于,包括:
    升级服务器存储目标应用软件的加密后的补丁文件和所述补丁文件对应的版本号;其中,所述加密后的补丁文件包含第一代码段,所述第一代码段包含加密后的第一代码段标识和加密后的第一代码内容;所述加密后的第一代码段标识是通过第一运算密钥对第一代码段标识加密得到的,所述加密后的第一代码内容是通过第一安全密钥对第一代码内容加密得到的,所述第一运算密钥与所述第一安全密钥不同;
    所述升级服务器从终端设备接收所述目标应用软件的补丁下载请求;
    所述升级服务器根据所述补丁下载请求确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号;
    所述升级服务器根据所述当前版本号和所述目标版本号,从本地存储的所述目标应用软件的加密后的补丁文件中,确定中间补丁文件,其中,所述中间补丁文件为版本号大于所述当前版本号,且小于或等于所述目标版本号的加密后的补丁文件;
    当所述中间补丁文件为多个时,所述升级服务器根据第二运算密钥,对每个中间补丁文件进行解密,所述解密包括对每个中间补丁文件的第一代码段包含的加密后的第一代码段标识进行解密,得到每个中间补丁文件的第一代码段包含的第一代码段标识;
    所述升级服务器根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件中的第一代码段包含的第一代码段标识,对解密后的所述多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件;其中,所述合并补丁文件包含更新后的第一代码段,所述更新后的第一代码段包括对通过第一安全密钥加密后的第一代码内容和更新后的第一代码段标识;
    所述升级服务器根据所述第一运算密钥对所述合并补丁文件进行加密,包括:根据所述第一运算密钥对所述合并补丁文件中更新后的第一代码段标识进行加密;
    所述升级服务器向所述终端设备发送加密后的所述合并补丁文件。
  12. 如权利要求11所述的方法,其特征在于,所述升级服务器根据所述多个中间补丁文件对应的版本号、每个解密后的中间补丁文件的第一代码段包含的第一代码段标识,对解密后的所述多个中间补丁文件进行合并,得到所述目标应用软件的合并补丁文件,包括:
    所述升级服务器根据存储的所述多个中间补丁文件对应的版本号的先后顺序,对解密后的所述多个中间补丁文件进行排序,得到文件序列,其中,版本号最先的解密后的中间补丁文件位于所述文件序列的首位,版本号最后的解密后的中间补丁文件位于所述文件序列的末位;
    所述升级服务器根据每个解密后的中间补丁文件中的第一代码段包含的第一代码段标识,按照所述文件序列的顺序依次将每个解密后的中间补丁文件进行合并,得到所述合并补丁文件。
  13. 如权利要求11或12所述的方法,其特征在于,所述加密后的补丁文件还包含加密后的补丁头部,所述加密后的补丁头部是通过所述第一安全密钥加密的;
    所述合并补丁文件还包含所述加密后的补丁头部。
  14. 如权利要求11-13任一项所述的方法,其特征在于,所述升级服务器根据所述补丁下载请求确定所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号,包括:
    所述升级服务器从所述补丁下载请求中获取所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
  15. 如权利要求11-14任一项所述的方法,其特征在于,所述加密后的补丁文件包含至少一个加密后的第一代码段;所述加密后的第一代码段为加密后的一行第一代码,所述第一代码段标识为所述第一代码的行号;
    所述合并补丁文件包含至少一个更新后的第一代码段。
  16. 一种软件升级方法,其特征在于,包括:
    终端设备向所述升级服务器发送目标应用软件的补丁下载请求;
    所述终端设备从所述升级服务器接收所述目标应用软件的加密后的合并补丁文件,其中,所述加密后的合并补丁文件是所述升级服务器对所述目标应用软件的多个目标补丁文件进行合并生成的,所述加密后的合并补丁文件包含第一代码段,所述第一代码段包含加密后的第一代码段标识和加密后的第一代码内容,所述加密后的第一代码段标识是通过第一运算密钥对第一代码段进行加密得到的,所述加密后的第一代码内容是通过第一安全密钥对第一代码内容加密得到的,所述第一运算密钥与所述第一安全密钥不同;
    所述终端设备对所述加密后的合并补丁文件进行解密处理,得到合并补丁文件,包括:所述终端设备根据第二运算密钥,对所述加密后的第一代码段标识进行解密,得到第一代码段标识;所述终端设备根据第二安全密钥,对所述加密后的第一代码内容进行解密,得到第一代码内容;
    所述终端设备根据所述合并补丁文件中的所述第一代码段包含的第一代码段标识和所述第一代码内容,对已安装的所述目标应用软件进行升级。
  17. 如权利要求16所述的方法,其特征在于,所述加密后的合并补丁文件还包含加密后的补丁头部,所述加密后的补丁头部是通过第一安全密钥加密的;
    所述终端设备对所述加密后的合并补丁文件进行解密处理,还包括:
    所述终端设备根据所述第二安全密钥,对所述加密后的合并补丁文件的所述加密后的补丁头部进行解密,得到补丁头部。
  18. 如权利要求16或17所述的方法,其特征在于,在所述终端设备对所述加密后的合并补丁文件进行解密处理之后,在所述终端设备根据所述合并补丁文件中的所述第一代码段包含的第一代码段标识和所述第一代码内容,对已安装的所述目标应用软件进行升级之前,还包括:
    所述终端设备获取所述目标应用软件的标识偏移值;
    所述终端设备根据所述标识偏移值,对所述合并补丁文件中所述第一代码段包含的所述第一代码段标识进行偏移。
  19. 如权利要求16-18任一项所述的方法,其特征在于,所述补丁下载请求中包含所述终端设备中已安装的所述目标应用软件的当前版本号,以及所述终端设备进行所述目标应用软件升级的目标版本号。
  20. 如权利要求16-19任一项所述的方法,其特征在于,所述加密后的合并补丁文件包含至少一个第一代码段;所述第一代码段为一行第一代码,所述第一代码段标识为所述第一代码的行号。
  21. 一种升级服务器,其特征在于,包括:
    通信单元,用于接收和发送数据;
    处理单元,用于通过所述通信单元,实现权利要求1-5任一项所述的方法。
  22. 一种终端设备,其特征在于,包括:
    通信单元,用于接收和发送数据;
    处理单元,用于通过所述通信单元,实现权利要求6-10任一项所述的方法。
  23. 一种升级服务器,其特征在于,包括:
    通信单元,用于接收和发送数据;
    处理单元,用于通过所述通信单元,实现权利要求11-15任一项所述的方法。
  24. 一种终端设备,其特征在于,包括:
    通信单元,用于接收和发送数据;
    处理单元,用于通过所述通信单元,实现权利要求16-20任一项所述的方法。
  25. 一种计算机程序,其特征在于,当所述计算机程序在计算机上运行时,使得所述计算机执行如权利要求1-20任一项所述的方法。
  26. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序,当所述计算机程序被计算机执行时,使得所述计算机执行如权利要求1-20任一项所述的方法。
  27. 一种芯片,其特征在于,所述芯片用于读取存储器中存储的计算机程序,执行如权利要求1-20任一项所述的方法。
PCT/CN2021/070365 2020-01-23 2021-01-05 一种软件升级方法及设备 WO2021147668A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
EP21743687.2A EP4086757A4 (en) 2020-01-23 2021-01-05 SOFTWARE UPGRADE METHOD AND DEVICE

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010077050.5 2020-01-23
CN202010077050.5A CN113157305B (zh) 2020-01-23 2020-01-23 一种软件升级方法及设备

Publications (1)

Publication Number Publication Date
WO2021147668A1 true WO2021147668A1 (zh) 2021-07-29

Family

ID=76882157

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/070365 WO2021147668A1 (zh) 2020-01-23 2021-01-05 一种软件升级方法及设备

Country Status (3)

Country Link
EP (1) EP4086757A4 (zh)
CN (1) CN113157305B (zh)
WO (1) WO2021147668A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115811413A (zh) * 2022-07-15 2023-03-17 北京金朗维科技有限公司 一种用于无线扫码设备的在线升级方法和装置

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114006791B (zh) * 2021-10-29 2023-05-30 东风商用车有限公司 一种低延时报文转发方法及网关

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106302592A (zh) * 2015-05-28 2017-01-04 腾讯科技(深圳)有限公司 终端应用的更新方法、服务器和终端
CN107861736A (zh) * 2017-11-01 2018-03-30 网易(杭州)网络有限公司 补丁生成和更新方法及装置、电子设备、存储介质
CN108710500A (zh) * 2018-05-23 2018-10-26 北京五八信息技术有限公司 资源发布方法、更新方法和装置
CN110162330A (zh) * 2019-07-08 2019-08-23 上海赫千电子科技有限公司 一种应用于汽车ecu升级文件的系统及方法
CN110442377A (zh) * 2019-08-13 2019-11-12 网易(杭州)网络有限公司 补丁包生成方法、应用更新方法、装置和电子设备
US20190394053A1 (en) * 2017-02-10 2019-12-26 Huawei Technologies Co., Ltd. Method and System for Updating Certificate Issuer Public Key, and Related Device

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1533695B1 (en) * 2003-11-19 2013-08-07 TELEFONAKTIEBOLAGET LM ERICSSON (publ) Updating data in a mobile terminal
CN102402438B (zh) * 2010-09-16 2014-07-09 金蝶软件(中国)有限公司 一种补丁文件的自动合并方法、装置及通信终端
CN105787367B (zh) * 2016-02-23 2018-09-21 华中科技大学 一种软件更新的补丁安全性检测方法及系统
WO2019083440A2 (zh) * 2017-10-24 2019-05-02 华为国际有限公司 一种车载设备升级方法及相关设备
CN110351314B (zh) * 2018-04-03 2023-11-21 厦门雅迅网络股份有限公司 汽车控制器的远程升级方法及计算机可读存储介质

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106302592A (zh) * 2015-05-28 2017-01-04 腾讯科技(深圳)有限公司 终端应用的更新方法、服务器和终端
US20190394053A1 (en) * 2017-02-10 2019-12-26 Huawei Technologies Co., Ltd. Method and System for Updating Certificate Issuer Public Key, and Related Device
CN107861736A (zh) * 2017-11-01 2018-03-30 网易(杭州)网络有限公司 补丁生成和更新方法及装置、电子设备、存储介质
CN108710500A (zh) * 2018-05-23 2018-10-26 北京五八信息技术有限公司 资源发布方法、更新方法和装置
CN110162330A (zh) * 2019-07-08 2019-08-23 上海赫千电子科技有限公司 一种应用于汽车ecu升级文件的系统及方法
CN110442377A (zh) * 2019-08-13 2019-11-12 网易(杭州)网络有限公司 补丁包生成方法、应用更新方法、装置和电子设备

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP4086757A4 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115811413A (zh) * 2022-07-15 2023-03-17 北京金朗维科技有限公司 一种用于无线扫码设备的在线升级方法和装置
CN115811413B (zh) * 2022-07-15 2023-07-25 北京金朗维科技有限公司 一种用于无线扫码设备的在线升级方法和装置

Also Published As

Publication number Publication date
CN113157305B (zh) 2022-04-05
EP4086757A1 (en) 2022-11-09
CN113157305A (zh) 2021-07-23
EP4086757A4 (en) 2023-06-21

Similar Documents

Publication Publication Date Title
US10834207B2 (en) System and method for updating software in an electronic device
CN107294729B (zh) 区块链中不同节点之间的通信方法及装置
JP4079770B2 (ja) モバイル電話ネットワーク上においてデータを処理し伝送するための方法およびオンボードマイクロチップシステム
CN109561118A (zh) 软件升级方法、装置、系统、存储介质、电子设备及车辆
US11947673B2 (en) Over-the-air upgrade method and related apparatus
WO2021147668A1 (zh) 一种软件升级方法及设备
US20220311625A1 (en) Certificate Application Method And Device
CN111953716B (zh) 消息通讯方法、系统、计算机设备及存储介质
CN113938880B (zh) 一种应用的验证方法及装置
CN112329044A (zh) 信息获取方法、装置、电子设备和计算机可读介质
CN113381938B (zh) 数据包发送方法、装置、存储介质及电子设备
US7743385B2 (en) System and method for simplification of data structure in wireless communications
WO2023276531A1 (ja) 車載通信システム,リプロポリシーメタデータのデータ構造及びダウンロードメタデータのデータ構造
US20240015063A1 (en) Communication system, construction method, and recording medium
CN113132409B (zh) 一种数据传输方法及装置
CN113542284B (zh) id包转译应用方法、系统、存储介质及电子设备
US20220377550A1 (en) Secure and trusted peer-to-peer offline communication systems and methods
TWI754950B (zh) 物聯網設備、伺服器及軟體更新方法
CN116528217B (zh) 对eUICC进行远程管理的方法及相关设备
CA2544032C (en) System and method for simplification of data structure in wireless communications
US20240169076A1 (en) Center apparatus, vehicle-side system, content protection method, and storage medium storing content protection program
WO2021148028A1 (zh) 车载设备的升级方法和装置
CN117060980A (zh) 数据发送方法、装置、电子设备及存储介质
CN117119055A (zh) 智能网关的多应用通信管理方法、装置、智能网关和介质
CN116668118A (zh) 基于内容链接的无状态用户数据处理方法、装置及系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21743687

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2021743687

Country of ref document: EP

Effective date: 20220802

NENP Non-entry into the national phase

Ref country code: DE