Secure communication method, chip, equipment and readable storage medium

By using identity authentication and random data to generate handshake keys during the communication process, the problem of low data security in communication between the master device and the slave device is solved, data encryption and decryption operations are realized, and communication security is improved.

CN118842601APending Publication Date: 2024-10-25HANGZHOU CHIPJET TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310456661.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-04-24
Publication Date
2024-10-25

AI Technical Summary

Technical Problem

In the field of communication, the communication data between the master device and the slave device is easily monitored or tampered by the outside, resulting in low communication security.

Method used

By sending specific authentication sequence data and random data to the slave device for identity authentication, a handshake key is generated for encrypting and decrypting communication data to ensure the security of data during transmission.

Benefits of technology

It effectively improves the security of communication data between the master device and the slave device, prevents data from being snooped or tampered with, and ensures the security of the communication process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118842601A_ABST
    Figure CN118842601A_ABST
Patent Text Reader

Abstract

The invention discloses a secure communication method, a chip, equipment and a readable storage medium, and belongs to the field of communication. The secure communication method provided by the invention is applied to a master device, and comprises the following steps: sending specific authentication sequence data and first random data to a slave device, so that the slave device performs identity authentication based on the specific authentication sequence data; under the condition that the slave device passes the identity authentication, receiving first authentication feedback data and second random data from the slave device; performing identity authentication on the master device based on the first authentication feedback data; under the condition that the master device passes identity authentication, a handshake key is generated based on the first random data and the second random data, and the handshake key is used for encryption operation of communication data to be sent to the slave device by the master device; and / or the handshake key is used for decryption operation of the communication data received by the master device from the slave device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of communications, and specifically relates to a secure communication method, chip, device and readable storage medium. Background Art

[0002] In the field of communication, data exchange between a master device and a slave device can generally be achieved based on standard communication protocols such as UART (Universal Asynchronous Receiver / Transmitter), SPI (Serial Peripheral interface) or I2C (Inter Integrated Circuit). In the normal communication process, it is very important to ensure secure data transmission between the master device and the slave device.

[0003] However, there is a problem in the related art that the security of communication between the master device and the slave device is easily affected. For example, during normal communication, the communication data between the master device and the slave device can be easily monitored, intercepted, or even tampered with by the outside, resulting in low communication security. Summary of the invention

[0004] The embodiments of the present application provide a secure communication method, chip, device and readable storage medium, which can solve the problem in the related art that the security of communication between a master device and a slave device is easily affected.

[0005] In a first aspect, an embodiment of the present application provides a secure communication method, which is applied to a master device, including:

[0006] Sending specific authentication sequence data and first random data to a slave device, so that the slave device passes identity authentication based on the specific authentication sequence data;

[0007] When the slave device passes the identity authentication, receiving first authentication feedback data and second random data from the slave device;

[0008] Based on the first authentication feedback data, performing identity authentication on the master device;

[0009] When the master device passes the identity authentication, a handshake key is generated based on the first random data and the second random data, and the handshake key is used for the encryption operation of the communication data to be sent by the master device to the slave device, and / or the handshake key is used for the decryption operation of the communication data received by the master device from the slave device.

[0010] In a second aspect, an embodiment of the present application provides a secure communication method, which is applied to a slave device, including:

[0011] receiving specific authentication sequence data and first random data from a master device;

[0012] Based on the specific authentication sequence data, performing identity authentication on the slave device;

[0013] When the slave device passes the identity authentication, send first authentication feedback data and second random data to the master device, so that the master device generates a handshake key based on the first random data and the second random data when the identity authentication is passed based on the first authentication feedback data; wherein the first authentication feedback data is calculated based on a preset second authentication algorithm;

[0014] When the master device passes the identity authentication, a handshake key is generated based on the first random data and the second random data, and the handshake key is used for the decryption operation of the communication data received by the slave device from the master device, and / or the handshake key is used for the encryption operation of the communication data to be sent by the slave device to the master device.

[0015] In a third aspect, an embodiment of the present application provides a master device, including:

[0016] A first sending module, used for sending specific authentication sequence data and first random data to a slave device, so that the slave device performs identity authentication based on the specific authentication sequence data;

[0017] A first receiving module, configured to receive first authentication feedback data and second random data from a slave device when the slave device passes identity authentication;

[0018] A first authentication module, configured to perform identity authentication on the master device based on the first authentication feedback data;

[0019] A first generating module is used to generate a handshake key based on the first random data and the second random data when the master device passes identity authentication, the handshake key being used for encryption operations of communication data to be sent by the master device to the slave device, and / or the handshake key being used for decryption operations of communication data received by the master device from the slave device.

[0020] In a fourth aspect, an embodiment of the present application provides a slave device, including:

[0021] A second receiving module, used for receiving specific authentication sequence data and first random data from a master device;

[0022] A second authentication module, configured to perform identity authentication on the slave device based on the specific authentication sequence data;

[0023] A second sending module is used to send first authentication feedback data and second random data to the master device when the slave device passes the identity authentication, so that the master device generates a handshake key based on the first random data and the second random data when the master device passes the identity authentication based on the first authentication feedback data; wherein the first authentication feedback data is calculated based on a preset second authentication algorithm;

[0024] A second generating module is used to generate a handshake key based on the first random data and the second random data when the master device passes identity authentication, and the handshake key is used for decryption operations of communication data received by the slave device from the master device, and / or the handshake key is used for encryption operations of communication data to be sent by the slave device to the master device.

[0025] In a fifth aspect, an embodiment of the present application provides a chip, comprising a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction, which, when executed, implements the steps of the method described in the first aspect or the second aspect.

[0026] In a sixth aspect, an embodiment of the present application provides an electronic device, comprising a processor and a memory, wherein the memory stores programs or instructions that can be run on the processor, and when the program or instructions are executed by the processor, the steps of the method described in the first aspect or the second aspect are implemented.

[0027] In the seventh aspect, an embodiment of the present application provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect or the second aspect are implemented.

