A device security communication method and device based on national secret security chip

By using national secret security chips for SM2 key pair generation and key negotiation between devices, the problem of key negotiation bottlenecks and centralized dependence in traditional communication security solutions is solved, efficient and secure communication between devices is achieved, and the problem of key negotiation is avoided. Single point of failure improves communication efficiency and flexibility.

CN118157859BActive Publication Date: 2024-09-06HARBIN INSTITUTE OF TECHNOLOGY (SHENZHEN) (INSTITUTE OF SCIENCE AND TECHNOLOGY INNOVATION HARBIN INSTITUTE OF TECHNOLOGY SHENZHEN)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410564483.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-05-09
Publication Date
2024-09-06
Estimated Expiration
2044-05-09

AI Technical Summary

Technical Problem

Traditional communication security solutions have bottlenecks in key negotiation and session management between devices, resulting in low communication efficiency. They also rely too much on centralized servers or third-party certification agencies, and there is a single point of failure risk. It is difficult to give full play to national security in device communication. The advantages of encryption algorithms lack simple, efficient and decentralized solutions.

Method used

Using a device secure communication method based on the national secret security chip, device A and device B generate an SM2 key pair during initialization, perform legality verification and key negotiation, generate an initial key seed value, and use the national secret algorithm to generate a session key key to ensure communication security and efficiency.

Benefits of technology

It improves the security and efficiency of communication between devices and prevents network attacks. The simple and efficient session key negotiation process realizes decentralized key negotiation, avoids single point of failure problems, and improves the flexibility and efficiency of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118157859B
    Figure CN118157859B
Patent Text Reader

Abstract

The present invention provides a device security communication method and device based on a national secret security chip, comprising: devices A and B respectively use a national secret security chip to initialize the device, and the national secret security chips of A and B respectively generate a pair of SM2 key pairs, including an SM2 public key and an SM2 private key; A sends a broadcast message to the network, including A's device identification information and a request for a response from the other device, and B parses the broadcast message and responds, including B's device identification information and SM2 public key; A verifies the legitimacy of B, and if the verification is legal, establishes a secure communication channel with B; A and B respectively generate initial key seed values; A generates a series of session keys for different communication stages; A uses a series of session keys to encrypt communication plaintexts, generates ciphertexts, and sends communication messages to communicate with B at different stages, and B obtains a series of session keys to decrypt ciphertexts to obtain the plaintexts. The present invention can realize device security communication.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication security technology, and in particular to a device security communication method and device based on a national secret security chip. Background Art

[0002] With the rapid development of smart device networks, communication between devices has become increasingly frequent, but this has also brought security challenges. Traditional communication methods are vulnerable to information leakage, tampering and replay attacks, especially in wireless environments, which are more vulnerable to malicious attacks.

[0003] Traditional communication security solutions usually use complex encryption algorithms and key management mechanisms, which makes implementation and maintenance costs high. Some solutions have bottlenecks in key negotiation and session management between devices, resulting in low communication efficiency. In addition, some communication solutions rely too much on centralized servers or third-party certification agencies, which poses a risk of single point failure and has certain restrictions on the real-time and scalability of device networks. At the same time, as an encryption algorithm promoted and applied in my country, the national encryption algorithm has the characteristics of high efficiency and security. However, how to give full play to the advantages of national encryption in device communication and improve the security and efficiency of communication is still an urgent problem to be solved. Therefore, the current communication security methods still have obvious deficiencies in simplicity, efficiency, decentralization, etc., and an innovative solution is urgently needed to improve the security and efficiency of communication between devices. Summary of the invention

[0004] The present invention provides a device security communication method and device based on a national secret security chip to achieve device security communication. The technical solution is as follows:

[0005] On the one hand, a device security communication method based on a national secret security chip is provided, comprising:

[0006] S1, device A and device B respectively use the national secret security chip to initialize the device. When the device is initialized, the national secret security chip of the device A and the device B respectively generates a pair of SM2 key pairs, and the SM2 key pair includes an SM2 public key and an SM2 private key;

[0007] S2, the device A sends a broadcast message to the network, the broadcast message includes the device identification information of the device A and requests the response of the other device, the device B parses the broadcast message and responds, and the response message includes the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B;

[0008] S3, the device A uses the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B to verify the legitimacy of the device B, and if the verification is legal, establishes a secure communication channel with the device B;

