Software flashing method and device, storage medium and computer program product

By combining symmetric and asymmetric encryption with a key update and rollback mechanism, the method secures the software flashing process, preventing unauthorized software flashing and ensuring vehicle control system integrity and safety.

CN119105775APending Publication Date: 2024-12-10DONGFENG MOTOR GRP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411043567.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2024-12-10

AI Technical Summary

Technical Problem

The security of vehicle control systems is compromised during software flashing due to the possibility of illegal or uncertified software being maliciously flashed into the controller, posing risks to vehicle safety and reliability.

Method used

A method combining symmetric and asymmetric encryption technologies to encrypt and verify software data, ensuring secure transmission and integrity, along with a key update mechanism and rollback mechanism to prevent unauthorized software flashing.

Benefits of technology

Ensures the security and integrity of the software flashing process, preventing illegal software flashing and maintaining vehicle control system integrity and safety.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119105775A_ABST
    Figure CN119105775A_ABST
Patent Text Reader

Abstract

The invention discloses a software flashing method and device, a storage medium and a computer program product, and relates to the technical field of vehicles, the software flashing method is disclosed and applied to a server side, and the method comprises the following steps: generating a target key based on a symmetric encryption algorithm, and encrypting to-be-flashed data through the target key to obtain a to-be-flashed ciphertext; generating a preset key pair based on an asymmetric algorithm, encrypting the target key through a public key in the preset key pair to obtain an encrypted key, and sending a private key in the preset key pair to the vehicle controller; processing the to-be-flashed ciphertext through a preset encryption algorithm to obtain summary information, and encrypting the summary information through the public key to obtain an encrypted summary; and sending the to-be-flashed ciphertext, the encryption key and the encryption abstract to a vehicle controller. According to the method, the safety of the vehicle control system in the software flashing process can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of vehicle technology, and in particular to a software flashing method, device, storage medium and computer program product. Background Art

[0002] As the automotive industry enters a new era of intelligence and networking, vehicle control systems are becoming increasingly complex and highly dependent on embedded software to implement advanced driver assistance systems (ADAS), autonomous driving, remote monitoring and diagnosis, and real-time communication between vehicles and the cloud. This transformation has greatly improved driving convenience and safety, but it has also posed unprecedented challenges to the safety and reliability of automotive controller software.

[0003] In the current automotive software development and deployment process, controller software flashing is a key step in loading new software or update packages into the vehicle control unit (ECU, Electronic Control Unit). The security of software flashing is directly related to the overall performance of the vehicle and road safety. However, due to the openness and accessibility of the automotive controller software flashing interface, there is a possibility that illegal or uncertified third-party software may be maliciously flashed into the controller during the software flashing process. These informal software may affect the security of the vehicle control system, thereby affecting vehicle safety.

[0004] The above contents are only used to assist in understanding the technical solution of the present application and do not constitute an admission that the above contents are prior art. Summary of the invention

[0005] The main purpose of this application is to provide a software flashing method, device, storage medium and computer program product, aiming to solve the technical problem that the security of the vehicle control system is affected during the software flashing process.

[0006] To achieve the above purpose, the present application proposes a software flashing method, which is applied to a server side and includes:

[0007] Generate a target key based on a symmetric encryption algorithm, and encrypt the data to be flashed using the target key to obtain the ciphertext to be flashed;

[0008] Generate a preset key pair based on an asymmetric algorithm, encrypt the target key by using a public key in the preset key pair to obtain an encrypted key, and send a private key in the preset key pair to a vehicle controller so that the vehicle controller stores the private key;

[0009] The ciphertext to be flashed is processed by a preset encryption algorithm to obtain summary information, and the summary information is encrypting by the public key to obtain an encrypted summary;

[0010] The ciphertext to be flashed, the encryption key and the encrypted summary are sent to the vehicle controller, so that the vehicle controller decrypts the encrypted summary by the private key to obtain a decrypted summary; if the decrypted summary verification passes, the encryption key is decrypted by the private key to obtain the target key; the ciphertext to be flashed is decrypted by the target key to obtain the data to be flashed, and the data to be flashed is flashed to a preset flashing area.

[0011] In one embodiment, the method further comprises:

[0012] When a key update command is received, a new key is generated based on a symmetric encryption algorithm, and the target key is updated with the new key.

[0013] In one embodiment, the step of sending the ciphertext to be flashed, the encryption key and the encryption summary to the vehicle controller includes:

[0014] Concatenating the encryption key and the ciphertext to be flashed to obtain a concatenated ciphertext;

[0015] The concatenated ciphertext and the encrypted summary are sent to the vehicle controller, so that the vehicle controller can decrypt the encrypted summary through the private key to obtain a decrypted summary; if the decrypted summary verification passes, the encryption key is read from the concatenated ciphertext and decrypted through the private key to obtain the target key; the ciphertext to be flashed is read from the concatenated ciphertext and decrypted through the target key to obtain the data to be flashed; and the data to be flashed is flashed to the preset flashing area.

[0016] In one embodiment, before the step of sending the ciphertext to be flashed, the encryption key and the encryption summary to the vehicle controller, the method further includes:

[0017] Generate a timestamp, and add the timestamp to the ciphertext to be flashed and the encryption key respectively;

[0018] Based on a preset key generation algorithm, generate a first key according to a preset shared key and the timestamp, and send the first key to the vehicle controller;

[0019] The step of sending the ciphertext to be flashed, the encryption key and the encryption summary to the vehicle controller comprises:

[0020] The timestamped ciphertext to be flashed, the timestamped encryption key and the encrypted summary are sent to the vehicle controller, so that the vehicle controller can extract the first timestamp in the timestamped ciphertext to be flashed and the second timestamp in the timestamped encryption key; when the first timestamp and the second timestamp are consistent, a second key is generated according to the first timestamp and the preset shared key based on the preset key generation algorithm; when the first key and the second key are consistent, software flashing is performed based on the timestamped ciphertext to be flashed, the timestamped encryption key and the encrypted summary.

[0021] To achieve the above purpose, the present application also proposes a software flashing method, which is applied to a vehicle controller and includes:

[0022] Receive and store a private key sent by the server, wherein the private key is a private key in a preset key pair generated by the server based on an asymmetric encryption algorithm;