[0028] In an embodiment of the present application, the slave device is used to receive specific authentication sequence data and first random data from the master device; based on the specific authentication sequence data, the slave device is authenticated; when the slave device passes the authentication, the first authentication feedback data and the second random data are sent to the master device, so that the master device generates a handshake key based on the first random data and the second random data when the authentication is passed based on the first authentication feedback data; wherein the first authentication feedback data is calculated based on a preset second authentication algorithm; when the master device passes the authentication, the handshake key is generated based on the first random data and the second random data, and the handshake key is used for the decryption operation of the communication data received by the slave device from the master device, and / or the handshake key is used for the encryption operation of the communication data to be sent by the slave device to the master device. In this way, when the master device and the slave device pass the authentication with each other, the slave device generates a handshake key based on the second random data generated by itself and the first random data from the master device. Due to the randomness of the first random data and the second random data, each time the master device and the slave device perform mutual authentication, the handshake key generated is also random, which ensures the security of the handshake key. Furthermore, when the slave device passes the identity authentication, the first authentication feedback data and the second random data are sent to the master device, so that the master device generates a handshake key based on the first random data and the second random data when the identity authentication is passed based on the first authentication feedback data. This is equivalent to the slave device and the master device both generating handshake keys based on the first random data and the second random data, respectively, so that the handshake key is not sent through the communication interface, thereby ensuring the security of the handshake key. Furthermore, since the handshake key is used for encryption and / or decryption operations of communication data between the master device and the slave device, the security of the communication data between the master device and the slave device is guaranteed. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 is a schematic flow chart of a secure communication method provided in an embodiment of the present application;

[0030] Figure 2 is a schematic flow chart of another secure communication method provided in an embodiment of the present application;

[0031] Figure 3 is a schematic flow chart of another secure communication method provided in an embodiment of the present application;

[0032] Figure 4 is a schematic flow chart of another secure communication method provided in an embodiment of the present application;

[0033] Figure 5is a schematic flow chart of another secure communication method provided in an embodiment of the present application;

[0034] Figure 6-1 is a schematic flow chart of another secure communication method provided in an embodiment of the present application;

[0035] Figure 6-2 is a schematic flow chart of another secure communication method provided in an embodiment of the present application;

[0036] Figure 7 is a schematic flow chart of another secure communication method provided in an embodiment of the present application;

[0037] Figure 8 is a schematic flow chart of another secure communication method provided in an embodiment of the present application;

[0038] Fig. 9 is a schematic structural diagram of a main device provided in an embodiment of the present application;

[0039] Fig.10 is a schematic structural diagram of a slave device provided in an embodiment of the present application;

[0040] Fig.11 is a schematic structural diagram of a chip provided in an embodiment of the present application;

[0041] Fig.12 It is a schematic structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0042] The following will be combined with the drawings in the embodiments of the present application to clearly describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the present application belong to the scope of protection of this application.

[0043] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.

[0044] The following, in conjunction with the accompanying drawings, describes in detail the secure communication method, chip and device provided in the embodiments of the present application through specific embodiments and their application scenarios.

[0045] Figure 1 It is a schematic flowchart of a secure communication method provided in an embodiment of the present application.

[0046] like Figure 1 As shown, the secure communication method provided in the embodiment of the present application, applied to the master device, may include:

[0047] Step 110: Sending specific authentication sequence data and first random data to a slave device, so that the slave device performs identity authentication based on the specific authentication sequence data;

[0048] Step 120: When the slave device passes identity authentication, receiving first authentication feedback data and second random data from the slave device;

[0049] Step 130: authenticating the master device based on the first authentication feedback data;

[0050] Step 140: When the master device passes the identity authentication, a handshake key is generated based on the first random data and the second random data, and the handshake key is used for the encryption operation of the communication data to be sent by the master device to the slave device, and / or the handshake key is used for the decryption operation of the communication data received by the master device from the slave device.

[0051] In step 110, the specific authentication sequence data and the first random data are data generated by the master device. The specific authentication sequence data can be used in the identity authentication process of the slave device, and the present application does not limit the specific authentication method. The first random data can be used in the key generation process of the master device / slave device.

[0052] In step 120, the first authentication feedback data and the second random data are data generated by the slave device. The first authentication feedback data can be used in the identity authentication process of the master device. The second random data can be used in the key generation process of the master device / slave device.

[0053] In step 130, the master device may perform identity authentication based on the first authentication feedback data. This application does not limit the specific authentication method.

[0054] In step 140, when the master device and the slave device mutually authenticate each other, the master device generates a handshake key based on the first random data generated by itself and the second random data from the slave device. Due to the randomness of the first random data and the second random data, each time the master device and the slave device perform mutual authentication, the generated handshake key is also random, which ensures the security of the handshake key. In addition, the handshake key is generated by the master device itself, so the handshake key is not sent through the communication interface, which ensures the security of the handshake key.

[0055] In the secure communication method provided in the embodiment of the present application, the master device sends specific authentication sequence data and first random data to the slave device so that the slave device performs identity authentication based on the specific authentication sequence data; when the slave device passes the identity authentication, the master device receives the first authentication feedback data and the second random data from the slave device; based on the first authentication feedback data, the master device is authenticated; when the master device passes the identity authentication, the master device generates a handshake key based on the first random data and the second random data, and the handshake key is used for the encryption operation of the communication data to be sent by the master device to the slave device, and / or the handshake key is used for the decryption operation of the communication data received by the master device from the slave device. In this way, when the master device and the slave device pass the identity authentication with each other, the master device generates a handshake key based on the first random data generated by itself and the second random data from the slave device. Due to the randomness of the first random data and the second random data, each time the master device and the slave device perform mutual identity authentication, the generated handshake key is also random, which ensures the security of the handshake key. In addition, the handshake key is generated by the master device itself, so the handshake key is not sent through the communication interface, which ensures the security of the handshake key. Furthermore, since the handshake key is used for encryption and / or decryption operations of communication data between the master device and the slave device, the security of the communication data between the master device and the slave device is guaranteed.

[0056] In a specific embodiment, in order to ensure the accuracy of the identity authentication performed by the master device, the embodiment of the present application may use a comparison authentication algorithm to perform identity authentication. Figure 2 As shown, the secure communication method provided in the embodiment of the present application, applied to the master device, may include:

[0057] Step 210: Sending specific authentication sequence data and first random data to a slave device, so that the slave device performs identity authentication based on the specific authentication sequence data;

[0058] Step 220: When the slave device passes identity authentication, receiving first authentication feedback data and second random data from the slave device;

[0059] Step 230: Calculate and obtain second authentication feedback data based on a preset first authentication algorithm;

[0060] Step 240: Determine whether the first authentication feedback data from the slave device matches the calculated second authentication feedback data;

[0061] Step 250: When the first authentication feedback data matches the second authentication feedback data, determining that the master device passes identity authentication;

[0062] Step 260: When the master device passes the identity authentication, a handshake key is generated based on the first random data and the second random data, and the handshake key is used for the encryption operation of the communication data to be sent by the master device to the slave device, and / or the handshake key is used for the decryption operation of the communication data received by the master device from the slave device.

[0063] Among them, step 210 can refer to the specific content of step 110, step 220 can refer to the specific content of step 120, and step 260 can refer to the specific content of step 140, which will not be repeated here.

[0064] Among them, steps 230 to 250 may be sub-steps of step 130 .