[0009] S4, after the device A establishes a secure communication channel with the device B, the device A and the device B respectively generate initial key seed values;

[0010] S5. The device A generates a series of session keys using the initial key seed value for use in different communication phases;

[0011] S6. The device A uses the series of session keys to encrypt the communication plaintext, generate ciphertext, and sends communication messages to communicate with the device B at different stages. The device B obtains the series of session keys and decrypts the ciphertext to obtain the plaintext.

[0012] Optionally, the S3 specifically includes:

[0013] The device A uses the SM2 public key of the device B to perform digital signature verification on certain data in the response message of the device B to ensure that the response message is indeed from the device B and has not been tampered with; and

[0014] The device A checks whether the device identification information of the device B is legal;

[0015] If the verification is successful, the device A determines that the device B is a legitimate device and establishes a secure communication channel with the device B.

[0016] Optionally, the generation methods of the initial key seed value in S4 include but are not limited to the following three methods:

[0017] When the devices are networked, the device A and the device B are respectively pre-configured with a shared initial key seed value;

[0018] The device A and the device B respectively use the SM2 key negotiation algorithm of the SM2 public key cryptographic algorithm module of the national secret security chip to obtain a shared initial key seed value through negotiation;

[0019] The device A and the device B respectively use the SM2 signature algorithm of the SM2 public key cryptographic algorithm module of the national secret security chip to negotiate the authentication key, and generate an authentication key based on a random number and the security chip ESAM serial number as the shared initial key seed value.

[0020] Optionally, the S5 specifically includes:

[0021] The device A uses the initial key seed value, connects different session serial numbers, and uses the SM3 hashing cryptographic algorithm module of the national secret security chip to perform a hashing operation to generate a series of session keys. The formula includes but is not limited to:

[0022] or

[0023] Where seed is the initial key seed value, S id is the session sequence number, K id is the session key corresponding to different session serial numbers, For the connection operation, It is an XOR operation.

[0024] Optionally, the structure of the communication message is:

[0025] Message identifier T||ciphertext M||session sequence number S id ||Device ID D id ||Check value

[0026] T={Session, Update_req, Update_resp}, which are the communication identifier, key update request identifier, and key update response identifier respectively;

[0027] The ciphertext M is encrypted using the SM4 block cipher algorithm module of the national security chip, and the key is the session key of the current communication stage;

[0028] The session sequence number must be strictly incremented, otherwise it should be discarded to prevent replay attacks and ensure the timeliness of communication;

[0029] The check value is the check information of the previous information. The short one uses CRC check, and the long one uses the hash value of the previous information. The length of the check information depends on the actual communication scenario to perform data integrity verification.

[0030] Optionally, the device B obtains the series of session keys, including:

[0031] In the case of frequent communication, a set of session keys is calculated and stored in advance;

[0032] In the case of infrequent communication, each time a communication message sent by the device A is received, the session key is calculated in the same manner as the device A according to the initial key seed value and the session sequence number carried in the communication message.

[0033] Optionally, the method further includes: updating the key seed value periodically or when a preset number of uses is reached:

[0034] Device A sends a random number to device B. XOR the updated value with the seed value :

[0035] ;

[0036] Device B sends a random number to device A. XOR the updated value with the seed value :

[0037] ;

[0038] The device A and the device B update the key seed value. :

[0039]

[0040] Among them, the random number uses the true random number generator module of the national secret security chip to generate high-quality random numbers.

[0041] In another aspect, a device A is provided, comprising:

[0042] The national secret security chip is used to generate a pair of SM2 key pairs when the device is initialized. The SM2 key pair includes an SM2 public key and an SM2 private key;

[0043] A sending module, used to send a broadcast message to the network, wherein the broadcast message includes the device identification information of the device A and a request for a response from the other device;

[0044] A receiving module, configured to receive a response message from device B, wherein the response message includes device identification information of device B and an SM2 public key generated in a national secret security chip of device B;

[0045] A legitimacy verification module, used to verify the legitimacy of the device B using the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B;

[0046] A secure communication channel establishing module, used to establish a secure communication channel with the device B if the verification is legitimate;

[0047] An initial key seed value generation module, used for generating an initial key seed value after the device A establishes a secure communication channel with the device B;

[0048] A session key generation module, used to generate a series of session keys for different communication stages using the initial key seed value;

