Encapsulation method and de-capsulation method of mirror image file, encryption equipment and communication terminal

By using T-box certificate private key encryption and symmetric encryption algorithms in image file transfer for dual encryption and splitting the image file into sub-files, the problem of data tampering and insufficient security during image file transfer is solved, and efficient data security protection is achieved.

CN119892519AActive Publication Date: 2025-04-25CHONGQING SELIS PHOENIX INTELLIGENT INNOVATION TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202510379319.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-28
Publication Date
2025-04-25
Estimated Expiration
2045-03-28

AI Technical Summary

Technical Problem

In the prior art, mirror files are easily subjected to malicious tampering during transmission, making it difficult to ensure the security of data transmission, and the existing encryption methods are relatively low in security, making it difficult to meet the growing security needs.

Method used

The target image file is encrypted once by the private key of the certificate of the vehicle communication terminal T-box to obtain the signature data; then the symmetric encryption algorithm is used to encrypt the first mirror head data, signature data and T-box certificate data to obtain the ciphertext; according to the storage information of the random number, the target image file is split into the first sub-file and the second sub-file, and the ciphertext, sub-file and random number are spliced ​​to form the encapsulated mirror file.

Benefits of technology

Through dual encryption and splitting files, the security of the image files is significantly improved, preventing data from being tampered during transmission, and even if the decryption key is leaked, the contents of the upgraded image files cannot be obtained.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119892519A_ABST
    Figure CN119892519A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of communication security, in particular to a mirror image file packaging method, a mirror image file unpackaging method, encryption equipment and a communication terminal. The encapsulation method comprises the following steps: performing primary encryption on an unencapsulated target mirror image file by adopting a private key of a certificate of a vehicle-mounted communication terminal T-box to obtain signature data; and performing secondary encryption on the first mirror image header data, the signature data and the T-box certificate data by adopting a symmetric encryption algorithm to obtain a ciphertext. Splitting the target mirror image file into a first sub-file and a second sub-file according to storage information of a random number; and splicing the size of the ciphertext, the ciphertext, the first sub-file, the random number and the second sub-file to form a packaged mirror image file. According to the invention, the communication security of the mirror image file 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 communication security technology, and to a mirror file encapsulation method, decapsulation method, encryption device and communication terminal. Background Art

[0002] Image files play a vital role in upgrading the vehicle's microcontroller unit (MCU). They are data files containing firmware or software updates, which are used to update the functions of the vehicle's MCU, fix vulnerabilities, or improve performance.

[0003] Image files are very susceptible to malicious tampering during the upgrade process, making it difficult to ensure the security of data transmission. To solve this problem, image files can be encapsulated to effectively prevent them from being intercepted during transmission, thereby ensuring data security.

[0004] However, the encryption methods used in existing solutions have low security and cannot meet the growing security needs. Summary of the invention

[0005] In order to improve the security of image files, the present application provides an image file packaging method, an unpacking method, an encryption device and a communication terminal.

[0006] In a first aspect, the present application provides a method for packaging an image file, comprising: The private key of the certificate of the vehicle communication terminal T-box is used to encrypt the unpackaged target image file once to obtain the signature data; A symmetric encryption algorithm is used to perform secondary encryption on the first image header data, the signature data and the certificate data of the T-box to obtain a ciphertext; wherein the first image header data includes storage information of the certificate, storage information of the random number and storage information of the signature data; Splitting the target image file into a first sub-file and a second sub-file according to the storage information of the random number; The size of the ciphertext, the ciphertext, the first sub-file, the random number, and the second sub-file are concatenated to form a packaged image file.

[0007] In a second aspect, the present application provides a method for unpacking an image file. The encapsulated image file is obtained according to the above method. The unpacking method includes: Obtain the size of the ciphertext, the ciphertext and the remaining data from the encapsulated image file; Decrypt the ciphertext once using a symmetric encryption algorithm to obtain first image header data, signature data and certificate data; wherein the first image header data includes: storage information of the certificate of the vehicle-mounted communication terminal T-box, storage information of the random number and storage information of the signature data; According to the storage information of the random number, the random number is removed from the remaining data to obtain the image file to be verified; Decrypting the signature data twice using the public key of the certificate to obtain reference data; If the data of the image file to be verified is consistent with the reference data, the image file to be verified is determined as the target image file.

