Encrypted communication method based on MQTT protocol identity authentication of lightweight national cipher SM9

Through the lightweight national secret SM9 algorithm and SM4 encryption technology, the problem of key management and authentication difficulty of embedded devices is solved, the secure identity authentication and data encryption of the MQTT protocol are realized, ensuring communication security and data integrity, and is suitable for Resource-constrained IoT and edge computing environments.

CN118694518APending Publication Date: 2024-09-24UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 0 Cites 5 Cited by

Patent Information

Application Number
CN202410663459.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

Embedded devices and edge computing systems have difficulty in key management and authentication. There are security risks in plaintext identity authentication and data transmission in the traditional MQTT protocol, and they are vulnerable to network attacks.

Method used

The lightweight national secret SM9 algorithm is used for identity authentication, session keys are generated, and SM4 symmetric encryption communication technology is used to ensure the communication security of the MQTT protocol. This scheme improves the efficiency and security of identity authentication by reducing the number of bilinear pairing operations and avoiding additional communication and computing overhead.

Benefits of technology

It achieves the security of identity authentication and data transmission of the MQTT protocol, reduces the risk of information leakage, and significantly shortens the identity authentication time. It is suitable for IoT and edge computing environments with limited resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118694518A
    Figure CN118694518A
Patent Text Reader

Abstract

The invention provides an encrypted communication method based on MQTT protocol identity authentication of lightweight SM9, which is suitable for providing identity authentication in the embedded field or edge computing and Internet of Things communication, and adopts an MQTT protocol to perform encrypted communication. The method comprises the following steps: before equipment carries out MQTT communication, carrying out identity verification on a client and a server by using a lightweight SM9 algorithm provided by the method so as to obtain a session key, and carrying out symmetric encryption on client identity verification information and published theme content in an MQTT protocol through SM4 by using the obtained session key; the method has the advantages that the lightweight SM9 algorithm of the identification-based cryptographic algorithm is adopted, and the public key can be uniquely determined by the corresponding identity of the equipment, so that a certificate infrastructure is not needed, and the method has the advantages of simple key management and flexible deployment. The number of times of bilinear pairing verification is reduced, the time of identity verification is greatly shortened, and the security problem in a traditional MQTT protocol is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to cryptographic encryption communication technology, and specifically designs a lightweight national secret SM9 MQTT identity authentication technology, as well as a symmetric encryption communication technology based on the national secret SM3 digital summary technology and SM4. Background Art

[0002] The national secret algorithm is a cryptographic algorithm standard and its application specification recognized and announced by the Cryptography Administration of my country. It is a set of data encryption processing algorithms independently developed by my country in the core field of cryptography. The national secret algorithms that have been promulgated include: symmetric encryption algorithm (SM1, SM4), asymmetric encryption algorithm (SM2, SM9), hash cryptographic algorithm (SM3), etc. The country is currently vigorously promoting the independent and controllable national secret algorithm. The popularization of the national secret algorithm is of great significance to improving my country's network information security and independent controllability.

[0003] The national secret SM9 identification cryptographic algorithm uses the R-ate pair in the elliptic curve bilinear pairing, which has good security and fast operation speed, and ensures a certain degree of computational efficiency while maintaining high security. The SM9 algorithm is currently the most widely used and most complete identification cryptographic algorithm in China. It has been adopted as an international standard by the International Organization for Standardization. It has the advantages of simple key management and flexible deployment in resource-constrained network environments, and has great application potential. This method adopts a lightweight SM9 authentication algorithm. Compared with the existing research schemes, the main innovation of this scheme is to design a pair of authentication key pairs to improve the efficiency of the authentication key negotiation protocol. The designed authentication key pair has two advantages: first, the structure is simple, which can greatly reduce the computational overhead of generating signature key pairs; second, the calculation is convenient, which minimizes the number of bilinear pairing operations. Compared with the two bilinear pairing operations and one elliptic curve exponentiation operation in the SM9 key exchange algorithm, the verification of the authentication key pair only requires one bilinear pairing operation. This scheme adopts the method of generating an authentication key pair in the initialization phase, avoiding the one-round communication required to send a digital signature and the computational overhead of generating and verifying a digital signature, and reducing the number of bilinear pairing operations in the key exchange protocol, thereby achieving higher time efficiency.