[0049] An encryption module, used to encrypt communication plaintext using the series of session keys to generate ciphertext;

[0050] The sending module is also used to send communication messages and communicate with the device B at different stages.

[0051] Optionally, the initial key seed value generation module is an SM2 public key cryptographic algorithm module of a national secret security chip;

[0052] The session key generation module is the SM3 hash cryptographic algorithm module of the national secret security chip;

[0053] The encryption module is the SM4 block cipher algorithm module of the national secret security chip.

[0054] In another aspect, a device B is provided, comprising:

[0055] The national secret security chip is used to generate a pair of SM2 key pairs when the device is initialized. The SM2 key pair includes an SM2 public key and an SM2 private key;

[0056] A receiving module, used to receive a broadcast message sent by device A to the network, wherein the broadcast message includes device identification information of device A and a request for a response from a counterpart device;

[0057] A sending module, configured to send a response message to the device A, wherein the response message includes the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B;

[0058] A secure communication channel establishing module, configured to establish a secure communication channel with device A if device A verifies that device B is legitimate;

[0059] An initial key seed value generation module, used for generating an initial key seed value after the device A establishes a secure communication channel with the device B;

[0060] The decryption module is used to obtain the series of session keys, decrypt the ciphertext generated by the device A using the series of session keys to encrypt the communication plaintext, and obtain the plaintext.

[0061] Compared with the prior art, the above technical solution has at least the following beneficial effects:

[0062] The secure communication process in the present invention adopts national secret security chip technology and national secret algorithm. The two communicating parties between devices negotiate to generate a session key group each, rather than transmitting the session key value itself. This design avoids the transmission of session keys on the network, greatly improves the security of communication, and effectively prevents various network attacks and information leakage risks.

[0063] In addition, the session key negotiation process in the present invention is concise and efficient, integrating device identity authentication and session key negotiation functions. At the same time, after the negotiation is completed, multiple session key groups can be generated at one time according to actual business needs, thereby improving the flexibility and efficiency of the system.

[0064] Moreover, the present invention realizes decentralized key negotiation between devices, avoiding the single point failure problem that may exist in traditional third-party centralized systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] 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 description of the embodiments. 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.

[0066] Figure 1 A flow chart of a device security communication method based on a national secret security chip provided by an embodiment of the present invention;

[0067] Figure 2 An interactive schematic diagram of a device security communication method based on a national secret security chip provided by an embodiment of the present invention;

[0068] Figure 3 A structural block diagram of a device A provided in an embodiment of the present invention;

[0069] Figure 4 A structural block diagram of a device B provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0070] In order to make the purpose, technical solution and advantages of the embodiment of the present invention clearer, the technical solution of the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings of the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all of the embodiments. Based on the described embodiment 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.

[0071] like Figure 1 As shown, an embodiment of the present invention provides a device security communication method based on a national secret security chip, including:

[0072] S1, device A and device B respectively use the national secret security chip to initialize the device. When the device is initialized, the national secret security chip of the device A and the device B respectively generates a pair of SM2 key pairs, and the SM2 key pair includes an SM2 public key and an SM2 private key;

[0073] Specifically, device initialization includes:

[0074] 1) Establish a secure communication channel: When the device is initialized, each device first establishes a secure communication channel with its national security chip to ensure confidentiality and integrity during initialization and subsequent communications.

[0075] 2) Generate SM2 key pair: The National Security Chip generates a pair of SM2 key pairs during the initialization phase. The key pair includes SM2 public key and SM2 private key. The SM2 public key is stored in the National Security Chip and subsequently sent to other devices. The SM2 private key will be securely protected in the chip to prevent unauthorized access.

[0076] The national secret security chip used in the embodiment of the present invention refers to a high-speed, high-performance 32-bit information security high-speed stream encryption chip, which is a series of security chips certified by the National Cryptography Administration. This series of chips integrates high-speed security algorithms and communication interfaces, abandons traditional data encryption and decryption processing methods, greatly improves the data stream encryption and decryption speed, and is suitable for high-speed data stream encryption. This series of chips has the following four characteristics:

[0077] 1. High-speed data stream encryption: The encrypted transmission speed can be as high as 20MByte / s.

[0078] 2. The first domestic product with USB host interface: It has two USB-OTG interfaces, which can be set as Host or Device according to application requirements; up to 6 endpoints, which can be set as multiple composite devices to meet the user's design needs to the greatest extent.