[0065] In steps 230 to 250, the specific method of authenticating the master device based on the first authentication feedback data may be: based on a pre-set first authentication algorithm, calculating the second authentication feedback data; determining whether the first authentication feedback data from the slave device matches the calculated second authentication feedback data; and determining that the master device has passed the identity authentication when the first authentication feedback data matches the second authentication feedback data.

[0066] In practical applications, in step 220, the first authentication feedback data may be calculated by the slave device based on a preset second authentication algorithm in combination with the first random data and / or the second random data. Similarly, in step 230, the second authentication feedback data may be calculated by the master device based on a preset first authentication algorithm in combination with the first random data and / or the second random data.

[0067] It can be understood that the first random data and / or the second random data are introduced into the calculation process of the first authentication feedback data and the first authentication feedback data. Since the first random data and / or the second random data are random, the randomness of the first authentication feedback data and the first authentication feedback data is improved, and the security of the main device using the first authentication feedback data and the first authentication feedback data for identity authentication is further improved.

[0068] In this way, the embodiment of the present application can more accurately authenticate the identity of the main device through comparative authentication.

[0069] In another specific embodiment, after the master device and the slave device pass mutual identity authentication, communication data can be transmitted between the master device and the slave device. In order to ensure the security of data transmission by the master device, in the embodiment of the present application, the master device can use the handshake key generated by itself to encrypt the data to be transmitted.

[0070] For example, Figure 2 As shown, the secure communication method provided in the embodiment of the present application, applied to the master device, may include:

[0071] Step 270: Obtain first plaintext data to be sent;

[0072] Step 280: Based on the handshake key and a preset first encryption algorithm, encrypt the first plaintext data to obtain first ciphertext data;

[0073] Step 290: Send the first ciphertext data to the slave device.

[0074] In this way, since the handshake key is generated by the master device itself, the handshake key is not sent through the communication interface, which ensures the security of the handshake key. On this basis, the handshake key is used to encrypt the first plaintext data to obtain the first ciphertext data, which ensures the security of the first ciphertext data sent to the slave device.

[0075] In a specific embodiment, in order to ensure the integrity of the first ciphertext data and further improve the security of the first ciphertext data, the embodiment of the present application can send the first ciphertext data to the slave device by carrying the verification data after the first ciphertext data. For example, sending the first ciphertext data to the slave device in the above step 290 may include:

[0076] Based on a preset verification algorithm, the first ciphertext data is calculated to obtain first verification data;

[0077] The first ciphertext data and the first verification data are sent to the slave device.

[0078] In an embodiment of the present application, the first verification data can be used to verify the first ciphertext data. For example, if the first verification data is used to verify the first ciphertext data successfully, it means that the first ciphertext data sent by the master device is consistent with the first ciphertext data received from the slave device, and the first ciphertext data is correct during the transmission process without any errors or omissions. In this case, the first ciphertext data received from the slave device is valid data. On the contrary, if the first verification data is used to verify the first ciphertext data unsuccessfully, it means that the first ciphertext data received from the slave device is invalid data.

[0079] Among them, the embodiment of the present application does not limit the specific verification method of the first verification data, for example, it can be CRC (Cyclic Redundancy Check), checksum, MD5 (Message-Digest Algorithm 5) check, parity check, ECC (Error Correcting Code) check, and so on.

[0080] In this way, the embodiment of the present application adopts a method of sending the first ciphertext data together with the first verification data, and sends the first ciphertext data to the slave device, thereby ensuring the integrity and security of the first ciphertext data during the transmission process, and further improving the security of the first ciphertext data.

[0081] Of course, the embodiment of the present application may not carry the verification data and only transmit the first ciphertext data, and the present application does not impose any specific restrictions on this.

[0082] In another specific embodiment, in addition to sending the first ciphertext data to the slave device, the master device may also receive the second ciphertext data from the slave device and perform a decryption operation on the second ciphertext data. Figure 3 As shown, the secure communication method provided in the embodiment of the present application, applied to the master device, may include:

[0083] Step 310: receiving second ciphertext data from the slave device;

[0084] Step 320: Based on the handshake key and a preset second decryption algorithm, decrypt the second ciphertext data to obtain second plaintext data.

[0085] Among them, step 310 and step 320 can be performed before step 140 or after step 140.

[0086] In the case where step 310 and step 320 are performed after step 140, the second plaintext data in step 310 may be data obtained based on the first plaintext data. For example, the slave device obtains the first plaintext data by performing a decryption operation on the first ciphertext data, and executes a control instruction corresponding to the first plaintext data to obtain the second plaintext data.

[0087] In step 320, the second ciphertext data may be data obtained by encrypting the second plaintext data from the device based on the handshake key and a preset second encryption algorithm, and the second decryption algorithm may be an inverse algorithm of the second encryption algorithm.

[0088] In this way, since the handshake key is generated by the master device itself, the handshake key is not sent through the communication interface, which ensures the security of the handshake key. On this basis, the handshake key is used to decrypt the second ciphertext data to obtain the second plaintext data, which ensures the security of the second ciphertext data received from the slave device.

[0089] In a specific embodiment, in order to ensure the integrity of the second ciphertext data during transmission and further improve the security of the second ciphertext data, the second ciphertext data may be verified before the decryption operation is performed on the second ciphertext data. For example, in the above step 320, based on the handshake key and the pre-set second decryption algorithm, the second ciphertext data is decrypted and calculated to obtain the second plaintext data, which may include:

[0090] Step 3201: receiving second verification data from a slave device; wherein the second verification data is verification data obtained by the slave device by calculating the second ciphertext data based on a preset verification algorithm;

[0091] Step 3202: Calculate the second ciphertext data based on a preset verification algorithm to obtain third verification data;

[0092] Step 3203: Determine whether the second verification data from the slave device matches the calculated third verification data;

[0093] Step 3204: When the second verification data matches the third verification data, the second ciphertext data is decrypted based on the handshake key and a preset second decryption algorithm to obtain second plaintext data.

[0094] In the embodiment of the present application, the second verification data can be used to verify the second ciphertext data. For example, if the second verification data is used to verify the second ciphertext data successfully, it means that the second ciphertext data sent by the slave device is consistent with the second ciphertext data received by the master device, and the second ciphertext data is correct during the transmission process without any errors or omissions. In this case, the second ciphertext data received by the master device is valid data. On the contrary, if the second verification data is used to verify the second ciphertext data unsuccessfully, it means that the second ciphertext data received by the master device is invalid data.

[0095] Among them, the embodiment of the present application does not limit the specific verification method of the second verification data, for example, it can be CRC checksum, MD5 check, parity check, ECC check, etc.

[0096] In this way, in the embodiment of the present application, the slave device sends the first ciphertext data to the master device by carrying the second verification data after the second ciphertext data. The master device can receive the second ciphertext data and the second verification data, thereby ensuring the integrity and security of the second ciphertext data during transmission and further improving the security of the second ciphertext data.