[0004] MQTT (Message Queuing Telemetry Transport) protocol is a communication protocol based on the publish / subscribe mode, which is built on the TCP / IP (Transmission Control Protocol / Internet Protocol) protocol. MQTT can provide real-time and reliable message services for connected terminals with less code and limited bandwidth. The MQTT protocol is widely used in the fields of Internet of Things and edge computing. However, the traditional MQTT protocol has been transmitted in plain text in the network during the data transmission process, and the data security and communication quality cannot be guaranteed. The present invention uses a lightweight national secret SM9 algorithm to realize the rapid identity authentication of the client and the MQTT server, and generates a session key at the same time, and the subject key is generated through negotiation through the session key to complete the encryption and decryption of the MQTT data communication process, so that the communication security and data integrity of the MQTT protocol are guaranteed. Summary of the invention

[0005] The problem to be solved by the present invention is that, for the edge computing systems of embedded devices, key management is difficult, authentication is difficult, and the computing resources of the equipment are limited; the traditional MQTT protocol uses plain text for identity authentication and data transmission, which is prone to network attacks and has great security risks. A method for optimizing the identity authentication process in encrypted communication based on the national secret SM9 is proposed.

[0006] The technical solution adopted by the present invention to solve the above technical problems is an encrypted communication method based on the MQTT protocol identity authentication of the lightweight national secret SM9, comprising the following steps:

[0007] 1) Key pair generation and acquisition: The client and server hash the device ID based on the CPU serial number and MAC address of their own devices, and then use the device ID to obtain the hash value to generate their respective device public keys. pub After that, the client and server devices obtain the corresponding device private key Key in the key generation center KGC through their unique device IDs. sec ;

[0008] 2) Lightweight SM9 authentication:

[0009] The client generates a random number n D and verification information And the client authentication information Sent to the server; Respectively represent the first verification information and the second verification information of the client, ID Dis the device ID of the client, and the subscript D indicates the client;

[0010] The server will receive the client's authentication information and perform a bilinear pairing check. After the check passes, the server will generate a random number n. S and certification information in, Respectively represent the first verification information and the second verification information of the server, ID S is the device ID of the server, the subscript S represents the server, and the server generates the session key sk S , and then calculate the session key hash value sk through the hash function Hash S_Hash :

[0011]

[0012] The server sends the server authentication information {ID s ,φ s ,σ s} and the session key hash value sk S_Hash Send to the client;

[0013] The client performs a bilinear pairing check on the received server authentication information. After the check passes, the client generates a session key sk D and the session key hash value sk D_Hash :

[0014]

[0015] sk D_Hash =Hash(sk D )

[0016] If there is sk D_Hash =sk S_Hash The client successfully authenticates the server and sends the session key hash value sk D_Hash To the server;

[0017] The server checks whether sk is satisfied D_Hash =sk S_Hash If yes, the server successfully authenticates the client and sets sk D ,sk S As the SM4 symmetric session key sk for encrypted communication between the client and the server session ;

[0018] 2) Derivation and distribution of subject keys:

[0019] The client uses the session key sk for the combination of username user, user password and current timestamp timeStamp {user, password, timeStamp} session Perform SM4 encryption to generate ciphertext C verify , and then {ID D ,C verify}Put it into the CONNECT data packet and send it to the server;

[0020] After receiving the CONNECT packet, the server extracts {ID D ,C verify}, using the session key sk session Get the client ID D The corresponding C verify Decrypt to get {user, password, timeStamp}, and check the timeStamp. If the time is within the specified range, it is considered that the C verify The server receives the valid data and performs MQTT protocol authentication on the obtained username and password. If the authentication succeeds and the timestamp is within the specified range, a CONNACK packet is returned to the client to confirm the connection request. Otherwise, the server returns an MQTT authentication failure message to the client.