[0023] Receive the ciphertext to be flashed, the encryption key and the encrypted digest sent by the server, wherein the ciphertext to be flashed is obtained by encrypting the data to be flashed by the server using the encryption key, the encryption key is obtained by encrypting the target key generated based on the symmetric encryption algorithm by the public key in the preset key pair by the server, the encrypted digest is obtained by encrypting the summary information by the public key by the server, and the summary information is obtained by processing the ciphertext to be flashed by the server using the preset encryption algorithm;

[0024] Decrypting the encrypted summary using the private key to obtain a decrypted summary;

[0025] In the case where the post-decryption digest verification passes, the encryption key is decrypted by the private key to obtain the target key, and the ciphertext to be flashed is decrypted by the target key to obtain the data to be flashed;

[0026] The data to be written is written to a preset writing area.

[0027] In one embodiment, the step of writing the data to be written to a preset writing area includes:

[0028] Erasing the original software data stored in the first storage area, and writing the data to be flashed into the first storage area, wherein the first storage area is a software running storage area;

[0029] Verifying the data to be flashed;

[0030] If the data to be written passes the verification, the data to be written is backed up to a second storage area, wherein the second storage area is a software backup storage area.

[0031] In one embodiment, after the step of verifying the data to be flashed, the method further comprises:

[0032] If the data to be written fails the verification, the data to be written in the first storage area is erased, and the backup software data corresponding to the original software data in the second storage area is loaded into the first storage area.

[0033] In one embodiment, the step of writing the data to be written to a preset writing area includes:

[0034] Splitting the data to be flashed into a plurality of sub-data blocks according to a preset segmentation rule, and assigning a unique identifier to each of the sub-data blocks;

[0035] Traversing each of the sub-data blocks, writing the sub-data blocks into a preset flash writing area, and writing a unique identifier of the sub-data block into a preset breakpoint information file;

[0036] If the vehicle controller is powered off, then after the vehicle controller is powered on, the most recently written unique identifier is read from the breakpoint information file, and starting from the next sub-data block of the sub-data block corresponding to the most recently written unique identifier, the traversal of each sub-data block is executed, the sub-data block is written into the preset flash area, and the unique identifier of the sub-data block is written into the preset breakpoint information file until each sub-data block is written into the preset flash area.

[0037] In addition, to achieve the above-mentioned purpose, the present application also proposes a software flashing device, which includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, and the computer program is configured to implement the steps of the software flashing method described above.

[0038] In addition, to achieve the above-mentioned purpose, the present application also proposes a storage medium, which is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the software flashing method described above are implemented.

[0039] In addition, to achieve the above-mentioned purpose, the present application also provides a computer program product, which includes a computer program, and when the computer program is executed by a processor, the steps of the software flashing method described above are implemented.

[0040] In the present application, the server generates a target key based on a symmetric encryption algorithm, and encrypts the data to be written by the target key to obtain the ciphertext to be written; generates a preset key pair based on an asymmetric algorithm, encrypts the target key by the public key in the preset key pair to obtain an encryption key, and sends the private key in the preset key pair to the vehicle controller so that the vehicle controller can store the private key; processes the ciphertext to be written by the preset encryption algorithm to obtain summary information, and encrypts the summary information by the public key to obtain an encrypted summary; sends the ciphertext to be written, the encryption key and the encrypted summary to the vehicle controller. The vehicle controller decrypts the encrypted summary by the private key to obtain a decrypted summary, and if the decrypted summary verification passes, decrypts the encryption key by the private key to obtain the target key, decrypts the ciphertext to be written by the target key to obtain the data to be written, and writes the data to be written to the preset writing area.

[0041] In this application, the security of the software flashing process is enhanced by introducing encryption mechanism and summary verification. Specifically, the original data to be flashed is encrypted to form ciphertext through a symmetric encryption algorithm. Even if the ciphertext data in transmission is intercepted, the original data cannot be directly read or tampered due to the lack of the corresponding key. In addition, the characteristics of asymmetric encryption are utilized in this application, that is, the public key can be made public, but only the corresponding private key can decrypt the data. Even if the encrypted symmetric key is intercepted, it cannot be decrypted without the correct private key, which ensures the safe transmission of the key. The summary information of the ciphertext to be flashed is calculated by a preset encryption algorithm, and then the summary is encrypted using the public key. The summary information is equivalent to creating a digital signature for the data to be flashed. When the vehicle controller receives the data, the encrypted summary can be decrypted using the private key, and then the summary of the ciphertext can be recalculated and compared with the decrypted summary. If they are consistent, it proves that the data has not been modified. The integrity and non-tampering status of the data during transmission can be ensured through the summary information.

[0042] To sum up, by combining symmetric encryption, asymmetric encryption and digest verification, this application can effectively prevent the flashing of illegal software, ensure the security of the software flashing process, and at the same time protect the integrity and security of the vehicle control system, thereby ensuring the normal operation and driving safety of the vehicle.

[0043] Moreover, compared to using symmetric encryption algorithm or asymmetric encryption algorithm alone, the present application combines asymmetric encryption technology and symmetric encryption technology to ensure the security of the flashing process while improving the efficiency of encryption and decryption. By using asymmetric encryption technology to encrypt the key, the security of the key is ensured. In the data transmission process, the efficiency of symmetric encryption technology is fully utilized to speed up the flashing speed and reduce the consumption of system resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0045] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0046] Figure 1 A flowchart of the first embodiment of the software flashing method of the present application is provided;

[0047] Figure 2 A flowchart of the second embodiment of the software flashing method of the present application is provided;

[0048] Figure 3 A schematic diagram of a brief process of flashing software provided in an embodiment of the present application;

[0049] Figure 4 A brief scenario diagram of storage partitions provided in an embodiment of the present application;

[0050] Figure 5 A brief flowchart of a software rollback mechanism provided in one embodiment of the present application;

[0051] Figure 6 A schematic diagram of a brief process of updating a secret key provided in an embodiment of the present application;

[0052] Figure 7 Schematic diagram of the device structure of the hardware operating environment involved in the software flashing method in the embodiment of the present application.

[0053] The purpose, features and advantages of this application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0054] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.

[0055] In order to better understand the technical solution of the present application, a detailed description will be given below in conjunction with the accompanying drawings and specific implementation methods.

