Secure communication method and system

By using the serialization and deserialization code generated by Python tools in MCU and SOC, and performing CRC16 or checksum verification on the receiver, the problem of large amount of code and data loss of protocol buf protocol is solved, achieving efficient and secure communication .

CN119271187APending Publication Date: 2025-01-07武汉光昱明晟智能科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411196476.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-29
Publication Date
2025-01-07

AI Technical Summary

Technical Problem

The existing protocol buf protocol has large code volume and high hardware resource consumption, which may lead to data loss and commercial development workload, affecting the safety of vehicle driving.

Method used

Use Python tools to generate serialization and deserialization code, integrate it and deploy it in MCU and SOC, communicate through serialization and deserialization, and perform CRC16 or checksum verification on the receiver side to ensure data integrity.

Benefits of technology

It reduces the amount of code and development workload, improves data transmission efficiency and security, avoids data loss, and enhances the reliability and security of communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119271187A_ABST
    Figure CN119271187A_ABST
Patent Text Reader

Abstract

The invention provides a secure communication method and system, and the method comprises the steps: calling a Python tool to generate a serialized code and a deserialized code, carrying out the integrated deployment of the serialized code at a transmitting end, and carrying out the integrated deployment of the deserialized code at a receiving end; the sending end serializes the pre-sent data according to the serialization code, and sends the serialized data to the receiving end; and the receiving end performs deserialization on the serialized data according to the deserialization code, and performs crc16 or checksum verification on the deserialized data. Through the scheme, the code quantity can be reduced, the application development efficiency is improved, and the security and reliability of data communication are guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of communication technology, and in particular relates to a secure communication method and system. Background Art

[0002] The communication between multiple cores on the PC / SOC side is usually processed using the protocol buf protocol. This is mainly because in the protocol buf protocol, the communication data uses a byte stream format, which can greatly reduce the amount of data transmitted. At the same time, the protocol buf protocol has a wide range of applications and is easy to understand and develop.

[0003] However, the code of protocol buf itself is relatively large, and the hardware resource consumption is large. Under the pressure of limited MCU resources and product cost, using protocol buf is not the best choice; MCU and SOC communicate through SPI / UART / ETH, etc., and data loss may occur during the communication process due to electromagnetic interference, vehicle jitter, etc., affecting the driving safety of the vehicle, and protocol buf itself cannot detect data loss. At the same time, protocol buf itself is open source, and commercial use requires substantial adjustments or optimizations, which requires a large development workload. Summary of the invention

[0004] In view of this, an embodiment of the present invention provides a secure communication method and system for solving the problems of large code size, possible data loss and large workload for commercial development of the protocolbuf protocol.

[0005] In a first aspect of an embodiment of the present invention, a secure communication method is provided, comprising:

[0006] Call Python tools to generate serialization code and deserialization code, integrate and deploy the serialization code on the sending end, and integrate and deploy the deserialization code on the receiving end;

[0007] The sending end serializes the pre-sent data according to the serialization code and sends the serialized data to the receiving end;

[0008] The receiving end deserializes the serialized data according to the deserialization code and performs CRC16 or checksum verification on the deserialized data;

[0009] Among them, if the sending end is an MCU chip, the receiving end is a SOC chip; if the sending end is an SOC chip, the receiving end is an MCU chip.

[0010] In a second aspect of an embodiment of the present invention, a secure communication system is provided, including:

[0011] A sending unit, used to serialize the pre-sent data according to the serialization code, and send the serialized data to the receiving end;

[0012] A receiving unit, used to deserialize the serialized data according to the deserialization code, and perform CRC16 or checksum verification on the deserialized data;

[0013] The sending unit integrates and deploys the serialization code generated by the Python tool, and the receiving end integrates and deploys the deserialization code generated by the Python tool;

[0014] If the sending unit is an MCU chip, the receiving unit is an SOC chip; if the sending unit is an SOC chip, the receiving unit is an MCU chip.

[0015] In a third aspect of an embodiment of the present invention, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method described in the first aspect of the embodiment of the present invention when executing the computer program.

[0016] In a fourth aspect of an embodiment of the present invention, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method provided in the first aspect of the embodiment of the present invention are implemented.

[0017] In the embodiment of the present invention, the required code is directly generated based on the Python platform code tool and integrated into the MCU and SOC. It can be applied by simply debugging and adding corresponding interface calls, which can reduce the amount of code, effectively improve development efficiency, and reduce development workload; communication is carried out by serialization and deserialization, and byte stream transmission is adopted, which can not only reduce the amount of transmitted data and improve data transmission efficiency, but also increase the difficulty of cracking and ensure communication security; through crc16 and checksum verification, data loss problems can be avoided, data consistency of both communicating parties is guaranteed, and data security and reliability are enhanced. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0019] Figure 1 A schematic diagram of a flow chart of a secure communication method provided by an embodiment of the present invention;