[0021] When the MQTT protocol authentication succeeds, the client confirms to subscribe or publish the topic and sends {topic,ID D} to the server, which uses the device private key Key S_sec Generate a topic key topic =Hash(topic||Key S_sec ) and set Key topic and timestamp timeStamp using session key sk session Perform SM4 encryption to obtain ciphertext C key ; C key Sent to the client, the client passes the session key sk session C key Decrypt to get the subject key Key topic , thus completing the subject key Key topic distribution;

[0022] 4)MQTT data encryption transmission and decryption:

[0023] The client sends a SUBSCRIBE packet to the server to subscribe to the topic content;

[0024] The client as the publisher will publish the information corresponding to the topic C data and timestamp {C data ,timeStamp} uses the subject key Key topic After SM4 encryption, the ciphertext C is obtained topic And generate a summary Hash (C data ), which constitutes the content published in the PUBLISH packet sent by the client {C topic ,Hash(C data )} and send to the server;

[0025] After receiving the PUBLISH data packet, the server uses the subject key Key topic C topic Decrypted to get C data , and then forward the PUBLISH data packet to the client as the topic subscriber, and the subscriber uses the topic key Key topic C topic Decryption yields {C data ,timeStamp}, and then check whether the timeStamp of the PUBLISH data packet is within the specified range. If it is within the specified range, the C data Take the hash to get C data_hash , the obtained hash value and the Hash (C extracted from the PUBLISH data packet data ) are compared, if they are consistent, it is determined that the plaintext message published by the subject is C data .

[0026] The beneficial effect of the present invention is that it proposes to use a lightweight SM9 algorithm to perform identity authentication and generate a session key before MQTT communication is performed between the client and the device, and further use the session key to encrypt data during the MQTT communication process, so that identity authentication and data security as well as data integrity are guaranteed during the MQTT communication process.

[0027] The lightweight national encryption SM9 is used for identity authentication to generate session keys, which are then used for subsequent MQTT encrypted identity authentication, solving the problem of information leakage that may be caused by plain text transmission of identity authentication in the MQTT protocol. The use of this lightweight SM9 authentication algorithm can reduce the bilinear pairing operations in the traditional SM9 algorithm, greatly shortening the time required for identity authentication. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] Figure 1 A flowchart of an embodiment.

[0029] Figure 2 This is the lightweight SM9 key pair generation and acquisition phase of the implementation example.

[0030] Figure 3 This is the authentication flowchart of the lightweight SM9 implementation example.

[0031] Figure 4 This is a timing diagram of the MQTT protocol encrypted communication between the client and the server in the embodiment. DETAILED DESCRIPTION

[0032] The specific implementation scheme of the present invention is described below in conjunction with the accompanying drawings, which is divided into four stages: key pair generation and acquisition stage, lightweight SM9 identity authentication stage, subject key derivation and distribution, data encryption transmission and acquisition and decryption stage, such as Figure 1 shown.

[0033] The encrypted communication system includes the key generation center KGC, the client and the server. The client here refers to the MQTT client, and the server refers to the MQTT server. The client and the server complete identity authentication through the following steps to perform encrypted communication:

[0034] 1. Key pair generation and acquisition phase: Figure 2 As shown, it includes obtaining the device ID, generating the device public key, and applying for the device private key from the key generation center KGC:

[0035] The client and server hash the device ID based on the CPU serial number and MAC address of their own devices. The device ID includes the client device ID and the server device ID, and the device public key Key is generated by taking the hash value of the device ID. pub ;

[0036] After that, the client and server devices obtain the corresponding device private key Key from the key generation center KGC. sec ;

[0037] Specifically, the key generation center KGC initializes the elliptic curve information: KGC, client, and MQTT server initialize the elliptic curve information respectively. SM9 adopts the 256-bit BN curve recommended in the national standard and selects two additive cyclic groups G with order as prime number N. 1 , G 2 , whose generator is P 1 , P 2 Then, choose the bilinear pairing and the multiplicative cyclic group G of prime order N T ,satisfy: : G 1 ×G 2 →G T ; N>=2 k , k is the key length;