[0056] The main solution of the embodiment of the present application is: the server generates a target key based on a symmetric encryption algorithm, and encrypts the data to be written by the target key to obtain the ciphertext to be written; generates a preset key pair based on an asymmetric algorithm, encrypts the target key by the public key in the preset key pair to obtain an encryption key, and sends the private key in the preset key pair to the vehicle controller so that the vehicle controller can store the private key; processes the ciphertext to be written by the preset encryption algorithm to obtain summary information, and encrypts the summary information by the public key to obtain an encrypted summary; sends the ciphertext to be written, the encryption key and the encrypted summary to the vehicle controller. The vehicle controller decrypts the encrypted summary by the private key to obtain a decrypted summary. If the decrypted summary verification passes, the encryption key is decrypted by the private key to obtain the target key, and the ciphertext to be written is decrypted by the target key to obtain the data to be written, and the data to be written is written to the preset writing area.

[0057] In this embodiment, for ease of description, the following description is made with the software flashing device as the execution subject.

[0058] As the automotive industry enters a new era of intelligence and networking, vehicle control systems are becoming increasingly complex and highly dependent on embedded software to implement advanced driver assistance systems, autonomous driving, remote monitoring and diagnosis, and real-time communication between vehicles and the cloud. This transformation has greatly improved driving convenience and safety, but it has also posed unprecedented challenges to the security and reliability of automotive controller software.

[0059] In the current automotive software development and deployment process, controller software flashing is a key step in loading new software or update packages into the vehicle control unit. The security of software flashing is directly related to the overall performance of the vehicle and road safety. However, due to the openness and accessibility of the automotive controller software flashing interface, there is a possibility that illegal or uncertified third-party software may be maliciously flashed into the controller during the software flashing process. These informal software may affect the security of the vehicle control system and thus affect vehicle safety.

[0060] However, there are certain security risks in the flashing of controller software, especially in the application of digital signatures, which has not yet been popularized. The lack of a digital signature mechanism may cause informal software to be flashed into the controller, causing a series of security issues, including but not limited to vehicle control system failures, data leakage, and potential physical damage risks. Although traditional digital signature technology has advantages in security, its difficulty in factoring large integers requires the selection of large prime numbers during key generation, and the key length is relatively long, which will result in slower encryption and decryption speeds in practical applications. At the same time, although symmetric encryption technology has significant advantages in encryption speed, its security is relatively low and is not enough to resist complex network attacks.

[0061] In order to solve the above problems, the embodiment of the present application proposes a method for secure flashing of automobile controller software that combines asymmetric encryption technology and symmetric encryption technology, which improves the efficiency of encryption and decryption while ensuring the security of the flashing process. By using asymmetric encryption technology to encrypt the key, the security of the key is ensured, and during the data transmission process, the efficiency of symmetric encryption technology is fully utilized to speed up the flashing speed and reduce the consumption of system resources.

[0062] And considering the possible failure of controller software flashing, a software rollback mechanism is added to ensure that after the software flashing fails, the original software of the controller can be loaded when the controller is restarted, so that it can continue to work normally.

[0063] In addition, in order to further ensure the security of the software flashing process, the embodiment of the present application not only introduces a hash algorithm, but also adds a key update mechanism. By calculating the hash value of the software and comparing it before and after flashing, any unauthorized changes to the data during transmission can be effectively detected and prevented. At the same time, updating the key through the key update mechanism enhances the security of the flashing process and ensures that only authorized users and systems can flash the software. This combination of multiple encryption and verification mechanisms not only improves the security of flashing, but also provides a reliable and efficient solution for software flashing in the automotive industry, which meets the current high standards for safety and reliability in the automotive industry.

[0064] In the embodiment of the present application, the security of the software flashing process is enhanced by introducing an encryption mechanism and summary verification. Specifically, the original data to be flashed is encrypted to form a ciphertext through a symmetric encryption algorithm. Even if the ciphertext data in transmission is intercepted, the original data cannot be directly read or tampered due to the lack of the corresponding key. In addition, the characteristics of asymmetric encryption are utilized in the present application, that is, the public key can be made public, but only the corresponding private key can decrypt the data. Even if the encrypted symmetric key is intercepted, it cannot be decrypted without the correct private key, which ensures the safe transmission of the key. The summary information of the ciphertext to be flashed is calculated by a preset encryption algorithm, and then the summary is encrypted using the public key. The summary information is equivalent to creating a digital signature for the data to be flashed. When the vehicle controller receives the data, the encrypted summary can be decrypted using the private key, and then the summary of the ciphertext is recalculated and compared with the decrypted summary. If they are consistent, it proves that the data has not been modified. The integrity and non-tampering state of the data during transmission can be ensured through the summary information.

[0065] To sum up, by combining symmetric encryption, asymmetric encryption and digest verification, the embodiments of the present application can effectively prevent the flashing of illegal software, ensure the security of the software flashing process, and at the same time protect the integrity and security of the vehicle control system, thereby ensuring the normal operation and driving safety of the vehicle.

[0066] Moreover, compared to using a symmetric encryption algorithm or an asymmetric encryption algorithm alone, the embodiments of the present application combine asymmetric encryption technology and symmetric encryption technology to ensure the security of the flashing process while improving the efficiency of encryption and decryption. By using asymmetric encryption technology to encrypt the key, the security of the key is ensured, and during the data transmission process, the efficiency of symmetric encryption technology is fully utilized to speed up the flashing speed and reduce the consumption of system resources.

[0067] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication and program running functions, such as a tablet computer, personal computer, mobile phone, etc., or an electronic device, software flashing device, etc. that can realize the above functions.

[0068] Based on this, the present application embodiment provides a software flashing method, referring to Figure 1 This is a flow chart of the first embodiment of the software flashing method of the present application. In this embodiment, the software flashing method is applied to the server side. The following takes the software flashing device as the server side as an example to illustrate this embodiment and the following embodiments.

[0069] In this embodiment, the software flashing method includes steps S10 to S40.

[0070] Step S10, generating a target key based on a symmetric encryption algorithm, and encrypting the data to be flashed using the target key to obtain a ciphertext to be flashed.

[0071] It should be noted that the key generated based on the symmetric encryption algorithm is called the target key, the software data to be flashed is called the data to be flashed, and the data obtained by encrypting the data to be flashed with the target key is called the ciphertext to be flashed.

[0072] The symmetric encryption algorithm is not limited here and can be set according to actual needs. For example, it can be an AES (Advanced Encryption Standard) algorithm or a ChaCha20 (a modern stream encryption algorithm) algorithm.

