Data security processing method, computer program product, electronic device and storage medium
By encrypting and encapsulating the vehicle ECU data, generating message frames of ciphertext, serial number and truncated message authentication code, the problem of insufficient security of the ECU data encryption algorithm in the prior art is solved, and higher data security and integrity are achieved.
Patent Information
- Application Number
- CN202510834474.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-20
- Publication Date
- 2025-08-15
AI Technical Summary
The existing vehicle ECU data encryption algorithm is insufficiently secure and vulnerable to malicious attacks.
The target data to be transmitted is encrypted using a key, and the ciphertext is generated, and the serial number and truncated message authentication code are encapsulated to form a message frame, and the receiver performs verification and decryption.
By encrypting and encapsulating the target data, the security of the data is improved, tampering is prevented and the authenticity and integrity of the data is improved.
Smart Images

Figure CN120498857A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security technology, and more specifically, to a data security processing method, a computer program product, an electronic device, and a storage medium. Background Art
[0002] The Electronic Control Unit (ECU), the core control hub of modern automotive electronics, is responsible for real-time monitoring and precise control of vehicle subsystems such as the engine, transmission, and braking system. The ECU sends and receives control commands and vehicle status information through the gateway.
[0003] The data transmitted between the vehicle ECU and the gateway needs to be encrypted to improve data security, but the existing encryption algorithm still has a certain probability of being maliciously attacked and is not secure enough.
[0004] In view of this, this application is filed. Summary of the Invention
[0005] The purpose of this application is to provide a data security processing method, a computer program product, an electronic device and a storage medium to improve data security.
[0006] In order to achieve the above objectives, this application adopts the following technical solutions: In a first aspect, the present application provides a data security processing method, comprising: Obtain target data to be transmitted; The target data to be transmitted is encrypted using a key to obtain a ciphertext; Encapsulating the ciphertext, the sequence number, and the truncated message authentication code to obtain a message frame; the truncated message authentication code is generated based on the ciphertext, the sequence number, and the key; The message frame is sent to a receiving end so that the receiving end can verify and decrypt the message frame.
[0007] Secondly, this application provides another data security processing method, including: Receive a message frame, wherein the message frame is obtained according to the method described in the first aspect; Parsing the message frame to obtain the ciphertext, the sequence number and the truncated message authentication code to be verified; Obtaining a reference truncated message authentication code based on the ciphertext, the sequence number, and the local key; If the reference truncated message authentication code is consistent with the truncated message authentication code to be verified, the ciphertext is decrypted using the key to obtain the target data.
[0008] In a third aspect, the present application provides a computer program product, which, when executed on a computer, enables the computer to execute the data security processing method described in the first or second aspect above.
[0009] In a fourth aspect, the present application provides an electronic device, comprising: at least one processor, and a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by at least one of the processors, and the instructions are executed by at least one of the processors so that at least one of the processors can execute the above-mentioned data security processing method.
[0010] In a fifth aspect, the present application provides a computer-readable storage medium, on which computer instructions are stored, and the computer instructions are used to enable a computer to execute the above-mentioned data security processing method.
[0011] Compared with the prior art, the present invention has the following advantages: This application first encrypts the target data to be transmitted to obtain ciphertext, and then generates a truncated message authentication code based on the ciphertext, sequence number, and key. The ciphertext, sequence number, and truncated message authentication code are then encapsulated into a message frame, so that the message frame includes the ciphertext, sequence number, and key information. This performs two operations on the target data: encryption and encapsulation. This allows the encapsulation layer to be verified using the truncated message authentication code, and the encryption layer to be decrypted using the key, thereby improving the security of the target data. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the specific implementation methods of the present application or the technical solutions in the prior art, the following will briefly introduce the drawings required for use in the specific implementation methods or the description of the prior art. Obviously, the drawings described below are some implementation methods of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0013] Figure 1 This is a flowchart of a data security processing method provided by this application; Figure 2 This is a flow chart of another data security processing method provided in an embodiment of the present application; Figure 3 This is a flowchart of another data security processing method provided in an embodiment of the present application; Figure 4 It is a structural diagram of the electronic device provided in this application. DETAILED DESCRIPTION
[0014] The following description of exemplary embodiments of the present application is made in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0015] The present application is further described in detail below with reference to the embodiments.
[0016] Figure 1 The following is a flow chart of a data security processing method provided in this embodiment. This method can be executed by a computer program and integrated into an electronic device, such as an electronic control unit (ECU). This embodiment uses the data security processing method integrated into the electronic device to encrypt and encapsulate target data to obtain a message frame, and then sends the message frame to another electronic device for verification and decryption.
[0017] like Figure 1 As shown, this embodiment provides a data security processing method for encrypting and encapsulating target data, which specifically includes the following steps: S110: Obtain target data to be transmitted.
[0018] This embodiment does not limit the type of target data; it can be vehicle status data or control instructions. This target data needs to be transmitted from one ECU (e.g., the engine ECU) to another ECU (e.g., the gateway ECU). For ease of description and distinction, the end that encrypts and encapsulates the target data is called the sending end, and the end that performs verification and decryption is called the receiving end.
[0019] S120: Encrypt the target data to be transmitted using a key to obtain a ciphertext.
[0020] This embodiment does not limit the encryption algorithm for the target data, and a symmetric encryption algorithm or an asymmetric encryption algorithm can be used. Taking the symmetric encryption algorithm as an example, the target data is encrypted using a symmetric encryption key to obtain a ciphertext.
[0021] S130. Encapsulate the ciphertext, the sequence number, and the truncated message authentication code to obtain a message frame.
[0022] A truncated MAC (Message Authentication Code) is generated based on the ciphertext, a sequence number, and a key. The sequence number identifies the order of multiple target data. For example, the sequence number of the first target data is 1, and the sequence number of the second target data is 2.
[0023] A MAC operation is performed on the ciphertext, sequence number, and key to obtain a MAC value. In some application scenarios, due to resource limitations or protocol design requirements, the length of the MAC value needs to be shortened to obtain a truncated MAC.
[0024] Then, the ciphertext, sequence number, and truncated message authentication code are formed into a complete string as the data field of the CAN (Controller Area Network) message frame. The frame start, arbitration field, and control field are added before the data field. The CRC field (Cyclic Redundancy Check Field), response field, and frame end are added after the data field to finally form a complete CAN message frame.
[0025] S140: Send the message frame to the receiving end, so that the receiving end can verify and decrypt the message frame.
[0026] The transmitter sends a message frame to the receiver, another ECU. The receiver verifies and decrypts the message frame. The verification process determines whether the message frame has been tampered with during transmission and discards any potentially tampered frames. For untampered frames, the target data is decrypted.
[0027] This application first encrypts the target data to be transmitted to obtain ciphertext, and then generates a truncated message authentication code based on the ciphertext, sequence number, and key. The ciphertext, sequence number, and truncated message authentication code are then encapsulated into a message frame, so that the message frame includes the ciphertext, sequence number, and key information. This performs two operations on the target data: encryption and encapsulation. This allows the encapsulation layer to be verified using the truncated message authentication code, and the encryption layer to be decrypted using the key, thereby improving the security of the target data.
[0028] Figure 2 This is a flow chart of another data security processing method provided in an embodiment of the present application, which describes in detail the encryption process and packaging process of the target data. Figure 2 The data security processing method shown includes the following operations: S200: Obtain a session key from the gateway electronic control unit ECU.
[0029] In this embodiment, the key used to encrypt the target data is the session key, which needs to be obtained from the gateway ECU. The gateway ECU is integrated with a hierarchical key management mechanism. KThe master key is embedded in a hardware security module (HSM). An HSM is a physical device designed specifically to protect sensitive data and perform cryptographic operations. It provides a highly secure environment for storing, managing, and processing encryption keys, ensuring data security and integrity. This embodiment uses an HSM for secure storage of the master key.
[0030] The gateway ECU uses the key derivation function to obtain the master key ( K master) generates a session key ( K session). For example, a key derivation function (HKDF) based on a hashed message authentication code (HMAC) is used. HKDF is a key derivation function based on a hashed message authentication code (HMAC). Its design purpose is to derive one or more highly secure keys from limited input key material (such as a shared secret, a random salt value, etc.). For details, see the following formula: K session=HKDF( K master,Salt∥VIN, L =128); Among them, Salt random number seed enhances key uniqueness; VIN: vehicle unique identifier, used to bind the key to the vehicle identity; L=128: the key length is 128 bits.
[0031] Optionally, the session key is rotated once every set period (for example, every hour) and broadcast by the gateway ECU to each ECU through a secure channel, thereby updating the local session key of each ECU.
[0032] Optionally, to further enhance the security of session keys and prevent them from being stolen, the gateway ECU broadcasts a revocation command to all other ECUs upon detecting a compromise of any ECU. Each ECU responds by revoking its local session key. The gateway ECU then derives a new session key from the master key and broadcasts it to all other ECUs, updating the session key.
[0033] S210: Acquire target data to be transmitted.
[0034] S220 , based on the stream cipher working mode, using the session key to encrypt the target data to be transmitted byte by byte to obtain a ciphertext.
[0035] This embodiment uses a dual buffer to concurrently acquire and encrypt target data, improving data encryption efficiency. The dual buffer comprises a first encryption buffer and a second encryption buffer. The first encryption buffer acquires target data A to be transmitted and stores it in the second encryption buffer. The first encryption buffer then acquires target data B. The second encryption buffer encrypts target data A using a key to obtain ciphertext, and then encrypts target data B to obtain ciphertext. This demonstrates that the parallel operation of the first and second encryption buffers effectively improves data encryption efficiency.
[0036] In specific implementations, the first encryption buffer is in the writable (READY) state when acquiring the target data, with exclusive access by the data receiving thread. The second encryption buffer is in the occupied (BUSY) state when encrypting the target data, with exclusive access by the encryption thread. By allocating the states of the two encryption buffers and threads, streaming filling and encryption of the target data is achieved.
[0037] During the encryption process of target data, if new data with a higher priority than the target data is detected, the encryption process is interrupted and the new data is encrypted using the key to generate ciphertext, ensuring that the high-priority new data is encrypted and transmitted first. For example, if a command with a higher priority than the target data (such as a brake command) arrives in the first encryption buffer, a hardware interrupt is triggered, pausing the encryption task of the target data in the second encryption buffer and saving the current operation status. The second encryption buffer immediately encrypts the high-priority command and then resumes encryption of the target data.
[0038] Optionally, to ensure the real-time nature of the interrupt triggering, a hardware interrupt of the second encryption buffer is triggered through a field programmable gate array (FPGA), with an interrupt response time of ≤ 10μs, ensuring that high-priority data is processed without delay.
[0039] This step uses a stream cipher mode to encrypt the target data byte by byte to produce ciphertext, without padding the target data. Optionally, Advanced Encryption Standard - Counter Mode (AES-CTR) can be used for encryption. AES-CTR is a stream cipher mode based on the AES block cipher. It achieves efficient encryption by converting the block cipher into a key stream, making it suitable for high-speed data transmission and parallel computing scenarios. The AES-CTR encryption process is shown in the following formula: ; in, P i : No. i Byte plaintext; C i: No. i Byte ciphertext; Nonce: sequence number. ⊕ is the exclusive OR operation.
[0040] The stream cipher mode is executed by a dedicated circuit in the HSM, which in this embodiment may be an AES-CTR dedicated circuit, ensuring that the single encryption delay is ≤ 0.3ms.
[0041] S230. Use a lightweight message authentication code algorithm to process the ciphertext, sequence number, and key to obtain a data sequence.
[0042] S240: intercept the data sequence to obtain an intercepted message authentication code.
[0043] A lightweight message authentication code algorithm, such as the Chaskey algorithm, is based on a pseudorandom function (PRF) and a block cipher structure. It uses a 128-bit key and a 128-bit message block to generate a data sequence, and then extracts the first 8 bytes of the data sequence as the message authentication code (MAC). See the following formula: MAC=Chaskey( K session, C ∥Nonce)[0:8]; Among them, C is the ciphertext, K Session is the key and Nonce is the serial number.
[0044] S250: sequentially concatenate the ciphertext, the sequence number, and the truncated message authentication code to obtain a message frame.
[0045] For example, the ciphertext occupies 5 bytes, the sequence number occupies 2 bytes, and the MAC occupies 1 byte. The data field of the concatenated message frame is as follows: | 5-byte ciphertext | 2-byte sequence number | 1-byte truncated MAC |; The serial number can be generated by a 16-bit cyclic counter to prevent replay attacks.
[0046] S260: Send the message frame to the receiving end, so that the receiving end can verify and decrypt the message frame.
[0047] This embodiment uses encryption and encapsulation without padding to obtain an 8-byte CAN frame with a payload rate of 100%. It can adapt to standard CAN frames without upgrading to the Controller Area Network with Flexible Data-Rate (CAN FD).
[0048] Figure 3This is a flow chart of another data security processing method provided by an embodiment of the present application. The method provided by this embodiment is applicable to the receiving end of the message frame, which can be any vehicle-mounted ECU. After receiving the message frame from the sending end, the receiving end verifies and decrypts the message frame and finally obtains the target data. Figure 3 , specifically including the following operations: S310: Receive a message frame.
[0049] S320: Parse the message frame to obtain the ciphertext, sequence number, and truncated MAC to be verified.
[0050] According to the description of the above embodiment, the ciphertext, sequence number, and truncated MAC are sequentially concatenated to form a message frame. The ciphertext, sequence number, and truncated MAC can then be parsed sequentially. Because the message frame may be intercepted and tampered with during transmission, the truncated MAC parsed here needs to be verified and is referred to as the unverified truncated MAC.
[0051] S330: Obtain a reference truncated MAC based on the ciphertext, the sequence number, and the local key.
[0052] If both the receiving and sending ends store the same key (derived session key), a lightweight message authentication code algorithm (such as the Chaskey algorithm) is used to process and truncate the receiving end's local key, ciphertext, and sequence number to obtain a baseline truncated MAC. The method for obtaining the baseline truncated MAC is described in the previous embodiment and will not be repeated here.
[0053] S340: Determine whether the reference truncated MAC is consistent with the MAC to be verified. If yes, execute S350; if not, execute S360.
[0054] S350: Decrypt the ciphertext using the key to obtain the target data.
[0055] This embodiment uses a dual buffer to load and decrypt target data in parallel, improving data decryption efficiency. The dual buffer consists of a first decryption buffer and a second decryption buffer. Ciphertext B is loaded into the first decryption buffer and stored in the second decryption buffer. The first decryption buffer then retrieves ciphertext C. Ciphertext B is decrypted using the key in the second decryption buffer to obtain the target data. Ciphertext C is then decrypted to obtain the target data. This demonstrates that the parallel operation of the first and second decryption buffers effectively improves data decryption efficiency.
[0056] In specific implementations, the first decryption buffer is in the writable (READY) state, recording the ciphertext and exclusively accessed by the data receiving thread. The second decryption buffer is in the occupied (BUSY) state while decrypting the ciphertext, and its access rights are exclusively reserved for the decryption thread. By allocating the two decryption buffer states and threads, stream-based filling and decryption of ciphertext is achieved.
[0057] During the ciphertext decryption process, if a new ciphertext with a higher priority is detected, the current ciphertext decryption process is interrupted and the new ciphertext is decrypted using the key to obtain the target data, ensuring that the high-priority new ciphertext is decrypted first. Optionally, a hardware interrupt is triggered in the second decryption buffer via a field-programmable gate array (FPGA), with an interrupt response time of ≤ 10μs, ensuring that high-priority ciphertext is processed without delay.
[0058] S360: Discard the parsed ciphertext, sequence number, and MAC to be verified.
[0059] If the baseline truncated MAC matches the MAC to be verified, indicating that the data is authentic and complete, the session key and the AES-CTR decryption algorithm are used to parse the ciphertext to obtain the target data. If the baseline truncated MAC does not match the MAC to be verified, indicating that the data has been tampered with, the parsed data is discarded.
[0060] In some technical solutions, before verifying the consistency of the truncated MAC, it is also necessary to perform a sequence number-based replay attack protection test. Replay attack protection is a security mechanism used to prevent attackers from intercepting and repeatedly sending valid old message frames, thereby deceiving the system into performing unauthorized operations (such as repeated transfers, forged identity authentication, etc.). Optionally, before obtaining the baseline truncated message authentication code based on the ciphertext, sequence number, and local key, the position of the sliding window is determined based on the current maximum valid sequence number. If the sequence number is within the sliding window and has not been recorded by the sliding window, it is determined that there has been no replay attack, and the position of the sliding window is updated based on the sequence number to prepare for receiving the sequence number of the next message frame.
[0061] Specifically, the receiver maintains a sliding window for each sender (ECU). This sliding window has a fixed size (e.g., W = 256 bits) and an initial window size of [0, 255]. It is used to record all valid sequence numbers sent by the corresponding sender. A valid sequence number here is a sequence number that excludes replay attack attacks from all sequence numbers.
[0062] The following describes in detail the anti-replay attack method based on sliding window with a specific embodiment.
[0063] When receiving a new sequence number Nonce new, and Nonce new Nonce max When , the sliding window slides forward 1 bit: ; Among them, W is the sliding window size, Nonce max Is the maximum valid sequence number among the valid sequence numbers. If the current sliding window is [100,355], the received Nonce new is 356, then the sliding window after sliding is [101,356].
[0064] After sliding the sliding window forward, determine whether the sequence number is within the sliding window. Specifically, if the received new sequence number Nonce new If the following conditions are met, the anti-replay attack detection is passed.
[0065] ; in, : Valid sequence number range, window follows Nonce max Increase while sliding forward.
[0066] if If a frame has been recorded within the sliding window, it is considered a replay attack and the data frame is discarded. Furthermore, a notification of the attack is sent to the gateway MAC, and the gateway ECU sends a revocation command to each ECU to update their session keys. The sender must resynchronize the sequence number to ensure continuity of subsequent communications. If the window overflows (e.g., due to a cyclical reset of the sequence number), the window is cleared and reset to the initial window.
[0067] In summary, the above embodiments can significantly improve the security of CAN communication while being compatible with standard CAN frames through the hierarchical key management mechanism, hardware-accelerated encryption engine design, compact data encapsulation and authentication, and anti-replay attack mechanism.
[0068] like Figure 4 As shown, this embodiment provides an electronic device, including: at least one processor; and a memory communicatively connected to at least one processor; wherein, The memory stores instructions executable by at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the above method. The at least one processor in the electronic device is capable of performing the above method, thereby having at least the same advantages as the above method.
[0069] Optionally, the electronic device also includes interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses and can be installed on a common motherboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of a GUI (Graphical User Interface) on an external input / output device (such as a display device coupled to the interface). In other embodiments, if necessary, multiple processors can be used with multiple memories, and / or multiple buses can be used with multiple memories. Similarly, multiple electronic devices can be connected (for example, as a server array, a group of blade servers, or a multi-processor system), with each device providing part of the necessary operations. Figure 4 A processor 301 is taken as an example.
[0070] Memory 302, as a computer-readable storage medium, can be used to store software programs, computer-executable programs, and modules, such as the program instructions / modules corresponding to the data security processing method in the embodiments of the present application. Processor 301 executes the software programs, instructions, and modules stored in memory 302 to execute various functional applications and data processing of the device, thereby implementing the aforementioned data security processing method.
[0071] The memory 302 may primarily include a program storage area and a data storage area. The program storage area may store an operating system and at least one application required for a function; the data storage area may store data created based on the use of the terminal, etc. Furthermore, the memory 302 may include high-speed random access memory and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 302 may further include a memory remotely located relative to the processor 301, and these remote memories may be connected to the device via a network. Examples of the aforementioned networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0072] The electronic device may further include: an input device 303 and an output device 304. The processor 301, the memory 302, the input device 303 and the output device 304 may be connected via a bus or other means. Figure 4 The bus connection is taken as an example.
[0073] The input device 303 can receive input digital or character information, and the output device 304 can include a display device, an auxiliary lighting device (e.g., an LED), a tactile feedback device (e.g., a vibration motor), etc. The display device may include, but is not limited to, a liquid crystal display (LCD), a light-emitting diode (LED) display, and a plasma display. In some embodiments, the display device may be a touch screen.
[0074] This embodiment provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to cause a computer to execute the above method. The computer instructions on the computer-readable storage medium are used to cause a computer to execute the above method, thereby having at least the same advantages as the above method.
[0075] The medium in this application may be any combination of one or more computer-readable media. The medium may be a computer-readable signal medium or a computer-readable storage medium. The medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination thereof. More specific examples of media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0076] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0077] The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wire, optical cable, RF (Radio Frequency), etc., or any suitable combination of the foregoing.
[0078] Computer program code for performing the operations of the present application can be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0079] In the above embodiments, all or part of the embodiments can be implemented using software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired connection, such as a coaxial cable, optical fiber, digital subscriber line (DSL), or wireless connection, such as infrared, wireless, or microwave. The computer-readable storage medium can be any available medium that can be accessed by a computer, or a data storage device, such as a server or data center, that includes one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, hard disk, or magnetic tape), an optical medium, or a semiconductor medium. It is worth noting that the computer-readable storage medium mentioned in the embodiments of the present application may be a non-volatile storage medium, in other words, a non-transitory storage medium.
[0080] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this application can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this application can be achieved. This is not a limitation herein.
[0081] The above specific embodiments do not constitute a limitation on the scope of protection of this application. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this application shall be included within the scope of protection of this application.
Claims
1. A data security processing method, characterized in that: include: Obtain target data to be transmitted; The target data to be transmitted is encrypted using a key to obtain a ciphertext; Encapsulating the ciphertext, the sequence number and the truncated message authentication code to obtain a message frame; The truncated message authentication code is generated based on the ciphertext, the sequence number and the key; The message frame is sent to a receiving end so that the receiving end can verify and decrypt the message frame.
2. The data security processing method according to claim 1, characterized in that: The target data to be transmitted is encrypted using a key to obtain ciphertext, including: Based on the stream cipher working mode, the target data to be transmitted is encrypted byte by byte using the key to obtain the ciphertext; The stream cipher working mode is executed by a dedicated circuit in a hardware security module.
3. The data security processing method according to claim 1, characterized in that: The key is a session key; Before using the key to encrypt the target data to be transmitted to obtain the ciphertext, the following steps are also included: Obtaining a session key from the gateway electronic control unit ECU; the session key is derived from the master key solidified in the hardware security module; The data security processing method further includes: In response to a revocation instruction broadcasted by the gateway ECU after detecting that any ECU has been invaded, the local session key is revoked.
4. The data security processing method according to claim 1, characterized in that: Get the target data to be transmitted, including: Acquire target data to be transmitted through the first encryption buffer, and store the target data in the second encryption buffer; encrypting the target data to be transmitted using a key in the second encryption buffer to obtain a ciphertext; During the encryption process of the target data, if new data with a higher priority than the target data is detected, the encryption process of the target data is interrupted, and the new data is encrypted with a key to obtain a ciphertext.
5. The data security processing method according to any one of claims 1 to 4, characterized in that: Before encapsulating the ciphertext, sequence number and truncated message authentication code to obtain a message frame, the method further includes: Using a lightweight message authentication code algorithm, the ciphertext, the sequence number and the key are processed to obtain a data sequence; intercepting the data sequence to obtain an intercepted message authentication code; The ciphertext, sequence number and truncated message authentication code are encapsulated to obtain a message frame, including: The ciphertext, sequence number and truncated message authentication code are sequentially concatenated to obtain a message frame.
6. A data security processing method, characterized in that: include: receiving a message frame, wherein the message frame is obtained according to the method according to any one of claims 1 to 5; Parsing the message frame to obtain the ciphertext, the sequence number and the truncated message authentication code to be verified; Obtaining a reference truncated message authentication code based on the ciphertext, the sequence number, and the local key; If the reference truncated message authentication code is consistent with the truncated message authentication code to be verified, the ciphertext is decrypted using the key to obtain the target data.
7. The data security processing method according to claim 6, characterized in that: Before obtaining a reference truncated message authentication code according to the ciphertext, the sequence number and the local key, the method further includes: Determine the position of a sliding window according to the current maximum valid sequence number, wherein the sliding window has a fixed size and is used to record all valid sequence numbers; If the sequence number is within the sliding window and is not recorded by the sliding window, it is determined that no replay attack has occurred; The position of the sliding window is updated according to the sequence number.
8. A computer program product, characterized in that include: The computer program product stores computer instructions, which, when executed by a processor, implement the steps of the data security processing method according to any one of claims 1 to 7.
9. An electronic device, characterized in that: include: at least one processor, and a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by at least one of the processors, and the instructions are executed by at least one of the processors to enable at least one of the processors to execute the data security processing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that The medium stores computer instructions, which are used to enable a computer to execute the data security processing method according to any one of claims 1 to 7.
Citation Information
Cited By
Security defense method, system and device for controller area network bus and medium
CN121547278A
Method for secure communication between programmable logic controllers, computing device and storage medium
CN122457388A