[0020] Figure 2 A schematic diagram of the principle of a secure communication method provided by an embodiment of the present invention;

[0021] Figure 3 A schematic diagram of the structure of a secure communication system provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0022] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0023] It should be understood that the term "including" and other similar expressions in the specification or claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions, such as a process, method, system, or device including a series of steps or units is not limited to the listed steps or units. In addition, "first" and "second" are used to distinguish different objects, not to describe a specific order.

[0024] See also Figure 1 , a flow chart of a secure communication method provided by an embodiment of the present invention includes:

[0025] S101. Calling a Python tool to generate serialization code and deserialization code, integrating and deploying the serialization code at the sending end, and integrating and deploying the deserialization code at the receiving end;

[0026] The Python tool automatically generates corresponding serialization and deserialization codes according to the structures or objects defined by the communicating parties. The Python tool can be a custom serialization / deserialization program generation tool. The serialization code is the program code that converts the state information of the object into a form that can be stored or transmitted, and the deserialization code is the program code that restores the serialized data to the original object.

[0027] The sending end can be an MCU (Micro Controller Unit) chip or a SOC (System On Chip) chip, and the receiving end can be a SOC chip or an MCU chip. The serialization code and the deserialization code are integrated and deployed, and the sending data can be serialized and the receiving data can be deserialized.

[0028] The serialization code and deserialization code are integrated and deployed separately. After code debugging and adding relevant interface calls, they can be used for communication between MCU and SOC.

[0029] S102, the sending end serializes the pre-sent data according to the serialization code, and sends the serialized data to the receiving end;

[0030] When the pre-sent structured data is serialized, the size of the serialized byte stream is continuously accumulated and used as the starting point for the next structured data serialization, and finally a large byte stream type of data is generated. During data transmission, it is divided into packets according to SPI, ETH (Ethernet protocol), etc., and then sent to the receiving end, which performs packet processing.

[0031] The structure or object data is transmitted through serialization (i.e. the structure / object is converted into a byte stream), which can greatly compress the size of the transmitted data. The internal comparison calculation can reduce the amount of transmitted data by about 1 / 3, increase the transmission rate and reduce the system load. At the same time, byte stream transmission can improve data security, and even if it is intercepted, it is more difficult to crack, avoiding data transmission risks.

[0032] S103, the receiving end deserializes the serialized data according to the deserialization code, and performs CRC16 or checksum verification on the deserialized data;

[0033] Among them, if the sending end is an MCU chip, the receiving end is a SOC chip; if the sending end is an SOC chip, the receiving end is an MCU chip.

[0034] To ensure the security of data stream transmission, a check code can be added to the data stream or a checksum can be calculated. After deserialization, the receiving end can determine whether there is an error in the data by verifying the check code or comparing the checksum.

[0035] CRC16 stands for Cyclic Redundancy Check Code, which is a check method used for data transmission or storage. Its purpose is to detect whether errors occur during data transmission. The principle is to calculate a check value through a specific polynomial and attach it to the end of the data for transmission or storage. After receiving the data, the receiver will recalculate the check value and compare it with the received check value to determine whether the data has changed during transmission.

[0036] Checksum is a data verification method used to check whether the data has changed during transmission or storage. It converts the data into a smaller value, called a checksum, which can be used to check whether the original data has been tampered with. The checksum is usually a string of numbers that can be compared with the received data to determine whether the data is wrong.

[0037] In this embodiment, the deserialized data is subjected to crc16 or checksum verification, and compared with the sent crc16 or checksum to determine whether the data is complete. Through crc16 and checksum verification, byte stream data loss or tampering can be avoided during transmission, ensuring communication security.

[0038] In one embodiment, the serialization code and the deserialization code are both C language codes.

[0039] In this embodiment, the serialization code and the deserialization code are written in C language, and the code is deployed on the MCU and SOC, which can facilitate the application on the MCU platform (many MCUs do not support the C++ language), enhance adaptability and compatibility, and reduce resource usage.

[0040] In one embodiment, code testing and function point detection are performed on the serialization code and the deserialization code.

[0041] After the MCU or SOC integrates the code, the reliability of the code can be guaranteed through code testing and function point detection.

[0042] In some embodiments, when the data verification fails, it is determined that the data transmission has failed, the data content is discarded, and the data content transmitted in the previous cycle is used as the data content received this time.