[0073] In this embodiment, the manner in which the server side obtains the data to be flashed is not limited here, and may specifically depend on the function of the server side. For example, when the server side is a software development side, the server side can receive the data to be flashed developed by the developer; when the server side is an external controller of the vehicle, the server side and the software development side can be communicated and connected, and the server side obtains the data to be flashed from the software development side. Specifically, the server side may access the software development side at a certain period to obtain the data to be flashed, and the server side may also receive the data to be flashed actively sent by the software development side, which is not limited here.

[0074] Step S20, generating a preset key pair based on an asymmetric algorithm, encrypting the target key by the public key in the preset key pair to obtain an encrypted key, and sending the private key in the preset key pair to the vehicle controller for the vehicle controller to store the private key.

[0075] It should be noted that the key pair generated based on the asymmetric algorithm is called a preset key pair. The public key in the preset key pair is used to encrypt the target key on the server side, and the private key in the preset key pair is sent from the server side and stored in the controller inside the vehicle (ie, the vehicle controller).

[0076] In this embodiment, the asymmetric encryption algorithm is not limited here and can be set according to actual needs. For example, it can be RSA (Rivest-Shamir-Adleman, an asymmetric encryption algorithm) algorithm, ECDSA (Elliptic Curve Digital Signature Algorithm, a digital signature algorithm based on elliptic curve), etc.

[0077] The server encrypts the target key using the public key in the preset asymmetric key pair to generate an encryption key. At the same time, the private key is sent to the vehicle controller so that it can be saved for subsequent decryption. Since the public key can be made public and the private key is kept confidential, the encryption key can only be decrypted by the vehicle controller that has the private key, ensuring the secure transmission of the symmetric key and preventing man-in-the-middle attacks.

[0078] Step S30: Process the ciphertext to be flashed by using a preset encryption algorithm to obtain summary information, and encrypt the summary information by using the public key to obtain an encrypted summary.

[0079] It should be noted that the preset encryption algorithm is not specifically limited here, and can be a hash algorithm, such as SHA-256 (Secure Hash Algorithm 256-bi, secure hash algorithm 256 bit), SHA-3 (Secure Hash Algorithm3, secure hash algorithm 3), MD5 (Message-Digest Algorithm5, message digest algorithm 5) and other algorithms. The data obtained by encrypting the ciphertext to be flashed by the preset encryption algorithm is referred to as summary information, and the summary information can verify whether the data has been tampered with.

[0080] The server uses a preset encryption algorithm to generate summary information for the flashed ciphertext, and then uses the public key to encrypt the summary information to produce an encrypted summary. The encrypted summary ensures the security of the summary information during transmission and prevents the data from being maliciously modified during transmission.

[0081] Step S40, the ciphertext to be flashed, the encryption key and the encrypted summary are sent to the vehicle controller, so that the vehicle controller decrypts the encrypted summary by the private key to obtain a decrypted summary, and when the decrypted summary verification passes, the encryption key is decrypted by the private key to obtain the target key, and the ciphertext to be flashed is decrypted by the target key to obtain the data to be flashed, and the data to be flashed is flashed to a preset flashing area.

[0082] The server sends the ciphertext to be flashed, the encryption key and the encryption summary to the vehicle controller.

[0083] The vehicle controller decrypts the encrypted summary using the private key to obtain a decrypted summary. If the decrypted summary verification passes, the vehicle controller decrypts the encrypted key using the private key to obtain the target key. The vehicle controller decrypts the ciphertext to be written using the target key to obtain the data to be written, and writes the data to be written to a preset writing area.

[0084] It should be noted that the method for verifying the decrypted digest is not limited here and can be set according to actual needs.

[0085] In this embodiment, the security of the software flashing process is enhanced by introducing an encryption mechanism and summary verification. Specifically, the original data to be flashed is encrypted to form a ciphertext through a symmetric encryption algorithm. Even if the ciphertext data in transmission is intercepted, the original data cannot be directly read or tampered due to the lack of the corresponding key. In addition, the characteristics of asymmetric encryption are utilized in this application, that is, the public key can be made public, but only the corresponding private key can decrypt the data. Even if the encrypted symmetric key is intercepted, it cannot be decrypted without the correct private key, which ensures the safe transmission of the key. The summary information of the ciphertext to be flashed is calculated by a preset encryption algorithm, and then the summary is encrypted using the public key. The summary information is equivalent to creating a digital signature for the data to be flashed. When the vehicle controller receives the data, the encrypted summary can be decrypted using the private key, and then the summary of the ciphertext is recalculated and compared with the decrypted summary. If they are consistent, it proves that the data has not been modified. The integrity and non-tampering status of the data during transmission can be ensured through the summary information.

[0086] To sum up, by combining symmetric encryption, asymmetric encryption and digest verification, this embodiment can effectively prevent the flashing of illegal software, ensure the security of the software flashing process, and at the same time protect the integrity and security of the vehicle control system, thereby ensuring the normal operation and driving safety of the vehicle.

[0087] Moreover, compared to using symmetric encryption algorithm or asymmetric encryption algorithm alone, the present embodiment combines asymmetric encryption technology and symmetric encryption technology to ensure the security of the flashing process while improving the efficiency of encryption and decryption. By using asymmetric encryption technology to encrypt the key, the security of the key is ensured. During data transmission, the efficiency of symmetric encryption technology is fully utilized to speed up the flashing speed and reduce the consumption of system resources.

[0088] In a feasible implementation manner, the method further includes step S50.

[0089] Step S50: upon receiving a key update command, generating a new key based on a symmetric encryption algorithm, and updating the target key with the new key.

[0090] When the server receives the key update command sent by the host computer, it generates a new key based on the symmetric encryption algorithm, and updates the target key with the new key, so as to execute the software flashing process with the updated target key.

[0091] In this implementation, the server can reduce the security risks caused by long-term use of the key by updating the target key. Even if the old key is leaked, the attacker will not be able to use the old key to decrypt the newly transmitted data because the key has been updated. In addition, updating the key can effectively defend against replay attacks, that is, the attacker attempts to repeat or delay legitimate data transmission to deceive the recipient.

[0092] In one implementation, step S40: the step of sending the ciphertext to be flashed, the encryption key and the encryption summary to the vehicle controller includes steps S401 to S402.

[0093] Step S401, concatenating the encryption key and the ciphertext to be flashed to obtain a concatenated ciphertext.