[0008] In a third aspect, the present application provides an encryption device, comprising: at least one processor, and a memory communicatively coupled to at least one of the processors; The memory stores instructions that can be executed by at least one of the processors, and the instructions are executed by at least one of the processors so that at least one of the processors can execute the above-mentioned image file packaging method.

[0009] In a fourth aspect, the present application provides a vehicle-mounted communication terminal, including: at least one processor, and a memory communicatively coupled to at least one of the processors; The memory stores instructions that can be executed by at least one of the processors, and the instructions are executed by at least one of the processors so that at least one of the processors can execute the above-mentioned method for decapsulating the image file.

[0010] This application includes at least the following beneficial effects: This application first uses the certificate private key to encrypt the target image file once, which can ensure the integrity and authenticity of the data and prevent the data from being tampered with during transmission; then a symmetric encryption algorithm is used to encrypt the first image header data, signature data and certificate data twice, further improving the security of the data. By splitting the target image file into a first sub-file and a second sub-file according to the storage information of the random number, the target image file is prevented from being intercepted and the communication security is improved; even if the decryption key is leaked, the content of the upgraded image file cannot be obtained. The final encapsulated image file includes an initialization vector, the size of the ciphertext, the ciphertext, the first sub-file, the random number and the second sub-file. This structural design can effectively organize and manage the target image file and certificate data, and improve the security of the data. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0012] Figure 1 It is a flowchart of a method for packaging an image file provided in an embodiment of the present application; Figure 2 It is a flowchart of a method for decompressing an image file provided in an embodiment of the present application; Figure 3 It is a schematic diagram of the structure of the encryption device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0013] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0014] An embodiment of the present application provides a method for packaging an image file. The method is applicable to the case of packaging an image file. The image file may be a file for upgrading a vehicle-mounted MCU or other files.

[0015] This embodiment is executed by an encryption device, which encapsulates the unencapsulated target image file to obtain an encapsulated image file. The encapsulated image file is transmitted to the vehicle communication terminal (Telematics BOX, T-box), and the T-box then decapsulates the received image file to obtain the target image file, which is provided to the vehicle MCU for upgrading.

[0016] See also Figure 1 , the present application provides a method for packaging an image file, comprising: S110: Use the private key of the certificate of the vehicle-mounted communication terminal T-box to encrypt the unpackaged target image file once to obtain signature data.

[0017] The target image file is the file to be encapsulated, including the file used to upgrade the MCU. Any encryption algorithm can be used to encrypt the target image file once using the private key to obtain the signature data.

[0018] S120, using a symmetric encryption algorithm to perform secondary encryption on the first image header data, the signature data, and the certificate data of the T-box to obtain a ciphertext.

[0019] In the image file, the image header is a key data structure located at the beginning of the image file. It contains metadata describing the content and attributes of the image file, which is used to guide the system on how to correctly parse and process the image file. In this embodiment, the image header of the target image file is referred to as the first image header. Optionally, the certificate data (i.e., the secondary certificate of the T-box) and the signature data (RSA value) are spliced ​​in sequence behind the first image header. The storage information of the certificate data (Cert data) and the signature data (RSA value) is written into the first image header. In addition, a random number and its storage information are randomly generated, and the storage information of the random number is also written into the first image header. Then, the first image header data includes the storage information of the certificate (i.e., the secondary certificate of the T-box), the storage information of the random number, and the storage information of the signature data (RSA value). The storage information is used to indicate the storage location and occupied space of the data, for example, it can be represented by the data size and the offset address. Table 1 shows the field name, number of bytes and meaning in the first image header.

[0020] Table 1 Structure of the first mirror head

[0021] In this embodiment, the first image header data, signature data and certificate data are encrypted twice as a whole.

[0022] Then, the first image header data, signature data and T-box certificate data are taken as a data block, and the data block is encrypted twice using a symmetric encryption algorithm to obtain a ciphertext (ED), and the size of the ciphertext (ES) is calculated.

[0023] S130. Split the target image file into a first sub-file and a second sub-file according to the storage information of the random number.

[0024] If the random number is stored in the middle of the target image file, the part of the target image file before the first random number is split into a first sub-file, and the remaining part of the target image file is used as a second sub-file. The first sub-file, the random number, and the second sub-file are sequentially spliced.

[0025] S140: Concatenate the size of the ciphertext, the ciphertext, the first sub-file, the random number, and the second sub-file to form a packaged image file.