[0097] In another specific embodiment, when the second verification data does not match the third verification data, the secure communication method provided in the embodiment of the present application, applied to the master device, may further include:

[0098] Step 330: If the second verification data does not match the third verification data, discard the second ciphertext data from the slave device.

[0099] In this way, when the second verification data does not match the third verification data, it means that the second ciphertext data received by the master device is invalid data. At this time, the master device can discard the second ciphertext data from the slave device and re-execute the data sending process.

[0100] Of course, the embodiment of the present application may not carry the verification data and only transmit the second ciphertext data, and the present application does not impose any specific restrictions on this.

[0101] It should be noted that in the embodiment of the present application, the master device and the slave device can be two sides of the same secure communication method. Based on the concept similar to the secure communication method executed by the master device in the above embodiment, the embodiment of the present application also provides a secure communication method executed by the slave device.

[0102] Figure 4 It is a schematic flowchart of a secure communication method provided in an embodiment of the present application.

[0103] like Figure 4As shown, the secure communication method provided in the embodiment of the present application, applied to a slave device, may include:

[0104] Step 410: receiving specific authentication sequence data and first random data from a master device;

[0105] Step 420: Authenticate the slave device based on the specific authentication sequence data;

[0106] Step 430: When the slave device passes the identity authentication, send first authentication feedback data and second random data to the master device, so that the master device generates a handshake key based on the first random data and the second random data when the master device passes the identity authentication based on the first authentication feedback data; wherein the first authentication feedback data is calculated based on a preset second authentication algorithm;

[0107] Step 440: When the master device passes identity authentication, a handshake key is generated based on the first random data and the second random data. The handshake key is used for decryption operations of communication data received by the slave device from the master device, and / or the handshake key is used for encryption operations of communication data to be sent by the slave device to the master device.

[0108] In step 410, the specific authentication sequence data and the first random data are data generated by the master device. The specific authentication sequence data can be used in the identity authentication process of the slave device, and the present application does not limit the specific authentication method. The first random data can be used in the key generation process of the master device / slave device.

[0109] In step 420, the slave device may perform identity authentication based on specific authentication sequence data, and this application does not limit the specific authentication method.

[0110] In step 430, the first authentication feedback data is calculated by the slave device based on a preset second authentication algorithm. The second random data is data randomly generated by the slave device. The first authentication feedback data can be used in the identity authentication process of the master device. The second random data can be used in the key generation process of the master device / slave device.

[0111] In step 440, when the master device and the slave device pass mutual identity authentication, the slave device generates a handshake key based on the second random data generated by itself and the first random data from the master device. Due to the randomness of the first random data and the second random data, each time the master device and the slave device perform mutual identity authentication, the handshake key generated by the slave device is also random, thereby ensuring the security of the handshake key. In addition, when the slave device passes the identity authentication, the first authentication feedback data and the second random data are sent to the master device, so that the master device generates a handshake key based on the first random data and the second random data when the identity authentication is passed based on the first authentication feedback data. It is equivalent to that the slave device and the master device both generate handshake keys based on the first random data and the second random data, respectively, so that the handshake key is not sent through the communication interface, thereby ensuring the security of the handshake key. Furthermore, since the handshake key is used for the encryption operation and / or decryption operation of the communication data between the master device and the slave device, the security of the communication data between the master device and the slave device is guaranteed. In the secure communication method provided in the embodiment of the present application, the slave device receives specific authentication sequence data and first random data from the master device; the slave device performs identity authentication on the slave device based on the specific authentication sequence data; when the slave device passes the identity authentication, the slave device sends first authentication feedback data and second random data to the master device, so that the master device generates a handshake key based on the first random data and the second random data when the identity authentication is passed based on the first authentication feedback data; wherein the first authentication feedback data is calculated based on a preset second authentication algorithm; when the master device passes the identity authentication, the slave device generates a handshake key based on the first random data and the second random data, and the handshake key is used for the decryption operation of the communication data received by the slave device from the master device, and / or the handshake key is used for the encryption operation of the communication data to be sent by the slave device to the master device. In this way, when the master device and the slave device pass the identity authentication with each other, the slave device generates a handshake key based on the second random data generated by itself and the first random data from the master device. Due to the randomness of the first random data and the second random data, each time the master device and the slave device perform mutual identity authentication, the handshake key generated by the slave device is also random, which ensures the security of the handshake key. Furthermore, when the slave device passes the identity authentication, the first authentication feedback data and the second random data are sent to the master device, so that the master device generates a handshake key based on the first random data and the second random data when the identity authentication is passed based on the first authentication feedback data. This is equivalent to the slave device and the master device both generating handshake keys based on the first random data and the second random data, respectively, so that the handshake key is not sent through the communication interface, thereby ensuring the security of the handshake key.Furthermore, since the handshake key is used for encryption and / or decryption of communication data between the master device and the slave device, the security of the communication data between the master device and the slave device is guaranteed. In a specific embodiment, in order to ensure the accuracy of the identity authentication of the slave device, the embodiment of the present application can use a comparison authentication algorithm to authenticate the slave device. For example, in the above step 420, based on the specific authentication sequence data, the identity authentication of the slave device includes:

[0112] Obtaining pre-set target authentication sequence data;

[0113] determining whether specific authentication sequence data from the master device matches predetermined target authentication sequence data;

[0114] In a case where the specific authentication sequence data matches the target authentication sequence data, it is determined that the slave device passes the identity authentication.

[0115] In this way, the embodiment of the present application can more accurately authenticate the identity of the slave device through comparative authentication.

[0116] In a specific embodiment, in order to ensure the security of data received from the slave device, in the embodiment of the present application, the slave device can use the handshake key generated by itself to decrypt the received data. Figure 4 As shown, the secure communication method provided in the embodiment of the present application, applied to a slave device, may include:

[0117] Step 450: receiving first ciphertext data from a master device;

[0118] Step 460: Based on the handshake key and a preset first decryption algorithm, decrypt the first ciphertext data to obtain first plaintext data.

[0119] In step 450, the first ciphertext data may be data obtained by the master device decrypting the first plaintext data based on the handshake key and a preset first encryption algorithm. In step 460, the first decryption algorithm may be an inverse algorithm of the above-mentioned first encryption algorithm.

[0120] In this way, since the handshake key is generated by the main device itself, the handshake key is not sent through the communication interface, which ensures the security of the handshake key. On this basis, the handshake key is used to decrypt the first ciphertext data to obtain the first plaintext data, which ensures the security of the first ciphertext data received from the main device.