[0094] In this implementation, the encryption key used for encryption and the ciphertext to be flashed are combined into a larger data block, called a concatenated ciphertext. In a specific implementation, the length of the encryption key can be a preset fixed length.

[0095] The form of splicing the encryption key and the ciphertext to be flashed is not limited here. The splicing can be in the form of the encryption key at the back and the ciphertext to be flashed at the front, or in the form of the encryption key at the front and the ciphertext to be flashed at the back. There is no limitation here.

[0096] Step S402, sending the concatenated ciphertext and the encrypted summary to the vehicle controller, so that the vehicle controller can decrypt the encrypted summary through the private key to obtain a decrypted summary, and when the decrypted summary verification passes, reading the encryption key from the concatenated ciphertext and decrypting it through the private key to obtain the target key, reading the ciphertext to be flashed from the concatenated ciphertext and decrypting it through the target key to obtain the data to be flashed, and flashing the data to be flashed to the preset flashing area.

[0097] The server sends the concatenated ciphertext and the encrypted summary to the vehicle controller.

[0098] The vehicle controller decrypts the encrypted summary by using the private key to obtain a decrypted summary. When the decrypted summary verification passes, the encryption key is read from the concatenated ciphertext and decrypted by using the private key to obtain the target key. The ciphertext to be flashed is read from the concatenated ciphertext and decrypted by using the target key to obtain the data to be flashed. The data to be flashed is flashed to the preset flashing area.

[0099] In one embodiment, before the step S40: sending the ciphertext to be flashed, the encryption key and the encryption summary to the vehicle controller, the method further includes steps S60 to S70.

[0100] Step S60, generating a timestamp, and adding the timestamp to the ciphertext to be flashed and the encryption key respectively.

[0101] When preparing the encrypted data to be flashed and the key used to encrypt the data, the server generates an accurate timestamp and appends it to the ciphertext to be flashed and the encryption key. It should be noted that a timestamp is a type of data containing a specific date and time, which is used to record the creation time of the data. By using a timestamp, it can be ensured that the data packet is only valid within a specific time. Data packets outside the time range will be rejected, thus preventing attackers from replaying old, valid data packets to impersonate new communications.

[0102] Step S70, based on a preset key generation algorithm, generate a first key according to a preset shared key and the timestamp, and send the first key to the vehicle controller.

[0103] The server uses a preset key generation algorithm and a pre-shared key (ie, a preset shared key) in combination with the above-mentioned timestamp to generate a new key (hereinafter referred to as the first key), and the generated first key is then sent to the vehicle controller.

[0104] It should be noted that since the first key is generated based on the timestamp and the preset shared key, only the legitimate communicating parties can correctly generate and verify this key, which enhances the security of the authentication process. Generating the first key based on the timestamp makes the first key unique, thereby enhancing the accuracy of the authentication process.

[0105] In this implementation, the preset key generation algorithm is not restricted here, and can be HMAC (Hash-based Message Authentication Code, which uses a shared key and a hash function to generate a message authentication code of a fixed length), PBKDF2 (Password-Based Key Derivation Function 2, a hash-based key derivation function) and other algorithms, which can be set according to actual needs.

[0106] In this implementation manner, the step S40: the step of sending the ciphertext to be flashed, the encryption key and the encryption summary to the vehicle controller includes step S403.

[0107] Step S403, sending the timestamped ciphertext to be flashed, the timestamped encryption key and the encrypted summary to the vehicle controller, so that the vehicle controller can extract the first timestamp in the timestamped ciphertext to be flashed and the second timestamp in the timestamped encryption key; when the first timestamp and the second timestamp are consistent, generating a second key based on the first timestamp and the preset shared key based on the preset key generation algorithm; when the first key and the second key are consistent, performing software flashing based on the timestamped ciphertext to be flashed, the timestamped encryption key and the encrypted summary.

[0108] The server sends the ciphertext to be flashed after adding the timestamp, the encryption key after adding the timestamp, and the encryption summary to the vehicle controller.

[0109] The vehicle controller extracts the first timestamp in the ciphertext to be flashed after adding the timestamp and the second timestamp in the encryption key after adding the timestamp. When the first timestamp and the second timestamp are consistent, a new key (i.e., the second key) is generated based on the preset key generation algorithm according to the first timestamp and the preset shared key. When the first key and the second key are consistent, software flashing is performed based on the ciphertext to be flashed after adding the timestamp, the encryption key after adding the timestamp and the encryption summary.

[0110] In this implementation, the security of communication is improved and various types of attacks are prevented through the combination of dynamic keys, timestamps and summary information. The use of timestamps and summary information ensures the integrity and freshness of the data and avoids the acceptance of expired or tampered data, thereby improving the security of software flashing.

[0111] Based on the first embodiment of the present application, in the second embodiment of the present application, the same or similar contents as those in the first embodiment can be referred to the above description, and will not be repeated in the following. In this embodiment, the software flashing method is applied to a vehicle controller. The following description of this embodiment is based on the software flashing device being a vehicle controller. On this basis, please refer to Figure 2 The method described includes steps A10 to A20.

[0112] Step A10, receiving and storing a private key sent by the server, wherein the private key is a private key in a preset key pair generated by the server based on an asymmetric encryption algorithm.

[0113] The server generates a preset key pair based on an asymmetric encryption algorithm and sends the private key to the vehicle controller. The vehicle controller receives and stores the private key sent by the server.

[0114] Step A20, receiving the ciphertext to be flashed, encryption key and encrypted summary sent by the server, wherein the ciphertext to be flashed is obtained by the server encrypting the data to be flashed by the encryption key, the encryption key is obtained by the server encrypting the target key generated based on the symmetric encryption algorithm by the public key in the preset key pair, the encrypted summary is obtained by the server encrypting the summary information by the public key, and the summary information is obtained by the server processing the ciphertext to be flashed by the preset encryption algorithm.

[0115] The server side generates a target key based on a symmetric encryption algorithm, and encrypts the data to be flashed with the target key to obtain the ciphertext to be flashed; generates a preset key pair based on an asymmetric algorithm, and encrypts the target key with the public key in the preset key pair to obtain an encryption key; processes the ciphertext to be flashed with the preset encryption algorithm to obtain summary information, and encrypts the summary information with the public key to obtain an encrypted summary; and sends the ciphertext to be flashed, the encryption key and the encrypted summary to the vehicle controller.