[0026] This embodiment does not limit the size of the ciphertext, the ciphertext, the first sub-file, the random number, and the splicing order of the second sub-file. In order to quickly read the data when unpacking, the size of the ciphertext (ES), the ciphertext (ED), the first sub-file (SW.TBOX.x.xx.xx.xxxx.zip1), the random number (Random data), and the second sub-file (SW.TBOX.x.xx.xx.xxxx.zip2) are sequentially spliced ​​to form a packaged image file (SW.TBOX.x.xx.xx.xxxx.bin).

[0027] The embodiment of the present application first uses the certificate private key to encrypt the target image file once, which can ensure the integrity and authenticity of the data and prevent the data from being tampered with during transmission; then a symmetric encryption algorithm is used to encrypt the first image header data, signature data and certificate data twice, further improving the security of the data. By splitting the target image file into a first sub-file and a second sub-file according to the storage information of the random number, the target image file is prevented from being intercepted and the communication security is improved; even if the decryption key is leaked, the content of the upgraded image file cannot be obtained. The final encapsulated image file includes an initialization vector, the size of the ciphertext, the ciphertext, the first sub-file, the random number and the second sub-file. This structural design can effectively organize and manage the target image file and certificate data and improve the security of the data.

[0028] Optionally, in this embodiment, when the private key of the certificate of the vehicle-mounted communication terminal T-box is used to encrypt the unpackaged target image file once, the following method is specifically adopted: First, calculate the first hash value of the target image file. For example, if the image file is SW.TBOX.x.xx.xx.xxxx.zip, calculate the SHA256 (Secure Hash Algorithm 256-bit) value of the image file. SHA256 is a cryptographic hash function. For the convenience of description and distinction, the obtained hash value is called the first hash value.

[0029] Then, an asymmetric encryption algorithm is used to encrypt the first hash value using the private key of the T-box certificate to obtain signature data. The asymmetric encryption algorithm uses a pair of keys: a public key and a private key. The public key is used to encrypt data or verify the signature, and the private key is used to decrypt data or generate a signature, using the private key of the T-box certificate (such as a secondary certificate). Optionally, this embodiment uses the RSA (Rivest-Shamir-Adleman) encryption algorithm to obtain RSA2048 signature data (RSA value). This embodiment uses public key encryption and private key decryption, without sharing private keys, reducing the risk of key leakage, and is conducive to improving the security of the target image file.

[0030] Optionally, in this embodiment, when a symmetric encryption algorithm is used to perform secondary encryption on the first image header data, the signature data, and the certificate data of the T-box to obtain a ciphertext, the symmetric encryption algorithm therein adopts the Advanced Encryption Standard with 128-bit key and CipherBlock Chaining (AES128 CBC) mode with a 128-bit key length.

[0031] AES128 CBC (AES-128 Cipher Block Chaining) mode is a symmetric encryption algorithm that requires a 128-bit key input; the data to be encrypted is divided into fixed-size blocks (128 bits for AES), and each block is XORed with the previous ciphertext block before encryption. The first block is encrypted using a randomly generated initialization vector IV to ensure that different ciphertexts are generated after the same plaintext is encrypted.

[0032] First, calculate the second hash value of the public key in the certificate (such as the root certificate) of the T-box. For example, convert the public key into DER (Distinguished Encoding Rules) format data (DERD), and calculate the MD5 (Message Digest Algorithm 5) value of the DERD. The MD5 value is used as the second hash value. Then, the second hash value is used as the key for the AES128 CBC mode. The first image header data, signature data, and T-box certificate data are encrypted twice according to the key and the initialization vector IV of the AES128 CBC mode to obtain a ciphertext. During the secondary encryption process, the first image header data, signature data, and certificate data need to be divided into blocks of fixed size. If the data length is not an integer multiple of the block size, it is necessary to use the Public Key Cryptography Standard #7 (PKCS#7) padding algorithm for padding.

[0033] Since the present embodiment adopts AES128 CBC mode for secondary encryption, it is also necessary to add the initialization vector of AES128 CBC mode when forming the encapsulated image file. For example, the initialization vector IV, the size of the ciphertext, the ciphertext, the first subfile, the random number and the second subfile are sequentially concatenated to form the encapsulated image file.

[0034] Optionally, before the unpackaged target image file is encrypted once using the private key of the certificate, this embodiment further includes a process of generating a target image file (SW.TBOX.x.xx.xx.xxxx.zip).