[0038] Specifically, the client and server obtain their own CPU serial number and the MAC address of the network card, and generate a 32-bit unique ID number by taking the hash value: ID = Hash (CPUID||MAC);

[0039] Among them, CPUID is the CPU serial number, MAC is the MAC address, and ID is the device ID; Hash is the hash function of the national encryption SM3, and || represents data splicing.

[0040] KGC generates a master private key and a master public key. KGC generates a random large prime number as KGC's encryption master private key s through a secure random number generator. Then the encryption master public key P is calculated. 0 , P 0 =s·P 1 , · represents the dot product, and the algorithm for generating the device public and private key pair is as follows:

[0041] Key pub =Hash(ID)

[0042]

[0043] The server accesses the database through the respective device ID to obtain the key pair Key D_pub and Key D_sec The client copies the file offline, such as to a USB flash drive, and then checks the USB flash drive to the device, and runs the script to obtain the key pair. S_pub and Key S_sec , subscript S represents the server, and subscript D represents the client.

[0044] 2. Lightweight SM9 identity authentication stage, such as Figure 3 As shown:

[0045] Before making an MQTT connection, the client and the device authenticate each other through lightweight SM9 and generate a session key:

[0046] The client and server communicate via TCP first, and the client generates a random number n using a secure random number generator. D and verification information And the client authentication information Sent to the server; Respectively represent the first verification information and the second verification information of the client, ID D The device ID of the client;

[0047] Specifically,

[0048] The server will perform a bilinear pairing check on the authentication information received from the client. If the check passes, the server will generate a random number n.S and certification information in, They represent the first verification information and the second verification information of the server, and the server generates a session key sk S and the session key hash value sk S_Hash :

[0049]

[0050] Specifically, the bilinear pairing check for the client needs to satisfy the following equation:

[0051]

[0052] The server sends the server authentication information {ID s ,φ s ,σ s} and the session key hash value sk S_Hash Send to the client;

[0053] If the authentication fails, the authentication process terminates.

[0054] The client performs the existing bilinear pairing check on the received server authentication information. If the check passes, the client generates a session key sk D and the session key hash value sk D_Hash :

[0055]

[0056] sk D_Hash =Hash(sk D )

[0057] Specifically, the bilinear pairing check on the server needs to satisfy the following equation:

[0058]

[0059] If there is sk D_Hash =sk S_Hash The client successfully authenticates the server and sends the session key hash value sk D_Hash To the server;

[0060] The server checks whether sk is satisfied D_Hash =sk S_Hash If the equation holds true, the server successfully authenticates the client and sets sk D ,sk S As the SM4 symmetric session key sk for encrypted communication between the client and the server session ,sk session =skD =sk S ;

[0061] 3. In the derivation and distribution phase of the topic key, clients that subscribe to and publish the same topic derive and distribute the topic key:

[0062] After the identity authentication of both the client and the server is passed, the MQTT authentication phase begins. The client first uses the username user and password password and the current timestamp timeStamp {user, password, timeStamp} to session Perform SM4 encryption to generate ciphertext C verify , and then {ID D ,C verify}Put it into the CONNECT data packet and send it to the server;

[0063] After receiving the CONNECT packet, the server extracts {ID D ,C verify}, get the client ID D The corresponding session key sk session C verify Decrypt to get {user, password, timeStamp}, check the timestamp, if the time is within the specified range, it is considered that the C verify The server sends a valid data to the client, and performs MQTT protocol authentication on the obtained username and password. If the authentication is successful and the timestamp is within the specified range, the server returns a CONNACK packet to the client to confirm the connection request; otherwise, the server returns a login failure message to the client. Timestamp verification is used to prevent replay attacks.

[0064] When the MQTT protocol identity authentication succeeds, it enters the topic key acquisition phase; in this phase, the client determines to subscribe to or publish the topic, and sends {topic, ID D} to the server, which uses the device private key Key S_sec Generate a topic key topic =Hash(topic||Key S_sec ), and Key topic and timestamp timeStamp using session key sk session Perform SM4 encryption to obtain ciphertext C key ; C key Sent to the client, the client passes the session key sk session C key Decrypt to get the subject key Key topic, thus completing the subject key Key topic distribution.