[0121] In a specific embodiment, in order to ensure the integrity of the first ciphertext data during transmission and further improve the security of the first ciphertext data, the slave device in the embodiment of the present application may perform a decryption operation on the first ciphertext data by first verifying and then decrypting after the verification is successful. Figure 4 As shown, in the above step 460, based on the handshake key and the preset first decryption algorithm, the first ciphertext data is decrypted and calculated to obtain the first plaintext data, which may include:

[0122] Step 4601: receiving first verification data from a master device; wherein the first verification data is verification data obtained by the master device by calculating the first ciphertext data based on a preset verification algorithm;

[0123] Step 4602: Calculate the first ciphertext data based on a preset verification algorithm to obtain fourth verification data;

[0124] Step 4603: Determine whether the first verification data from the master device matches the calculated fourth verification data;

[0125] Step 4604: When the first verification data matches the fourth verification data, the first ciphertext data is decrypted based on the handshake key and a pre-set first decryption algorithm to obtain first plaintext data.

[0126] Among them, step 4601 can be executed simultaneously with step 450.

[0127] In an embodiment of the present application, the first verification data can be used to verify the first ciphertext data. For example, if the first verification data is used to verify the first ciphertext data successfully, it means that the first ciphertext data sent by the master device is consistent with the first ciphertext data received from the slave device, and the first ciphertext data is correct during the transmission process without any errors or omissions. In this case, the first ciphertext data received from the slave device is valid data. On the contrary, if the first verification data is used to verify the first ciphertext data unsuccessfully, it means that the first ciphertext data received from the slave device is invalid data.

[0128] Among them, the embodiment of the present application does not limit the specific verification method of the first verification data.

[0129] In a specific embodiment, when the first verification data does not match the fourth verification data, Figure 4 As shown, the secure communication method provided by the embodiment of the application, applied to a slave device, may also include:

[0130] Step 470: When the first verification data does not match the fourth verification data, discard the first ciphertext data from the master device, generate first verification error information, and send the first verification error information to the master device.

[0131] In this way, when the first verification data does not match the fourth verification data, it means that the first ciphertext data received from the slave device is invalid data. At this time, the slave device can discard the first ciphertext data from the master device, generate first verification error information, and send the first verification error information to the master device, so that the master device re-executes the data sending process based on the first verification error information.

[0132] In another specific embodiment, in addition to receiving the first ciphertext data from the master device, the slave device may also send second ciphertext data to the master device, wherein the second ciphertext data may be data obtained by the slave device performing an encryption operation on the second plaintext data. Figure 5 As shown, the secure communication method provided in the embodiment of the present application, applied to a slave device, may include:

[0133] Step 510: Acquire second plaintext data to be sent, wherein the second plaintext data is obtained based on the first plaintext data;

[0134] Step 520: Based on the handshake key and a preset second encryption algorithm, encrypt the second plaintext data to obtain second ciphertext data;

[0135] Step 530: Send the second ciphertext data to the master device.

[0136] In step 510, the second plaintext data may be data obtained based on the first plaintext data, and the specific method of obtaining the second plaintext data to be sent may be: parsing the first plaintext data to obtain target control information; performing a target control operation according to the target control information to generate a target control result, and saving the target control result as the second plaintext data. In this way, the slave device obtains the first plaintext data by performing a decryption operation on the first ciphertext data, and executes the control instruction corresponding to the first plaintext data to obtain the second plaintext data.

[0137] In step 520, based on the handshake key and a preset second encryption algorithm, the second plaintext data is encrypted to obtain second ciphertext data.

[0138] In this way, since the handshake key is generated by the main device itself, the handshake key is not sent through the communication interface, which ensures the security of the handshake key. On this basis, the handshake key is used to encrypt the second plaintext data to obtain the second ciphertext data, which ensures the security of the second ciphertext data sent to the main device.

[0139] In a specific embodiment, in order to ensure the integrity of the second ciphertext data during transmission and further improve the security of the second ciphertext data, when sending the second ciphertext data, the second ciphertext data may be sent to the master device by carrying the verification data after the second ciphertext data. For example, in the above step 530, sending the second ciphertext data to the master device may specifically include:

[0140] Step 5301: Calculate the second ciphertext data based on a preset verification algorithm to obtain second verification data;

[0141] Step 5302: Send the second ciphertext data and the second verification data to the master device.

[0142] In the embodiment of the present application, the second verification data can be used to verify the second ciphertext data. For example, if the second verification data is used to verify the second ciphertext data successfully, it means that the second ciphertext data sent by the slave device is consistent with the second ciphertext data received by the master device, and the second ciphertext data is correct during the transmission process without any errors or omissions. In this case, the second ciphertext data sent by the slave device is valid data. On the contrary, if the second verification data is used to verify the second ciphertext data unsuccessfully, it means that the second ciphertext data sent by the slave device is invalid data.

[0143] Among them, the embodiment of the present application does not limit the specific verification method of the first verification data.

[0144] In this way, in the embodiment of the present application, the slave device sends the second ciphertext data to the master device by carrying the second verification data after the second ciphertext data, thereby ensuring the integrity and security of the second ciphertext data during transmission and further improving the security of the second ciphertext data.

[0145] In addition, in practical applications, such as Figure 6-1 As shown, in order to ensure the integrity and security of communication data, the secure communication method provided in the embodiment of the present application may include the following 6 stages: a mutual identity authentication stage between the master device and the slave device, a master device data sending stage, a slave device data receiving stage, a slave device data execution stage, a slave device data feedback stage, and a master device data receiving stage. Among them:

[0146] The first stage is the mutual identity authentication stage between the master device and the slave device.

[0147] In the first stage, the master device can perform mutual identity authentication with the slave device to build a trusted communication platform.

[0148] For example, Figure 6-2 As shown, in the first stage, the secure communication method provided by the embodiment of the present application may include:

[0149] Step 610: The master device sends specific authentication sequence data and first random data to the slave device;

[0150] Step 620: The slave device receives specific authentication sequence data and first random data from the master device;

[0151] Step 630: The slave device performs identity authentication on the slave device based on the specific authentication sequence data;

[0152] Step 640: When the slave device passes the identity authentication, the slave device sends first authentication feedback data and second random data to the master device; wherein the first authentication feedback data is calculated based on a preset second authentication algorithm;

[0153] Step 650: When the slave device passes the identity authentication, the master device receives the first authentication feedback data and the second random data from the slave device;

[0154] Step 660: The master device performs identity authentication on the master device based on the first authentication feedback data;

[0155] Step 670: When the master device passes the identity authentication, the master device generates a handshake key based on the first random data and the second random data. The handshake key is used for encryption operations of communication data to be sent by the master device to the slave device, and / or the handshake key is used for decryption operations of communication data received by the master device from the slave device.