[0035] First, obtain the original application APP file (2-TBOX-App-A01.srec) used to upgrade the MCU. Then, generate the second image header data based on the data size and checksum of the App in the original APP file. For example, perform CRC32 (Cyclic Redundancy Check) check calculation on the data of the original APP to obtain a 32-bit checksum. In addition to the data size and checksum, the second image header also includes the MCU image header identifier, version number, timestamp for generating the second image header data, and MCU program entry. The following table shows the field names and meanings in the second image header.

[0036] Table 2 Structure of the second mirror head

[0037] Then, the second image header data is inserted into the original APP file. For example, the offset address of the second image header data in the original APP file is predefined as 0x800, and the second image header data is inserted into the offset address 0x800 of the original APP file. The file inserted with the second image header data is converted and compressed to obtain the target image file (SW.TBOX.x.xx.xx.xxxx.zip).

[0038] The following is a specific example to explain in detail the process of generating the target image file (SW.TBOX.x.xx.xx.xxxx.zip). A script (McuPack.sh) can be run to execute the generation process: 1) Initialize the production environment of the second image header and delete the MCU Flash image file that may be left over from the previous installation.

[0039] 2) Initialize the second image header structure and write the version number and timestamp.

[0040] 3) Convert the original APP file (2-TBOX-App-A01.srec) into a Bin format file (2-TBOX-App-A01.bin).

[0041] 4) Calculate the size of the original APP file data in 2-TBOX-App-A01.bin and write it to the location corresponding to the second image header.

[0042] 5) Calculate the CRC32 checksum of the original APP file data in 2-TBOX-App-A01.bin and write it to the corresponding position of the second image header.

[0043] 6) Insert the data of the second image header into the offset address 0x800 of the 2-TBOX-App-A01.bin file.

[0044] 7) Use the SRecord tool command to convert the 2-TBOX-App-A01.bin with the second image header data inserted into it into 2-TBOX-App-A01.s19 to complete the format conversion. The main function of the SRecord tool is to operate the Erasable Programmable Read-Only Memory (EPROM) to load files and support the conversion and processing of multiple file formats.

[0045] Optionally, the interrupt vector table and the configuration of the operating environment are also included before the second image header, forming the following MCU Flash file (ie, 2-TBOX-App-A01.s19). The structure of the Flash file is shown in the following table: Table 3 Flash file structure

[0046] The Interrupt Vector Table (IVT) is used to store the address of the Interrupt Service Routine (ISR). When the MCU receives an interrupt signal, it will jump to the corresponding address in the interrupt vector table according to the interrupt type, thereby executing the corresponding interrupt service routine.

[0047] 8) Compress 2-TBOX-App-A01.s19, Flash Driver (1-TBOX-Drv-D01.s19) and NAD original upgrade package (Nad.zip) to form the target image file (SW.TBOX.x.xx.xx.xxxx.zip). Among them, FlashDriver is the key component for managing and operating Flash files (i.e. 2-TBOX-App-A01.s19), responsible for implementing functions such as reading and writing, erasing, bad block management, and wear leveling. NAD (Network Access Device) original upgrade package refers to the firmware file used to update the NAD module. The NAD module is a core component of the vehicle communication system, responsible for the communication between the vehicle and external networks (such as 4G / 5G, GPS, Bluetooth, etc.). Upgrading the firmware of the NAD module can fix problems, optimize performance, or add new features.

[0048] The file directory after decompressing SW.TBOX.x.xx.xx.xxxx.zip is as follows: ├── MCU │├── 1-TBOX-Drv-D01.s19 │└── 2-TBOX-App-A01.s19 └──Nad.zip In this embodiment, the generation process of SW.TBOX.x.xx.xx.xxxx.zip is mainly the packaging process of the Flash file. By packaging the Flash file, the security of the target image file during transmission is greatly improved. Even if the target image file is intercepted during transmission, the attacker cannot obtain the content of the target image file, thereby avoiding the problem of malicious upgrade.

[0049] The following is a specific example to explain in detail the packaging process of the target image file (SW.TBOX.x.xx.xx.xxxx.zip). The packaging process can be executed by running a script (TBoxPack.sh): 1) Initialize the first image header and write a random 16-byte initialization vector IV, version number, and timestamp.

[0050] 2) Calculate the data size (SWS) of SW.TBOX.x.xx.xx.xxxx.zip.