[0079] 3. Rich interfaces: In addition to the keyboard controller interface and 2-way USB-OTG interface, it also supports 2 SPI high-speed master / slave interfaces, 32 I / O interfaces (including 8 interrupt I / O interfaces), Nand Flash interface with ECC check, I2C interface and UART interface, which can meet customers' board-level communication needs to the greatest extent.

[0080] 4. Comprehensive algorithms: Integrates multiple information security algorithms such as SM1, SM2, SM3, SM4, DES and RSA, and is widely used.

[0081] S2, the device A sends a broadcast message to the network, the broadcast message includes the device identification information of the device A (usually the device serial number / national secret security chip ESAM serial number) and requests the response of the other device, the device B parses the broadcast message and responds, and the response message includes the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B;

[0082] Device A and device B need to discover each other's existence, which can be achieved by one sending a broadcast message and the other responding.

[0083] S3, the device A uses the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B to verify the legitimacy of the device B, and if the verification is legal, establishes a secure communication channel with the device B;

[0084] Optionally, the S3 specifically includes:

[0085] The device A uses the SM2 public key of the device B to perform digital signature verification on certain data in the response message of the device B to ensure that the response message is indeed from the device B and has not been tampered with; and

[0086] The device A checks whether the device identification information of the device B is legal (for example, whether it is in the trust list of the device A);

[0087] If the verification is successful, the device A determines that the device B is a legitimate device and establishes a secure communication channel with the device B.

[0088] S4, after the device A establishes a secure communication channel with the device B, the device A and the device B respectively generate initial key seed values;

[0089] Optionally, the generation methods of the initial key seed value in S4 include but are not limited to the following three methods:

[0090] When the devices are networked, the device A and the device B are respectively pre-configured with a shared initial key seed value;

[0091] The device A and the device B respectively use the SM2 key negotiation algorithm of the SM2 public key cryptographic algorithm module of the national secret security chip to obtain a shared initial key seed value through negotiation;

[0092] The device A and the device B respectively use the SM2 signature algorithm of the SM2 public key cryptographic algorithm module of the national secret security chip to negotiate the authentication key, and generate an authentication key based on a random number and the security chip ESAM serial number as the shared initial key seed value.

[0093] The device stores the communication device identifications and the corresponding key seed value list with which communication has been established, and updates the corresponding key seed value periodically or when a preset number of uses is reached.

[0094] S5. The device A generates a series of session keys using the initial key seed value for use in different communication phases;

[0095] Optionally, the S5 specifically includes:

[0096] The device A uses the initial key seed value, connects different session serial numbers, and uses the SM3 hashing cryptographic algorithm module of the national secret security chip to perform a hashing operation to generate a series of session keys. The formula includes but is not limited to:

[0097] or

[0098] Where seed is the initial key seed value, S id is the session sequence number, K id is the session key corresponding to different session serial numbers, For the connection operation, It is an XOR operation.

[0099] Specifically, the session key is a 128-bit key obtained by performing an SM3 hash operation on the currently stored key seed value and data processed in an optional manner (such as XOR or concatenation) without using the session sequence number.

[0100] S6. The device A uses the series of session keys to encrypt the communication plaintext, generate ciphertext, and sends communication messages to communicate with the device B at different stages. The device B obtains the series of session keys and decrypts the ciphertext to obtain the plaintext.

[0101] Optionally, the structure of the communication message is:

[0102] Message identifier T||ciphertext M||session sequence number S id ||Device ID D id ||Check value

[0103] T={Session, Update_req, Update_resp}, which are the communication identifier, key update request identifier, and key update response identifier respectively;

[0104] The ciphertext M is encrypted using the SM4 block cipher algorithm module of the national security chip, and the key is the session key of the current communication stage;

[0105] The session sequence number must be strictly incremented (the sender uses the session sequence number in order, but because of packet loss, the receiver only needs to determine whether it is strictly incremented after receiving it. The difference between strict increment and increment is that they exclude equality). Otherwise, it should be discarded to prevent replay attacks and ensure the timeliness of communication.

[0106] The check value is the check information of the previous information. The short one uses CRC check, and the long one uses the hash value of the previous information. The length of the check information depends on the actual communication scenario to perform data integrity verification.

[0107] Optionally, the device B obtains the series of session keys, including:

[0108] In the case of frequent communication, a set of session keys is calculated and stored in advance to improve efficiency;

[0109] In the case of infrequent communication, in order to save storage space, each time a communication message sent by device A is received, the session key is calculated in the same manner as device A based on the initial key seed value and the session sequence number carried in the communication message.

[0110] Optionally, the method further includes: updating the key seed value periodically or when a preset number of uses is reached:

[0111] Device A sends a random number to device B. XOR the updated value with the seed value :

[0112] ;

[0113] Device B sends a random number to device A. XOR the updated value with the seed value :

[0114] ;

[0115] The device A and the device B update the key seed value. :

[0116]

[0117] Among them, the random number uses the true random number generator module of the national secret security chip to generate high-quality random numbers.

[0118] A device security communication method based on a national secret security chip according to an embodiment of the present invention is also as follows Figure 2 shown.

[0119] like Figure 3 As shown, the embodiment of the present invention further provides a device A, including:

[0120] The national secret security chip 310 is used to generate a pair of SM2 key pairs when the device is initialized, and the SM2 key pair includes an SM2 public key and an SM2 private key;

[0121] A sending module 320 is used to send a broadcast message to the network, wherein the broadcast message includes the device identification information of the device A and a request for a response from the other device;

[0122] The receiving module 330 is used to receive a response message from device B, where the response message includes the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B;

[0123] The legitimacy verification module 340 is used to verify the legitimacy of the device B using the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B;

[0124] A secure communication channel establishing module 350, configured to establish a secure communication channel with the device B if the verification is legitimate;

[0125] An initial key seed value generation module 360, configured to generate an initial key seed value after the device A establishes a secure communication channel with the device B;

[0126] A session key generation module 370, configured to generate a series of session keys using the initial key seed value for use in different communication phases;

[0127] An encryption module 380, configured to encrypt communication plaintext using the series of session keys to generate ciphertext;

[0128] The sending module 320 is further used to send communication messages and communicate with the device B at different stages.

[0129] Optionally, the initial key seed value generation module is an SM2 public key cryptographic algorithm module of a national secret security chip;

[0130] The session key generation module is the SM3 hash cryptographic algorithm module of the national secret security chip;

[0131] The encryption module is the SM4 block cipher algorithm module of the national secret security chip.

[0132] like Figure 4 As shown, the embodiment of the present invention further provides a device B, including:

[0133] The national secret security chip 410 is used to generate a pair of SM2 key pairs when the device is initialized, and the SM2 key pair includes an SM2 public key and an SM2 private key;

[0134] The receiving module 420 is used to receive a broadcast message sent by device A to the network, wherein the broadcast message includes device identification information of device A and a request for a response from a counterpart device;

[0135] A sending module 430 is used to send a response message to the device A, where the response message includes the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B;

[0136] A secure communication channel establishing module 440, configured to establish a secure communication channel with the device A if the device A verifies the device B is legitimate;

[0137] An initial key seed value generation module 450 is used to generate an initial key seed value after the device A and the device B establish a secure communication channel;

[0138] The decryption module 460 is used to obtain the series of session keys, decrypt the ciphertext generated by the device A using the series of session keys to encrypt the communication plaintext, and obtain the plaintext.

[0139] An embodiment of the present invention provides a device A and a device B, whose functional structures correspond to a device security communication method based on a national secret security chip provided by an embodiment of the present invention, and will not be repeated here.

[0140] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims

1. A device security communication method based on a national secret security chip, characterized in that: include: S1, device A and device B respectively use the national secret security chip to initialize the device. When the device is initialized, the national secret security chip of the device A and the device B respectively generates a pair of SM2 key pairs, and the SM2 key pair includes an SM2 public key and an SM2 private key; S2, the device A sends a broadcast message to the network, the broadcast message includes the device identification information of the device A and requests the response of the other device, the device B parses the broadcast message and responds, and the response message includes the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B; S3, the device A uses the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B to verify the legitimacy of the device B, and if the verification is legal, establishes a secure communication channel with the device B; S4, after the device A establishes a secure communication channel with the device B, the device A and the device B respectively generate initial key seed values; S5. The device A generates a series of session keys using the initial key seed value for use in different communication phases; S6, the device A uses the series of session keys to encrypt the communication plaintext to generate ciphertext, and sends communication messages to the device B to communicate at different stages, and the device B obtains the series of session keys and decrypts the ciphertext to obtain the plaintext; The method for generating the initial key seed value in S4 includes: When the devices are networked, the device A and the device B are respectively pre-configured with a shared initial key seed value; The device A and the device B respectively use the SM2 key negotiation algorithm of the SM2 public key cryptographic algorithm module of the national secret security chip to obtain a shared initial key seed value through negotiation; The device A and the device B respectively use the SM2 signature algorithm of the SM2 public key cryptographic algorithm module of the national secret security chip to negotiate the authentication key, and generate the authentication key based on the random number and the ESAM serial number of the security chip as the shared initial key seed value; The S5 specifically includes: The device A uses the initial key seed value, connects different session serial numbers, and uses the SM3 hashing cryptographic algorithm module of the national secret security chip to perform a hashing operation to generate a series of session keys. The formula includes: or ; in seed is the initial key seed value, S id is the session sequence number, K id is the session key corresponding to different session serial numbers, For the connection operation, is an XOR operation; The structure of the communication message is: Message identifier T||Ciphertext M||Session sequence number S id ||Device identification D id ||Check value T={Session, Update_req, Update_resp}, which are the communication identifier, key update request identifier, and key update response identifier respectively; The ciphertext M is encrypted using the SM4 block cipher algorithm module of the national security chip, and the key is the session key of the current communication stage; The session sequence number must be strictly incremented, otherwise it should be discarded to prevent replay attacks and ensure the timeliness of communication; The check value is the check information of the previous information. The short one uses CRC check, and the long one uses the hash value of the previous information. The length of the check information depends on the actual communication scenario to perform data integrity check. The method further includes: updating the key seed value periodically or when a preset number of times of use is reached: Device A sends a random number to device B. XOR the updated value with the seed value : ; Device B sends a random number to device A. XOR the updated value with the seed value : ; The device A and the device B update the key seed value. : ; Among them, the random number uses the true random number generator module of the national secret security chip to generate high-quality random numbers.

2. The method according to claim 1, characterized in that The S3 specifically includes: The device A uses the SM2 public key of the device B to perform digital signature verification on certain data in the response message of the device B to ensure that the response message is indeed from the device B and has not been tampered with; and the device A checks whether the device identification information of the device B is legal; If the verification is successful, the device A determines that the device B is a legitimate device and establishes a secure communication channel with the device B.

3. The method according to claim 1, characterized in that The device B obtains the series of session keys, including: In the case of frequent communication, a set of session keys is calculated and stored in advance; In the case of infrequent communication, each time a communication message sent by the device A is received, the session key is calculated in the same manner as the device A according to the initial key seed value and the session sequence number carried in the communication message.

4. A device A for device secure communication based on a national secret security chip, characterized in that: include: The national secret security chip is used to generate a pair of SM2 key pairs when the device is initialized. The SM2 key pair includes an SM2 public key and an SM2 private key; A sending module, used to send a broadcast message to the network, wherein the broadcast message includes the device identification information of the device A and a request for a response from the other device; A receiving module, used to receive a response message from device B, wherein the response message includes the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B; A legitimacy verification module, used to verify the legitimacy of the device B using the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B; A secure communication channel establishing module, used to establish a secure communication channel with the device B if the verification is legitimate; An initial key seed value generation module, used for generating an initial key seed value after the device A establishes a secure communication channel with the device B; A session key generation module, used to generate a series of session keys for different communication stages using the initial key seed value; An encryption module, used for encrypting communication plaintext using the series of session keys to generate ciphertext; The sending module is also used to send communication messages and communicate with the device B at different stages; The initial key seed value generation module is specifically used to: When the devices are networked, the device A and the device B are respectively pre-configured with a shared initial key seed value; The device A and the device B respectively use the SM2 key negotiation algorithm of the SM2 public key cryptographic algorithm module of the national secret security chip to obtain a shared initial key seed value through negotiation; The device A and the device B respectively use the SM2 signature algorithm of the SM2 public key cryptographic algorithm module of the national secret security chip to negotiate the authentication key, and generate the authentication key based on the random number and the ESAM serial number of the security chip as the shared initial key seed value; The session key generation module is specifically used for: The device A uses the initial key seed value, connects different session serial numbers, and uses the SM3 hashing cryptographic algorithm module of the national secret security chip to perform a hashing operation to generate a series of session keys. The formula includes: or ; in seed is the initial key seed value, S id is the session sequence number, K id is the session key corresponding to different session serial numbers, For the connection operation, is an XOR operation; The structure of the communication message is: Message identifier T||Ciphertext M||Session sequence number S id ||Device identification D id ||Check value T={Session, Update_req, Update_resp}, which are the communication identifier, key update request identifier, and key update response identifier respectively; The ciphertext M is encrypted using the SM4 block cipher algorithm module of the national security chip, and the key is the session key of the current communication stage; The session sequence number must be strictly incremented, otherwise it should be discarded to prevent replay attacks and ensure the timeliness of communication; The check value is the check information of the previous information. The short one uses CRC check, and the long one uses the hash value of the previous information. The length of the check information depends on the actual communication scenario to perform data integrity check. The device A also includes a key seed value updating module, which is used to update the key seed value periodically or when a preset number of times of use is reached: Device A sends a random number to device B. XOR the updated value with the seed value : ; Device B sends a random number to device A. XOR the updated value with the seed value : ; The device A and the device B update the key seed value. : ; Among them, the random number uses the true random number generator module of the national secret security chip to generate high-quality random numbers.

