Device data encryption method, computer device, storage medium and program product
By generating a random key pool file based on the device hardware identifier and random seed text, the target key is determined, and the data of the vehicle ECU device is encrypted. This solves the problem of low data security of the vehicle ECU devices already in use and achieves efficient encryption protection without hardware upgrades.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-09
- Publication Date
- 2026-03-24
AI Technical Summary
In existing technologies, the data security of in-vehicle ECU devices already in use is low, and they cannot effectively protect sensitive information, especially lacking special hardware support.
By obtaining the device hardware identifier and random seed text, a random key pool file is generated. Based on this file, the target key is determined, and the device data is encrypted to ensure that the target key for each device is unique.
Without requiring hardware upgrades, it improves the security of device data, increases the difficulty of cracking, and ensures the uniqueness of the encryption key for each device.
Smart Images

Figure CN119740245B_ABST
Abstract
Description
Technical Field
[0001] This 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 Technology
[0002] Today, vehicle ECUs (Electronic Control Units) store a lot of sensitive business data, such as communication keys, autonomous driving model files, driving history trajectories, and in-vehicle video recordings. If this business data is illegally obtained, it will cause automotive information security problems.
[0003] Traditional technologies require specialized hardware to protect sensitive information from unauthorized access. However, this approach is not applicable to already deployed vehicle ECUs that lack such specialized hardware.
[0004] It is evident that existing technologies still suffer from low data security in in-vehicle equipment already in use. Summary of the Invention
[0005] Therefore, 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-mentioned technical problems.
[0006] In a first aspect, this application provides a device data encryption method, the device data encryption method comprising:
[0007] In response to the encryption command, obtain the device hardware identifier code of the current device and the random seed text corresponding to the device hardware identifier code;
[0008] Based on the device hardware identifier and the random seed text, a random key pool file is generated;
[0009] The target key is determined based on the aforementioned random key pool file;
[0010] The device data of the current device is encrypted based on the target key to obtain ciphertext data.
[0011] In one embodiment, obtaining the device hardware identifier code of the current device and the random seed text corresponding to the device hardware identifier code includes:
[0012] Read the device hardware identification code of the current device;
[0013] Based on the number of bytes in the device hardware identifier code, a random seed text corresponding to the number of bytes is generated.
[0014] In one embodiment, the random key pool file includes a byte matrix; generating the random key pool file based on the device hardware identifier and the random seed text includes:
[0015] Based on the device hardware identification code, a first identification code is determined;
[0016] Based on the device hardware identification code and the random seed text, a second identification code is determined;
[0017] Based on the first identification code and the second identification code, a byte matrix is determined; the order of the byte matrix is the same as the number of bytes in the device hardware identification code.
[0018] In one embodiment, determining the second identification code based on the device hardware identifier and the random seed text includes:
[0019] The second identification code is determined based on the XOR operation result of the device hardware identifier code and the random seed text.
[0020] In one embodiment, determining the byte matrix based on the first identification code and the second identification code includes:
[0021] The first identification code is shifted left by N bytes to obtain a left-shifted string, and the second identification code is shifted right by N bytes to obtain a right-shifted string; N is a positive integer less than or equal to the number of bytes.
[0022] The byte matrix is determined based on the XOR operation result of each pair of left-shifted strings and right-shifted strings.
[0023] In one embodiment, determining the target key based on the random key pool file includes:
[0024] Based on the device hardware identifier and the random seed text, an index list for the random key pool file is determined; the index list includes multiple tuples; each tuple includes a first element determined by the random seed text and a second element determined by the device hardware identifier; the number of tuples is the same as the number of bytes in the device hardware identifier.
[0025] Based on each of the two tuples, the bytes in the random key pool file are searched sequentially to obtain multiple index bytes;
[0026] The target key is determined based on multiple index bytes.
[0027] In one embodiment, determining the index list of the random key pool file based on the device hardware identifier and the random seed text includes:
[0028] Based on the Nth byte of the random seed text, determine the first element of the Nth tuple;
[0029] Based on the Nth byte of the device hardware identifier, the second element of the Nth tuple is obtained;
[0030] N is a positive integer less than or equal to the number of bytes.
[0031] In one embodiment,
[0032] The step of obtaining the first element of the Nth tuple based on the Nth byte of the random seed text includes: obtaining the first element of the Nth tuple based on the result of the modulo operation between the unsigned integer of the Nth byte of the random seed text and N;
[0033] The step of obtaining the second element of the Nth tuple based on the Nth byte of the device hardware identifier code includes: obtaining the second element of the Nth tuple by taking the remainder of the unsigned integer of the Nth byte of the device hardware identifier code and N.
[0034] In one embodiment, determining the target key based on a plurality of the index bytes includes:
[0035] The concatenated string is obtained by combining multiple index bytes.
[0036] The target key is determined by performing a hash operation based on the concatenated string.
[0037] In one embodiment, after encrypting the device data of the current device based on the target key to obtain ciphertext data, the method further includes:
[0038] Store the encrypted data and delete the target key and the device data.
[0039] In one embodiment, after storing the ciphertext data and deleting the target key and the device data, the method further includes:
[0040] A target key is generated based on the device hardware identifier and the random seed text;
[0041] The encrypted data is decrypted based on the target key to obtain device data;
[0042] Based on the number of bytes in the device hardware identifier code, generate an update random seed text corresponding to the number of bytes;
[0043] Based on the updated random seed text, the random seed text is updated;
[0044] The target key is updated based on the device hardware identifier and the updated random seed text;
[0045] The device data is encrypted based on the updated target key;
[0046] Store the encrypted data and delete the target key and the device data.
[0047] Secondly, this application provides a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method described above.
[0048] Thirdly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described above.
[0049] Fourthly, this application provides a computer program product that, when executed by a processor, implements the method described above.
[0050] The aforementioned device data encryption method, computer equipment, storage medium, and program product, in response to an encryption command, obtain the device hardware identification code of the current device and the random seed text corresponding to the device hardware identification code; generate a random key pool file based on the device hardware identification code and the random seed text; determine a target key based on the random key pool file; and encrypt the device data of the current device based on the target key to obtain ciphertext data. This method enables the encryption of business data without requiring hardware upgrades. Because the encryption key is generated based on device characteristics and random text, it ensures that the target key for each device is unique, achieving one key per device. This effectively increases the difficulty for third parties to crack the encryption, thereby improving device data security. Attached Figure Description
[0051] Figure 1 This is a diagram illustrating the application environment of a device data encryption method in one embodiment;
[0052] Figure 2 This is a flowchart illustrating a device data encryption method in one embodiment;
[0053] Figure 3 This is a flowchart illustrating a device data encryption method in another embodiment;
[0054] Figure 4 This is a schematic diagram of the process for generating a random key pool file in one embodiment.
[0055] Figure 5This is a flowchart illustrating the process of generating an index list in one embodiment;
[0056] Figure 6 This is a schematic diagram of the process for generating the target key in one embodiment;
[0057] Figure 7 This is a structural block diagram of a device data encryption device in one embodiment;
[0058] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0059] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0060] The device data encryption method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, it is understood that the device data encryption in this application can be limited to, but is not limited to, device data encryption of vehicle electronic control units (ECUs), and can also be applied to data encryption of other terminals. Terminal 102 communicates with server 104 via a network. A data storage system can store the data that server 104 needs to process. The data storage system can be integrated on server 104 or placed on the cloud or other network servers. In response to an encryption command, terminal 102 obtains the device hardware identifier code of the current device and the random seed text corresponding to the device hardware identifier code; based on the device hardware identifier code and the random seed text, it generates a random key pool file; based on the random key pool file, it determines a target key; and based on the target key, it encrypts the device data of the current device to obtain ciphertext data. Terminal 102 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can be smart speakers, smart TVs, smart air conditioners, smart vehicle devices, etc. Portable wearable devices can be smartwatches, smart bracelets, head-mounted devices, etc. Server 104 can be implemented using a standalone server or a server cluster composed of multiple servers.
[0061] In one embodiment, such as Figure 2 As shown, a device data encryption method is provided, which can be applied to... Figure 1 Taking terminal 102 as an example, the explanation includes the following steps:
[0062] Step S100: In response to the encryption command, obtain the device hardware identifier code of the current device and the random seed text corresponding to the device hardware identifier code.
[0063] Among them, the device hardware identifier can be information that uniquely identifies a hardware device, such as a MAC address or serial number.
[0064] The random seed text can be a string or number generated based on a random generation algorithm. The random seed text corresponds to the device hardware identifier code and can be randomly generated based on the characteristics of the device hardware identifier code and environmental parameters at the time the device hardware identifier code is obtained. For example, it can be generated based on the byte length of the device hardware identifier code itself, or it can be generated based on the timestamp at the time the device hardware identifier code is obtained, environmental noise, etc.
[0065] By generating random seed text, the unpredictability of the target key can be increased, thereby improving the security of device data.
[0066] Step S200: Generate a random key pool file based on the device hardware identifier and the random seed text.
[0067] The random key pool file can be a dataset containing multiple candidate keys. These candidate keys can be created according to preset rules, combining the device hardware identifier and a random seed text.
[0068] For example, generating a random key pool file can be achieved by transforming the device hardware identifier and / or random seed text multiple times according to preset rules, concatenating the device hardware identifier and random seed text under each transformation, performing a hash operation on the concatenated string to obtain multiple fixed-length hash values, thereby obtaining the random key pool file; alternatively, the device hardware identifier can be used as the master key and the random seed text as additional information, and multiple independent keys can be generated using a key derivation function to obtain the random key pool file; alternatively, based on elliptic curve cryptography, the device hardware identifier and random seed text can be used as private keys to generate multiple candidate keys to obtain the random key pool file; other methods based on the transformation and operation of the device hardware identifier and random seed text to obtain multiple candidate keys are also possible, which are not limited in this embodiment.
[0069] Step S300: Determine the target key based on the random key pool file.
[0070] The determination of the target key based on the random key pool file can be achieved by selecting one of the candidate keys as the target key; or by further processing the selected key to obtain the target key, for example, by performing a hash operation on the selected key; or by selecting one or more candidate keys from the random key pool file according to preset rules, and selecting one or more characters or bytes from the candidate keys as the target key, or by performing further processing to obtain the target key.
[0071] Step S400: Encrypt the device data of the current device based on the target key to obtain ciphertext data.
[0072] The device data can be sensitive data within the current device that needs to be encrypted. For example, it can include business data such as communication keys, autonomous driving model files, driving history trajectories, and in-vehicle video recordings. For instance, when the communication key needs to be encrypted as device data, a target key is generated using the device hardware identifier code of the current device and the corresponding random seed text. The communication key is then encrypted using the target key to obtain ciphertext data.
[0073] Encryption using a selected target key ensures that ciphertext data can only be decrypted if the target key is correct. Device data can be encrypted using a symmetric encryption algorithm with the target key to obtain ciphertext data.
[0074] Furthermore, when device data is needed, a target key can be generated using the current device's random key pool file and the corresponding random seed text. The encrypted data can then be decrypted using this target key to obtain the device data, which can then be used and further processed.
[0075] This embodiment provides a device data encryption method that, in response to an encryption command, obtains the device hardware identifier code of the current device and a random seed text corresponding to the device hardware identifier code; generates a random key pool file based on the device hardware identifier code and the random seed text; determines a target key based on the random key pool file; and encrypts the device data of the current device based on the target key to obtain ciphertext data. This method enables the encryption of business data without requiring hardware upgrades. Since the encryption key is generated based on device characteristics and random text, it ensures that the target key for each device is unique, achieving one key per device. This effectively increases the difficulty for third parties to crack the encryption, thereby improving device data security.
[0076] In one embodiment, obtaining the device hardware identifier code of the current device and the random seed text corresponding to the device hardware identifier code includes:
[0077] Read the device hardware identification code of the current device;
[0078] Based on the number of bytes in the device hardware identifier code, a random seed text corresponding to the number of bytes is generated.
[0079] Reading the device hardware identifier of the current device can be achieved by accessing the path where the device hardware identifier is stored in the current device, and then extracting the device hardware identifier.
[0080] The number of bytes can be the data length occupied by the device hardware identifier, that is, the number of bytes contained in the device hardware identifier.
[0081] Based on the number of bytes in the device hardware identifier code, a random seed text corresponding to the number of bytes is generated. Alternatively, a random seed text with the same number of bytes as the number of bytes in the device hardware identifier code can be generated.
[0082] For example, generating random seed text can be achieved using a pseudo-random number generator or other secure random number generation algorithms.
[0083] This embodiment provides a device data encryption method that creates a random seed text of the same size. Since the generated random seed text matches the size of the hardware identifier code, subsequent calculations can be performed more efficiently, increasing the difficulty for attackers to guess or crack the key, thereby improving the security of device data.
[0084] In one embodiment, the random key pool file includes a byte matrix; generating the random key pool file based on the device hardware identifier and the random seed text includes:
[0085] Based on the device hardware identification code, a first identification code is determined;
[0086] Based on the device hardware identification code and the random seed text, a second identification code is determined;
[0087] The byte matrix is determined based on the first identification code and the second identification code.
[0088] The first identification code can be either a direct representation of the device hardware identifier or a unique value generated based on the device hardware identifier. For example, it can be obtained by transforming or calculating the device hardware identifier to obtain a fixed-length first identification code.
[0089] The second identification code can be obtained by combining the device hardware identification code and the random seed text. For example, the device hardware identification code and the random seed text can be concatenated or characters at specific positions can be extracted, and the concatenated or extracted strings can be transformed and calculated to obtain the second identification code, thereby further increasing the complexity of the identification code.
[0090] The byte matrix can be a two-dimensional array structure, with the order of the byte matrix being the same as the number of bytes in the device hardware identifier. The byte matrix is determined based on the first and second identifiers, and can be generated using methods such as hybrid hashing or pseudo-random number generation, with the first and second identifiers as input parameters. This enhances key diversity, and because the matrix size is related to the device hardware identifier, it further increases the difficulty of cracking.
[0091] During the generation of the byte matrix, hash functions and pseudo-random number generators can be repeatedly applied to fill the matrix, ensuring that the bytes at each position are random and unpredictable. To improve efficiency and reduce storage requirements, the byte matrix can be dynamically generated only when needed, rather than pre-storing the entire matrix.
[0092] This embodiment provides a device data encryption method that, by determining a byte matrix based on the device hardware identifier and random seed text, and on the first identifier and the second identifier, can generate a more refined and secure random key pool file, thereby improving the security of device data.
[0093] In one embodiment, determining the second identification code based on the device hardware identifier and the random seed text includes:
[0094] The second identification code is determined based on the XOR operation result of the device hardware identifier code and the random seed text.
[0095] The XOR operation determines whether the input bits are the same or different, resulting in either 0 or 1. Since the device hardware identifier and the random seed text have the same byte length, a bit-by-bit XOR operation can be performed on the binary bits of the device hardware identifier and the random seed text to obtain the XOR result. When the device hardware identifier and the random seed text have different byte lengths, the two strings used in the XOR operation can be made to have the same length by truncating the longer string, padding with the shorter string, or using circular padding.
[0096] This embodiment provides a device data encryption method that obtains a second identification code through an XOR operation. This provides a certain degree of data obfuscation, making it difficult for attackers to deduce the complete second identification code based on only partial information. This enhances the security and unpredictability of the generated second identification code, thereby improving the security of device data.
[0097] In one embodiment, determining the byte matrix based on the first identification code and the second identification code includes:
[0098] The first identification code is shifted left by N bytes to obtain a left-shifted string, and the second identification code is shifted right by N bytes to obtain a right-shifted string;
[0099] The byte matrix is determined based on the XOR operation result of each pair of left-shifted strings and right-shifted strings.
[0100] Where N is a positive integer less than or equal to the number of bytes. Shifting the identification code by N bytes can be achieved by shifting the first identification code by a certain number of bits in binary representation.
[0101] In this embodiment, the first and second identification codes may be shifted N times each, with the number of bytes shifted increasing from 1 to N in each shift. Left and right shifts can be determined according to preset settings to move the identification code towards higher or lower bits.
[0102] The following explanation uses left shift (moving data to higher digits) and right shift (moving data to lower digits) as examples:
[0103] Shifting the first identification code to the left by N bytes can move the data to the higher bits by N bytes. Taking the first identification code as 0x12345678 as an example, shifting the first identification code by 1 byte can result in 0x34567812 or 0x34567800. You can set whether the bytes overflowing after the left shift are filled into the original low bit area.
[0104] Shifting the second identification code to the right by N bytes can move the data to the lower bits by N bytes. Taking the second identification code as 0x9ABCDEF0 as an example, shifting the second identification code by 1 byte can result in 0x009ABCDE or 0xF09ABCDE. You can set whether the overflow bytes after the right shift are filled into the original high-bit area.
[0105] It is understandable that by performing N bit-by-bit shifts, N pairs of left-shifted strings and right-shifted strings can be obtained. Furthermore, based on the XOR operation results of each pair of left-shifted strings and right-shifted strings, all XOR operation results can be combined into a two-dimensional array to obtain a byte matrix with the same order as the device hardware identification code.
[0106] This embodiment provides a device data encryption method that sequentially shifts the first identification code to the left and the second identification code to the right according to different step sizes to obtain multiple pairs of left-shifted strings and right-shifted strings. Then, an XOR operation is performed to obtain a byte matrix, which can increase the encryption strength and complexity, increase the difficulty of cracking, and achieve the effect of improving device data security.
[0107] In one embodiment, determining the target key based on the random key pool file includes:
[0108] Based on the device hardware identifier and the random seed text, determine the index list of the random key pool file;
[0109] Based on each of the two tuples, the bytes in the random key pool file are searched sequentially to obtain multiple index bytes;
[0110] The target key is determined based on multiple index bytes.
[0111] In this embodiment, an index list is obtained by using the device hardware identification code and random seed text, and multiple bytes in the random key pool file are searched according to the index list to obtain the target key.
[0112] The index list is a data structure that includes multiple tuples, each of which can point to a specific location in the random key pool file.
[0113] By using an index list to retrieve multiple bytes from the random key pool file and then generating the target key, and by extracting bytes from the random key pool file using an index list, it becomes difficult for a third party to obtain the complete target key when analyzing the current device. Compared to hardcoding it into the current device, this increases the difficulty for a third party to analyze the current device and obtain the target key.
[0114] Each of the tuples includes a first element determined by the random seed text and a second element determined by the device hardware identifier; the number of the tuples is the same as the number of bytes of the device hardware identifier.
[0115] Generating the first element can be achieved by sequentially calculating multiple values based on the random seed text, using these values as the first element in each tuple. Generating the second element can be achieved by sequentially calculating multiple values based on the device hardware identifier, using these values as the second element in each tuple.
[0116] Based on each tuple, the bytes in the random key pool file are searched sequentially to obtain multiple index bytes. Alternatively, the candidate key in the random key pool file can be determined based on the first element in each tuple, and the corresponding byte in the candidate key can be determined based on the second element as the candidate byte corresponding to the tuple.
[0117] The target key is determined based on multiple index bytes. This can be achieved by concatenating and arranging the multiple index bytes in the order of the tuples, or by concatenating and arranging them in a preset order.
[0118] This embodiment provides a device data encryption method that obtains multiple index bytes by establishing an index list to search for bytes in the random key pool file, thereby obtaining the target key. This avoids the situation where a single candidate key can be successfully decrypted. By concatenating parts of multiple candidate keys, security can be further improved, thus enhancing the security of device data.
[0119] In one embodiment, determining the index list of the random key pool file based on the device hardware identifier and the random seed text includes:
[0120] Based on the Nth byte of the random seed text, determine the first element of the Nth tuple;
[0121] The second element of the Nth tuple is obtained based on the Nth byte of the device hardware identifier code.
[0122] Where N is a positive integer less than or equal to the number of bytes. By determining the second element and the first element based on the number of bytes of the device hardware identifier, a set of tuples with the same number of bytes as the device hardware identifier can be obtained, and the second element of each tuple is associated with the device hardware identifier.
[0123] For example, taking the random seed text 0x9ABCDEF0 as an example, when N is 1, byte 9A is taken to obtain the first element of the first tuple. The first element can also be obtained based on the Nth byte by transforming the Nth byte so that the maximum value of the first element is less than or equal to the number of bytes in the candidate key. For example, this could be achieved by using a modulo operation or normalization followed by integer division on the Nth byte.
[0124] Similarly, taking the device hardware identifier code 0x12345678 as an example, when N is 1, byte 12 is taken to obtain the second element of the first tuple. It can be understood that obtaining the second element based on the Nth byte can also be achieved by transforming the Nth byte so that the maximum value of the second element is less than or equal to the number of candidate keys. For example, this could be done by using a modulo operation or normalizing and then rounding down the Nth byte to obtain the second element.
[0125] By extracting the Nth byte from 1 to N multiple times, N pairs can be obtained, thus establishing an index list.
[0126] This embodiment provides a device data encryption method that ensures each tuple accurately reflects the device hardware identifier and random seed text information, thereby making the index list highly unique, enhancing the security of the target key, and ensuring that even with the same device model, different hardware identifiers will result in different generated target keys. This improves the security of sensitive data within the vehicle ECU and enhances the robustness of the entire encryption mechanism, ultimately improving device data security.
[0127] In one embodiment,
[0128] The step of obtaining the first element of the Nth tuple based on the Nth byte of the random seed text includes: obtaining the first element of the Nth tuple by taking the remainder of the unsigned integer of the Nth byte of the random seed text with N.
[0129] Determining the first element through the Nth byte can be achieved by converting the Nth byte into a decimal number. For example, when the Nth byte is 9A, the decimal value is 154. Furthermore, the remainder of 154 and N can be calculated. For instance, when N is 3, the remainder of 154 and N is 1.
[0130] The step of obtaining the second element of the Nth tuple based on the Nth byte of the device hardware identifier code includes: obtaining the second element of the Nth tuple by taking the remainder of the unsigned integer of the Nth byte of the device hardware identifier code and N.
[0131] The second element is determined by the Nth byte. This can be achieved by converting the Nth byte to a decimal number. For example, if the Nth byte is 12, the decimal value is 18. Further, the remainder of 18 is taken with N. For instance, if N is 3, the remainder of 154 with N is 0. It's understandable that computer programs typically start indexing from bit 0 during actual execution; therefore, the 0th candidate key is the 1st candidate key in the random key pool file.
[0132] This embodiment provides a device data encryption method that uses modulo operations to map larger values to a smaller range, thereby simplifying the index generation process and increasing the randomness of the index values. This makes it difficult for attackers to deduce the index values through simple mathematical relationships, thus improving the security of device data.
[0133] In one embodiment, determining the target key based on a plurality of the index bytes includes:
[0134] The concatenated string is obtained by combining multiple index bytes.
[0135] The target key is determined by performing a hash operation based on the concatenated string.
[0136] The index byte is a byte extracted from the random key pool according to the index list, and the concatenated string can be a string formed by connecting multiple index bytes in a preset order.
[0137] The target key is determined by performing a hash operation on the concatenated string. This can be achieved using a one-way encryption algorithm that converts data of arbitrary length into a fixed-length output to obtain the target key.
[0138] This embodiment provides a device data encryption method that obtains a concatenated string by concatenating multiple index bytes; and determines the target key by performing a hash operation on the concatenated string, thereby generating a highly unique and secure target key to improve device data security.
[0139] In one embodiment, after encrypting the device data of the current device based on the target key to obtain ciphertext data, the method further includes:
[0140] Store the encrypted data and delete the target key and the device data.
[0141] This involves selecting a secure and reliable storage location to store the encrypted data. This could be the internal memory of the vehicle's ECU, an external storage device, or a cloud storage service, and then writing the encrypted data to the selected storage medium. To ensure data integrity and security, security features provided by the file system, such as access control and access auditing, can be used.
[0142] Deleting the target key and the device data can be done by deleting the target key and device data from memory, to ensure that third parties cannot obtain the target key by reading memory, thereby preventing data leakage and effectively protecting sensitive data in the vehicle ECU.
[0143] This embodiment provides a device data encryption method that, by storing the ciphertext data and deleting the target key and the device data, can prevent third parties from obtaining the target key by reading memory, thereby improving the security of device data.
[0144] In one embodiment, after storing the ciphertext data and deleting the target key and the device data, the method further includes:
[0145] A target key is generated based on the device hardware identifier and the random seed text;
[0146] The encrypted data is decrypted based on the target key to obtain device data;
[0147] Based on the number of bytes in the device hardware identifier code, generate an update random seed text corresponding to the number of bytes;
[0148] Based on the updated random seed text, the random seed text is updated;
[0149] The target key is updated based on the device hardware identifier and the updated random seed text;
[0150] The device data is encrypted based on the updated target key;
[0151] Store the encrypted data and delete the target key and the device data.
[0152] In this embodiment, a data encryption method for random seed text updates is provided. By updating the seed text randomly, data leakage caused by fixed seeds can be prevented.
[0153] Based on the device hardware identifier and the random seed text, a target key is generated. This can be done using the target key generation method employed in any of the above embodiments, which will not be elaborated upon in this embodiment.
[0154] Since the encrypted data is obtained by symmetric encryption of the device data using the target key, the device data can be obtained by decryption using the target key if the target key is correct.
[0155] Based on the number of bytes of the device hardware identifier code, an updated random seed text corresponding to the number of bytes is generated. This can be done by regenerating a random seed text with the same number of bytes, denoted as the updated random seed text.
[0156] Based on the updated random seed text, after updating the random seed text, the target key is updated based on the device hardware identifier and the updated random seed text. This can be done by generating a target key corresponding to the updated random seed text using the same target key generation method as that used to generate the target key based on the device hardware identifier and the updated random seed text. The target key is then updated based on this key, and the device data is re-encrypted based on the target key to obtain ciphertext data under the new random seed text.
[0157] This embodiment provides a device data encryption method that can significantly improve system security by periodically updating the random seed text and target key. Even if the previous key is leaked, the updated key prevents attackers from accessing the latest encrypted data, ensuring that the data is always under the latest encryption protection, thus improving device data security.
[0158] To more clearly illustrate the technical solution of this application, a detailed embodiment is also provided.
[0159] In one embodiment, such as Figure 3 As shown, a device data encryption method is provided, including:
[0160] I. Key Initialization Phase
[0161] The main tasks in this stage are to read the unique hardware ID from the vehicle's ECU, generate a seed, and store it in the ECU's flash memory. Then, using the ID and seed as input, a random key pool file (KPF) is generated. The unique hardware ID is the device hardware identifier, and the seed is the random seed text. The detailed process is as follows:
[0162] Step 1.1: Read ID. After the vehicle ECU starts, read the device hardware identification code ID of the internal hardware of the ECU.
[0163] Step 1.2: The ECU uses a pseudo-random number generator to generate a random seed text (seed) and stores it in the ECU's flash memory. The length of the seed is the same as the length of the device hardware identifier (ID) in bytes.
[0164] Step 1.3: Initialize two variables in the ECU memory, namely the first identification code L-ID and the second identification code R-ID. The first identification code L-ID is assigned by the device hardware identification code ID, and the second identification code R-ID is assigned by the XOR operation result of the device hardware identification code ID and the random seed text seed, that is, R-ID = ID xor seed.
[0165] Step 1.4: Initialize an n-order byte matrix nSmatrix in the ECU memory, where n is the length of ID in bytes from step 1.1.
[0166] Step 1.5 assigns values to the byte matrix nSmartix. This step involves performing the following operation on the first identification code L-ID and the second identification code R-ID from step 1.3 and assigning the values to nSmartix: Figure 4 As shown, the specific process is as follows:
[0167] Step 1.5.1: The first row of the byte matrix nSmartix is equal to the result of XORing the first identification code L-ID cyclically shifted left by 1 byte and the second identification code R-ID cyclically shifted right by 1 byte.
[0168] Step 1.5.2: The second row of the byte matrix nSmartix is equal to the result of XORing the first identification code L-ID cyclically shifted left by 2 bytes and the second identification code R-ID cyclically shifted right by 2 bytes.
[0169] The subsequent steps follow the same pattern. The nth row of nSmartix is equal to the result of XORing the first identification code L-ID shifted left by n bytes and the second identification code R-ID shifted right by n bytes.
[0170] II. Key WK Generation Stage
[0171] The main task of this stage is to use the device hardware identifier (ID), random seed text, and byte matrix nSmatrix generated in step 1 to generate the working key (WK), i.e., the target key, for encryption later, through a multi-dimensional keyderivator (MDKD). The detailed process of the multi-dimensional keyderivator is as follows:
[0172] Step 2.1, as follows Figure 5 As shown, n tuples are generated using a random seed text (seed) and a device hardware identifier (ID), where n is the length of the device hardware identifier (ID) in bytes from step 1.1. The specific process is as follows:
[0173] Step 2.1.1: Take the first byte of the random seed text seed, convert the byte into an unsigned integer denoted as Sunit1, and then calculate sI-1 = Sunit1 mode n. Calculate sI-n in the same way to obtain the first element of each tuple.
[0174] Step 2.1.2: Take the first byte of the device hardware identifier ID, convert the byte into an unsigned integer denoted as Dunit1, and then calculate DI-1 = Dunit1moden. Calculate DI-n in the same way, so as to obtain the second element of each tuple.
[0175] Step 2.1.3: Using sI-n calculated in 2.1.1 as the first element and DI-n calculated in 2.1.2 as the second element, generate n pairs (sI-1, DI-1)...(sI-n, DI-n), denoted as IndexBinarySet, which is the index list used for later calculations.
[0176] Step 2.2, as follows Figure 6 As shown, using the index list IndexBinarySet as the index, the corresponding bytes are read sequentially from the byte matrix nSmartix generated in step 1, and concatenated one by one to generate a string of length n, denoted as the concatenation string prebinarystring.
[0177] Step 2.3: The target key WK is obtained by performing a hash operation on the concatenated string prebinarystring, where WK = hash(prebinarystring).
[0178] III. Business Data Encryption Phase
[0179] The main task of the business encryption phase is to use the WK generated in the key generation phase as the target key to encrypt the business data (textdata) into ciphertext data (encryptedata). Then, the ciphertext data (encryptedata) is stored in the ECU's storage, and the target key WK is deleted to prevent memory dump attacks by attackers, as well as the business data (textdata). In this embodiment, the business data is the device data.
[0180] IV. Business Data Decryption Phase
[0181] The main task of the business encryption / decryption section is to use the WK generated in the key generation stage as the key to decrypt the encrypted data into business data and delete the WK to prevent attackers from performing memory dump attacks.
[0182] V. Key WK Update Phase
[0183] Step 5.1: Using the key initialization phase, key WK generation phase, and business data decryption phase, the business data textdata is decrypted.
[0184] Step 5.2: Regenerate the random seed text using the method in Step 1.2, recalculate the key initialization phase and the key WK generation phase, and generate a new target key WK.
[0185] Step 5.3: Perform the business data encryption phase using the new target key WK.
[0186] In one specific embodiment, the device data encryption method is applied to an autonomous driving system. Before installation on the vehicle, the autonomous driving system (ADS) needs to inject SecOC. SecOC uses a communication key SecocKey for communication, and it is required that SecocKey not be stored in plaintext. Therefore, the steps of the key initialization stage and the key WK generation stage can be executed. When SecocKey is injected into the ADS on the production line, the ADS system uses the generated WK as the encryption key to encrypt SecocKey, generating ciphertext data EncryptoSecocKey, which is stored in the ADS's internal flash memory. Simultaneously, WK and intermediate process data are cleared from memory. When the ADS needs to use SecocKey, the target key WK can be calculated temporarily using the same method as in the key WK generation stage. Using the AES-256 decryption algorithm, with WK as the key and EncryptoSecocKey as the ciphertext, SecocKey is decrypted, and WK and process data are deleted. The ADS system uses SecocKey for normal business operations, performing a complete operation and supporting the deletion of SecocKey.
[0187] Understandably, the random key pool file can be generated either outside or inside the ECU. The random seed text can be a random number generated internally by the ECU, or it can be the ECU's hardware ID.
[0188] This embodiment provides a device data encryption method that uses the unique hardware ID inside the vehicle ECU and the seed generated by a pseudo-random number generator as two input parameters. Through special changes in the scheme, a unique key is generated for each device to encrypt the data inside the user ECU.The hardware ID ensures the uniqueness of the key, while the seed ensures its unpredictability. The seed is variable data stored in the ECU's internal flash memory; updating the seed value updates the encryption key, preventing the vehicle ECU from using only one key throughout its product lifecycle and improving encryption security. In response to an encryption command, the system obtains the device hardware identifier and the corresponding random seed text. Based on the device hardware identifier and the random seed text, a random key pool file is generated. Based on the random key pool file, a target key is determined. Finally, the device data of the current device is encrypted using the target key. This method enables the encryption of business data without requiring hardware upgrades. Since the encryption key is generated based on device characteristics and random text, it effectively increases the difficulty for third parties to crack the code, thus enhancing device data security. By creating a random seed text of the same size, which matches the hardware identifier code, subsequent calculations can be performed more efficiently, increasing the difficulty for attackers to guess or crack the key, thereby improving device data security. Furthermore, by determining the byte matrix based on the device hardware identifier code and the random seed text, and using the first and second identifier codes, a more precise and secure encryption process can be achieved. A random key pool file is generated to improve device data security. The second identification code, obtained through XOR operation, provides a degree of data obfuscation, making it difficult for attackers to deduce the complete second identification code from partial information, thus enhancing the security and unpredictability of the generated second identification code and improving device data security. By sequentially shifting the first identification code left and the second identification code right according to different step sizes, multiple pairs of left-shifted and right-shifted strings are obtained. XORing these strings to obtain a byte matrix increases encryption strength and complexity, making it more difficult to crack and improving device data security. The random key pool file is then searched using an index list. The bytes in the key pool file are used to obtain multiple index bytes, which in turn yield the target key. This avoids the situation where a single candidate key can be successfully decrypted. By concatenating portions of multiple candidate keys, security can be further improved, thereby enhancing the security of device data. Each tuple accurately reflects the device hardware identifier and random seed text information, making the index list highly unique, enhancing the security of the target key, and ensuring that even with the same device model, different hardware identifiers will result in different generated target keys. This improves the security of sensitive data within the vehicle ECU and enhances the robustness of the entire encryption mechanism, thus improving the security of device data.
[0189] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0190] Based on the same inventive concept, this application also provides a device data encryption apparatus for implementing the device data encryption method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more device data encryption apparatus embodiments provided below can be found in the limitations of the device data encryption method described above, and will not be repeated here.
[0191] In one embodiment, such as Figure 7 As shown, a device data encryption apparatus is provided, comprising: an acquisition module, a generation module, a key module, and an encryption module, wherein:
[0192] The acquisition module is used to acquire the device hardware identifier code of the current device and the random seed text corresponding to the device hardware identifier code in response to the encryption command;
[0193] The generation module is used to generate a random key pool file based on the device hardware identifier code and the random seed text;
[0194] The key module is used to determine the target key based on the random key pool file;
[0195] The encryption module is used to encrypt the device data of the current device based on the target key to obtain ciphertext data.
[0196] In one embodiment, the acquisition module is further configured to:
[0197] Read the device hardware identification code of the current device;
[0198] Based on the number of bytes in the device hardware identifier code, a random seed text corresponding to the number of bytes is generated.
[0199] In one embodiment, the random key pool file includes a byte matrix; the generation module is further configured to:
[0200] Based on the device hardware identification code, a first identification code is determined;
[0201] Based on the device hardware identification code and the random seed text, a second identification code is determined;
[0202] Based on the first identification code and the second identification code, a byte matrix is determined; the order of the byte matrix is the same as the number of bytes in the device hardware identification code.
[0203] In one embodiment, the generation module is further configured to:
[0204] The second identification code is determined based on the XOR operation result of the device hardware identifier code and the random seed text.
[0205] In one embodiment, the generation module is further configured to:
[0206] The first identification code is shifted left by N bytes to obtain a left-shifted string, and the second identification code is shifted right by N bytes to obtain a right-shifted string; N is a positive integer less than or equal to the number of bytes.
[0207] The byte matrix is determined based on the XOR operation result of each pair of left-shifted strings and right-shifted strings.
[0208] In one embodiment, the key module is further configured to:
[0209] Based on the device hardware identifier and the random seed text, an index list for the random key pool file is determined; the index list includes multiple tuples; each tuple includes a first element determined by the random seed text and a second element determined by the device hardware identifier; the number of tuples is the same as the number of bytes in the device hardware identifier.
[0210] Based on each of the two tuples, the bytes in the random key pool file are searched sequentially to obtain multiple index bytes;
[0211] The target key is determined based on multiple index bytes.
[0212] In one embodiment, the key module is further configured to:
[0213] Based on the Nth byte of the random seed text, determine the first element of the Nth tuple;
[0214] Based on the Nth byte of the device hardware identifier, the second element of the Nth tuple is obtained;
[0215] N is a positive integer less than or equal to the number of bytes.
[0216] In one embodiment,
[0217] The step of obtaining the first element of the Nth tuple based on the Nth byte of the random seed text includes: obtaining the first element of the Nth tuple based on the result of the modulo operation between the unsigned integer of the Nth byte of the random seed text and N;
[0218] The step of obtaining the second element of the Nth tuple based on the Nth byte of the device hardware identifier code includes: obtaining the second element of the Nth tuple by taking the remainder of the unsigned integer of the Nth byte of the device hardware identifier code and N.
[0219] In one embodiment, the key module is further configured to:
[0220] The concatenated string is obtained by combining multiple index bytes.
[0221] The target key is determined by performing a hash operation based on the concatenated string.
[0222] In one embodiment, the device includes a cleaning module for:
[0223] Store the encrypted data and delete the target key and the device data.
[0224] In one embodiment, the device further includes an update module for:
[0225] A target key is generated based on the device hardware identifier and the random seed text;
[0226] The encrypted data is decrypted based on the target key to obtain device data;
[0227] Based on the number of bytes in the device hardware identifier code, generate an update random seed text corresponding to the number of bytes;
[0228] Based on the updated random seed text, the random seed text is updated;
[0229] The target key is updated based on the device hardware identifier and the updated random seed text;
[0230] The device data is encrypted based on the updated target key;
[0231] Store the encrypted data and delete the target key and the device data.
[0232] Each module in the aforementioned data encryption device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in the processor of the computer device in hardware form or independent of it, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0233] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 8 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database stores random seed text and encrypted data. The network interface communicates with external terminals via a network connection. When executed by the processor, the computer program implements a device data encryption method.
[0234] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0235] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the device data encryption method of any of the above embodiments.
[0236] In response to the encryption command, obtain the device hardware identifier code of the current device and the random seed text corresponding to the device hardware identifier code;
[0237] Based on the device hardware identifier and the random seed text, a random key pool file is generated;
[0238] The target key is determined based on the aforementioned random key pool file;
[0239] The device data of the current device is encrypted based on the target key to obtain ciphertext data.
[0240] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the device data encryption method of any of the above embodiments:
[0241] In response to the encryption command, obtain the device hardware identifier code of the current device and the random seed text corresponding to the device hardware identifier code;
[0242] Based on the device hardware identifier and the random seed text, a random key pool file is generated;
[0243] The target key is determined based on the aforementioned random key pool file;
[0244] The device data of the current device is encrypted based on the target key to obtain ciphertext data.
[0245] In one embodiment, a computer program product is provided, wherein when the computer program is executed by a processor, it implements the device data encryption method of any of the above embodiments:
[0246] In response to the encryption command, obtain the device hardware identifier code of the current device and the random seed text corresponding to the device hardware identifier code;
[0247] Based on the device hardware identifier and the random seed text, a random key pool file is generated;
[0248] The target key is determined based on the aforementioned random key pool file;
[0249] The device data of the current device is encrypted based on the target key to obtain ciphertext data.
[0250] 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, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0251] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this 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), magnetic 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. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0252] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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.
[0253] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for encrypting device data, characterized in that, The device data encryption method includes: In response to the encryption command, the device hardware identifier of the current device and the random seed text corresponding to the device hardware identifier obtained based on the random generation algorithm are obtained. Based on the device hardware identifier and the random seed text, a random key pool file is generated; The target key is determined based on the aforementioned random key pool file; The device data of the current device is encrypted based on the target key to obtain ciphertext data; The encrypted data is decrypted based on the target key to obtain device data; Based on the number of bytes in the device hardware identifier code, generate an update random seed text corresponding to the number of bytes; The random seed text is updated based on the updated random seed text.
2. The device data encryption method according to claim 1, characterized in that, The step of obtaining the device hardware identifier code of the current device and the random seed text corresponding to the device hardware identifier code includes: Read the device hardware identification code of the current device; Based on the number of bytes in the device hardware identifier code, a random seed text corresponding to the number of bytes is generated.
3. The device data encryption method according to claim 1, characterized in that, The random key pool file includes a byte array; generating the random key pool file based on the device hardware identifier and the random seed text includes: Based on the device hardware identification code, a first identification code is determined; Based on the device hardware identification code and the random seed text, a second identification code is determined; Based on the first identification code and the second identification code, a byte matrix is determined; the order of the byte matrix is the same as the number of bytes in the device hardware identification code.
4. The device data encryption method according to claim 3, characterized in that, The process of determining the second identification code based on the device hardware identifier and the random seed text includes: The second identification code is determined based on the XOR operation result of the device hardware identifier code and the random seed text.
5. The device data encryption method according to claim 3, characterized in that, The step of determining the byte matrix based on the first identification code and the second identification code includes: The first identification code is shifted left by N bytes to obtain a left-shifted string, and the second identification code is shifted right by N bytes to obtain a right-shifted string; N is a positive integer less than or equal to the number of bytes. The byte matrix is determined based on the XOR operation result of each pair of left-shifted strings and right-shifted strings.
6. The device data encryption method according to claim 1, characterized in that, Determining the target key based on the random key pool file includes: Based on the device hardware identifier and the random seed text, an index list for the random key pool file is determined; the index list includes multiple tuples; each tuple includes a first element determined by the random seed text and a second element determined by the device hardware identifier; the number of tuples is the same as the number of bytes in the device hardware identifier. Based on each of the two tuples, the bytes in the random key pool file are searched sequentially to obtain multiple index bytes; The target key is determined based on multiple index bytes.
7. The device data encryption method according to claim 6, characterized in that, The step of determining the index list of the random key pool file based on the device hardware identifier and the random seed text includes: Based on the Nth byte of the random seed text, determine the first element of the Nth tuple; Based on the Nth byte of the device hardware identifier, the second element of the Nth tuple is obtained; N is a positive integer less than or equal to the number of bytes.
8. The device data encryption method according to claim 7, characterized in that, The step of obtaining the first element of the Nth tuple based on the Nth byte of the random seed text includes: obtaining the first element of the Nth tuple based on the result of the modulo operation between the unsigned integer of the Nth byte of the random seed text and N; The step of obtaining the second element of the Nth tuple based on the Nth byte of the device hardware identifier code includes: obtaining the second element of the Nth tuple by taking the remainder of the unsigned integer of the Nth byte of the device hardware identifier code and N.
9. The device data encryption method according to claim 6, characterized in that, Determining the target key based on multiple index bytes includes: The concatenated string is obtained by combining multiple index bytes. The target key is determined by performing a hash operation based on the concatenated string.
10. The device data encryption method according to claim 1, characterized in that, After encrypting the device data of the current device based on the target key to obtain ciphertext data, the process further includes: Store the encrypted data and delete the target key and the device data.
11. The device data encryption method according to claim 10, characterized in that, After storing the ciphertext data and deleting the target key and the device data, the process further includes: A target key is generated based on the device hardware identifier and the random seed text; The encrypted data is decrypted based on the target key to obtain device data; Based on the number of bytes in the device hardware identifier code, generate an update random seed text corresponding to the number of bytes; Based on the updated random seed text, the random seed text is updated; The target key is updated based on the device hardware identifier and the updated random seed text; The device data is encrypted based on the updated target key; Store the encrypted data and delete the target key and the device data.
12. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the method of any one of claims 1 to 11.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 11.
14. A computer program product, characterized in that, When the computer program product is executed by a processor, it implements the method of any one of claims 1 to 11.
Citation Information
Patent Citations
File encryption and decryption method and device and storage medium
CN116015650A
A secure computing hardware apparatus and methods of manufacturing a secure computing hardware apparatus
WO2021007162A1