[0116] The vehicle controller receives the ciphertext to be flashed, the encryption key and the encryption summary sent by the server.

[0117] Step A30: decrypt the encrypted summary using the private key to obtain a decrypted summary.

[0118] The vehicle controller decrypts the encrypted summary using the private key to obtain a decrypted summary.

[0119] Step A40, when the post-decryption summary verification passes, decrypt the encryption key using the private key to obtain the target key, and decrypt the ciphertext to be flashed using the target key to obtain the data to be flashed.

[0120] When the post-decryption summary verification passes, the vehicle controller decrypts the encryption key using the private key to obtain the target key, and decrypts the ciphertext to be flashed using the target key to obtain the data to be flashed.

[0121] Step A50, writing the data to be written to a preset writing area.

[0122] The vehicle controller writes the data to be written to a preset writing area.

[0123] It should be noted that the specific implementations of steps A10 to A50 may refer to the various implementations in the first embodiment, and will not be described in detail here.

[0124] In this embodiment, the security of the software flashing process is enhanced by introducing an encryption mechanism and summary verification. Specifically, the original data to be flashed is encrypted to form a ciphertext through a symmetric encryption algorithm. Even if the ciphertext data in transmission is intercepted, the original data cannot be directly read or tampered due to the lack of the corresponding key. In addition, the characteristics of asymmetric encryption are utilized in this application, that is, the public key can be made public, but only the corresponding private key can decrypt the data. Even if the encrypted symmetric key is intercepted, it cannot be decrypted without the correct private key, which ensures the safe transmission of the key. The summary information of the ciphertext to be flashed is calculated by a preset encryption algorithm, and then the summary is encrypted using the public key. The summary information is equivalent to creating a digital signature for the data to be flashed. When the vehicle controller receives the data, the encrypted summary can be decrypted using the private key, and then the summary of the ciphertext is recalculated and compared with the decrypted summary. If they are consistent, it proves that the data has not been modified. The integrity and non-tampering status of the data during transmission can be ensured through the summary information.

[0125] To sum up, by combining symmetric encryption, asymmetric encryption and digest verification, this embodiment can effectively prevent the flashing of illegal software, ensure the security of the software flashing process, and at the same time protect the integrity and security of the vehicle control system, thereby ensuring the normal operation and driving safety of the vehicle.

[0126] Moreover, compared to using symmetric encryption algorithm or asymmetric encryption algorithm alone, the present embodiment combines asymmetric encryption technology and symmetric encryption technology to ensure the security of the flashing process while improving the efficiency of encryption and decryption. By using asymmetric encryption technology to encrypt the key, the security of the key is ensured. During data transmission, the efficiency of symmetric encryption technology is fully utilized to speed up the flashing speed and reduce the consumption of system resources.

[0127] In one implementation, step A50: the step of writing the data to be written to a preset writing area, includes steps A501 to A503.

[0128] Step A501, erasing the original software data stored in the first storage area, and writing the data to be flashed into the first storage area, wherein the first storage area is a software running storage area.

[0129] Before starting the update, the vehicle controller will first erase the first storage area storing the running software (ie, the software running storage area), and then write the newly downloaded data to be flashed into this area.

[0130] Step A502, verifying the data to be flashed.

[0131] The vehicle controller verifies the data to be flashed.

[0132] Step A503: if the data to be flashed passes verification, the data to be flashed is backed up to a second storage area, wherein the second storage area is a software backup storage area.

[0133] If the data to be flashed passes the verification, the vehicle controller backs up the data to be flashed to a second storage area, wherein the second storage area is a software backup storage area.

[0134] In this embodiment, backing up data through the second storage area provides an additional layer of safety, so that in case the primary storage area, that is, the first storage area, fails, the old version can be quickly restored from the backup.

[0135] In one embodiment, after step A502: verifying the data to be flushed, the method further includes step A504.

[0136] Step A504: if the data to be flashed fails verification, the data to be flashed in the first storage area is erased, and the backup software data corresponding to the original software data in the second storage area is loaded into the first storage area.

[0137] If the new software fails to pass the verification, the vehicle controller clears the new software in the first storage area and restores the previous software version from the second storage area.

[0138] By adding a software rollback mechanism, it is ensured that after the vehicle controller fails to flash its software, restarting the controller can load the original software of the controller, so that it can continue to work normally.

[0139] In one embodiment, the step A50: the step of writing the data to be written to a preset writing area, includes steps A505 to A507.

[0140] Step A505 , dividing the data to be flushed into a plurality of sub-data blocks according to a preset division rule, and assigning a unique identifier to each of the sub-data blocks.

[0141] The vehicle controller divides the data to be flashed into multiple smaller sub-data blocks, each of which has its own unique identifier. It should be noted that the preset segmentation rules are not limited here. For example, the segmentation can be based on the amount of data (for example, 1KB per block), or based on logical segmentation points (for example, the boundaries of code segments or data segments). The specific settings can be made according to actual needs.

[0142] Step A506, traverse each of the sub-data blocks, write the sub-data blocks into a preset flash writing area, and write the unique identifier of the sub-data block into a preset breakpoint information file.

[0143] The vehicle controller traverses all sub-data blocks in order, writes each sub-data block to the preset flash area, and records the unique identifier of each sub-data block in the breakpoint information file. The breakpoint information file serves as a record of progress and helps to resume operation after an abnormal interruption. By recording the unique identifier, it can track which sub-data blocks have been correctly written.

[0144] Step A507, if the vehicle controller is powered off, then after the vehicle controller is powered on, read the most recently written unique identifier from the breakpoint information file, and starting from the next sub-data block of the sub-data block corresponding to the most recently written unique identifier, execute the traversal of each sub-data block, write the sub-data block into the preset flash area, and write the unique identifier of the sub-data block into the preset breakpoint information file until each sub-data block is written into the preset flash area.

[0145] If the vehicle controller is accidentally powered off during the flashing process, when the vehicle controller is powered on again, the last successful unique identifier will be read from the breakpoint information file, and the flashing process will continue from the sub-data block after the last successful identifier until all sub-data blocks are written.

[0146] In this implementation, by segmenting data, marking unique identifiers, recording breakpoint information, and providing a power-off recovery mechanism, this process significantly improves the reliability and efficiency of software flashing. Even if an interruption occurs during the flashing process, data integrity can be ensured, avoiding unnecessary waste of resources and potential system failures.