[0051] 3) Calculate the first hash value of SW.TBOX.x.xx.xx.xxxx.zip, such as the SHA256 value (shaValue), and use the private key of the T-box secondary certificate (Cert) to encrypt and calculate shaValue to obtain the signature data (RSA value).

[0052] 4) Calculate the size of the Cert data and the size of the RSA value, and write them into the header.

[0053] 5) Concatenate the Cert data and RSA value in sequence after the header, and write the offset address of the Cert data and RSA value relative to the target image file into the header.

[0054] 6) Randomly generate a number in the range of (0, SWS) as the offset address (RO) of the random number (Random data).

[0055] 7) Randomly generate a number in the range of (0, SWS - RO) as the size of the Random data (Randomsize), and write RO and Random size into the header.

[0056] 8) Split SW.TBOX.x.xx.xx.xxxx.zip into two parts according to Random data and Random size, namely the first sub-file (SW.TBOX.x.xx.xx.xxxx.zip1) and the second sub-file (SW.TBOX.x.xx.xx.xxxx.zip2).

[0057] 9) Read the public key in the T-Box root certificate and convert it into DER format data (DERD), calculate the MD5 value of DERD, and use the MD5 value as the input key of AES128 CBC NoPadding. Then, use IV as the initialization vector of AES CBC mode and use the PKCS#7 padding algorithm for data padding. Calculate the ciphertext (ED) of header+ Cert+ RSA value. Calculate the size (ES) of ED.

[0058] 10) Concatenate in sequence: IV+ES+ED+SW.TBOX.x.xx.xx.xxxx.zip1+Random data+SW.TBOX.x.xx.xx.xxxx.zip2 to generate the encapsulated image file SW.TBOX.x.xx.xx.xxxx.bin.

[0059] The directory structure of the encapsulated target image file is as follows. After encapsulation is completed, the bin file is sent to the T-box.

[0060] ├── TBox │ ├── SW.TBOX.x.xx.xx.xxxx.zip │ └── version ├── PKI │├── root.pem │ ├── cert.pem │ └── private.key ├── SW.TBOX.x.xx.xx.xxxx.bin └── TBoxPack.sh Among them, version: T-box version number, its content will be written into the version field of the header after running TBoxPack.sh. PKI (Public Key Infrastructure) is a security framework based on public key cryptography. root.pem: T-box root certificate. cert.pem: Secondary certificate for signature verification (issued by T-box root certificate). private.key: Private key for signing. SW.TBOX.x.xx.xx.xxxx.bin: The packaged image file obtained after running the script TBoxPack.sh.

[0061] See also Figure 2 The present application provides a method for decapsulating an image file, which aims to decapsulate an encapsulated image file to obtain a target image file. The method can be executed by a vehicle-mounted communication terminal T-box. Figure 2 The methods shown include: S210. Obtain the size of the ciphertext, the ciphertext, and the remaining data from the encapsulated image file.

[0062] The size of the ciphertext is represented by a fixed-length byte, which can be read out according to the byte length in the encapsulated image file (SW.TBOX.x.xx.xx.xxxx.bin). According to the size of the ciphertext, the bytes that match the size length are read as the ciphertext. The remaining data includes the first sub-file, the random number, and the second sub-file. Currently, it is not possible to determine which of the remaining data is the first sub-file and which is the second sub-file.

[0063] S220. Decrypt the ciphertext once using a symmetric encryption algorithm to obtain first image header data, signature data, and certificate data.

[0064] The first image header data includes: storage information of the certificate of the vehicle-mounted communication terminal T-box, storage information of the random number and storage information of the signature data, and the storage information is represented by data size and offset address.

[0065] When the symmetric encryption algorithm is used for decryption, the same key as that used for encryption is required, and the first image header data, signature data and certificate data are obtained after decryption.

[0066] S230. According to the storage information of the random number, the random number is removed from the remaining data to obtain the image file to be verified.

[0067] The storage information of the random number indicates the storage location of the random number in the target image file. The remaining data is generated by inserting the random number into the target image file. Therefore, the image file can be obtained by removing the random number from the remaining data, which is called the image file to be verified.

[0068] S240: Use the public key of the certificate to perform secondary decryption on the signature data to obtain reference data.

[0069] The signature data is generated by encrypting the target image file using the private key of the secondary certificate, and the signature data is decrypted using the public key of the secondary certificate. Since the target image file has been encrypted twice, the security is higher. The data of the target image file (such as a hash value or summary, etc.) obtained by the secondary decryption in this step is called the reference data.