[0156] Step 680: When the master device passes the identity authentication, the slave device generates a handshake key based on the first random data and the second random data. The handshake key is used for decryption operations of communication data received by the slave device from the master device, and / or the handshake key is used for encryption operations of communication data to be sent from the slave device to the master device.

[0157] Among them, step 610, step 650, step 660 and step 670 can be executed by the master device; step 620, step 630, step 640 and step 680 can be executed by the slave device.

[0158] In the first stage, when the master device and the slave device perform mutual identity authentication, the master device generates a handshake key based on the first random data generated by itself and the second random data from the slave device; the slave device generates a handshake key based on the first random data from the master device and the second random data generated by itself. Due to the randomness of the first random data and the second random data, each time the master device and the slave device perform mutual identity authentication, the handshake key generated is also random, which ensures the security of the handshake key; and the handshake key is generated by the master device / slave device itself, so the handshake key is not sent through the communication interface, thereby ensuring the security of the handshake key, completing the construction of a trusted communication platform, and subsequently using the handshake key to perform encryption and / or decryption operations on the communication data between the master device and the slave device, ensuring the security of the communication data between the master device and the slave device.

[0159] The second stage is the master device data sending stage.

[0160] In the second stage, after the trusted communication platform is built, the master device sends secure communication data to the slave device.

[0161] For example, Figure 7 As shown, in the second stage, the secure communication method provided by the embodiment of the present application may include:

[0162] Step 710: Obtain first plaintext data to be sent;

[0163] Step 720: Based on the handshake key and a preset first encryption algorithm, encrypt the first plaintext data to obtain first ciphertext data;

[0164] Step 730: Calculate the first ciphertext data based on a preset verification algorithm to obtain first verification data;

[0165] Step 740: Send the first ciphertext data and the first verification data to the slave device.

[0166] Among them, step 710 to step 740 can be executed by the master device.

[0167] The third stage is the stage of receiving data from the device.

[0168] In the third stage, after the construction of the trusted communication platform is completed, the slave device can receive secure communication data.

[0169] For example, Figure 7 As shown, in the third stage, the secure communication method provided by the embodiment of the present application may include:

[0170] Step 750: receiving first ciphertext data and first verification data from a master device;

[0171] Step 760: Based on a preset verification algorithm, the first ciphertext data is calculated to obtain fourth verification data; and it is determined whether the first verification data from the master device matches the calculated fourth verification data;

[0172] Step 770: When the first verification data matches the fourth verification data, decrypt the first ciphertext data based on the handshake key and a preset first decryption algorithm to obtain first plaintext data;

[0173] Step 780: When the first verification data does not match the fourth verification data, discard the first ciphertext data from the master device, generate first verification error information, and send the first verification error information to the master device.

[0174] Among them, step 750 to step 780 can be executed by the slave device.

[0175] The fourth stage is the slave device data execution stage.

[0176] In the fourth stage, the slave device decrypts the first ciphertext data sent by the master device to obtain the first plaintext data. At this time, the slave device parses the first plaintext data to obtain the corresponding operation. After the slave device performs this operation, it saves the result as the second plaintext data and waits to encrypt the second plaintext data and feed it back to the master device.

[0177] For example, Figure 7 As shown, in the fourth stage, the secure communication method provided by the embodiment of the present application may include:

[0178] Step 790: Parse the first plaintext data to obtain target control information; perform a target control operation according to the target control information to generate a target control result, and save the target control result as second plaintext data.

[0179] Among them, step 790 can be executed by the slave device, and step 790 can be executed after step 770.

[0180] The fifth stage is the stage of data feedback from the device.

[0181] In the fifth stage, the data feedback process of the slave device is similar to the data sending process of the master device in the second stage. The slave device uses the internal encryption algorithm combined with the handshake key to encrypt the data to be sent (the second plaintext data), and then feeds back the encrypted second ciphertext data and the calculation result of the verification data to the master device according to the communication protocol.

[0182] For example, Figure 8 As shown, in the fifth stage, the secure communication method provided by the embodiment of the present application may include:

[0183] Step 810: Acquire second plaintext data to be sent, where the second plaintext data is obtained based on the first plaintext data;

[0184] Step 820: Based on the handshake key and a preset second encryption algorithm, encrypt the second plaintext data to obtain second ciphertext data;

[0185] Step 830: Calculate the second ciphertext data based on a preset verification algorithm to obtain second verification data;

[0186] Step 840: Send the second ciphertext data and the second verification data to the master device.

[0187] Among them, step 810 to step 840 can be executed by the master device.

[0188] The sixth stage is the master device data receiving stage.

[0189] In the sixth stage, the data receiving process of the master device is similar to the data receiving process of the slave device in the third stage. For example, after receiving the second encrypted data sent by the slave device, the master device performs a CRC check. If the CRC check fails, the data sent by the slave device is discarded and the master device returns to the data sending stage; if the CRC check passes, the master device decrypts the second encrypted data sent by the slave device using an internal decryption algorithm combined with a handshake key to obtain the second plaintext data.

[0190] For example, Figure 8 As shown, in the sixth stage, the secure communication method provided by the embodiment of the present application may include:

[0191] Step 850: Receive second ciphertext data and second verification data from a slave device; wherein the second verification data is verification data obtained by the slave device by calculating the second ciphertext data based on a preset verification algorithm;

[0192] Step 860: Calculate the second ciphertext data based on a preset verification algorithm to obtain third verification data; determine whether the second verification data from the slave device matches the calculated third verification data;

[0193] Step 870: When the second verification data matches the third verification data, the second ciphertext data is decrypted based on the handshake key and a preset second decryption algorithm to obtain second plaintext data.

[0194] Step 880: When the second verification data does not match the third verification data, the second ciphertext data from the slave device is discarded, and the master device returns to the data sending stage (ie, the second stage mentioned above).

[0195] Among them, step 850 to step 880 can be executed by the master device.

[0196] In practical applications, the embodiments of the present application can repeatedly execute the above six stages, which can prevent the communication data from being spied on, stolen or tampered with, ensure the security of the communication data between the master device and the slave device, and thus realize secure communication between the master device and the slave device.

[0197] It should be noted that the execution subject of the secure communication method provided in the embodiment of the present application can be a master device or a slave device, or a control module in the master device or the slave device for executing the secure communication method. In the embodiment of the present application, the master device and the slave device provided in the embodiment of the present application are explained by taking the execution of the secure communication method by the master device or the slave device as an example.

[0198] Fig. 9 It is a schematic structural diagram of a main device provided in an embodiment of the present application.

[0199] like Fig. 9 As shown, the main device 900 provided in the embodiment of the present application may include:

[0200] A first sending module 910, configured to send specific authentication sequence data and first random data to a slave device, so that the slave device performs identity authentication based on the specific authentication sequence data;