[0065] 4. MQTT data encryption transmission and decryption stage, in which the topic key is used to encrypt and decrypt the topic message, and the hash value of the topic information content is used to determine the data integrity:

[0066] In the MQTT encrypted communication phase, the client sends a SUBSCRIBE packet to the server to subscribe to the topic content;

[0067] The client as the publisher will publish the information corresponding to the topic C data and timestamp {C data ,timeStamp} uses the subject key Key topic After SM4 encryption, the ciphertext C is obtained topic And generate a summary Hash (C data ), which constitutes the content published in the PUBLISH packet sent by the client {C topic ,Hash(C data )} and send to the server;

[0068] Specifically, Indicates that the subject key is used topic SM4 encryption algorithm for encryption;

[0069] After receiving the PUBLISH data packet, the server uses the subject key Key topic C topic Decrypted to get C data , and then forward the PUBLISH data packet to the client as the topic subscriber, and the subscriber uses the topic key Key topic C topic Decryption yields {C data ,timeStamp}, and then check whether the timeStamp of the PUBLISH data packet is within the specified range. If it is within the specified range, the C data Take the hash to get C data_hash , the obtained hash value and the Hash (C extracted from the PUBLISH data packet data ) are compared. If they are consistent, it means that the information has not been tampered with. So far, it is determined that the plaintext message published by the subject is C data , thus realizing MQTT encrypted communication and information integrity judgment.

[0070] In MQTT encrypted communication, timestamps are added to determine the real-time and validity of information, which can effectively prevent replay attacks by hackers, which is extremely important in IoT devices. SM4 and SM3 are used to derive topic keys. After generating and distributing topic keys, the MQTT server only needs to forward data. SM3 is used to obtain hash values ​​for topic information. This method can be used to determine whether a message has been tampered with while consuming less computing resources. It is very suitable for platforms with limited computing resources such as the IoT and edge computing.

Claims

1. An encrypted communication method based on the MQTT protocol identity authentication of the lightweight national secret SM9, characterized in that: Includes steps: 1) Key pair generation and acquisition: The client and server hash the device ID based on the CPU serial number and MAC address of their own devices, and then use the device ID to obtain the hash value to generate their respective device public keys. pub After that, the client and server devices obtain the corresponding device private key Key in the key generation center KGC through their unique device IDs. sec ; 2) Lightweight SM9 authentication: The client generates a random number n D and verification information And the client authentication information Sent to the server; Respectively represent the first verification information and the second verification information of the client, ID D is the device ID of the client, and the subscript D indicates the client; The server will perform a bilinear pairing check on the authentication information received from the client. After the check passes, the server will generate a random number n. S and certification information in, Respectively represent the first verification information and the second verification information of the server, ID S is the device ID of the server, the subscript S represents the server, and the server generates the session key sk S , and then calculate the session key hash value sk through the hash function Hash S_Hash : The server sends the server authentication information {ID s ,φ s ,σ s } and the session key hash value sk S_Hash Send to the client; The client performs a bilinear pairing check on the received server authentication information. After the check passes, the client generates a session key sk D and the session key hash value sk D_Hash : If there is sk D_Hash =sk S_Hash The client successfully authenticates the server and sends the session key hash value sk D_Hash To the server; The server checks whether sk is satisfied D_Hash =sk S_Hash If yes, the server successfully authenticates the client and sets sk D ,sk S As the SM4 symmetric session key sk for encrypted communication between the client and the server session ; 3) Derivation and distribution of subject keys: The client uses the session key sk for the combination of username user, user password and current timestamp timeStamp {user, password, timeStamp} session Perform SM4 encryption to generate ciphertext C verify , and then {ID D ,C verify }Put it into the CONNECT data packet and send it to the server; After receiving the CONNECT packet, the server extracts {ID D ,C verify }, using the session key sk session Get the client ID D The corresponding C verify Decrypt to get {user, password, timeStamp}, and check the timeStamp. If the time is within the specified range, it is considered that the C verify The server receives the valid data and performs MQTT protocol authentication on the obtained username and password. If the authentication succeeds and the timestamp is within the specified range, a CONNACK packet is returned to the client to confirm the connection request. Otherwise, the server returns an MQTT authentication failure message to the client. When the MQTT protocol authentication succeeds, the client confirms to subscribe or publish the topic and sends {topic,ID D } to the server, which uses the device private key Key S_sec Generate a topic key topic =Hash(topic||Key S_sec ) and set Key topic and timestamp timeStamp using session key sk session Perform SM4 encryption to obtain ciphertext C key ; C key Sent to the client, the client passes the session key sk session C key Decrypt to get the subject key Key topic , thus completing the subject key Key topic distribution; 4)MQTT data encryption transmission and decryption: The client sends a SUBSCRIBE packet to the server to subscribe to the topic content; The client as the publisher will publish the information corresponding to the topic C data and timestamp {C data ,timeStamp} uses the subject key Key topic After SM4 encryption, the ciphertext C is obtained topic And generate a summary Hash (C data ), which constitutes the content published in the PUBLISH packet sent by the client {C topic ,Hash(C data )} and send to the server; After receiving the PUBLISH data packet, the server uses the subject key Key topic C topic Decrypted to get C data , and then forward the PUBLISH data packet to the client as the topic subscriber, and the subscriber uses the topic key Key topic C topic Decryption yields {C data ,timeStamp}, and then check whether the timeStamp of the PUBLISH data packet is within the specified range. If it is within the specified range, the C data Take the hash to get C data_hash , the obtained hash value and the Hash (C extracted from the PUBLISH data packet data ) are compared, if they are consistent, it is determined that the plaintext message published by the subject is C data .