[0070] S250: If the data of the image file to be verified is consistent with the reference data, the image file to be verified is determined as the target image file.

[0071] For example, if the hash value of the image file to be verified is consistent with the reference data, it is considered that the image file has not been tampered with during the transmission process, and the real target image file has been obtained.

[0072] This embodiment has the following technical effects: by performing secondary decryption on the encapsulated image file and verifying the image file, the security of the image file during transmission is greatly improved. Even if the upgrade image file is intercepted during transmission, the attacker cannot obtain the content of the upgrade image file, thereby avoiding the problem of malicious upgrades and enhancing the storage security of data. This application greatly improves the security of the image file during storage by encrypting the image file. This application can effectively prevent the image file from being tampered with during transmission or storage by signing data, thereby ensuring the integrity of the upgrade image file. The encapsulation and parsing scheme of this application makes the transmission and storage of the upgrade image file more convenient, thereby optimizing the upgrade process and improving the upgrade efficiency.

[0073] Optionally, in this embodiment, when a symmetric encryption algorithm is used to decrypt the ciphertext once to obtain the first image header data, signature data and certificate data, the symmetric encryption algorithm is AES128 CBC mode. When decrypting in AES128 CBC mode, the encryption key and initialization vector IV are required, and the ciphertext is grouped into multiple ciphertext blocks according to 16 bytes. For each ciphertext block, the AES128 algorithm is used to decrypt to obtain a plaintext block, and finally each plaintext block is spliced ​​in order to obtain the first image header data, signature data and certificate data.

[0074] First, calculate the second hash value of the public key in the certificate of the T-box. For the convenience of description and distinction, the hash value of the public key is called the second hash value. The second hash value is used as the key of the AES128 CBC mode; the ciphertext is decrypted once according to the key and the initialization vector IV of the AES128 CBC mode to obtain the first image header data; the certificate data is obtained according to the storage information of the certificate in the first image header data, and the signature data is obtained according to the storage information of the signature data in the first image header data.

[0075] Optionally, in this embodiment, when removing the random number from the remaining data according to the storage information of the random number to obtain the image file to be verified, the following scheme is adopted: According to the storage information of the random number, the data segment of the random number is determined from the remaining data, that is, xx bytes to yy bytes belong to the random number. Since the random number divides the target image header file into the first sub-file and the second sub-file, the data before and after the data segment are sequentially spliced ​​to obtain the image file to be verified. Since only the target image file is split and spliced ​​with the random number during encapsulation, there is a certain security risk. At this time, the spliced ​​image file needs to be verified, which is called the image file to be verified.

[0076] Optionally, after the image file to be verified is determined as the target image file, it is necessary to parse the original APP file and the second image header data therein from the target image file. First, the target image file is decompressed and formatted to obtain the file to be parsed; then, according to the storage information of the second image header data, the second image header data and the original APP file are read from the file to be parsed; the second image header data is accessed to obtain the final parsing information.

[0077] The following is a specific implementation method to illustrate the process of parsing the original APP file and the second image header data from the target image file.

[0078] 1) Unzip the target image file and read 2-TBOX-App-A01.s19 from it, and convert 2-TBOX-App-A01.s19 to a Bin format file (2-TBOX-App-A01.bin).

[0079] 2) Load 2-TBOX-App-A01.bin. Since the storage location of the second image header (McuImageHeader_st) is offset address 0x800 and occupies 1 byte, read 1 byte of data from the offset address 0x800 at the beginning of the binary stream of the 2-TBOX-App-A01.bin file and store it in the variable (mcuImageHeader). If the data of the second image header is not read, an error message is displayed.

[0080] Remove the second image header data from 2-TBOX-App-A01.bin to obtain the original APP data in Bin format, and then perform format conversion to obtain 2-TBOX-App-A01.srec.

[0081] 3) The second image header data can be obtained by accessing the members in mcuImageHeader. If the aforementioned members are not accessed, an error message is displayed.

[0082] After unpacking, the following directory is formed: ├── MCU │├── 2-TBOX-App-A01.srec │└── version └── McuPack.sh The following is a specific implementation method to describe in detail the process of parsing the target image file from the encapsulated image file: 1) Get the encapsulated image file, including the following fields: Table 4 Image file structure after encapsulation