[0201] A first receiving module 920, configured to receive first authentication feedback data and second random data from a slave device when the slave device passes identity authentication;

[0202] A first authentication module 930, configured to perform identity authentication on the master device based on the first authentication feedback data;

[0203] The first generating module 940 is used to generate a handshake key based on the first random data and the second random data when the master device passes the identity authentication. The handshake key is used for the encryption operation of the communication data to be sent by the master device to the slave device, and / or the handshake key is used for the decryption operation of the communication data received by the master device from the slave device.

[0204] The master device provided in the embodiment of the present application includes a first sending module, which is used to send specific authentication sequence data and first random data to the slave device, so that the slave device performs identity authentication based on the specific authentication sequence data; a first receiving module, which is used to receive first authentication feedback data and second random data from the slave device when the slave device passes the identity authentication; a first authentication module, which is used to authenticate the master device based on the first authentication feedback data; a first generating module, which is used to generate a handshake key based on the first random data and the second random data when the master device passes the identity authentication, and the handshake key is used for the encryption operation of the communication data to be sent by the master device to the slave device, and / or the handshake key is used for the decryption operation of the communication data received by the master device from the slave device. In this way, when the master device and the slave device pass the identity authentication, the master device generates a handshake key based on the first random data generated by itself and the second random data from the slave device. Due to the randomness of the first random data and the second random data, each time the master device and the slave device perform mutual identity authentication, the generated handshake key is also random, which ensures the security of the handshake key. Furthermore, the handshake key is generated by the master device itself, so the handshake key is not sent through the communication interface, thereby ensuring the security of the handshake key. Furthermore, since the handshake key is used for encryption and / or decryption operations of communication data between the master device and the slave device, the security of the communication data between the master device and the slave device is ensured.

[0205] In addition, the main device in the embodiment of the present application can implement each process implemented by the main device in the above method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0206] Fig.10 It is a schematic structural diagram of a slave device provided in an embodiment of the present application.

[0207] like Fig.10 As shown, the slave device 1000 provided in the embodiment of the present application may include:

[0208] The second receiving module 1010 is used to receive specific authentication sequence data and first random data from the master device;

[0209] A second authentication module 1020, configured to perform identity authentication on the slave device based on the specific authentication sequence data;

[0210] A second sending module 1030 is configured to send first authentication feedback data and second random data to the master device when the slave device passes identity authentication, so that the master device generates a handshake key based on the first random data and the second random data when the master device passes identity authentication based on the first authentication feedback data; wherein the first authentication feedback data is calculated based on a preset second authentication algorithm;

[0211] The second generation module 1040 is used to generate a handshake key based on the first random data and the second random data when the master device passes the identity authentication. The handshake key is used for the decryption operation of the communication data received by the slave device from the master device, and / or the handshake key is used for the encryption operation of the communication data to be sent by the slave device to the master device.

[0212] The slave device provided in the embodiment of the present application includes a second receiving module for receiving specific authentication sequence data and first random data from the master device; a second authentication module for authenticating the slave device based on the specific authentication sequence data; a second sending module for sending first authentication feedback data and second random data to the master device when the slave device passes the authentication, so that the master device generates a handshake key based on the first random data and the second random data when the master device passes the authentication based on the first authentication feedback data; wherein the first authentication feedback data is calculated based on a preset second authentication algorithm; a second generating module for generating a handshake key based on the first random data and the second random data when the master device passes the authentication, the handshake key being used for the decryption operation of the communication data received by the slave device from the master device, and / or the handshake key being used for the encryption operation of the communication data to be sent by the slave device to the master device. In this way, when the master device and the slave device pass the authentication with each other, the slave device generates a handshake key based on the second random data generated by itself and the first random data from the master device. Due to the randomness of the first random data and the second random data, each time the master device and the slave device perform mutual identity authentication, the handshake key generated by the slave device is also random, which ensures the security of the handshake key. In addition, when the slave device passes the identity authentication, the first authentication feedback data and the second random data are sent to the master device, so that the master device generates a handshake key based on the first random data and the second random data when the identity authentication is passed based on the first authentication feedback data. It is equivalent to that the slave device and the master device both generate handshake keys based on the first random data and the second random data, respectively, so that the handshake key is not sent through the communication interface, thereby ensuring the security of the handshake key. Furthermore, since the handshake key is used for the encryption operation and / or decryption operation of the communication data between the master device and the slave device, the security of the communication data between the master device and the slave device is guaranteed.

[0213] In addition, the slave device in the embodiment of the present application can implement each process implemented by the slave device in the above method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0214] The master device or slave device in the embodiment of the present application can be a mobile electronic device or a non-mobile electronic device. For example, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook or a personal digital assistant (PDA), etc., and the non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), a teller machine or a self-service machine, etc., which is not specifically limited in the embodiment of the present application.

[0215] The master device or slave device in the embodiment of the present application may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiment of the present application.

[0216] Fig.11 It is a schematic structural diagram of a chip provided in an embodiment of the present application.

[0217] like Fig.11 As shown, an embodiment of the present application further provides a chip 1100, including a processor 1110 and a communication interface 1120, wherein the communication interface is coupled to the processor, and the processor is used to run a program or instruction, and the program or instruction implements each process of the above method embodiment when executed.

[0218] Among them, the chip provided in the embodiment of the present application may include a network switching chip, a PHY chip or an FPGA chip, etc. The present application does not make any specific restrictions on the chip type.

[0219] The chip provided in the embodiment of the present application can implement each process implemented in the above method embodiment and can achieve the same technical effect. To avoid repetition, it will not be described here.

[0220] Fig.12 It is a schematic structural diagram of an electronic device provided in an embodiment of the present application.

[0221] like Fig.12 As shown, an embodiment of the present application also provides an electronic device 1000, including a processor 1210 and a memory 1220, and a program or instruction stored in the memory and executable on the processor. When the program or instruction is executed by the processor, the various processes of the above-mentioned method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0222] It should be noted that the electronic devices in the embodiments of the present application include the mobile electronic devices and non-mobile electronic devices mentioned above.

[0223] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0224] The processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0225] It should be noted that, in this article, the terms "comprise", "include" or any other variant thereof are intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise one..." do not exclude the presence of other identical elements in the process, method, article or device including the element. In addition, it should be pointed out that the scope of the methods and devices in the embodiments of the present application is not limited to performing functions in the order shown or discussed, and may also include performing functions in a substantially simultaneous manner or in reverse order according to the functions involved, for example, the described method may be performed in an order different from that described, and various steps may also be added, omitted, or combined. In addition, the features described with reference to certain examples may be combined in other examples.