[0147] Exemplarily, in order to help understand the technical concept or technical principle of software flashing after the present embodiment is combined with the above-mentioned embodiments one and two, a third embodiment is proposed. In this embodiment, the method for securely flashing software of an automobile controller based on multi-layer encryption technology includes three aspects: software flashing process, software rollback mechanism, and key update mechanism.

[0148] In this embodiment, please refer to Figure 3 , the software flashing process can be:

[0149] Step 1: Use RSA asymmetric encryption technology to determine the public key (n, e) and private key (n, d), where the private key (n, d) is stored in the ECU's security module HSM (Hardware Security Module). Step 2: Use AES symmetric encryption technology to determine the key K. Step 3: Flash the software encryption, use the key K to encrypt the software Msg to obtain the ciphertext Enc_Msg. Step 4: Use the hash algorithm SHA-256 to process the ciphertext Enc_Msg to obtain the abstract information Abstract_Msg. Step 5: Use the public key (n, e) to encrypt the abstract information Abstract_Msg to obtain the encrypted abstract information Enc_Abstract_Msg. Step 6: Use the public key (n, e) to encrypt the key K to obtain the encrypted key Enc_K. Step 7: Transmit the ciphertext Enc_Msg, the encrypted abstract information Enc_Abstract_Msg and the encrypted key Enc_K to the controller together. Step 8: Verify the signature. Use the same hash algorithm as in step 4 to obtain the ciphertext abstract Abstract_Msg_YZ. Use the private key (n, d) to decrypt the encrypted abstract information Enc_Abstract_Msg to obtain Abstract_Msg. If Abstract_Msg_YZ is exactly the same as Abstract_Msg, the signature verification is successful. Otherwise, the signature verification fails, and software that fails the verification is not allowed to be written to the controller. Step 9: Use the private key (n, d) to decrypt the encrypted key Enc_K to obtain the original key K. Step 10: Use the key K to decrypt the ciphertext Enc_Msg to obtain the original software Msg. Step 11: Write the original software Msg to the area specified by the controller.

[0150] In this embodiment, please refer to Figure 4 ,In the software rollback mechanism, the controller’s internal software storage area is divided into ,area A and area B. Area A is the storage area when the software is ,running normally, and area B is the backup area for normal software.

[0151] Please refer to Figure 5 ,The software rollback steps are as follows: Step 1: The controller receives the software flash ,instruction.

[0152] Step 2: Erase the software stored in area A. Step 3: Store the flashed software App_new in area A. Step 4: Verify the legitimacy of App_new. If the verification passes: Erase the backup software App1_Backup in area B, and back up the new software App_new to area B. If the verification fails: Erase the new software App_new in area A, and load the original software App1_Backup backed up in area B to area A.

[0153] In this embodiment, please refer to Figure 6 , the process of the key update mechanism is as follows: Step 1: The host computer sends a key update command and uses the new key K_new to encrypt the software original text to obtain the software ciphertext Enc_Msg. Step 2: Use the public key (n, e) of the RSA algorithm to encrypt the new key K_new to obtain the new encrypted key Enc_K_new. Step 3: Splice the encrypted key Enc_K_new with a fixed length of Len to the back of the software ciphertext Enc_Msg; Step 4: The controller receives the key update command, reads the data with a fixed Len length behind the incoming information, and uses the private key (n, d) to decrypt the encrypted key Knc_K_new to obtain the new key K_new. Step 5: Use the new key K_new to decrypt the software ciphertext Knc_Msg to obtain the software original text Msg. The remaining flashing and verification steps in the software update process are the same as the software flashing steps, and will not be repeated here.

[0154] It should be noted that the above examples are only used to understand the present application and do not constitute a limitation on the software flashing method of the present application. More simple transformations based on this technical concept are all within the scope of protection of the present application.

[0155] The present application also provides a software flashing device. The software flashing device provided by the present application adopts the software flashing method in the above embodiment, which can solve the technical problem that the safety of the vehicle control system is affected during the software flashing process. Compared with the prior art, the beneficial effects of the software flashing device provided by the present application are the same as the beneficial effects of the software flashing method provided by the above embodiment, and the other technical features in the software flashing device are the same as the features disclosed in the above embodiment method, which will not be repeated here.

[0156] The present application provides a software flashing device, which includes: at least one processor; and a memory that is communicatively connected to the at least one processor; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the software flashing method in the above-mentioned embodiment one.

[0157] Reference below Figure 7, which shows a schematic diagram of the structure of a software flashing device suitable for implementing the embodiment of the present application. The software flashing device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The software flashing device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0158] like Figure 7 As shown, the software flashing device may include a processing device 1001 (e.g., a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the software flashing device are also stored. The processing device 1001, ROM1002, and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touch pad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the software flashing device to communicate with other devices wirelessly or by wire to exchange data. Although the figure shows a software flashing device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or have alternatively.

[0159] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.

[0160] The software flashing device provided by the present application adopts the software flashing method in the above embodiment, which can solve the technical problem that the safety of the vehicle control system is affected during the software flashing process. Compared with the prior art, the beneficial effects of the software flashing device provided by the present application are the same as the beneficial effects of the software flashing method provided by the above embodiment, and the other technical features in the software flashing device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.

[0161] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.

[0162] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

[0163] The present application provides a computer-readable storage medium having computer-readable program instructions (ie, computer programs) stored thereon, and the computer-readable program instructions are used to execute the software flashing method in the above-mentioned embodiment.

[0164] The computer-readable storage medium provided in the present application may be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, systems or devices, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, system or device. The program code contained on the computer-readable storage medium may be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination of the above.

[0165] The computer-readable storage medium may be included in the software flashing device; or may exist independently without being assembled into the software flashing device.

[0166] The computer-readable storage medium carries one or more programs. When the one or more programs are executed by the software flashing device, the software flashing device implements the software flashing method provided in the above embodiment.

[0167] Computer program code for performing the operations of the present application may be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, C++, and conventional procedural programming languages ​​such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0168] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0169] The modules involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of the module does not constitute a limitation on the unit itself in some cases.

[0170] The readable storage medium provided in the present application is a computer-readable storage medium, which stores computer-readable program instructions (i.e., computer programs) for executing the above-mentioned software flashing method, and can solve the technical problem that the safety of the vehicle control system is affected during the software flashing process. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in the present application are the same as the beneficial effects of the software flashing method provided in the above-mentioned embodiment, and will not be repeated here.

