Device data encryption method, computer device, storage medium and program product
By obtaining random key pool files, random seed text and key index files to generate target keys, encrypting the data of on-board ECU equipment, solving the problem of low security of equipment data in the prior art, and achieving efficient data encryption and unique key generation.
Patent Information
- Application Number
- CN202411801083.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2025-04-01
- Estimated Expiration
- 2044-12-09
AI Technical Summary
The prior art is difficult to effectively protect the equipment data of on-board ECUs that have been put into use without special hardware, resulting in low data security.
By responding to encryption instructions, the random key pool file, random seed text and key index file of the current device are obtained, and memory temporary variables and target keys are generated based on these files, thereby encrypting the device data.
It enables the encryption of device data without hardware upgrades, ensuring that the target key of each device is unique, and improving data security and cracking difficulty.
Smart Images

Figure CN119740247A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security technology, and in particular to a device data encryption method, computer equipment, storage medium and program product. Background Art
[0002] Nowadays, a lot of sensitive business data is stored in the vehicle's ECU (Electronic Control Unit), such as communication keys, autonomous driving model files, driving history trajectories, in-vehicle videos, etc. If the business data is illegally obtained, it will cause vehicle information security problems.
[0003] In order to prevent illegal access, traditional technologies require special hardware support to protect sensitive information. However, this solution cannot be applied to the in-vehicle ECUs that are already in use and do not have special hardware.
[0004] It can be seen that the existing technology still has the problem of low data security of the vehicle-mounted equipment that has been put into use. Summary of the invention
[0005] Based on this, it is necessary to provide a device data encryption method, computer device, storage medium and program product that can improve the security of device data in response to the above technical problems.
[0006] In a first aspect, the present application provides a device data encryption method, the device data encryption method comprising:
[0007] In response to the encryption instruction, obtaining a random key pool file, a random seed text, and a key index file of the current device;
[0008] Generate a temporary memory variable based on the key index file and the random key pool file;
[0009] Generate a target key based on the random seed text and the temporary memory variable;
[0010] The device data of the current device is encrypted based on the target key to obtain ciphertext data.
[0011] In one embodiment, the random key pool file is generated by a key pool generator outside the current device and burned into the current device; generating the random key pool file includes:
[0012] Generate a binary byte matrix based on a preset number of rows and a preset number of columns;
[0013] Based on a random number generator, binary data of each element in the binary byte matrix is generated in sequence to obtain a random key pool file; the binary data is a random number of a preset byte size.
[0014] In one embodiment, obtaining a random key pool file, a random seed text, and a key index file of the current device includes:
[0015] Get the random key pool file and random seed text of the current device;
[0016] A key index file is generated based on the matrix dimension of the random key pool file and a random number generator.
[0017] In one embodiment, generating a key index file based on the matrix dimension and random number generator of the random key pool file includes:
[0018] Based on the random number generator, generate a first random value and a second random value;
[0019] Perform a modulo operation on the number of matrix columns of the random key pool file and the first random value to obtain a random index abscissa;
[0020] Perform a modulo operation on the number of matrix rows of the random key pool file and the second random value to obtain a random index ordinate;
[0021] Based on the random index abscissa and the random index ordinate, the key index file is obtained.
[0022] In one embodiment, generating a temporary memory variable based on the key index file and the random key pool file includes:
[0023] Determine a data selection range based on the key index file;
[0024] Select part or all of the data corresponding to the data selection range in the random key pool file to obtain a temporary memory variable.
[0025] In one embodiment, generating a target key based on the random seed text and the temporary memory variable includes:
[0026] Perform splicing based on the random seed text and the temporary memory variable to obtain spliced data;
[0027] A hash operation is performed based on the concatenated data to generate the target key.
[0028] In one embodiment, after generating the target key based on the random seed text and the temporary memory variable, the method further includes:
[0029] Delete the temporary memory variable.
[0030] In a second aspect, the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the above method when executing the computer program.
[0031] In a third aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the method described above when executed by a processor.
[0032] In a fourth aspect, the present application provides a computer program product, which implements the method described above when executed by a processor.
[0033] The above-mentioned device data encryption method, computer device, storage medium and program product obtain the random key pool file, random seed text and key index file of the current device by responding to the encryption instruction; generate a temporary memory variable based on the key index file and the random key pool file; generate a target key based on the random seed text and the temporary memory variable; encrypt the device data of the current device based on the target key to obtain ciphertext data, and can implement the encryption process of business data without upgrading the hardware of the device. Since the encryption key is generated based on the random seed text, the random key pool file and the key index file, it can ensure that the target key of each device is unique, and one machine and one secret are achieved, which can effectively increase the difficulty of cracking by a third party and achieve the effect of improving the security of device data. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A diagram of an application environment of a device data encryption method in an embodiment;
[0035] Figure 2 It is a schematic diagram of a flow chart of a device data encryption method in one embodiment;
[0036] Figure 3 A schematic diagram of a process for generating a random key pool file in one embodiment;
[0037] Figure 4 A schematic diagram of a process for generating a target key in one embodiment;
[0038] Figure 5 It is a flowchart of a method for encrypting device data in another embodiment;
[0039] Figure 6 It is a structural block diagram of a device data encryption apparatus in one embodiment;
[0040] Figure 7 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0042] The device data encryption method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. It can be understood that the device data of the present application can be not limited to the device data encryption of the vehicle-mounted electronic control unit ECU, and can also be applied to the data encryption of other terminals. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The terminal 102 responds to the encryption instruction, obtains the random key pool file, random seed text and key index file of the current device; based on the key index file and the random key pool file, a temporary memory variable is generated; based on the random seed text and the temporary memory variable, a target key is generated; based on the target key, the device data of the current device is encrypted to obtain ciphertext data. Among them, the terminal 102 can be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented with an independent server or a server cluster consisting of multiple servers.
[0043] In one embodiment, Figure 2 As shown, a device data encryption method is provided, which is applied to Figure 1 The terminal 102 in the example is used as an example to illustrate, and the following steps are included:
[0044] Step S100, in response to the encryption instruction, obtain the random key pool file, random seed text and key index file of the current device.
[0045] The random key pool file may be a random key set that is pre-generated and stored in a protected storage location, and the random key may be used for subsequent encryption operations. The random key pool file may be generated by a key pool generator of an external device or by a key pool generator inside the device.
[0046] The random seed text may be a random value generated by a random number generator. For example, the first encryption may be generated based on an encryption instruction, and the random seed text may be saved. When the new device data is encrypted again or the ciphertext data is decrypted, the random seed text may be obtained to perform the method steps of this embodiment to generate the target key. Furthermore, when the random seed text needs to be updated, the target key may be generated based on the original random seed text and decrypted, and then a new random seed text may be generated to generate an updated target key, and encryption may be performed based on the new target key.
[0047] The key index file is used to indicate how to select one or more keys from the random key pool file for generating a target key. It may include one or more key selection rules, or provide information that matches the built-in selection rules of the device. For example, when it is known that the current device includes three built-in selection rules, the key index file provides information that matches the selection rules of the device, which may be a number that records one of the key selection rules, so that the current device obtains the key according to the selected built-in key selection rule.
[0048] By introducing diverse key sources, it is more difficult for attackers to crack the keys, thereby improving data security.
[0049] Step S200, generating a temporary memory variable based on the key index file and the random key pool file.
[0050] Among them, selecting a suitable key or key combination from the random key pool file and loading it into the memory as a temporary variable can be performed by obtaining the required data from the random key pool file according to the key index file, thereby obtaining the memory temporary variable. The memory temporary variable may include some or all of the candidate keys in the random key pool file. Furthermore, after obtaining the required data, the required data can be further processed, such as modulo operation, hash operation, etc., to obtain the memory temporary variable.
[0051] The target key is generated by obtaining multiple bytes from the random key pool file through the key index file. The bytes in the random key pool file are extracted through the key index file, making it difficult for a third party to obtain the complete target key when analyzing the current device. Compared with hard coding in the current device, it can increase the difficulty for a third party to analyze the current device and obtain the target key. By dynamically constructing a temporary key, the risk of long-term storage of a single fixed key is reduced, while ensuring the flexibility and security of the encryption process. Loading it into the memory as a temporary variable can reduce the risk of directly exposing the key. After the target key is generated, the temporary variable in the memory will be cleared.
[0052] Step S300, generating a target key based on the random seed text and the temporary memory variable.
[0053] Among them, it is possible to intercept part of the random seed text and the memory temporary variable according to the preset rules, or use the whole of it, and use the encryption algorithm to generate the target key. The encryption algorithm can be, for example, a hash function or other forms of key derivation functions, etc., which are not limited in this embodiment.
[0054] Step S400: encrypt the device data of the current device based on the target key to obtain ciphertext data.
[0055] Among them, device data refers to sensitive data that needs to be encrypted in the current device. For example, device data may include business data such as communication keys used for communication and interaction with other devices, autonomous driving model files, driving history trajectories, and in-car videos. For example, when the communication key needs to be encrypted as device data, the target key is generated through the random key pool file, random seed text, and key index file of the current device, and the communication key is encrypted by the target key to obtain ciphertext data.
[0056] Encryption through the selected target key can ensure that the ciphertext data can only be decrypted when the target key is correct. To encrypt device data, the target key can be used to encrypt the device data using a symmetric encryption algorithm to obtain ciphertext data.
[0057] Furthermore, when the device data needs to be used, the target key can be generated through the random key pool file, random seed text and key index file of the current device, and the ciphertext data can be decrypted through the target key to obtain the device data, so that the device data can be used and further processed.
[0058] The device data of the current device is encrypted based on the target key to obtain ciphertext data. The symmetric encryption method may be used to encrypt the device data using the target key, so that the ciphertext data obtained after encryption cannot be directly read.
[0059] It is understandable that after obtaining the ciphertext data, it also includes deleting the target key in the device memory to prevent the attacker from obtaining the target key by reading the memory.
[0060] A device data encryption method provided in this embodiment obtains a random key pool file, a random seed text, and a key index file of the current device in response to an encryption instruction; generates a temporary memory variable based on the key index file and the random key pool file; generates a target key based on the random seed text and the temporary memory variable; encrypts the device data of the current device based on the target key to obtain ciphertext data. The encryption process of business data can be implemented without upgrading the hardware of the device. Since the encryption key is generated based on the random seed text, the random key pool file, and the key index file, it can ensure that the target key of each device is unique, and one machine and one secret are implemented, which can effectively increase the difficulty of cracking by a third party and achieve the effect of improving the security of device data.
[0061] In one embodiment, generating the random key pool file includes:
[0062] Generate a binary byte matrix based on a preset number of rows and a preset number of columns;
[0063] Based on a random number generator, binary data of each element in the binary byte matrix is generated in sequence to obtain a random key pool file; the binary data is a random number of a preset byte size.
[0064] The random key pool file is generated by a key pool generator outside the current device and burned into the current device.
[0065] The random key pool file includes a binary byte matrix. The binary byte matrix includes a preset number of rows × a preset number of columns of key elements, so that the random key pool file will include a preset number of rows × a preset number of columns of independent keys or key fragments. Each element can be represented by binary data.
[0066] The binary byte matrix is generated based on the preset number of rows and the preset number of columns, and an empty matrix of a corresponding size is created according to the determined preset number of rows and the preset number of columns.
[0067] A random number generator is an algorithm or hardware device used to generate true random or pseudo-random values. By generating random numbers, the randomness and security of the key can be further improved.
[0068] The preset byte size may be the size of the space occupied by each element. For example, a length of one byte, two bytes, etc. may be used to generate random numbers. The length of binary data may be set according to actual needs, and this embodiment does not limit this.
[0069] By filling the created empty matrix with a verified random number generator, it can be ensured that each part of the key pool file is highly unpredictable. If the quality of the random number generator is high enough, the key pool file will be difficult to guess or copy.
[0070] Furthermore, the random key pool file can also provide information of a preset number of rows and a preset number of columns before the matrix, so that when the target key is subsequently generated, the relevant information of the random key pool file can be obtained more efficiently, thereby improving the speed of generating the target key.
[0071] A device data encryption method provided in this embodiment generates binary data of each element in the binary byte matrix in sequence based on a random number generator to obtain a random key pool file; the binary data is a random number of a preset byte size, which can greatly increase the difficulty for an attacker to try to obtain a target key, and can improve data protection capabilities without changing the existing vehicle-mounted ECU hardware, thereby achieving the effect of improving device data security.
[0072] In one embodiment, obtaining a random key pool file, a random seed text, and a key index file of the current device includes:
[0073] Get the random key pool file and random seed text of the current device;
[0074] A key index file is generated based on the matrix dimension of the random key pool file and a random number generator.
[0075] In this embodiment, the key index file is based on the matrix dimension and random number generator of the random key pool. The matrix dimension is the number of rows and columns of the binary byte matrix in the random key pool file. When the number of rows and columns is added to the preamble of the random key pool file, the number of rows and columns can be directly read to obtain the matrix dimension information, thereby eliminating the need to traverse the binary byte matrix to determine the matrix dimension, thereby improving the generation efficiency of the target key.
[0076] The key index file may include one or more index coordinates, each of which may be used to index a specific element in the random key pool file. Exemplarily, the maximum values of the index horizontal coordinate and the index vertical coordinate may be determined according to the matrix dimension of the random key pool file, thereby generating one or more index coordinates based on a random number generator within the maximum value range. Further, the number of index coordinates to be generated may be determined according to the preset number of coordinates, and then the index coordinates may be generated.
[0077] When there are multiple index coordinates, the binary data corresponding to the multiple index coordinates may be obtained separately, the binary data may be pieced together, and further processed, for example, by hash operation, to obtain a temporary memory variable; or the data at a specific position in the binary data corresponding to the multiple index coordinates may be obtained separately, and a temporary memory variable may be obtained by pieced together; or other methods may be used to obtain a temporary memory variable using multiple index coordinates, which are not limited in this embodiment.
[0078] The device data encryption method provided in this embodiment not only improves the security of the data encryption process but also maintains a certain degree of operational flexibility by dynamically generating a key index file and combining it with a static random key pool file and a random seed text. It can enhance data protection capabilities without changing existing hardware, thereby achieving the effect of improving device data security.
[0079] In one embodiment, generating a key index file based on the matrix dimension and random number generator of the random key pool file includes:
[0080] Based on the random number generator, generate a first random value and a second random value;
[0081] Perform a modulo operation on the number of matrix columns of the random key pool file and the first random value to obtain a random index abscissa;
[0082] Perform a modulo operation on the number of matrix rows of the random key pool file and the second random value to obtain a random index ordinate;
[0083] Based on the random index abscissa and the random index ordinate, the key index file is obtained.
[0084] In this embodiment, the random index abscissa and the random index ordinate are obtained by modulo operation, so that the random index abscissa and the random index ordinate do not exceed the dimension of the binary byte matrix. The first random value and the second random value can be random values generated within a preset value range.
[0085] The key index file is obtained based on the random index abscissa and the random index ordinate. The index coordinates are obtained by combining the random index abscissa and the random index ordinate and written into the key index file.
[0086] It is understandable that multiple groups of first random values and second random values can be generated based on a random number generator, and modulus operations of the number of matrix columns and the number of matrix rows are performed respectively to obtain multiple index coordinates, so that the key index file includes multiple index coordinates.
[0087] A device data encryption method provided in this embodiment randomly selects a key position in a key pool, so that even if an attacker has access to a random key pool file, it is still difficult to guess the key actually used, thereby avoiding the storage of a large amount of fixed key index information, simplifying the management process while saving storage space, and maintaining good flexibility and efficiency, thereby achieving the effect of improving the security of device data.
[0088] In one embodiment, generating a temporary memory variable based on the key index file and the random key pool file includes:
[0089] Determine a data selection range based on the key index file;
[0090] Select part or all of the data corresponding to the data selection range in the random key pool file to obtain a temporary memory variable.
[0091] When there is only one index coordinate in the key index file, the first or second part of the random key pool file divided by the index coordinate may be selected as the data selection range according to the index coordinate.
[0092] In a specific embodiment, when the number of matrix rows is 6, the number of matrix columns is 6, and the index coordinate is (3, 2), when selecting the first part, the range within 3 rows and within 2 rows in the byte matrix can be selected as the data selection range, or the first 2 rows in the byte matrix and the range from the 1st column of the 3rd row to the 2nd column can be selected as the data selection range; when selecting the second part, data outside the range within 3 rows and within 2 rows in the byte matrix can be selected as the selected data; or all data in the 3rd row, the 3rd to the 6th columns, and the 4th to the 6th rows can be selected.
[0093] When the key index file includes multiple index coordinates, the corresponding element in the random key pool file may be selected in sequence according to each index coordinate.
[0094] Selecting part or all of the data corresponding to the data selection range in the random key pool file to obtain a temporary memory variable. Selecting part of the data corresponding to the data selection range may be selecting data at a specific position in each element to obtain a temporary memory variable.
[0095] The temporary memory variable is obtained according to the selected data, which can be obtained by splicing multiple data. Furthermore, the splicing order of the multiple data can be according to the arrangement order of each element in the random key pool file, or according to the arrangement order of multiple index coordinates in the key index file, or can be arranged and spliced according to other preset arrangement orders.
[0096] A device data encryption method provided in this embodiment obtains a temporary memory variable by selecting part or all of the data corresponding to the data selection range in the random key pool file. The necessary key material can be extracted from the pre-prepared random key pool file efficiently and securely, thereby improving the security of data processing and optimizing memory usage efficiency, thereby achieving the effect of improving the security of device data.
[0097] In one embodiment, generating a target key based on the random seed text and the temporary memory variable includes:
[0098] Perform splicing based on the random seed text and the temporary memory variable to obtain spliced data;
[0099] A hash operation is performed based on the concatenated data to generate the target key.
[0100] The random seed text and the temporary memory variable may be connected to form a new data string or character string. In another embodiment, the random seed text and the temporary memory variable may be alternately inserted to obtain alternately inserted data, and a hash operation may be performed based on the alternately inserted data to generate the target key.
[0101] The hash operation can be performed using an existing secure hash function, such as SHA-256, SHA-3, etc.
[0102] The key obtained after the hash operation is the target key, which represents the unique summary of the input data.
[0103] The device data encryption method provided in this embodiment combines random seed text and temporary memory variables and performs hash operations to generate a target key that is not only difficult to guess, but also may be different each time the key is generated, which increases the complexity and security of the system. When the input data is the same, the consistency of the target key during the encryption and decryption process can be ensured, thereby achieving the effect of improving the security and stability of device data.
[0104] In one embodiment, after generating the target key based on the random seed text and the temporary memory variable, the method further includes:
[0105] Delete the temporary memory variable.
[0106] Deleting temporary memory variables can be done by overwriting or clearing them, or by using a safe deletion algorithm or library function.
[0107] The present embodiment provides a device data encryption method, which deletes the temporary memory variable. Since the temporary memory variable is used to generate a target key, after the target key is generated, the temporary memory variable is deleted, which is beneficial to prevent attackers from obtaining sensitive information by means of memory transfer or side channel attacks. Even if the attacker can access the physical memory of the device, it is difficult to recover useful information, reducing the attack surface, thereby achieving the effect of improving the security and stability of device data.
[0108] In order to more clearly illustrate the technical solution of the present application, the present application also provides a detailed embodiment.
[0109] In one embodiment, a device data encryption method is provided, comprising:
[0110] 1. Firmware packaging and burning stage
[0111] The KPF (Key Pool File) is packaged into the firmware of the vehicle ECU and enters the vehicle ECU through the vehicle ECU firmware burning process. The randomness and business independence of KPF ensure that attackers cannot obtain the encryption key by analyzing the firmware package of the vehicle ECU (for example, it is impossible to obtain valid key information from KPF through string search).
[0112] Step S1.1, KPF generation process.
[0113] The maximum KPF is generated based on the available storage space of the vehicle ECU. The larger the KPF, the more time it takes for the attacker to analyze the key. The main purpose of generating KPF outside the vehicle is that compared with the random number generation capability inside the ECU, more random number generation systems can be used outside, and professional true random generators can be used. The generation of KPF is implemented using a key pool generator (KPG). The execution steps of KPG are as follows:
[0114] a. Initialize a file for storing the contents of KPF, where the first line of the file records the row size (M) of the binary random byte matrix, the second line of the file records the column size (N) of the binary random byte matrix, and the third line starts to store the contents of the binary random byte matrix;
[0115] b. The random number generator generates a random number of 1 byte each time and stores them in the positions of 1×1, 1×2, ..., 1×N, ..., M×N in sequence;
[0116] c. Output matrix data as KPF file.
[0117] Step S1.2: Pack KPF into the vehicle ECU firmware to form the final firmware for burning the vehicle ECU.
[0118] Step S1.3, write the KPF into the storage of the ECU through production line burning or OTA and other ECU burning methods.
[0119] 2. Vehicle ECU key initialization stage
[0120] The main task of the vehicle ECU key initialization phase is to generate a random seed text seed, a key index file KIF, and then use the multi-dimensional key derivator MDKD (Multi-Dimensional Key Derivator) to generate the target key WK used in the third and fourth stages with the random seed text seed, the key index file KIF and the random key pool file KPF as input parameters. Since the random seed text seed and KIF are independently generated inside the ECU, each vehicle ECU can generate a different WK. The specific process is as follows:
[0121] Step S2.1, generate a random seed text seed and store it in the storage of the ECU for use when generating WK next time. The ECU uses a random number generator to generate a 32-byte random number and stores it in the storage medium inside the ECU. Since the random seed text seed is generated independently by each ECU, it ensures that the target key WK generated by each ECU is different.
[0122] like Figure 3 As shown, step S2.2 generates a key index file KIF and stores it in the storage of the ECU for use when the target key WK is generated next time, including:
[0123] Step S2.2.1, read the M in the first line and the N in the second line of the random key pool file KPF stored in the ECU storage in step S1.3.
[0124] Step S2.2.2, the random number generator generates a 32-byte random number InRandom. Since each InRandom is independently generated by an ECU, it ensures that the WK generated by each ECU is different.
[0125] Step S2.2.3, calculate the random index vertical coordinate RowStartbit=InRandom mode M, the random index horizontal coordinate ColumnStartbit=InRandom mode N, and delete InRandom to prevent the attacker from performing a memory dump attack.
[0126] Step S2.2.4, write the above random index ordinate RowStartbit and random index abscissa ColumnStartbit into the key index file KIF, and store the key index file KIF in the storage inside the ECU.
[0127] Next, the multidimensional key derivation device MDKD is used to generate the target key WK used in the third and fourth stages with the random seed text seed, the key index file KIF and the random key pool file KPF as input parameters.
[0128] Step S2.3, generating a temporary memory variable bytes2bit-Matrix, including:
[0129] Step S2.3.1, initialize a structure in the memory denoted as bytes2bit-Matrix.
[0130] Step S2.3.2, read the key index file KIF generated in step S2.2, and store the random index horizontal coordinate RowStartbit and the random index vertical coordinate ColumnStartbit into a temporary memory structure, namely, the index coordinate (RowStartbit, ColumnStartbit).
[0131] Step S2.3.3, read all the data after (RowStartbit, ColumnStartbit) in the third part of the random key pool file KPF stored in the ECU storage in step S1.3, and store it in the temporary memory variable bytes2bit-Matrix variable.
[0132] like Figure 4 As shown, step S2.4, generating WK, includes:
[0133] Step S2.4.1, initialize a temporary variable WK in the memory to store the following calculation results.
[0134] Step S2.4.2, read step S2.1, and determine the seed value in the random seed text seed.
[0135] Step S2.4.3, store and read the calculation result of the bytes2bit-Matrix common input hash function generated in step S2.3.3 and store it in the target key WK.
[0136] Step S2.4.4, delete the temporary memory variable bytes2bit-Matrix to prevent the attacker from performing a memory dump attack.
[0137] 3. Business Data Encryption Phase
[0138] The main work of the business encryption phase is to use the WK generated in the key WK generation phase as the target key to encrypt the business data (textdata) into ciphertext data (encryptedata), and then store the ciphertext data encryptedata in the storage of the ECU, and delete the target key WK to prevent the attacker from memory dump attacks and business data textdata. The business data in this embodiment is the device data.
[0139] 4. Business Data Decryption Phase
[0140] The main task of the business encryption and decryption segment is to use the WK generated in the key WK generation phase as the key to decrypt the ciphertext data (encryptedata) into business data (textdata), and delete the WK to prevent memory dump attacks by attackers.
[0141] It is understandable that the random key pool file KPF of the present application can be generated outside the vehicle ECU or inside the vehicle ECU. The random seed text can be a random number generated inside the vehicle ECU or can be replaced by the hardware ID of the vehicle ECU.
[0142] In a specific embodiment, before the automatic driving system (ADS) is installed on the vehicle, there is a business requirement that the communication key SecocKey of the security onboard communication SecOC (Security Onboard Communication) must not be stored in plain text. The communication key SecocKey can be used as device data to execute the device data encryption method of any embodiment of the present application, such as Figure 5 Specifically, in the ADS firmware system and related packaging and release system:
[0143] In the stage of packaging KPF into ADS firmware: the function of the key pool generator KPG is implemented in the packaging and release system, and the information security administrator uses KPG to generate the necessary random key pool file KPF.
[0144] ADS internally generates the target key MK phase: ADS internally implements the key index file KIF, generates the random seed text seed, generates the target key WK through the multidimensional key derivator MDKD, and configures the universal standard AES-256 encryption algorithm.
[0145] Equipment data encryption and decryption stage: When the production line injects equipment data SecocKey into ADS, the ADS system uses the generated target key WK as the encryption key to encrypt SecocKey, encrypts the equipment data SecocKey to generate ciphertext data EncryptoSecocKey, and stores it in the internal flash of ADS. At the same time, the target WK and intermediate process data are cleared from the memory;
[0146] When ADS needs to use the device data SecocKey, the same method as in step S2 can be used to calculate the target key WK at zero time, and the AES-256 decryption algorithm can be used, with WK as the key and EncryptoSecocKey as the ciphertext to decrypt the device data SecocKey. At the same time, the target key WK and process data are deleted. The ADS system uses the device data SecocKey for normal business and deletes the device data SecocKey after execution.
[0147] The present embodiment provides a device data encryption method, which obtains a random key pool file, a random seed text and a key index file of the current device in response to an encryption instruction; generates a temporary memory variable based on the key index file and the random key pool file; generates a target key based on the random seed text and the temporary memory variable; encrypts the device data of the current device based on the target key to obtain ciphertext data, and can implement the encryption process of business data without upgrading the hardware of the device. Since the encryption key is generated based on the random seed text, the random key pool file and the key index file, it can ensure that the target key of each device is unique, and one machine and one secret are achieved, thereby effectively improving the difficulty of cracking by a third party and achieving the effect of improving the security of device data; by sequentially generating binary data of each element in the binary byte matrix based on a random number generator, a random key pool file is obtained; the binary data is a random number of a preset byte size, which can greatly increase the difficulty for an attacker to try to obtain the target key, and can improve the data protection capability without changing the existing vehicle-mounted ECU hardware, thereby achieving the effect of improving the security of device data; by dynamically generating a key index file and combining it with a static random key pool file and a random seed text, it is not necessary to The method not only improves the security of the data encryption process, but also maintains a certain degree of operational flexibility, and can improve the data protection capability without changing the existing hardware, thereby achieving the effect of improving the data security of the device; by randomly selecting the key position in the key pool, even if the attacker has access to the random key pool file, it is still difficult to guess the key actually used, avoiding the storage of a large amount of fixed key index information, simplifying the management process while saving storage space, and maintaining good flexibility and efficiency, thereby achieving the effect of improving the data security of the device; by selecting part or all of the data corresponding to the data selection range in the random key pool file to obtain a temporary memory variable, the necessary key material can be efficiently and securely extracted from the pre-prepared random key pool file, thereby improving the security of data processing and optimizing the memory usage efficiency, thereby achieving the effect of improving the data security of the device; by combining the random seed text and the temporary memory variable, and after a hash operation, the generated target key is not only difficult to guess, but also the key generated each time may be different, which increases the complexity and security of the system, and when the input data is the same, the consistency of the target key in the encryption and decryption process can be ensured, thereby achieving the effect of improving the data security and stability of the device;By deleting the temporary memory variable, since the temporary memory variable is used to generate the target key, after the target key is generated, the temporary memory variable is deleted, which is conducive to preventing attackers from obtaining sensitive information by using memory dump or side channel attack. Even if the attacker can access the physical memory of the device, it is difficult to recover useful information, reducing the attack surface, thereby achieving the effect of improving the security and stability of device data. ;
[0148] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0149] Based on the same inventive concept, the embodiment of the present application also provides a device data encryption device for implementing the device data encryption method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more device data encryption device embodiments provided below can refer to the limitations on the device data encryption method above, and will not be repeated here.
[0150] In one embodiment, Figure 6 As shown, a device data encryption device is provided, comprising: an acquisition module, a generation module, a key module and an encryption module, wherein:
[0151] An acquisition module, used to acquire a random key pool file, a random seed text, and a key index file of a current device in response to an encryption instruction;
[0152] A generation module, used to generate a temporary memory variable based on the key index file and the random key pool file;
[0153] A key module, used for generating a target key based on the random seed text and the temporary memory variable;
[0154] The encryption module is used to encrypt the device data of the current device based on the target key to obtain ciphertext data.
[0155] In one embodiment, the random key pool file is generated by a key pool generator outside the current device and burned into the current device; generating the random key pool file includes:
[0156] Generate a binary byte matrix based on a preset number of rows and a preset number of columns;
[0157] Based on a random number generator, binary data of each element in the binary byte matrix is generated in sequence to obtain a random key pool file; the binary data is a random number of a preset byte size.
[0158] In one embodiment, the acquisition module is further used for:
[0159] Get the random key pool file and random seed text of the current device;
[0160] A key index file is generated based on the matrix dimension of the random key pool file and a random number generator.
[0161] In one embodiment, the acquisition module is further used for:
[0162] Based on the random number generator, generate a first random value and a second random value;
[0163] Perform a modulo operation on the number of matrix columns of the random key pool file and the first random value to obtain a random index abscissa;
[0164] Perform a modulo operation on the number of matrix rows of the random key pool file and the second random value to obtain a random index ordinate;
[0165] Based on the random index abscissa and the random index ordinate, the key index file is obtained.
[0166] In one embodiment, the generating module is further used for:
[0167] Determine a data selection range based on the key index file;
[0168] Select part or all of the data corresponding to the data selection range in the random key pool file to obtain a temporary memory variable.
[0169] In one embodiment, the key module is further used for:
[0170] Perform splicing based on the random seed text and the temporary memory variable to obtain spliced data;
[0171] A hash operation is performed based on the concatenated data to generate the target key.
[0172] In one embodiment, the key module is further used for:
[0173] Delete the temporary memory variable.
[0174] Each module in the above-mentioned device data encryption device can be implemented in whole or in part by software, hardware and their combination. Each module can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module above.
[0175] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7 As shown. The computer device includes a processor, a memory and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store a random key pool file, a random seed text and a key index file. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a device data encryption method is implemented.
[0176] Those skilled in the art will understand that Figure 7 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0177] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the device data encryption method of any of the above embodiments is implemented:
[0178] In response to the encryption instruction, obtaining a random key pool file, a random seed text, and a key index file of the current device;
[0179] Generate a temporary memory variable based on the key index file and the random key pool file;
[0180] Generate a target key based on the random seed text and the temporary memory variable;
[0181] The device data of the current device is encrypted based on the target key to obtain ciphertext data.
[0182] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the device data encryption method of any of the above embodiments is implemented:
[0183] In response to the encryption instruction, obtaining a random key pool file, a random seed text, and a key index file of the current device;
[0184] Generate a temporary memory variable based on the key index file and the random key pool file;
[0185] Generate a target key based on the random seed text and the temporary memory variable;
[0186] The device data of the current device is encrypted based on the target key to obtain ciphertext data.
[0187] In one embodiment, a computer program product is provided. When the computer program is executed by a processor, the device data encryption method of any of the above embodiments is implemented:
[0188] In response to the encryption instruction, obtaining a random key pool file, a random seed text, and a key index file of the current device;
[0189] Generate a temporary memory variable based on the key index file and the random key pool file;
[0190] Generate a target key based on the random seed text and the temporary memory variable;
[0191] The device data of the current device is encrypted based on the target key to obtain ciphertext data.
[0192] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0193] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0194] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0195] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A device data encryption method, characterized in that: The device data encryption method comprises: In response to the encryption instruction, obtaining a random key pool file, a random seed text, and a key index file of the current device; Generate a temporary memory variable based on the key index file and the random key pool file; Generate a target key based on the random seed text and the temporary memory variable; The device data of the current device is encrypted based on the target key to obtain ciphertext data.
2. The device data encryption method according to claim 1, characterized in that: The random key pool file is generated by a key pool generator outside the current device and burned into the current device; Generating the random key pool file includes: Generate a binary byte matrix based on a preset number of rows and a preset number of columns; Based on a random number generator, binary data of each element in the binary byte matrix is generated in sequence to obtain a random key pool file; the binary data is a random number of a preset byte size.
3. The device data encryption method according to claim 1, characterized in that: The obtaining of the random key pool file, random seed text and key index file of the current device includes: Get the random key pool file and random seed text of the current device; A key index file is generated based on the matrix dimension of the random key pool file and a random number generator.
4. The device data encryption method according to claim 3, characterized in that: The generating of the key index file based on the matrix dimension and the random number generator of the random key pool file comprises: Based on the random number generator, generate a first random value and a second random value; Perform a modulo operation on the number of matrix columns of the random key pool file and the first random value to obtain a random index abscissa; Perform a modulo operation on the number of matrix rows of the random key pool file and the second random value to obtain a random index ordinate; Based on the random index abscissa and the random index ordinate, the key index file is obtained.
5. The device data encryption method according to claim 1, characterized in that: The generating of temporary memory variables based on the key index file and the random key pool file comprises: Determine a data selection range based on the key index file; Select part or all of the data corresponding to the data selection range in the random key pool file to obtain a temporary memory variable.
6. The device data encryption method according to claim 1, characterized in that: The generating a target key based on the random seed text and the temporary memory variable comprises: Perform splicing based on the random seed text and the temporary memory variable to obtain spliced data; A hash operation is performed based on the concatenated data to generate the target key.
7. The device data encryption method according to claim 1, characterized in that: After generating the target key based on the random seed text and the temporary memory variable, the method further includes: Delete the temporary memory variable.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer program product, characterized in that When the computer program product is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Encrypted storage method and device for sensitive information blocks in file
CN114756887A
5G module based on quantum key, communication system, method and application
CN115567204A
Quantum key security management method and system, computer equipment and storage medium
CN118282653A
Encryption method and device for burnt firmware, storage medium and computer equipment
CN118981784A
System and method for key establishment
US20240072996A1