A two-way authentication method and system based on the SM2 algorithm
By combining a hybrid key system with dual signatures, a two-way authentication method is developed, which solves the security deficiencies and response delays of existing SM2 algorithm authentication schemes. This method achieves efficient and secure two-way authentication and is suitable for resource-constrained devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHANGHAI UNI SENTRY INTELLIGENT TECH CO LTD
- Filing Date
- 2026-03-11
- Publication Date
- 2026-06-02
AI Technical Summary
Existing identity authentication schemes based on the SM2 algorithm suffer from one-way authentication risks, high response latency, and weak resistance to quantum attacks, making it difficult to meet the needs of resource-constrained devices such as IoT terminals.
A hybrid key system is adopted, combining national cryptographic key pairs and quantum-resistant key pairs for dual signatures. Combined with base point caching and parameter pre-computation mechanism, a session key is generated through two-way authentication and random challenge verification mechanism to ensure communication security.
It achieves security and efficiency in two-way identity authentication, has resistance to quantum attacks, is compatible with resource-constrained devices, meets national cryptographic compliance requirements, improves response speed, and prevents the vulnerability of one-way authentication to attacks.
Smart Images

Figure CN122137641A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of network security technology, and in particular to a two-way authentication method and system based on the SM2 algorithm. Background Technology
[0002] Identity authentication is a core component of cybersecurity, serving to verify the true identities of both communicating parties and prevent unauthorized access and data leaks. With the rapid development of new energy, the Internet of Things, and e-government, the demand for remote communication between devices is increasing, placing higher demands on the security, efficiency, and attack resistance of identity authentication.
[0003] The SM2 algorithm, an elliptic curve public-key cryptography algorithm independently designed in my country, features short key length and high security, and has been widely used in various secure communication scenarios. However, existing authentication schemes based on the SM2 algorithm mostly adopt a one-way authentication mode, where only the client verifies the server's identity or vice versa, which poses a risk of identity forgery. At the same time, the real-time computation of elliptic curve multiplication during the authentication process is large, resulting in high response latency, which is difficult to meet the needs of resource-constrained devices such as IoT terminals. In addition, traditional SM2 authentication schemes do not consider the threat of quantum computing; encryption systems based on the discrete logarithm problem are vulnerable to being cracked by quantum computers, posing potential security risks.
[0004] In existing technologies, some solutions enhance security by introducing dual signatures, but lack a two-way mutual verification mechanism; some solutions improve efficiency through pre-computation optimization, but neglect resistance to quantum attacks; and some solutions attempt to integrate post-quantum algorithms, but lack compatibility with national cryptographic algorithms, making it difficult to meet compliance requirements. Therefore, there is an urgent need for an SM2 authentication solution that combines two-way authentication security, high-efficiency response speed, and quantum resistance to address the shortcomings of existing technologies. Summary of the Invention
[0005] The purpose of this invention is to provide a two-way authentication method and system based on the SM2 algorithm, which solves the problems of insufficient security, high response latency and weak resistance to quantum attacks in existing authentication schemes.
[0006] To achieve the above objectives, this invention provides a two-way authentication method based on the SM2 algorithm, comprising the following steps: S1. Key initialization: The terminal device and the server generate a hybrid key pair and a hybrid digital certificate, respectively. The hybrid key pair includes a national cryptographic key pair based on the SM2 algorithm and a quantum-resistant key pair based on the post-quantum cryptography algorithm. The hybrid digital certificate contains dual digital signatures and dual public key information. S2, Base point cache preprocessing: The terminal device and the server extract the base point G parameters from the SM2 standard document, store them in the high-speed cache after CRC32 hash verification, pre-calculate and store several elliptic curve multiple point parameters and associated timestamps to form a parameter pool. S3. Two-way authentication is initiated. The terminal device sends an authentication request to the server. The authentication request carries a hybrid digital signature, a random challenge instruction, and a pre-calculated parameter index. After receiving the request, the server returns a response message containing its own hybrid digital signature, a corresponding random number, and the server's pre-calculated parameter index. S4. Dual signature verification: The terminal device and the server respectively parse the other party's hybrid digital signature, extract the hybrid public key and verify the validity of the dual signature to confirm the legitimacy of the other party's identity. S5. Random challenge verification: The terminal device verifies the matching between the random number returned by the server and the local random challenge command. The server verifies the random number verification result subsequently fed back by the terminal device, thus completing the two-way challenge verification. S6. After successful session key negotiation, identity authentication, and challenge verification, both parties generate a session key using a key derivation function based on the hybrid key pair, pre-calculated parameters, and random numbers, which is then used for subsequent encrypted data transmission.
[0007] Preferably, in S1, the national cryptographic key pair includes an SM2 private key and an SM2 public key, and the quantum-resistant key pair is generated using a lattice-based cryptographic algorithm; the dual digital signature uses the SM2 private key to perform national cryptographic signature on the mixed public key digest, and simultaneously uses the quantum-resistant private key to perform quantum-resistant signature on the same digest, and the two signatures are combined to form a mixed digital signature.
[0008] Preferably, in S2, the reference G point parameter is verified twice by the reference hash value stored in the hardware trust root, the pre-calculated parameter is generated by the sliding window algorithm, the parameter in the parameter pool is associated with a valid timestamp, and is automatically updated after a preset period to avoid security risks caused by reuse.
[0009] Preferably, in S4, the signature verification process includes: extracting the SM2 public key and the quantum-resistant public key from the hybrid digital certificate, verifying the corresponding digital signatures respectively, and determining the identity to be legitimate only when both signatures pass verification and the certificate chain is complete.
[0010] Preferably, in S6, the session key generation process integrates the security factor of the SM2 algorithm with the elliptic curve characteristics of the pre-calculated parameters, and is derived through the KDF function, including an encryption subkey and an integrity verification subkey.
[0011] This invention also provides a two-way authentication system based on the SM2 algorithm, comprising: The key generation module is used for terminal devices and servers to generate hybrid key pairs and hybrid digital certificates. The hybrid key pairs include SM2 national cryptographic key pairs and quantum-resistant key pairs, and support dual digital signature generation. The cache preprocessing module is used to extract and verify the SM2 baseline G-point parameters, build a high-speed cache, pre-calculate the elliptic curve multiple point parameters and maintain the parameter pool to achieve secure storage and dynamic updating of parameters. The authentication interaction module is used for terminal devices to initiate two-way authentication requests and responses with the server, and to transmit mixed digital signatures, random challenge instructions and pre-calculated parameter indexes. The signature verification module is used to parse the hybrid digital signature, extract the dual public keys, and verify the validity of the dual signatures respectively, thus completing the confirmation of the legitimacy of both parties' identities. The challenge verification module is used to match and verify random challenge commands and response results to prevent replay attacks and man-in-the-middle attacks. The key negotiation module is used to generate session keys based on the hybrid key, pre-calculated parameters, and random numbers to ensure the security of subsequent communication.
[0012] Preferably, the cache preprocessing module includes a hash verification unit and a parameter management unit. The hash verification unit performs multi-layer verification on the G-point parameters using the CRC32 algorithm. The parameter management unit updates the parameter pool according to a preset period, marks the parameters that have been used, and triggers the pre-calculation of new parameters.
[0013] Preferably, the signature verification module is compatible with both the SM2 national cryptographic signature verification process and the post-quantum signature verification process, supports step-by-step parsing and independent verification of hybrid digital signatures, and terminates the authentication process and records the audit log if any signature verification fails.
[0014] The present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of a two-way authentication method based on the SM2 algorithm.
[0015] The present invention also includes a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the two-way authentication method based on the SM2 algorithm.
[0016] Therefore, this invention adopts the above-mentioned two-way identity authentication method and system based on the SM2 algorithm, which combines a hybrid key system with dual signatures. This not only meets the national cryptographic compliance requirements but also has the ability to resist quantum attacks, achieving dual protection against traditional and future security threats. It introduces a base point caching and parameter pre-computation mechanism to reduce the real-time computation load in the authentication process, improve response speed, and adapt to resource-constrained devices. It constructs a dual verification mechanism of two-way authentication and random challenge to prevent the vulnerability of one-way authentication to attacks and ensure that the identities of both communicating parties are legitimate and trustworthy.
[0017] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0018] Figure 1 This is a flowchart of a two-way authentication method based on the SM2 algorithm according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the hybrid key generation and dual signature structure according to an embodiment of the present invention; Figure 3 This is a timing diagram of the two-way authentication interaction according to an embodiment of the present invention. Detailed Implementation
[0019] The technical solution of the present invention will be further described below with reference to the accompanying drawings and embodiments.
[0020] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning understood by one of ordinary skill in the art to which this invention pertains. The terms "first," "second," and similar terms used in this invention do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0021] Example 1 The following describes the implementation of this invention in detail, using a specific application scenario, namely a remote monitoring system for new energy power plants. The process is as follows: Figure 1As shown. In a remote monitoring system for a new energy power plant, monitoring terminals, such as photovoltaic inverter monitoring modules and hydropower gate control terminals, need to interact with a remote monitoring center for data exchange and command issuance. This involves sensitive information such as power plant operation data and control commands, requiring secure and reliable identity authentication, timely response, and protection against potential quantum computing attacks to ensure the safe operation of the power plant. This invention is applied to this scenario to achieve two-way identity authentication between the monitoring terminal and the monitoring center. The specific process is as follows: S1, Key Initialization Both the monitoring terminal and the monitoring center (server) generate hybrid key pairs in the trusted execution environment: National Cryptographic Key Pair Generation: The SM2 algorithm is used to generate the private key on the monitoring terminal. d 1 and public key P 1= d 1G, the monitoring center generates the private key. d 2 and public key P 2= d 2G, where G is the base point of the SM2 elliptic curve; Quantum-resistant key pair generation: Generating private keys using lattice-based cryptography algorithms. sk q and public key pk q ; Hybrid public key combination: Combine the SM2 public key and the quantum-resistant public key in TLV format to form a hybrid public key, and calculate the SM3 hash digest of the hybrid public key; Double signature generation: The monitoring terminal uses a private key d 1. Sign the digest using SM2 with the private key. sk q Quantum-resistant signatures are applied to the same digest, and these signatures are combined to form hybrid digital signatures. Certificate Issuance: The hybrid public key, hybrid digital signature, and device identity information (terminal number, monitoring center identifier) are submitted to the CA authority to issue a hybrid digital certificate and store it in the device's secure storage area. A schematic diagram of hybrid key generation and dual signature structure is shown below. Figure 2 As shown.
[0022] S2, Base Point Cache Preprocessing Reference G-point parameter extraction: Extracting G-points from SM2 standard documents x coordinate, y Coordinates and order n A base hash value is generated using the CRC32 algorithm and stored in the unmodifiable area of the hardware trust root (TPM). Cache initialization: Read the preset G-point parameters from external storage, write them to the cache after CRC32 verification, establish a key-value pair index, and compare the real-time hash value with the base hash value twice to ensure parameter integrity; Pre-computed parameter pool construction: generating several parameters based on a true random number generator. k value (1< k < n -1), calculated using the sliding window algorithm k G obtains the elliptic curve multiple point parameters and encrypts them using the SM4 algorithm. k After the value is obtained, the encrypted value will be used. k The value, multiplier parameter, and generation timestamp are associated and stored in the parameter pool, and the parameter validity period is set to 2 task cycles.
[0023] S3, Initiation of Two-Way Authentication The monitoring terminal initiates authentication: The monitoring terminal selects pre-calculated parameters that have not expired from the parameter pool, obtains their indexes, constructs an authentication request message, which includes a hybrid digital certificate, a random challenge command, a parameter index, and a device identifier, and sends it to the monitoring center through an SSL VPN tunnel; Monitoring Center Response: After receiving the request, the monitoring center verifies the integrity of the message, selects pre-calculated parameters from its own parameter pool, constructs a response message, which includes the monitoring center's hybrid digital certificate, the corresponding random number (generated based on the terminal challenge command), the parameter index, and the center identifier, and returns it to the monitoring terminal.
[0024] S4, Dual Signature Verification Signature verification at the monitoring terminal: Parse the hybrid digital certificate from the monitoring center and extract the hybrid public key (including the SM2 public key). P 2 and quantum-resistant public keys pk q 2) Separate the SM2 signature and the quantum-resistant signature in the hybrid digital signature; use P 2. Verify the validity of the SM2 signature using... pk q 2. Verify the validity of the quantum-resistant signature. If both parts pass, the identity of the monitoring center is confirmed as legitimate. Signature verification at the monitoring center: Similarly, the mixed digital signature of the monitoring terminal is parsed using the terminal's SM2 public key. P 1 and quantum-resistant public keys pk q 1. Verify the corresponding signatures separately. If all of them pass, the terminal's identity is confirmed to be legitimate.
[0025] S5, Random Challenge Verification Terminal verification of random number: The monitoring terminal receives the random number returned by the monitoring center, matches and verifies it with the random challenge command sent locally, calculates the SM3 hash value of the random number and feeds it back to the monitoring center; Central verification result: After receiving the hash value, the monitoring center compares it with the SM3 hash value of its own generated random number. If they match, the challenge verification passes and the two-way identity confirmation is completed.
[0026] S6, Session Key Negotiation Intermediate parameter calculation: The monitoring terminal calculates parameters based on its own pre-calculated parameters. k 1G, the double-point parameters corresponding to the pre-calculated parameter index of the monitoring center k 2G and SM2 private keys d 1. Monitoring terminal calculates intermediate points Q 1= d 1 ( k 2G+ x 2 P 2), of which x 2 is k The horizontal axis of 2G; the monitoring center calculates the midpoint similarly. Q 2= d 2( k 1G+ x 1 P 1), x 1 is k The x-axis of 1G; Session key generation: Both parties respectively set the coordinates of the intermediate point ( x Q , y Q ) Execute the key derivation function KDF( x Q || y Q , klen), and generate a 128-bit session key by fusing random number hash values, which includes an SM4 key for data encryption and an HMAC key for integrity verification; Communication security assurance: Subsequent data transmission and control command issuance between the monitoring terminal and the center will be encrypted using this session key. Data is encrypted using the SM4 algorithm, and a message authentication code is generated using the SM3 algorithm to ensure data confidentiality and integrity. The specific timing sequence of the two-way authentication interaction between the monitoring terminal and the monitoring center is as follows: Figure 3 As shown.
[0027] Therefore, this invention adopts the above-mentioned two-way identity authentication method and system based on the SM2 algorithm, which combines a hybrid key system with dual signatures. This not only meets the national cryptographic compliance requirements but also has the ability to resist quantum attacks, achieving dual protection against traditional and future security threats. It introduces a base point caching and parameter pre-computation mechanism to reduce the real-time computation load in the authentication process, improve response speed, and adapt to resource-constrained devices. It constructs a dual verification mechanism of two-way authentication and random challenge to prevent the vulnerability of one-way authentication to attacks and ensure that the identities of both communicating parties are legitimate and trustworthy.
[0028] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.
Claims
1. A two-way authentication method based on the SM2 algorithm, characterized in that, Includes the following steps: S1. Key initialization: The terminal device and the server generate a hybrid key pair and a hybrid digital certificate, respectively. The hybrid key pair includes a national cryptographic key pair based on the SM2 algorithm and a quantum-resistant key pair based on the post-quantum cryptography algorithm. The hybrid digital certificate contains dual digital signatures and dual public key information. S2, Base point cache preprocessing: The terminal device and the server extract the base point G parameters from the SM2 standard document, store them in the high-speed cache after CRC32 hash verification, pre-calculate and store several elliptic curve multiple point parameters and associated timestamps to form a parameter pool. S3. Two-way authentication is initiated. The terminal device sends an authentication request to the server. The authentication request carries a hybrid digital signature, a random challenge instruction, and a pre-calculated parameter index. After receiving the request, the server returns a response message containing its own hybrid digital signature, a corresponding random number, and the server's pre-calculated parameter index. S4. Dual signature verification: The terminal device and the server respectively parse the other party's hybrid digital signature, extract the hybrid public key and verify the validity of the dual signature to confirm the legitimacy of the other party's identity. S5. Random challenge verification: The terminal device verifies the matching between the random number returned by the server and the local random challenge command. The server verifies the random number verification result subsequently fed back by the terminal device, thus completing the two-way challenge verification. S6. After successful session key negotiation, identity authentication, and challenge verification, both parties generate a session key using a key derivation function based on the hybrid key pair, pre-calculated parameters, and random numbers, which is then used for subsequent encrypted data transmission.
2. The two-way authentication method based on the SM2 algorithm according to claim 1, characterized in that, In S1, the national cryptographic key pair includes an SM2 private key and an SM2 public key, and the quantum-resistant key pair is generated using a lattice-based cryptographic algorithm; the dual digital signature uses the SM2 private key to perform national cryptographic signature on the mixed public key digest, and simultaneously uses the quantum-resistant private key to perform quantum-resistant signature on the same digest, and the two signatures are combined to form a mixed digital signature.
3. The two-way authentication method based on the SM2 algorithm according to claim 1, characterized in that, In S2, the reference G point parameters are verified twice by the reference hash value stored in the hardware trust root. The pre-calculated parameters are generated by the sliding window algorithm. The parameters in the parameter pool are associated with valid timestamps and are automatically updated after a preset period to avoid security risks caused by reuse.
4. The two-way authentication method based on the SM2 algorithm according to claim 1, characterized in that, In S4, the signature verification process includes: extracting the SM2 public key and the quantum-resistant public key from the hybrid digital certificate, verifying the corresponding digital signatures respectively, and determining the identity as legitimate only when both signatures pass verification and the certificate chain is complete.
5. The two-way authentication method based on the SM2 algorithm according to claim 1, characterized in that, In S6, the session key generation process integrates the security factor of the SM2 algorithm with the elliptic curve characteristics of the pre-calculated parameters, and is derived through the KDF function, including an encryption subkey and an integrity verification subkey.
6. A two-way authentication system based on the SM2 algorithm, characterized in that, include: The key generation module is used for terminal devices and servers to generate hybrid key pairs and hybrid digital certificates. The hybrid key pairs include SM2 national cryptographic key pairs and quantum-resistant key pairs, and support dual digital signature generation. The cache preprocessing module is used to extract and verify the SM2 baseline G-point parameters, build a high-speed cache, pre-calculate the elliptic curve multiple point parameters and maintain the parameter pool to achieve secure storage and dynamic updating of parameters. The authentication interaction module is used for terminal devices to initiate two-way authentication requests and responses with the server, and to transmit mixed digital signatures, random challenge instructions and pre-calculated parameter indexes. The signature verification module is used to parse the hybrid digital signature, extract the dual public keys, and verify the validity of the dual signatures respectively, thus completing the confirmation of the legitimacy of both parties' identities. The challenge verification module is used to match and verify random challenge commands and response results to prevent replay attacks and man-in-the-middle attacks. The key negotiation module is used to generate session keys based on the hybrid key, pre-calculated parameters, and random numbers to ensure the security of subsequent communication.
7. The two-way authentication system based on the SM2 algorithm according to claim 6, characterized in that, The cache preprocessing module includes a hash verification unit and a parameter management unit. The hash verification unit performs multi-layer verification on the G-point parameters using the CRC32 algorithm. The parameter management unit updates the parameter pool according to a preset period, marks the parameters that have been used, and triggers the pre-calculation of new parameters.
8. The two-way authentication system based on the SM2 algorithm according to claim 6, characterized in that, The signature verification module is compatible with both the SM2 national cryptographic signature verification process and the post-quantum signature verification process. It supports step-by-step parsing and independent verification of hybrid digital signatures. If any signature verification fails, the authentication process will be terminated and an audit log will be recorded.
9. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the two-way authentication method based on the SM2 algorithm as described in any one of claims 1-5.
10. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, implements the steps of the two-way authentication method based on the SM2 algorithm as described in any one of claims 1-5.