2. The method according to claim 1, characterized in that: In the key pair generation and acquisition step, the client and server obtain their own CPU serial number and the MAC address of the network card, and generate a 32-bit unique ID number by taking the hash value: ID = Hash (CPUID||MAC); Among them, CPUID is the CPU serial number, MAC is the MAC address, ID is the device ID; Hash is the hash function of the national secret SM3.

3. The method according to claim 1, characterized in that: In the key pair generation and acquisition step, the key generation center KGC initializes the elliptic curve information: KGC, the client, and the server initialize the elliptic curve information respectively; SM9 adopts the 256-bit BN curve recommended in the national standard, and selects two additive cyclic groups G1 and G2 with an order of prime number N, and their generators are P1 and P2. Then, select the bilinear pairing and the multiplicative cyclic group G of prime order N T ,satisfy: G1×G2→G T ; N>=2 k , k is the key length.

4. The method according to claim 3, characterized in that: In the key pair generation step, the hash value is taken from the device ID to generate the respective device public key Key pub The specific method is: Key pub =Hash(ID); Device private key sec The specific generation method is: Among them, s is a random large prime number generated by KGC as the encryption master private key of KGC; the encryption master public key P0 is specifically P0=s·P1.

5. The method according to claim 3, characterized in that: The first verification information of the client and the second verification information σ D The specific generation method is: σ D =n D Key D_sec ; The first verification information of the server and the second verification information σ S The specific generation method is: σ S =n S Key S_sec Among them, Key D_sec The client's device private key, Key S_sec The private key of the server device.

6. The method according to claim 4, characterized in that: In lightweight SM9 authentication, the bilinear pairing check on the client needs to satisfy the following equation: The bilinear pairing check on the server needs to satisfy the following equation:

Citation Information

Cited By

  • Secure communication method and system of MQTT protocol based on national cipher module

    CN119232499A

  • Data transmission method and device oriented to Internet of Things, electronic equipment and storage medium

    CN119997024A

  • Data transmission method and device for internet of things, electronic device and storage medium

    CN119997024B

  • Authentication encryption method based on national secret algorithm and application

    CN120546865A

  • Remote login and control method and system based on virtual serial port and MQTT protocol

    CN121262242A