[0226] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a computer software product, which is stored in a storage medium (such as ROM / RAM, a disk, or an optical disk), and includes a number of instructions for a terminal (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present application.

[0227] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.

Claims

1. A secure communication method, characterized in that: Applicable to main equipment, including: Sending specific authentication sequence data and first random data to a slave device, so that the slave device performs identity authentication based on the specific authentication sequence data; When the slave device passes the identity authentication, receiving first authentication feedback data and second random data from the slave device; Based on the first authentication feedback data, performing identity authentication on the master device; When the master device passes the identity authentication, a handshake key is generated based on the first random data and the second random data, and the handshake key is used for the encryption operation of the communication data to be sent by the master device to the slave device, and / or the handshake key is used for the decryption operation of the communication data received by the master device from the slave device.

2. The method according to claim 1, characterized in that The performing identity authentication on the master device based on the first authentication feedback data includes: Based on a preset first authentication algorithm, second authentication feedback data is calculated; determining whether the first authentication feedback data from the slave device matches the calculated second authentication feedback data; When the first authentication feedback data matches the second authentication feedback data, it is determined that the master device passes the identity authentication.

3. The method according to claim 1, characterized in that After generating the handshake key, the method further includes: Obtaining first plaintext data to be sent; Based on the handshake key and a preset first encryption algorithm, encrypt the first plaintext data to obtain first ciphertext data; The first ciphertext data is sent to the slave device.

4. The method according to claim 3, characterized in that The sending the first ciphertext data to the slave device includes: Based on a preset verification algorithm, the first ciphertext data is calculated to obtain first verification data; The first ciphertext data and the first verification data are sent to the slave device.

5. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: receiving second ciphertext data from the slave device; Based on the handshake key and a preset second decryption algorithm, the second ciphertext data is decrypted to obtain second plaintext data.

6. The method according to claim 5, characterized in that The decrypting calculation of the second ciphertext data based on the handshake key and a preset second decryption algorithm to obtain the second plaintext data includes: Receiving second verification data from a slave device; wherein the second verification data is verification data obtained by the slave device by calculating the second ciphertext data based on a preset verification algorithm; Based on a preset verification algorithm, the second ciphertext data is calculated to obtain third verification data; determining whether the second verification data from the slave device matches the calculated third verification data; In the case where the second verification data matches the third verification data, the second ciphertext data is decrypted based on the handshake key and a preset second decryption algorithm to obtain second plaintext data.

7. The method according to claim 6, characterized in that The method further comprises: In the case where the second verification data does not match the third verification data, the second ciphertext data from the slave device is discarded.

8. A secure communication method, characterized in that: Applicable to slave devices, including: receiving specific authentication sequence data and first random data from a master device; Based on the specific authentication sequence data, performing identity authentication on the slave device; When the slave device passes the identity authentication, send first authentication feedback data and second random data to the master device, so that the master device generates a handshake key based on the first random data and the second random data when the identity authentication is passed based on the first authentication feedback data; wherein the first authentication feedback data is calculated based on a preset second authentication algorithm; When the master device passes the identity authentication, a handshake key is generated based on the first random data and the second random data, and the handshake key is used for the decryption operation of the communication data received by the slave device from the master device, and / or the handshake key is used for the encryption operation of the communication data to be sent by the slave device to the master device.

9. The method according to claim 8, characterized in that The performing identity authentication on the slave device based on the specific authentication sequence data includes: Obtaining pre-set target authentication sequence data; determining whether specific authentication sequence data from the master device matches predetermined target authentication sequence data; In a case where the specific authentication sequence data matches the target authentication sequence data, it is determined that the slave device passes the identity authentication.

10. The method according to claim 8, characterized in that After generating the handshake key, the method further includes: Receiving first ciphertext data from a master device; Based on the handshake key and a preset first decryption algorithm, the first ciphertext data is decrypted to obtain first plaintext data.

11. The method according to claim 10, characterized in that The decrypting calculation of the first ciphertext data based on the handshake key and a preset first decryption algorithm to obtain the first plaintext data includes: Receiving first verification data from a master device; wherein the first verification data is verification data obtained by the master device calculating the first ciphertext data based on a preset verification algorithm; Based on a preset verification algorithm, the first ciphertext data is calculated to obtain fourth verification data; determining whether the first verification data from the master device matches the calculated fourth verification data; In the case where the first verification data matches the fourth verification data, the first ciphertext data is decrypted based on the handshake key and a preset first decryption algorithm to obtain first plaintext data.

12. The method according to claim 11, characterized in that The method further comprises: In the case where the first verification data does not match the fourth verification data, the first ciphertext data from the master device is discarded, first verification error information is generated, and the first verification error information is sent to the master device.

13. The method according to claim 10, characterized in that After calculating and obtaining the first plaintext data, the method further includes: Acquire second plaintext data to be sent, where the second plaintext data is obtained based on the first plaintext data; Based on the handshake key and a preset second encryption algorithm, encrypt the second plaintext data to obtain second ciphertext data; The second ciphertext data is sent to the master device.

14. The method according to claim 13, characterized in that The sending the second ciphertext data to the master device includes: Based on a preset verification algorithm, the second ciphertext data is calculated to obtain second verification data; The second ciphertext data and the second verification data are sent to the master device.

15. A master device, characterized in that: include: A first sending module, used for sending specific authentication sequence data and first random data to a slave device, so that the slave device performs identity authentication based on the specific authentication sequence data; A first receiving module, configured to receive first authentication feedback data and second random data from a slave device when the slave device passes identity authentication; A first authentication module, configured to perform identity authentication on the master device based on the first authentication feedback data; A first generating module is used to generate a handshake key based on the first random data and the second random data when the master device passes identity authentication, the handshake key being used for encryption operations of communication data to be sent by the master device to the slave device, and / or the handshake key being used for decryption operations of communication data received by the master device from the slave device.

16. A slave device, characterized in that: include: A second receiving module, used for receiving specific authentication sequence data and first random data from a master device; A second authentication module, configured to perform identity authentication on the slave device based on the specific authentication sequence data; A second sending module is used to send first authentication feedback data and second random data to the master device when the slave device passes the identity authentication, so that the master device generates a handshake key based on the first random data and the second random data when the master device passes the identity authentication based on the first authentication feedback data; wherein the first authentication feedback data is calculated based on a preset second authentication algorithm; A second generating module is used to generate a handshake key based on the first random data and the second random data when the master device passes identity authentication, and the handshake key is used for decryption operations of communication data received by the slave device from the master device, and / or the handshake key is used for encryption operations of communication data to be sent by the slave device to the master device.

17. A chip, characterized in that: The method comprises a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run a program or an instruction, and when the program or the instruction is executed, the steps of the method according to any one of claims 1 to 14 are implemented.

18. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a program or instruction that can be run on the processor, and when the program or instruction is executed by the processor, the steps of the method according to any one of claims 1 to 14 are implemented.

19. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 14.