[0083] 2) Read the IV data (IV), encrypted data size (ES), encrypted data (ED), and remaining data in the image header.

[0084] 3) Read the public key in the T-box root certificate and convert it into DER format data (DERD).

[0085] 4) Use IV as the initialization vector of CBC mode, encrypt the MD5 value of DERD as the input key of AES128, and decrypt ED to get the plaintext (DE).

[0086] 5) Parse DE according to the second image header data structure to obtain the offset address and size of the secondary certificate data (Cert data), the offset address and size of the signature data (RSA value), and the offset address and size of the random number (Random data). Read Cert data and RSA value according to the above offset address and size.

[0087] 6) Use the T-box root certificate to verify the Cert data. If the verification fails, the process ends.

[0088] 7) If the verification passes, Randomdata is removed from the remaining data according to the offset address and size of Random data to obtain the SW.TBOX.x.xx.xx.xxxx.zip to be verified, and the SHA256 value (shaValue) of the SW.TBOX.x.xx.xx.xxxx.zip to be verified is calculated.

[0089] 8) Use Cert data to verify and calculate RSA value to obtain decodeValue (i.e. the SHA256 value of the real target image file).

[0090] 9) Compare shaValue and decodeValue. If they are different, the program ends. If they are the same, SW.TBOX.x.xx.xx.xxxx.zip is extracted.

[0091] like Figure 3 As shown, the present application provides an encryption device, comprising: at least one processor; and a memory in communication with the at least one processor; wherein, The memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor so that at least one processor can execute the above-mentioned image file packaging method. At least one processor in the encryption device can execute the above-mentioned image file packaging method, and thus has at least the same advantages as the above-mentioned image file packaging method.

[0092] The encryption device also includes interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the terminal, including instructions stored in or on a memory to display graphical information of a GUI (Graphical User Interface) on an external input / output device (such as a display device coupled to an interface). In other embodiments, if necessary, multiple processors can be used together with multiple memories, and / or multiple buses can be used together with multiple memories. Similarly, multiple electronic devices can be connected (for example, as a server array, a group of blade servers, or a multi-processor system), and each device provides some necessary operations. Figure 3 A processor 301 is taken as an example.

[0093] The memory 302 is a computer-readable storage medium that can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the image file packaging method in the embodiment of the present application. The processor 301 executes various functional applications and data processing of the encryption device by running the software programs, instructions and modules stored in the memory 302, that is, implementing the above-mentioned image file packaging method.

[0094] The memory 302 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 302 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some examples, the memory 302 may further include a memory remotely arranged relative to the processor 301, and these remote memories may be connected to the encryption device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0095] like Figure 3 As shown, the encryption device may further include: an input device 303 and an output device 304. The processor 301, the memory 302, the input device 303 and the output device 304 may be connected via a bus or other means. Figure 3 The example of connecting through bus is taken in the following.

[0096] The input device 303 can receive input digital or character information, and the output device 304 can include a display device, an auxiliary lighting device (e.g., LED), and a tactile feedback device (e.g., a vibration motor), etc. The display device can include, but is not limited to, a liquid crystal display (LCD), a light emitting diode (LED) display, and a plasma display. In some embodiments, the display device can be a touch screen.

[0097] The embodiment of the present application also provides a communication terminal, which can be mounted on a vehicle and used for vehicle communication. Figure 3 The communication terminal includes: at least one processor, and a memory connected to the at least one processor in communication; the memory stores instructions executable 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 image file decapsulation method. The communication terminal also includes an input device and an output device, which are described above for details and will not be repeated here.

[0098] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this application can be executed in parallel, sequentially or in different orders, as long as the expected results of the technical solution disclosed in this application can be achieved, and this document is not limited here.

[0099] The above specific implementations do not constitute a limitation on the protection scope of this application. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of this application should be included in the protection scope of this application.

Claims

1. A method for packaging an image file, characterized in that: include: The private key of the certificate of the vehicle communication terminal T-box is used to encrypt the unpackaged target image file once to obtain the signature data; A symmetric encryption algorithm is used to perform secondary encryption on the first image header data, the signature data and the certificate data of the T-box to obtain a ciphertext; wherein the first image header data includes storage information of the certificate, storage information of the random number and storage information of the signature data; Splitting the target image file into a first sub-file and a second sub-file according to the storage information of the random number; The size of the ciphertext, the ciphertext, the first sub-file, the random number, and the second sub-file are concatenated to form a packaged image file.