[0043] Add regular crc16 or checksum verification. When the verification fails, it is considered that the data transmission has failed. The data content of this cycle is directly discarded and the content of the previous cycle is used. This can ensure the stability and reliability of communication and avoid serious accidents.

[0044] In some embodiments, developers call tools to generate serialization and deserialization C codes, which are integrated in MCU and SOC respectively. MCU or SOC serializes the sent data, and the other end receives and deserializes it. The deserialized data is subjected to CRC16 or checksum verification. If the verification passes, it means that the data is available. Otherwise, the corresponding fail-safe processing is performed if the communication fails. Figure 2 As shown in the figure, MCU integrates serialization code and SOC integrates deserialization code. After MCU serializes the pre-sent data, it calls the underlying sending interface to transmit the data stream to SOC through SPI or ETH. After SOC calls the underlying interface to receive the data stream, it parses the required data through deserialization, and then performs crc16 or checksum verification to verify whether the received data is complete.

[0045] It should be understood that the serial numbers of the steps in the above embodiments do not imply a sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0046] Figure 3 A schematic diagram of the structure of a secure communication system provided by an embodiment of the present invention, the system 30 includes:

[0047] The sending unit 310 is used to serialize the pre-sent data according to the serialization code and send the serialized data to the receiving end;

[0048] The receiving unit 320 is used to deserialize the serialized data according to the deserialization code, and perform CRC16 or checksum verification on the deserialized data;

[0049] The sending unit integrates and deploys the serialization code generated by the Python tool, and the receiving end integrates and deploys the deserialization code generated by the Python tool;

[0050] If the sending unit is an MCU chip, the receiving unit is an SOC chip; if the sending unit is an SOC chip, the receiving unit is an MCU chip.

[0051] Preferably, the serialization code and the deserialization code are both C language codes.

[0052] In one embodiment, before integrating the serialization code and the deserialization code, the deployment includes:

[0053] Perform code testing and function point detection on serialization code and deserialization code.

[0054] In one embodiment, the receiving unit 320 further includes:

[0055] When the data verification fails, it is determined that the data transmission has failed, the data content is discarded, and the data content transmitted in the previous cycle is used as the data content received this time.

[0056] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and modules described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0057] A person skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, part or all of the processes in steps S101 to S103 are implemented, and the storage medium includes ROM / RAM, etc.

[0058] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0059] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features thereof may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A secure communication method, characterized in that: include: Call Python tools to generate serialization code and deserialization code, integrate and deploy the serialization code on the sending end, and integrate and deploy the deserialization code on the receiving end; The sending end serializes the pre-sent data according to the serialization code and sends the serialized data to the receiving end; The receiving end deserializes the serialized data according to the deserialization code and performs CRC16 or checksum verification on the deserialized data; Among them, if the sending end is an MCU chip, the receiving end is a SOC chip; if the sending end is an SOC chip, the receiving end is an MCU chip.

2. The method according to claim 1, characterized in that The serialization code and the deserialization code are both C language codes.

3. The method according to claim 1, characterized in that The step of integrating and deploying the serialization code at the sending end and integrating and deploying the deserialization code at the receiving end includes: Perform code testing and function point detection on serialization code and deserialization code.

4. The method according to claim 1, characterized in that: The crc16 or checksum verification of the deserialized data also includes: When the data verification fails, it is determined that the data transmission has failed, the data content is discarded, and the data content transmitted in the previous cycle is used as the data content received this time.

5. A secure communication system, characterized in that: include: A sending unit, used to serialize the pre-sent data according to the serialization code, and send the serialized data to the receiving end; A receiving unit, used to deserialize the serialized data according to the deserialization code, and perform CRC16 or checksum verification on the deserialized data; The sending unit integrates and deploys the serialization code generated by the Python tool, and the receiving end integrates and deploys the deserialization code generated by the Python tool; If the sending unit is an MCU chip, the receiving unit is an SOC chip; if the sending unit is an SOC chip, the receiving unit is an MCU chip.

6. The system according to claim 5, characterized in that The serialization code and the deserialization code are both C language codes.

7. The system according to claim 5, characterized in that include: Perform code testing and function point detection on serialization code and deserialization code.

8. The system according to claim 5, characterized in that The crc16 or checksum verification of the deserialized data also includes: When the data verification fails, it is determined that the data transmission has failed, the data content is discarded, and the data content transmitted in the previous cycle is used as the data received this time.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of a secure communication method according to any one of claims 1 to 4 are implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed, the steps of a secure communication method according to any one of claims 1 to 4 are implemented.