Key injection method and device, computer equipment and storage medium
Through the key injection method of encrypting and safe verification of on-board ECU keys, the problem of easy key leakage is solved, and the security management and flexible use is realized in production lines and after-sales scenarios are realized, and the risk of key leakage is reduced.
Patent Information
- Application Number
- CN202510490032.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-18
- Publication Date
- 2025-07-25
AI Technical Summary
In the prior art, the on-board ECU key injection scheme has the risk of key leakage, especially in production lines and after-sales scenarios, which leads to a high risk of key leakage.
The key injection method of encryption processing is adopted, random numbers are generated through the KMS system as the initial vector, and the key is encrypted using the AES-128-CBC and AES-128-GCM algorithms, and the key in the form of ciphertext is injected into the ECU, and decrypted inside the ECU, combining the check bits and labels for secure verification to avoid the transmission of the key plaintext.
It reduces the risk of key leakage in production lines and after-sales scenarios, improves the security and flexibility of key management, increases the difficulty of hacker attacks, and reduces the risk of key replacement.
Smart Images

Figure CN120378095A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of control technologies, and particularly to a key injection method, apparatus, computer device, and storage medium. Background Art
[0002] In related technologies, the in-vehicle ECU (Electronic Control Unit) key injection solution writes data into the ECU through the UDS2E service (write data service) using DID (Data ID, data identifier). The solution of writing keys through DID is transmitted in plaintext on the production line. It is necessary to strengthen information security training for production line personnel and after-sales personnel to ensure the security of the keys. However, the controllability of personnel is large, and there is a risk of key leakage. Summary of the Invention
[0003] Based on this, a key injection method, apparatus, computer device, and storage medium are provided to improve the problem of easy key leakage in the prior art.
[0004] On the one hand, a key injection method is provided, and the method includes:
[0005] Obtain the ciphertext of the first key, where the ciphertext of the first key is obtained by encrypting the first key and a first initial vector;
[0006] Obtain the ciphertext of the second key, where the ciphertext of the second key is obtained by encrypting the second key, the first key, and a second initial vector;
[0007] Inject the ciphertext of the first key and the ciphertext of the second key into the electronic control unit, where the electronic control unit is configured to decrypt the first key based on the ciphertext of the first key and the first initial vector; and decrypt the second key based on the ciphertext of the second key, the first key, and the second initial vector.
[0008] In one embodiment, the obtaining the ciphertext of the first key and the obtaining the ciphertext of the second key include:
[0009] Obtain the ciphertext of the first key based on a first encryption mode;
[0010] Obtain the ciphertext of the second key based on a second encryption mode.
[0011] In one embodiment, the obtaining the ciphertext of the first key further includes:
[0012] Fill check bits in the first key according to a preset value and a preset number of bytes to obtain a combination of the first key and the check bits;
[0013] Obtain the ciphertext of the first key according to the combination of the first key and the check bit;
[0014] The electronic control unit is further configured to:
[0015] Decrypt based on the ciphertext of the first key and the first initial vector to obtain the first key and the check bit, perform verification according to the check bit, and store the first key when the check bit verification passes.
[0016] In one embodiment, obtaining the ciphertext of the second key further includes:
[0017] Encrypt according to the second key, the first key and the second initial vector to obtain the ciphertext of the second key and the tag;
[0018] The electronic control unit is configured to:
[0019] Decrypt based on the ciphertext of the second key, the first key, the second initial vector and the tag to obtain the second key.
[0020] In one embodiment, after decrypting to obtain the second key, it further includes:
[0021] Perform verification according to the tag, and store the second key when the tag verification passes.
[0022] In one embodiment, before obtaining the ciphertext of the first key and obtaining the ciphertext of the second key, it further includes:
[0023] Obtain a first random number as the first initial vector and a second random number as the second initial vector;
[0024] After injecting the ciphertext of the first key and the ciphertext of the second key into the electronic control unit, it further includes:
[0025] Bind the first random number, the second random number to the electronic control unit, and store the binding relationship.
[0026] In one embodiment, after injecting the ciphertext of the first key and the ciphertext of the second key into the electronic control unit, it further includes:
[0027] When the check bit verification or the tag verification fails, receive the verification failure feedback sent by the electronic control unit to determine the failure reason according to the verification failure feedback.
[0028] On the other hand, a key injection device is provided, and the device includes:
[0029] An acquisition module, configured to acquire the ciphertext of a first key and the ciphertext of a second key, wherein the ciphertext of the first key is obtained by encrypting the first key with a first initialization vector, and the ciphertext of the second key is obtained by encrypting the second key, the first key, and a second initialization vector;
[0030] An injection module, configured to inject the ciphertext of the first key and the ciphertext of the second key into an electronic control unit;
[0031] Wherein, the electronic control unit is configured to decrypt the ciphertext of the first key and the first initialization vector to obtain the first key; decrypt the ciphertext of the second key, the first key, and the second initialization vector to obtain the second key.
[0032] On the other hand, provided is a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the method is implemented when the processor executes the computer program.
[0033] Also provided is a computer-readable storage medium, on which a computer program is stored, and the method is implemented when the computer program is executed by a processor.
[0034] In the above key injection method, device, computer device, and storage medium, the ciphertext of the first key is obtained by encrypting the first key with the first initialization vector, the ciphertext of the second key is obtained by encrypting the second key, the first key, and the second initialization vector, injecting the ciphertext of the first key and the ciphertext of the second key into the electronic control unit, the electronic control unit obtains the first key through the first unlocking, and applies the first key to perform the second unlocking to obtain the second key. In this form, after the encryption operation, the key for communication transmission is the ciphertext, avoiding excessive personnel from contacting the key and reducing the risk of key leakage. Description of the Drawings
[0035] Figure 1 It is an application environment diagram of the key injection method in an embodiment;
[0036] Figure 2 It is a flowchart of the key injection method in an embodiment;
[0037] Figure 3 It is a schematic diagram of the first key encryption step in an embodiment;
[0038] Figure 4 It is a schematic diagram of signal transmission during the first key encryption process;
[0039] Figure 5 It is a schematic diagram of the first key decryption step in an embodiment;
[0040] Figure 6 The ECU logic judgment process during the decryption of the first key
[0041] Figure 7 Schematic diagram of the second key encryption step in an embodiment
[0042] Figure 8 Schematic diagram of signal transmission during the second key encryption process
[0043] Figure 9 Schematic diagram of the second key decryption step in an embodiment
[0044] Figure 10 The ECU logic judgment process during the decryption of the second key
[0045] Figure 11 Structural block diagram of the key injection device in an embodiment
[0046] Figure 12 Internal structure diagram of a computer device in an embodiment Detailed implementation manners
[0047] In order to make the objectives, technical solutions and advantages of the present application clearer, the present application will be further described in detail below with reference to 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.
[0048] The key in the vehicle-mounted ECU is a core component of vehicle network security, and its function runs through multiple levels such as vehicle identity authentication, communication security, and function control. With the popularization of intelligent connected vehicles, vehicle information security has attracted increasing attention, and the security management of keys is particularly important.
[0049] In the related art, the vehicle-mounted ECU key injection scheme writes the key into the ECU through the UDS2E service using DID. When writing the key through DID, the key is transmitted in plaintext in the production line or after-sales scenarios. It is necessary to strengthen information security training for production line personnel and after-sales personnel to ensure the security of the key. However, the controllability of personnel is large, and there is a risk of key leakage.
[0050] The present application provides a key injection method. In view of the above situation, the key is encrypted to reduce the risk of key leakage in the production line or after-sales scenarios.
[0051] Exemplarily, the key injection method is applied in, for example Figure 1In the application environment shown, it includes a KMS (Key Management System) system, an MES (Manufacturing Execution System) system, and a programming device. The KMS system is used to generate random numbers, the MES system is used to issue ciphertexts, and the programming device is used to inject ciphertexts and transmit back the injection status. Which device is specifically used to implement the corresponding functions can be adjusted according to the specific situation of the factory.
[0052] In one embodiment, taking the programming device as the host computer, the key injection method is described as Figure 2 shown, and it includes the following steps:
[0053] Step 110, obtain the ciphertext of the first key.
[0054] Among them, the ciphertext of the first key is obtained by encrypting the first key and the first initialization vector. In the actual implementation process, the KMS system issues the first random number as the first initialization vector. The first initialization vector is bound to the ECU, and different ECUs can be realized. The first initialization vectors are different. Even if the first initialization vector is leaked, it is only the leakage of important information of a single ECU and will not cause a larger-scale network security accident.
[0055] The MES system calculates the ciphertext of the first key according to the first initialization vector and the first key by using an encryption algorithm, and issues the ciphertext of the first key to the programming device.
[0056] The initialization vector (Initialization Vector, IV) uses a random or pseudo-random input value. It ensures that the same plaintext generates different ciphertexts during encryption, thereby enhancing the security of encryption.
[0057] Step 120, obtain the ciphertext of the second key.
[0058] The ciphertext of the second key is obtained by encrypting the second key, the first key, and the second initialization vector. In the actual implementation process, the KMS system issues the second random number as the second initialization vector. The second initialization vector is bound to the ECU, and different ECUs can be realized. The second initialization vectors are different. Even if the second initialization vector is leaked, it is only the leakage of important information of a single ECU and will not cause a larger-scale network security accident.
[0059] The MES system calculates the ciphertext of the second key according to the second key, the first key, and the second initialization vector by using an encryption algorithm, and issues the ciphertext of the second key to the programming device.
[0060] Step 130, inject the ciphertext of the first key and the ciphertext of the second key into the electronic control unit.
[0061] During the actual implementation process, the ciphertext of the first key and the ciphertext of the second key are written using the UDS2E service, and this process is carried out on the production line flashing device.
[0062] In this application, the ECU is configured to decrypt and obtain the first key based on the ciphertext of the first key and the first initial vector; decrypt and obtain the second key based on the ciphertext of the second key, the first key, and the second initial vector.
[0063] Specifically, the ECU performs corresponding protection functions based on the second key (such as ECU legality verification, repair tool or diagnostic device authorization operations, data encryption functions, etc.). When the second key is needed, the ECU first obtains the first key through decryption internally. The decryption process is based on the ciphertext of the first key and the first initial vector. After obtaining the first key, the ciphertext of the second key is decrypted in combination with the second initial vector to obtain the plaintext of the second key.
[0064] Among them, the first initial vector and the second initial vector are injected into the ECU when decryption operations are required. For another example, in the embodiments provided in this application, the first initial vector and the second initial vector are injected synchronously when ciphertext injection is performed.
[0065] In the above embodiments, after the encryption operation, the key for communication transmission is ciphertext, which avoids too many people coming into contact with the key and reduces the risk of key leakage.
[0066] In a feasible implementation manner, the encryption methods of the first key and the second key are different, so that in the process of a hacker attacking and replacing the key, it is necessary to crack the encryption methods of the first key and the second key, which improves the cracking difficulty and reduces the risk of the key being replaced after the vehicle is sold. Exemplarily, in this application, the first key is encrypted using the first encryption mode, and the second key is encrypted using the second encryption mode. For example:
[0067] The encryption of the first key uses the AES-128-CBC algorithm, and the encryption of the second key uses the AES-128-GCM algorithm.
[0068] The AES-128-CBC algorithm is a kind of AES (Advanced Encryption Standard) encryption algorithm. The length of the key is 128 bits, and it uses the CBC (Cipher Block Chaining) mode. The AES-128-GCM algorithm uses the GCM (Galois / Counter Mode) mode of the AES encryption algorithm.
[0069] When encrypting the first key, parity bits are filled in the first key according to a preset value and a preset number of bytes to obtain a combination of the first key and the parity bits; the ciphertext of the first key is obtained according to the combination of the first key and the parity bits.
[0070] The electronic control unit is further configured to decrypt based on the ciphertext of the first key and the first initial vector to obtain the first key and the parity bits, and perform verification according to the parity bits. When the parity bit verification passes, the first key is stored.
[0071] Exemplarily, fill 00 (16 bytes) after the first key. During the ciphertext generation process, input the combination of the first key + filled 00 (16 bytes), and the first initial vector, and use the AES-128-CBC algorithm for encryption calculation to obtain the ciphertext of the first key.
[0072] Inside the ECU, the first key and the last 16 bytes of all 0x00 are obtained through decryption. If the last 16 bytes are not all 0x00, it means that the ECU decryption is incorrect, or the ciphertext calculation process by the host computer is incorrect. The ECU sends a corresponding verification failure feedback to facilitate troubleshooting the failure reason from the above two situations. For example, return NRC (Negative Response Code).
[0073] When encrypting the second key, according to the second key, the first key, and the second initial vector, encrypt to obtain the ciphertext of the second key and the tag;
[0074] The electronic control unit is configured to decrypt based on the ciphertext of the second key, the first key, the second initial vector, and the tag to obtain the second key.
[0075] The encryption of the second key uses the AES-128-GCM algorithm. During the encryption process, a tag (TAG) for authentication is generated. When decrypting inside the ECU, the tag needs to be input for decryption. Otherwise, the second key cannot be obtained, increasing the difficulty of hacking.
[0076] On the other hand, when the ECU decrypts to obtain the second key, it also performs verification based on the algorithm characteristics according to the tag. For example, the ECU calculates the TAG again. If the TAG calculated by the ECU is inconsistent with the TAG provided during decryption, it means that the data has been modified during the transmission process, so as to be able to detect whether the data has been tampered with during the transmission process.
[0077] If the tag verification fails, the ECU sends a corresponding verification failure feedback to determine the reason.
[0078] In some embodiments of the present application, the MES system binds the first random number, the second random number to the ECU, and uploads the binding relationship to the KMS system for storage, so as to perform corresponding queries according to the ECU identifier and other methods in scenarios such as after-sales.
[0079] The following describes the processes of the first key encryption, the first key decryption, the second key encryption, and the second key decryption in one embodiment:
[0080] The first key encryption process is as Figure 3 shown, and the signal transmission process among the KMS system, the MES system, and the programming device is as Figure 4 shown, and the description is as follows:
[0081] For the ciphertext generation process, input the first initial vector (16 bytes), the first key (16 bytes) + padding with all 00s (16 bytes), and the default key with all FFs (16 bytes). Specify the first key. Since the first initial vector has been randomly generated, the first keys of all ECUs can be fixed, reducing the key management cost; fill all 00s after the first key for internal logic judgment in the ECU; use the AES-128-CBC algorithm. For this algorithm, the input also includes the default key with all FFs (16 bytes).
[0082] The first key decryption process is as Figure 5 shown, Figure 6 indicating the ECU logic judgment process during the first key decryption, and the description is as follows:
[0083] Use the UDS2E service to write the ciphertext of the first key in the format of "2E DID IV ciphertext of the first key". The ECU decrypts the ciphertext of the first key using the AES-128-CBC algorithm. After decryption, check whether the last 16 bytes are all 0x00. If so, the first key can be stored in the ECU secure environment; otherwise, return NRC22 to the host computer for the staff to find the problem.
[0084] The second key encryption process is as Figure 7 shown, and the signal transmission process among the KMS system, the MES system, and the programming device is as Figure 8 shown, and the description is as follows:
[0085] For the ciphertext generation process, input the second initial vector (12 bytes), the second key, and the first key obtained by decryption. Figure 8 In , the KMS system is used to issue a 12-byte random number as the second initial vector. Since the second initial vector has been randomly generated, the second keys of all ECUs can be fixed, reducing the key management cost.
[0086] Using the AES-128-GCM algorithm, the ciphertext (16 bytes) and TAG (16 bytes) of the second key are obtained. This process can be executed on the production line MES system. The reason for choosing the GCM algorithm here is that it combines efficient encryption capabilities and data integrity checks. According to the algorithm definition, associated data (AAD) can also be added, such as session identifiers, timestamps, serial numbers, or device identifiers, etc.
[0087] The decryption process of the second key, as Figure 9 shown, Figure 10 indicates the ECU logic judgment process during the decryption of the second key, which is explained as follows:
[0088] The ciphertext of the second key is written using the UDS2E service. This process can be carried out on the production line flashing device, and the format is "2E DID Second IV Ciphertext of the second key TAG". Inside the ECU, the ciphertext of the second key is decrypted through the AES-128-GCM algorithm, and it is judged whether the TAG data has been tampered with. If the verification passes, the second key is stored in the ECU secure environment; otherwise, NRC22 is sent to the host computer.
[0089] The key injection method provided by this application is applicable to the situation where the ECU needs to use a 16-byte key for calculations. For example, in the SecOC (Secure Onboard Communication) security solution, as the key of the AES-128-CMAC (Cipher based Message Authentication Code) algorithm, it can be used to verify the integrity of communication data.
[0090] The key injection method provided by this application is applicable when there is a mature KMS system on the production line. If there is no KMS system, the random number generator interface can be called, but in this scenario, the key management process needs to be added to ensure that relevant information is not leaked and can be effectively managed.
[0091] The key injection method provided by this application designs an implementation method of injecting the ciphertext of the key into the ECU, including the design scheme on the production line and the internal implementation logic of the ECU, avoiding the transmission of the cleartext of the key and reducing the control costs of production line and after-sales personnel; this application designs two layers of keys, and the ciphertext of one key is decrypted and obtained by using the cleartext of another key, improving the difficulty of hackers' key replacement after the vehicle is sold; this application designs a method of writing the ECU key through the UDS2E service, avoiding writing the key into the code, and improving the flexibility of key replacement in the after-sales scenario; in the design of this application, the AES-128-GCM algorithm is adopted, making full use of the characteristics of the algorithm itself to increase the integrity check during the key injection process; this application designs the KMS system to generate the IV, ensuring the randomness of the IV and the security of IV control.
[0092] It should be understood that although Figure 1 the steps in the flowchart of Figure 1 are shown in sequence according to the indication of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, there is no strict order limit for the execution of these steps, and these steps can be executed in other orders. Moreover,
[0093] In one embodiment, as Figure 11 shown, a key injection device is provided, including: an acquisition module 210 and an injection module 220, where:
[0094] The acquisition module 210 is configured to acquire the ciphertext of the first key and acquire the ciphertext of the second key, where the ciphertext of the first key is encrypted based on the first key and the first initial vector, and the ciphertext of the second key is encrypted based on the second key, the first key and the second initial vector;
[0095] The injection module 220 is configured to inject the ciphertext of the first key and the ciphertext of the second key into the electronic control unit;
[0096] wherein, the electronic control unit is configured to decrypt and obtain the first key based on the ciphertext of the first key and the first initial vector; decrypt and obtain the second key based on the ciphertext of the second key, the first key and the second initial vector.
[0097] For the above key injection device, the ciphertext of the first key is obtained by encrypting the first key and the first initial vector, and the ciphertext of the second key is obtained by encrypting the second key, the first key, and the second initial vector. The ciphertexts of the first key and the second key are injected into the electronic control unit. The electronic control unit obtains the first key through the first unlocking, and applies the first key to perform the second unlocking to obtain the second key. In this form, after the encryption operation, the key for communication transmission is the ciphertext, which avoids excessive personnel from contacting the key and reduces the risk of key leakage.
[0098] In one embodiment, the obtaining module 210 fills check bits in the first key according to a preset value and a preset number of bytes to obtain a combination of the first key and the check bits; and obtains the ciphertext of the first key according to the combination of the first key and the check bits.
[0099] For the electronic control unit to decrypt the ciphertext of the first key and the first initial vector to obtain the first key and the check bits, and perform verification according to the check bits. When the check bits pass the verification, the first key is stored.
[0100] In one embodiment, the obtaining module 210 is further configured to encrypt the second key, the first key, and the second initial vector to obtain the ciphertext of the second key and a tag, for the electronic control unit to decrypt the ciphertext of the second key, the first key, the second initial vector, and the tag to obtain the second key, and perform verification according to the tag. When the tag passes the verification, the second key is stored.
[0101] Among them, the ciphertext of the first key is obtained based on the first encryption mode; the ciphertext of the second key is obtained based on the second encryption mode.
[0102] In one embodiment, the obtaining module 210 obtains a first random number as the first initial vector and a second random number as the second initial vector.
[0103] The key injection device further includes a storage module, configured to bind the first random number, the second random number to the electronic control unit, and store the binding relationship.
[0104] The injection module 220 is further configured to receive a verification failure feedback sent by the electronic control unit when the check bit verification or the tag verification fails, so as to determine the failure reason according to the verification failure feedback.
[0105] For the specific limitations of the key injection device, reference can be made to the limitations of the key injection method in the above text, which will not be elaborated here. Each module in the above key injection device can be implemented in whole or in part by software, hardware, and their combination. The above 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 the above modules.
[0106] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structural diagram may be as shown in Figure 12 . The computer device includes a processor, a memory, a network interface, a display screen, and an input device 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 and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. 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 key injection method is implemented. The display screen of the computer device may be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device may be a touch layer covering the display screen, or a button, a trackball, or a touchpad provided on the housing of the computer device, or an external keyboard, touchpad, or mouse, etc.
[0107] Those skilled in the art can understand that Figure 12 the structure shown in is only a block diagram of some structures 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 some components, or have a different component layout.
[0108] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the computer program, the following steps are implemented:
[0109] Obtain the ciphertext of the first key, where the ciphertext of the first key is obtained by encrypting the first key and the first initial vector;
[0110] Obtain the ciphertext of the second key, where the ciphertext of the second key is obtained by encrypting the second key, the first key, and the second initial vector;
[0111] Inject the ciphertext of the first key and the ciphertext of the second key into the electronic control unit, where the electronic control unit is configured to decrypt the ciphertext of the first key and the first initial vector to obtain the first key; based on the ciphertext of the second key, the first key, and the second initial vector, decrypt to obtain the second key.
[0112] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0113] Fill check bits in the first key according to a preset value and a preset number of bytes to obtain a combination of the first key and the check bits;
[0114] Obtain the ciphertext of the first key according to the combination of the first key and the check bit;
[0115] The electronic control unit is further configured to:
[0116] Decrypt based on the ciphertext of the first key and the first initial vector to obtain the first key and the check bit, perform verification according to the check bit, and store the first key when the check bit verification passes.
[0117] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0118] Encrypt according to the second key, the first key and the second initial vector to obtain the ciphertext of the second key and the tag;
[0119] The electronic control unit is configured to:
[0120] Decrypt based on the ciphertext of the second key, the first key, the second initial vector, and the tag to obtain the second key.
[0121] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0122] Perform verification according to the tag, and store the second key when the tag verification passes.
[0123] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0124] Obtain the ciphertext of the first key based on the first encryption mode;
[0125] Obtain the ciphertext of the second key based on the second encryption mode.
[0126] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0127] Obtain the first random number as the first initial vector and the second random number as the second initial vector;
[0128] After injecting the ciphertext of the first key and the ciphertext of the second key into the electronic control unit, it further includes:
[0129] Bind the first random number, the second random number with the electronic control unit, and store the binding relationship.
[0130] In one embodiment, when the processor executes the computer program, the following steps are further implemented:
[0131] When the check bit verification or the tag verification fails, receive the verification failure feedback sent by the electronic control unit to determine the failure reason according to the verification failure feedback.
[0132] 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 following steps are implemented:
[0133] Obtain the ciphertext of the first key, where the ciphertext of the first key is obtained by encrypting the first key and the first initialization vector;
[0134] Obtain the ciphertext of the second key, where the ciphertext of the second key is obtained by encrypting the second key, the first key, and the second initialization vector;
[0135] Inject the ciphertext of the first key and the ciphertext of the second key into the electronic control unit, where the electronic control unit is configured to decrypt the ciphertext of the first key and the first initialization vector to obtain the first key; decrypt the ciphertext of the second key, the first key, and the second initialization vector to obtain the second key.
[0136] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0137] Fill the check bits in the first key according to a preset value and a preset number of bytes to obtain a combination of the first key and the check bits;
[0138] Obtain the ciphertext of the first key according to the combination of the first key and the check bits;
[0139] The electronic control unit is further configured to:
[0140] Decrypt the ciphertext of the first key and the first initialization vector to obtain the first key and the check bits, perform verification according to the check bits, and store the first key when the verification of the check bits passes.
[0141] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0142] Encrypt the second key, the first key, and the second initialization vector to obtain the ciphertext of the second key and the tag;
[0143] The electronic control unit is configured to:
[0144] Decrypt the ciphertext of the second key, the first key, the second initialization vector, and the tag to obtain the second key.
[0145] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0146] Perform verification according to the tag, and store the second key when the verification of the tag passes.
[0147] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0148] Obtain the ciphertext of the first key based on the first encryption mode;
[0149] Obtain the ciphertext of the second key based on the second encryption mode.
[0150] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0151] Obtain a first random number as the first initial vector and a second random number as the second initial vector;
[0152] After injecting the ciphertext of the first key and the ciphertext of the second key into the electronic control unit, the following is further included:
[0153] Bind the first random number, the second random number to the electronic control unit, and store the binding relationship.
[0154] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0155] In the case where the parity check or the tag check fails, receive the check failure feedback sent by the electronic control unit to determine the cause of failure according to the check failure feedback.
[0156] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. 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 methods. Among them, any reference to a memory, storage, database or other medium used in the embodiments provided in the present application can include non-volatile and / or volatile memories. Non-volatile memories can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memories can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0157] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, 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, it should be considered as the scope described in this specification.
[0158] The above embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed. However, it should not be construed as a limitation on the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.
Claims
1. A key injection method, characterized in that, Including: Obtain the ciphertext of the first key, where the ciphertext of the first key is obtained by encrypting the first key and a first initial vector; Obtain the ciphertext of the second key, where the ciphertext of the second key is obtained by encrypting the second key, the first key, and a second initial vector; Inject the ciphertext of the first key and the ciphertext of the second key into an electronic control unit, where the electronic control unit is configured to decrypt the ciphertext of the first key and the first initial vector to obtain the first key; decrypt the ciphertext of the second key, the first key, and the second initial vector to obtain the second key.
2. The key injection method according to claim 1, characterized in that, The obtaining the ciphertext of the first key and the obtaining the ciphertext of the second key include: Obtain the ciphertext of the first key based on a first encryption mode; Obtain the ciphertext of the second key based on a second encryption mode.
3. The key injection method according to claim 1, characterized in that, The obtaining the ciphertext of the first key further includes: Fill a check bit in the first key according to a preset value and a preset number of bytes to obtain a combination of the first key and the check bit; Obtain the ciphertext of the first key according to the combination of the first key and the check bit; The electronic control unit is further configured to: Decrypt the ciphertext of the first key and the first initial vector to obtain the first key and the check bit, perform a check according to the check bit, and store the first key when the check of the check bit passes.
4. The key injection method according to claim 1, wherein The obtaining the ciphertext of the second key further includes: Encrypt the second key, the first key, and the second initial vector to obtain the ciphertext of the second key and a tag; The electronic control unit is configured to: Decrypt the ciphertext of the second key, the first key, the second initial vector, and the tag to obtain the second key.
5. The key injection method according to claim 4, wherein After decrypting to obtain the second key, it further includes: Perform a check according to the tag, and store the second key when the check of the tag passes.
6. The key injection method according to claim 1, characterized in that, Before the obtaining the ciphertext of the first key and the obtaining the ciphertext of the second key, it further includes: Obtain a first random number as the first initial vector and a second random number as the second initial vector; After injecting the ciphertext of the first key and the ciphertext of the second key into the electronic control unit, it further includes: Bind the first random number, the second random number to the electronic control unit, and store the binding relationship.
7. The key injection method according to any one of claims 3 or 5, characterized in that After injecting the ciphertext of the first key and the ciphertext of the second key into the electronic control unit, it further includes: When the check of the check bit or the check of the tag fails, receive a check failure feedback sent by the electronic control unit to determine the cause of failure according to the check failure feedback.
8. A key injection device, characterized in that, The device includes: An obtaining module, configured to obtain the ciphertext of the first key and obtain the ciphertext of the second key, where the ciphertext of the first key is obtained by encrypting the first key and a first initial vector, and the ciphertext of the second key is obtained by encrypting the second key, the first key, and a second initial vector; An injecting module, configured to inject the ciphertext of the first key and the ciphertext of the second key into an electronic control unit; Wherein, the electronic control unit is configured to decrypt and obtain the first key based on the ciphertext of the first key and the first initial vector; decrypt and obtain the second key based on the ciphertext of the second key, the first key and the second initial vector.
9. A computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the method according to any one of claims 1 to 7 is implemented.