2. The method according to claim 1, characterized in that The private key of the certificate of the vehicle communication terminal T-box is used to encrypt the unpackaged target image file once to obtain the signature data, including: Calculate a first hash value of the target image file; An asymmetric encryption algorithm is adopted to encrypt the first hash value using the private key of the T-box certificate to obtain signature data.

3. The method according to claim 1, characterized in that The first image header data, the signature data and the certificate data of the T-box are encrypted twice using a symmetric encryption algorithm to obtain a ciphertext, including: Calculate a second hash value of the public key in the certificate of the T-box, and use the second hash value as a key for the Advanced Encryption Standard 128-bit cipher block chaining AES128 CBC mode; The first image header data, the signature data and the certificate data of the T-box are encrypted twice according to the key and the initialization vector IV of the AES128 CBC mode to obtain a ciphertext; The size of the ciphertext, the ciphertext, the first sub-file, the random number, and the second sub-file are concatenated to form a packaged image file, including: The initialization vector IV, the size of the ciphertext, the ciphertext, the first sub-file, the random number and the second sub-file are sequentially concatenated to form a packaged image file.

4. The method according to claim 1, characterized in that: The private key of the certificate of the vehicle communication terminal T-box is used to encrypt the unpackaged target image file once. Before obtaining the signature data, it also includes: Get the original application APP file; Generate the second image header data according to the data size and checksum of the App in the original App file; The second image header data is inserted into the original APP file, and the target image file is obtained after format conversion and compression.

5. The method for unpacking an image file is characterized in that: The encapsulated image file is obtained according to the method according to any one of claims 1 to 4; the method for decapsulating the image file comprises: Obtain the size of the ciphertext, the ciphertext and the remaining data from the encapsulated image file; Decrypt the ciphertext once using a symmetric encryption algorithm to obtain first image header data, signature data and certificate data; wherein the first image header data includes: storage information of the certificate of the vehicle-mounted communication terminal T-box, storage information of the random number and storage information of the signature data; According to the storage information of the random number, the random number is removed from the remaining data to obtain the image file to be verified; Decrypting the signature data twice using the public key of the certificate to obtain reference data; If the data of the image file to be verified is consistent with the reference data, the image file to be verified is determined as the target image file.

6. The method according to claim 5, characterized in that The symmetric encryption algorithm is used to decrypt the ciphertext once to obtain the first image header data, signature data and certificate data, including: Calculate a second hash value of the public key in the certificate of the T-box, and use the second hash value as a key for the Advanced Encryption Standard 128-bit cipher block chaining AES128 CBC mode; Decrypt the ciphertext once according to the key and the initialization vector IV of the AES128 CBC mode to obtain the first image header data; The certificate data is obtained according to the storage information of the certificate in the first image header data, and the signature data is obtained according to the storage information of the signature data in the first image header data.

7. The method according to claim 6, characterized in that According to the storage information of the random number, the random number is removed from the remaining data to obtain the image file to be verified, including: Determining a data segment of the random number from the remaining data according to the storage information of the random number; The data before and after the data segment are sequentially spliced ​​together to obtain the image file to be verified.

8. The method according to claim 6, characterized in that After the image file to be verified is determined as the target image file, the following steps are also included: Decompressing and formatting the target image file to obtain a file to be parsed; According to the storage information of the second image header data, read the second image header data and the original APP file from the file to be parsed; The second image header data is accessed to obtain final parsing information.

9. An encryption device, characterized in that include: at least one processor, and a memory communicatively coupled to at least one of the processors; The memory stores instructions executable by at least one of the processors, and the instructions are executed by at least one of the processors so that at least one of the processors can execute the image file packaging method described in any one of claims 1 to 4.

10. A communication terminal, characterized in that: include: at least one processor, and a memory communicatively coupled to at least one of the processors; The memory stores instructions that can be executed by at least one of the processors, and the instructions are executed by at least one of the processors so that at least one of the processors can execute the image file decapsulation method described in any one of claims 5-8.

Citation Information

Patent Citations

  • A method and system for protecting digital content

    CN102279908A

  • Safety secrecy method and system for data transmission

    CN113572614A

  • Signature method, signature verification method and signature verification system for custom mirror image file

    CN118797745A

  • Filter module for excuting encryption function

    KR102328597B1

  • File encrypting method and device

    US20240089095A1