5. The device A according to claim 4, characterized in that: The initial key seed value generation module is the SM2 public key cryptographic algorithm module of the national secret security chip; The session key generation module is the SM3 hash cryptographic algorithm module of the national secret security chip; The encryption module is the SM4 block cipher algorithm module of the national secret security chip.

6. A device B for device security communication based on a national secret security chip, characterized in that: include: The national secret security chip is used to generate a pair of SM2 key pairs when the device is initialized. The SM2 key pair includes an SM2 public key and an SM2 private key; A receiving module, used to receive a broadcast message sent by device A to the network, wherein the broadcast message includes device identification information of device A and a request for a response from a counterpart device; A sending module, configured to send a response message to the device A, wherein the response message includes the device identification information of the device B and the SM2 public key generated in the national secret security chip of the device B; A secure communication channel establishing module, configured to establish a secure communication channel with device A if device A verifies that device B is legitimate; An initial key seed value generation module, used for generating an initial key seed value after the device A establishes a secure communication channel with the device B; A decryption module, used to obtain a series of session keys, decrypt the ciphertext generated by the device A using the series of session keys to encrypt the communication plaintext, and obtain the plaintext; The initial key seed value generation module is specifically used to: When the devices are networked, the device A and the device B are respectively pre-configured with a shared initial key seed value; The device A and the device B respectively use the SM2 key negotiation algorithm of the SM2 public key cryptographic algorithm module of the national secret security chip to obtain a shared initial key seed value through negotiation; The device A and the device B respectively use the SM2 signature algorithm of the SM2 public key cryptographic algorithm module of the national secret security chip to negotiate the authentication key, and generate the authentication key based on the random number and the ESAM serial number of the security chip as the shared initial key seed value; The decryption module is specifically used for: The device B uses the initial key seed value, connects different session serial numbers, and uses the SM3 hashing cryptographic algorithm module of the national secret security chip to perform a hashing operation to generate a series of session keys. The formula includes: or ; in seed is the initial key seed value, S id is the session sequence number, K id is the session key corresponding to different session serial numbers, For the connection operation, is an XOR operation; The structure of the ciphertext is: Message identifier T||Ciphertext M||Session sequence number S id ||Device identification D id ||Check value T={Session, Update_req, Update_resp}, which are the communication identifier, key update request identifier, and key update response identifier respectively; The ciphertext M is encrypted using the SM4 block cipher algorithm module of the national security chip, and the key is the session key of the current communication stage; The session sequence number must be strictly incremented, otherwise it should be discarded to prevent replay attacks and ensure the timeliness of communication; The check value is the check information of the previous information. The short one uses CRC check, and the long one uses the hash value of the previous information. The length of the check information depends on the actual communication scenario to perform data integrity check. The device B also includes a key seed value updating module, which is used to update the key seed value periodically or when a preset number of times of use is reached: Device A sends a random number to device B. XOR the updated value with the seed value : ; Device B sends a random number to device A. XOR the updated value with the seed value : ; The device A and the device B update the key seed value. : ; Among them, the random number uses the true random number generator module of the national secret security chip to generate high-quality random numbers.