[0171] The present application also provides a computer program product, including a computer program, which implements the steps of the software flashing method as described above when executed by a processor.

[0172] The computer program product provided by the present application can solve the technical problem that the safety of the vehicle control system is affected during the software flashing process. Compared with the prior art, the beneficial effects of the computer program product provided by the present application are the same as the beneficial effects of the software flashing method provided by the above embodiment, and will not be repeated here.

[0173] The above descriptions are only some embodiments of the present application, and are not intended to limit the patent scope of the present application. All equivalent structural changes made using the contents of the present application specification and drawings under the technical concept of the present application, or direct / indirect applications in other related technical fields are included in the patent protection scope of the present application.

Claims

1. A software flashing method, characterized in that: The method is applied to the server side, and the method includes: Generate a target key based on a symmetric encryption algorithm, and encrypt the data to be flashed using the target key to obtain the ciphertext to be flashed; Generate a preset key pair based on an asymmetric algorithm, encrypt the target key by using a public key in the preset key pair to obtain an encrypted key, and send a private key in the preset key pair to a vehicle controller so that the vehicle controller stores the private key; The ciphertext to be flashed is processed by a preset encryption algorithm to obtain summary information, and the summary information is encrypting by the public key to obtain an encrypted summary; The ciphertext to be flashed, the encryption key and the encrypted summary are sent to the vehicle controller, so that the vehicle controller decrypts the encrypted summary by the private key to obtain a decrypted summary; if the decrypted summary verification passes, the encryption key is decrypted by the private key to obtain the target key; the ciphertext to be flashed is decrypted by the target key to obtain the data to be flashed, and the data to be flashed is flashed to a preset flashing area.

2. The method according to claim 1, characterized in that The method further comprises: When a key update command is received, a new key is generated based on a symmetric encryption algorithm, and the target key is updated with the new key.

3. The method according to claim 1, characterized in that The step of sending the ciphertext to be flashed, the encryption key and the encryption summary to the vehicle controller comprises: Concatenating the encryption key and the ciphertext to be flashed to obtain a concatenated ciphertext; The concatenated ciphertext and the encrypted summary are sent to the vehicle controller, so that the vehicle controller can decrypt the encrypted summary through the private key to obtain a decrypted summary; if the decrypted summary verification passes, the encryption key is read from the concatenated ciphertext and decrypted through the private key to obtain the target key; the ciphertext to be flashed is read from the concatenated ciphertext and decrypted through the target key to obtain the data to be flashed; and the data to be flashed is flashed to the preset flashing area.

4. The method according to any one of claims 1 to 3, characterized in that Before the step of sending the ciphertext to be flashed, the encryption key and the encryption summary to the vehicle controller, the method further includes: Generate a timestamp, and add the timestamp to the ciphertext to be flashed and the encryption key respectively; Based on a preset key generation algorithm, generate a first key according to a preset shared key and the timestamp, and send the first key to the vehicle controller; The step of sending the ciphertext to be flashed, the encryption key and the encryption summary to the vehicle controller comprises: The timestamped ciphertext to be flashed, the timestamped encryption key and the encrypted summary are sent to the vehicle controller, so that the vehicle controller can extract the first timestamp in the timestamped ciphertext to be flashed and the second timestamp in the timestamped encryption key; when the first timestamp and the second timestamp are consistent, a second key is generated according to the first timestamp and the preset shared key based on the preset key generation algorithm; when the first key and the second key are consistent, software flashing is performed based on the timestamped ciphertext to be flashed, the timestamped encryption key and the encrypted summary.

5. A software flashing method, characterized in that: The method is applied to a vehicle controller, and the method comprises: Receive and store a private key sent by the server, wherein the private key is a private key in a preset key pair generated by the server based on an asymmetric encryption algorithm; Receive the ciphertext to be flashed, the encryption key and the encrypted digest sent by the server, wherein the ciphertext to be flashed is obtained by encrypting the data to be flashed by the server using the encryption key, the encryption key is obtained by encrypting the target key generated based on the symmetric encryption algorithm by the public key in the preset key pair by the server, the encrypted digest is obtained by encrypting the summary information by the public key by the server, and the summary information is obtained by processing the ciphertext to be flashed by the server using the preset encryption algorithm; Decrypting the encrypted summary using the private key to obtain a decrypted summary; In the case where the post-decryption digest verification passes, the encryption key is decrypted by the private key to obtain the target key, and the ciphertext to be flashed is decrypted by the target key to obtain the data to be flashed; The data to be written is written to a preset writing area.

6. The method according to claim 5, characterized in that The step of writing the data to be written to the preset writing area includes: Erasing the original software data stored in the first storage area, and writing the data to be flashed into the first storage area, wherein the first storage area is a software running storage area; Verifying the data to be flashed; If the data to be written passes the verification, the data to be written is backed up to a second storage area, wherein the second storage area is a software backup storage area.

7. The method according to claim 6, characterized in that After the step of verifying the data to be written, the method further comprises: If the data to be written fails the verification, the data to be written in the first storage area is erased, and the backup software data corresponding to the original software data in the second storage area is loaded into the first storage area.

8. The method according to any one of claims 5 to 7, characterized in that The step of writing the data to be written to the preset writing area includes: Splitting the data to be flashed into a plurality of sub-data blocks according to a preset segmentation rule, and assigning a unique identifier to each of the sub-data blocks; Traversing each of the sub-data blocks, writing the sub-data blocks into a preset flash writing area, and writing a unique identifier of the sub-data block into a preset breakpoint information file; If the vehicle controller is powered off, then after the vehicle controller is powered on, the most recently written unique identifier is read from the breakpoint information file, and starting from the next sub-data block of the sub-data block corresponding to the most recently written unique identifier, the traversal of each sub-data block is executed, the sub-data block is written into the preset flash area, and the unique identifier of the sub-data block is written into the preset breakpoint information file until each sub-data block is written into the preset flash area.

9. A software flashing device, characterized in that: The device comprises: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is configured to implement the steps of the software flashing method according to any one of claims 1 to 8.

10. A storage medium, characterized in that: The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, the steps of the software flashing method according to any one of claims 1 to 8 are implemented.

11. A computer program product, characterized in that The computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the software flashing method according to any one of claims 1 to 8 are implemented.