Identity authentication method and device, server, storage medium and product

By employing the SM9 digital signature algorithm to sign the header and payload information in JWT, the security vulnerabilities of the JWT scheme are resolved, achieving higher data integrity and resistance to attacks, and improving the security of identity authentication.

CN120856353AInactive Publication Date: 2025-10-28CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202511351617.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-22
Publication Date
2025-10-28
Estimated Expiration
Not applicable · inactive patent

Smart Images

  • Figure CN120856353A_ABST
    Figure CN120856353A_ABST
Patent Text Reader

Abstract

The invention discloses an identity authentication method and device, a server, a storage medium and a product, and the method comprises the steps: determining the head information of a JWT as an identity authentication token and the identity information of a user in response to a login request from a client; determining load information of the JWT based on the identity information; determining a to-be-sent message based on the header information and the load information; determining signature information based on the to-be-sent message and an SM9 digital signature algorithm; and generating a JWT based on the header information, the load information and the signature information, and sending the JWT to the client. After a user logs in by using a client, the SM9 algorithm is used as a signature algorithm of the JWT, and the information in the head and the load of the JWT is signed, so that the security of the JWT is greatly improved based on the algorithm characteristics of the SM9. In this way, the JWT scheme can resist attacks such as bypassing of the one algorithm, sensitive information leakage, algorithm confusion and key exhaustion.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of network security technology, and in particular to an identity authentication method, device, server, storage medium and product. Background Technology

[0002] Currently, most projects and systems require identity authentication, and many authentication solutions are based on authentication tokens, such as the JSON Web Token (JWT). JWT is an open standard (RFC 7519) that defines a compact, self-contained way to securely transmit information between parties in the form of JSON objects. However, due to the complexity of the JWT standard and developers' insufficient understanding of the technical details and encryption algorithms, while JWT brings convenience to development, it also introduces security vulnerabilities into applications. Some libraries introduce vulnerabilities in their implementation of the JWT specification; for example, the signature verification process can be bypassed by using the `none` algorithm or by directly deleting the signature during interaction. Furthermore, key exhaustion attacks and algorithm obfuscation attacks exist online, making JWT-based authentication solutions vulnerable to security issues. Summary of the Invention

[0003] In view of this, embodiments of this application provide an identity authentication method, apparatus, server, storage medium, and product, aiming to improve the security of JWT.

[0004] The technical solution of this application embodiment is implemented as follows: In a first aspect, embodiments of this application provide an identity authentication method applied to an authorization server, comprising: In response to a login request from a client, determine the header information of the JWT used as an authentication token and the user's identity information; The payload information of the JWT is determined based on the identity information; The message to be sent is determined based on the header information and the payload information; The signature information is determined based on the message to be sent and the SM9 digital signature algorithm; The JWT is generated based on the header information, the payload information, and the signature information, and then sent to the client.

[0005] In the above scheme, the load information includes time information, which represents the time when the JWT generation begins.

[0006] In the above scheme, determining the message to be sent based on the header information and the payload information includes: A first string is determined based on the header information and the time information, and a second string is determined based on the payload information and the time information; the first string and the second string have the same length. The message to be sent is determined based on the first string and the second string.

[0007] In the above scheme, determining the first string based on the header information and the time information, and determining the second string based on the payload information and the time information, includes: Based on the SM3 cryptographic hash algorithm, the header information and the time information are converted into a first string; Based on the SM3 cryptographic hash algorithm, the payload information and the time information are converted into a second string.

[0008] In the above scheme, determining the signature information based on the message to be sent and the SM9 digital signature algorithm includes: The message to be signed by the SM9 digital signature algorithm is determined based on the message to be sent; The signature information is determined based on the message to be signed and the SM9 digital signature algorithm.

[0009] In the above scheme, determining the signature information based on the message to be signed and the SM9 digital signature algorithm includes: Generate user private key and master public key based on the SM9 digital signature algorithm; Generate a first random number, and determine a third string based on the first random number and the master public key; The first sub-signature information is determined based on the message to be signed and the third string; The second sub-signature information is determined based on the first sub-signature information, the first random number, and the user's private key; The signature information is determined based on the first sub-signature information and the second sub-signature information.

[0010] In the above scheme, generating the JWT based on the header information, the payload information, and the signature information includes: The fourth string is determined based on the header information and the base64 algorithm; The fifth string is determined based on the aforementioned load information and the base64 algorithm; The sixth string is determined based on the signature information and the base64 algorithm; The JWT is generated based on the fourth string, the fifth string, and the sixth string.

[0011] Secondly, embodiments of this application provide an identity authentication method applied to a resource server, comprising: In response to a resource acquisition request from the client, obtain the JWT from the client and the master public key from the authorization server; Based on the JWT, the user's identity information, first sub-signature information, and second sub-signature information are determined; The first sub-signature information and the second sub-signature information are determined by the authorization server based on the message to be signed and the SM9 digital signature algorithm to form the signature information; The first information is determined based on the master public key and the first sub-signature information; The second information is determined based on the master public key, the identity information, and the second sub-signature information; The third sub-signature information is determined based on the first information and the second information; Compare the first sub-signature information with the third sub-signature information. If they are the same, generate a verification result indicating successful verification; otherwise, generate a verification result indicating failed verification.

[0012] Thirdly, according to an embodiment of this application, an identity authentication device is applied to an authorization server, comprising: The first determination module is used to determine the header information of the JWT, which serves as the authentication token, and the user's identity information in response to a login request from the client. The second determining module is used to determine the load information of the JWT based on the identity information; The third determining module is used to determine the message to be sent based on the header information and the payload information; The fourth determining module is used to determine signature information based on the message to be sent and the SM9 digital signature algorithm; The first generation module is used to generate the JWT based on the header information, the payload information and the signature information, and send the JWT to the client.

[0013] Fourthly, embodiments of this application provide an identity authentication device applied to a resource server, comprising: The acquisition module is used to respond to resource acquisition requests from clients, acquire the JWT from the client, and acquire the master public key from the authorization server; The fifth determining module is used to determine the user's identity information, first sub-signature information, and second sub-signature information based on the JWT; the first sub-signature information and the second sub-signature information are determined by the authorization server based on the message to be signed and the SM9 digital signature algorithm to constitute signature information; The sixth determining module is used to determine the first information based on the master public key and the first sub-signature information; The seventh determining module is used to determine the second information based on the master public key, the identity information, and the second sub-signature information; The eighth determining module is used to determine the third sub-signature information based on the first information and the second information; The second generation module is used to compare whether the first sub-signature information and the third sub-signature information are the same. If they are the same, a verification result indicating successful verification is generated; if they are different, a verification result indicating failed verification is generated.

[0014] Fifthly, embodiments of this application provide an authorization server, including a processor and a memory for storing a computer program capable of running on the processor, wherein the processor executes the computer program to implement the steps of the method described in the first aspect above.

[0015] In a sixth aspect, embodiments of this application provide a resource server, including a processor and a memory for storing a computer program capable of running on the processor, wherein the processor executes the computer program to implement the steps of the method described in the second aspect above.

[0016] In a seventh aspect, embodiments of this application provide a computer storage medium storing a computer program, which, when executed by a processor, implements the steps of the method as described in the first or second aspect above.

[0017] Eighthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the steps of the method as described in the first or second aspect above.

[0018] The technical solution provided in this application is applied to an authorization server, including: responding to a login request from a client, determining the header information of a JWT (Junior Token for Authentication) and the user's identity information; determining the payload information of the JWT based on the identity information; determining the message to be sent based on the header information and payload information; determining signature information based on the message to be sent and the SM9 digital signature algorithm; generating a JWT based on the header information, payload information, and signature information, and sending the JWT to the client. After logging in using the client, the user uses the SM9 algorithm as the signature algorithm for the JWT to sign the information in the JWT header and payload, thereby significantly improving the security of the JWT based on the characteristics of the SM9 algorithm. Thus, the solution provided in this application can generate a JWT that combines the compactness and self-containment of a JWT with the security of SM9. Compared with JWT solutions in related technologies, the JWT solution in this application has the characteristics of data integrity, non-repudiation, and resistance to replay attacks, and can resist attacks such as bypassing the none algorithm, leakage of sensitive information, algorithm obfuscation, and key exhaustion. Attached Figure Description

[0019] Figure 1 This is a flowchart illustrating the JWT authentication process in related technologies. Figure 2 This is a flowchart illustrating the authorization server authentication method according to an embodiment of this application; Figure 3 This is a flowchart illustrating the resource server authentication method according to an embodiment of this application; Figure 4 This is a schematic diagram illustrating the JWT generation process, an application example of this application. Figure 5 This is a schematic diagram illustrating the workflow of an application example identity authentication scheme in this application; Figure 6 This is a schematic diagram of the identity authentication device of the authorization server in an embodiment of this application; Figure 7 This is a schematic diagram of the structure of the identity authentication device for the resource server in an embodiment of this application; Figure 8 This is a schematic diagram of the structure of the authorized server in an embodiment of this application; Figure 9 is a schematic diagram of the structure of the resource server in an embodiment of this application. Detailed Implementation

[0020] The present application will now be described in further detail with reference to the accompanying drawings and embodiments.

[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application pertains. The terms used herein in the specification of this application are for the purpose of describing specific embodiments only and are not intended to limit this application.

[0022] Before describing the embodiments of this application, the relevant terms will be explained.

[0023] JWT (JSON Web Token): An open standard (RFC 7519) that defines a compact, self-contained way to securely transmit information across networks in the form of a JSON object. A JWT consists of three parts: a header, a payload, and a signature. The header describes the token type (typ) and the signature algorithm (alg); for example, in a JWT, the typ is usually "JWT," while the alg might specify HMAC SHA256 or RSA. This information is Base64 encoded to form the header of the JWT. The payload contains the actual data to be transmitted, such as the user ID, username, etc. The payload can also contain metadata, such as expiration time and publisher information. Unlike the header, the payload can be encrypted, depending on the application's security requirements. The signature is generated based on the header and payload and is used to verify that the JWT has not been tampered with during transmission. The signature is generated using the algorithm and key specified in the header, ensuring the authenticity and integrity of the JWT.

[0024] JWT is primarily used for user login authentication. It is a distributed, stateless token and currently the most popular cross-domain authentication solution. The steps for using JWT include: the user logs into the server; upon successful authentication, the server generates and returns a JWT token; the client saves the JWT and includes it in requests sent to the business system. Figure 1 This is a flowchart illustrating the JWT authentication process in related technologies.

[0025] The SM9 algorithm is an identifier-based cryptography standard adopted by the government of the People's Republic of China. It was released by the State Cryptography Administration on March 28, 2016, and the relevant standard is "GM / T 0044-2016 SM9 Identifier Cryptography Algorithm". The SM9 algorithm is an identifier-based cryptography algorithm (IBC) consisting of three parts: a digital signature algorithm, an identifier encryption algorithm, and a key exchange protocol. The SM9 algorithm employs the principles of elliptic curve cryptography, using points on an elliptic curve to perform digital signatures, authentication, and key exchange. The key generation and derivation processes, as well as encryption and decryption operations in the SM9 algorithm, are all based on mathematical operations on elliptic curves. This application's embodiments mainly use the digital signature algorithm within the SM9 algorithm, which is divided into four main steps: system parameter setting, user private key generation, signature generation, and signature verification.

[0026] Currently, most projects or systems involve scenarios such as session management, thus requiring identity authentication. Many authentication solutions are based on authentication tokens, such as the JSON Web Token (JWT). JWT is an open standard (RFC 7519) that defines a compact, self-contained way to securely transmit information between parties in the form of JSON objects. However, due to the complexity of the JWT standard and developers' insufficient understanding of technical details and encryption algorithms, while JWT brings convenience to development, it also introduces security vulnerabilities into applications. Some libraries introduce vulnerabilities in their implementation of the JWT specification. For example, the signature verification process can be bypassed by using the none algorithm or by directly deleting the signature during interaction. Furthermore, key exhaustion attacks and algorithm obfuscation attacks exist online, making JWT-based authentication solutions vulnerable to security issues.

[0027] In various embodiments of this application, after a user logs in using a client, the SM9 algorithm is used as the signature algorithm for the JWT to sign the information in the JWT header and payload. This significantly improves the security of the JWT based on the characteristics of the SM9 algorithm. Thus, the scheme provided in this application can generate JWTs that combine the compactness and self-containment of JWTs with the security of SM9. Compared with JWT schemes in related technologies, the JWT scheme of this application has characteristics such as data integrity, non-repudiation, and resistance to replay attacks, and can resist attacks such as bypassing the none algorithm, leakage of sensitive information, algorithm obfuscation, and key exhaustion.

[0028] This application provides an identity authentication method applied to an authorization server, such as... Figure 2 Shown, including: Step 201: In response to the login request from the client, determine the header information of the JWT used as the authentication token and the user's identity information; Here, when the client initiates a login request, if the user enters a username and password, the authorization server generates a JWT header. The JWT header can include {"typ": "JWT", "alg": "SM9"}, and the user's identity information can be the user's username.

[0029] Step 202: Determine the JWT payload information based on the identity information; Here, the JWT payload is determined using the user's account name (i.e., identity information), which can include {"userId": "SAAMTI", "exp": "1721095431190"}, where exp refers to the JWT's expiration time, which can be set by the authorization server.

[0030] Step 203: Determine the message to be sent based on the header and payload information; In practical applications, the header and payload can be converted into strings using a hash-like algorithm, and the message to be sent can be obtained using the first operation method.

[0031] Step 204: Determine the signature information based on the message to be sent and the SM9 digital signature algorithm; Here, the message to be sent is signed using the SM9 digital signature algorithm to obtain signature information.

[0032] Step 205: Generate a JWT based on the header information, payload information, and signature information, and send the JWT to the client.

[0033] It is understandable that after a user logs in using a client, the SM9 algorithm is used as the signing algorithm for the JWT, signing the information in the JWT header and payload. This significantly improves the security of the JWT based on the characteristics of the SM9 algorithm. Thus, the scheme provided in this application can generate JWTs that combine the compactness and self-containment of JWTs with the security of SM9. Compared with JWT schemes in related technologies, the JWT scheme in this application has characteristics such as data integrity, non-repudiation, and resistance to replay attacks, and can resist attacks such as bypassing the none algorithm, sensitive information leakage, algorithm obfuscation, and key exhaustion.

[0034] On the resource server side, the following attacks may occur: After an attacker intercepts a valid JWT token, they can reuse the token within its validity period to impersonate a legitimate user and initiate requests.

[0035] Therefore, in some embodiments, the load information includes time information, which represents the time when the JWT generation begins.

[0036] For example, the payload of a JWT can include {"userId": "SAAMTI", "exp": "1721095431190", "iat": "1721095431190"}, where "iat" represents the time when the JWT was first generated. Therefore, when the resource server receives a resource request carrying a JWT from a client, it can parse the time information and verify it against the current system time. If the time information exceeds the allowed deviation range, the JWT is considered invalid or tampered with and is therefore rejected. This approach helps prevent the reuse of JWTs, enhancing system security and controllability.

[0037] In some embodiments, determining the message to be sent based on the header information and the payload information includes: A first string is determined based on the header information and the time information, and a second string is determined based on the payload information and the time information; the first string and the second string have the same length. The message to be sent is determined based on the first string and the second string.

[0038] Here, the lengths (i.e., the number of characters) of the first and second strings are kept consistent to facilitate string concatenation or encryption operations in subsequent steps.

[0039] Furthermore, the message to be sent is determined based on the first string and the second string. Specifically, the message to be sent can be determined based on the first string, the second string, and a first operation method. For example, the first string and the second string can be directly merged in order to obtain the message to be sent; alternatively, the first string and the second string can be converted into two bit strings of the same length, and then an addition or XOR operation can be performed on the two bit strings. For example, converting the first string to 0101 and the second string to 1001, the result of the XOR operation is 1100, which is the message to be sent. Here, the first operation method can be kept confidential by the authorization server. This application embodiment does not limit the first operation method.

[0040] In some embodiments, determining a first string based on the header information and the time information, and determining a second string based on the payload information and the time information, includes: Based on the SM3 cryptographic hash algorithm, the header information and the time information are converted into a first string; Based on the SM3 cryptographic hash algorithm, the payload information and the time information are converted into a second string.

[0041] Here, the SM3 cryptographic hash algorithm is a national standard hash algorithm issued by the State Cryptography Administration of China, characterized by collision resistance, fast computation speed, and high security. The SM3 cryptographic hash algorithm can output a fixed-length (e.g., 256-bit) hash value from input data of arbitrary length. By converting the header and payload information into signature-worthy information based on the SM3 cryptographic hash algorithm, the immutability and uniqueness of the signature-worthy information can be ensured, thereby enhancing the security and integrity of the authentication token.

[0042] For example, the header (Cheader) and payload (Cpayload) are mapped to strings of the same length using the SM3 cryptographic hash algorithm Hsm3, that is, the first string Sh = Hsm3(Cheader, iat) and the second string SP = Hsm3(Cpayload, iat) are calculated respectively.

[0043] In some embodiments, determining the signature information based on the message to be sent and the SM9 digital signature algorithm includes: The message to be signed by the SM9 digital signature algorithm is determined based on the message to be sent; The signature information is determined based on the message to be signed and the SM9 digital signature algorithm.

[0044] In practical applications, the message to be sent is used as parameter M in the SM9 digital signature algorithm, i.e., the message to be signed. The signature information is obtained by calculating parameter M.

[0045] In some embodiments, determining the signature information based on the message to be signed and the SM9 digital signature algorithm includes: Generate user private key and master public key based on the SM9 digital signature algorithm; Generate a first random number, and determine a third string based on the first random number and the master public key; The first sub-signature information is determined based on the message to be signed and the third string; The second sub-signature information is determined based on the first sub-signature information, the first random number, and the user's private key; The signature information is determined based on the first sub-signature information and the second sub-signature information.

[0046] Here, the SM9 digital signature algorithm is a cryptographic algorithm based on the elliptic curve discrete logarithm problem, which uses points on an elliptic curve to perform digital signatures.

[0047] For example, the authorization server first sets system parameters, including the parameters a and b of the elliptic curve equation, the prime factor N of the curve order, generators P1 and P2, and the bilinear pair e, etc. These parameters are publicly available. The specific system parameters that need to be set in the SM9 algorithm can be understood by referring to relevant technical explanations. Subsequently, the user's private key dsA and the master public key Ppub-s are generated based on the SM9 digital signature algorithm. Specifically, a random number generator is used to generate a random number as the master private key ks. The master public key Ppub-s is calculated using the master private key ks and generator P2. Finally, the user's private key dsA is generated using the user's identity information IDA (i.e., userId "SAAMTI" in the JWT payload) and the master private key ks.

[0048] Then, the signature information is calculated using steps A1-A7, as follows: A1: Calculate the element g = e(P1, Ppub-s) in the group GT; Here, GT is a multiplicative cyclic group of order N.

[0049] A2: Generate random numbers r∈[1, N-1]; Here, r is the first random number.

[0050] A3: Calculate the element w = gr in the group GT, and convert the data type of w into a bit string (i.e., a string of numbers including 0 and 1), which is also the third string.

[0051] A4: Calculate the integer h = H2(M||w, N); Here, the message to be sent is substituted into the message M to be signed in SM9 to obtain the first sub-signature information h. H2 is a hash-like algorithm, which can be the SM3 cryptographic hash algorithm.

[0052] A5: Calculate the integer l = (rh) mod N. If l = 0, return A2. A6: Calculate the element S = [l]dsA in group G1; Here, we calculate the second sub-signature information S.

[0053] A7: The signature of message M is (h, S).

[0054] Finally, the signature information Signature (h, S) was determined based on h and S.

[0055] It should be noted that the specific implementation of the SM9 digital signature algorithm for signing messages to be sent can be understood by referring to relevant technical explanations.

[0056] In some embodiments, generating the JWT based on the header information, the payload information, and the signature information includes: The fourth string is determined based on the header information and the base64 algorithm; The fifth string is determined based on the aforementioned load information and the base64 algorithm; The sixth string is determined based on the signature information and the base64 algorithm; The JWT is generated based on the fourth string, the fifth string, and the sixth string.

[0057] Here, the header, payload, and signature information (h, S) are processed using the base64 algorithm to construct a clear and easy-to-parse standard JWT format, thereby enabling cross-platform authentication. For example, the generated JWT = Base64Url(Header) + "." + Base64Url(Payload) + "." + Base64Url(Signature).

[0058] The technical solution provided in this application is applied to an authorization server, including: responding to a login request from a client, determining the header information of a JWT (Junior Token for Authentication) and the user's identity information; determining the payload information of the JWT based on the identity information; determining the message to be sent based on the header information and payload information; determining signature information based on the message to be sent and the SM9 digital signature algorithm; generating a JWT based on the header information, payload information, and signature information, and sending the JWT to the client. After logging in using the client, the user uses the SM9 algorithm as the signature algorithm for the JWT to sign the information in the JWT header and payload, thereby significantly improving the security of the JWT based on the characteristics of the SM9 algorithm. Thus, the solution provided in this application can generate a JWT that combines the compactness and self-containment of a JWT with the security of SM9. Compared with JWT solutions in related technologies, the JWT solution in this application has the characteristics of data integrity, non-repudiation, and resistance to replay attacks, and can resist attacks such as bypassing the none algorithm, leakage of sensitive information, algorithm obfuscation, and key exhaustion.

[0059] This application also provides an identity authentication method applied to a resource server, such as... Figure 3 Shown, including: Step 301: In response to the resource acquisition request from the client, obtain the JWT from the client and the master public key from the authorization server; Here, after obtaining the JWT granted by the authorization server, the user sends the JWT to the resource server to request resources, while the resource server obtains the master public key Ppub-s generated by the authorization server.

[0060] Step 302: Determine the user's identity information, first sub-signature information, and second sub-signature information based on JWT; the first sub-signature information and second sub-signature information are determined by the authorization server based on the message to be signed and the SM9 digital signature algorithm to constitute the signature information; Here, the resource server, upon receiving a JWT in base64 format, can reconstruct the JWT's payload content, thereby obtaining the user's identity information and reconstructing the first sub-signature h' and the second sub-signature S' from the signature information. This reconstruction method involves either the inverse operation of the base64 algorithm or calling a third-party tool to reconstruct the base64 JWT.

[0061] Step 303: Determine the first information based on the master public key and the first sub-signature information; Step 304: Determine the second information based on the master public key, identity information, and second sub-signature information; Step 305: Determine the third sub-signature information based on the first information and the second information; Step 306: Compare the first sub-signature information with the third sub-signature information. If they are the same, generate a verification result indicating successful verification; otherwise, generate a verification result indicating failed verification.

[0062] For example, the signature information is calculated using steps B1-B9, as follows: B1: Check whether h'∈[1, N-1] is true; if not, the verification fails. B2: Convert the data type of S' to a point on the elliptic curve in the SM9 algorithm, and check whether S'∈G1 is true. If it is not true, the verification fails. Here, G1 is an additive cyclic group of order N, which is a prime number.

[0063] B3: Calculate the element g = e(P1, Ppub-s) in the group GT; B4: The element t=g in the computational group GT h’ ; Here, t represents the first piece of information, which can be a string.

[0064] B5: Calculate the integer h1 = H1(IDA||hid, N); Here, H1 is a hash-like algorithm, which can be the SM3 cryptographic hash algorithm. `hid` is a one-byte identifier representing the signature private key generation function, selected and published by the authorization server.

[0065] B6: Calculate the element P = [h1]P2 + Ppub-s in group G2; B7: Calculate the element u = e(S', P) in the group GT; Here, u represents the second piece of information, which can specifically be a string.

[0066] B8: Calculate the element w' = u• t in the group GT, and convert the data type of w' to a bit string; B9: Calculate the integer h2 = H2(M'||w', N), and check whether h2 = h' is true. If it is true, the verification is successful; otherwise, the verification is unsuccessful.

[0067] Here, the third sub-signature information h2 is determined based on the first information t and the second information u. The first sub-signature information h' received by the resource server is compared with the third sub-signature information h2. If they are the same, a verification result indicating successful verification is generated; otherwise, a verification result indicating failed verification is generated. Thus, the resource server provides the user with the resources they need based on the verification result indicating successful verification.

[0068] It should be noted that M' here refers to the message to be sent contained in the JWT received by the resource server. The contents of the JWT header and payload can be restored first, and then M' can be calculated using the SM3 cryptographic hash algorithm and the first calculation method. Thus, if the final verification result indicates successful verification, meaning that the messages M and M' to be sent by the user are the same, and the first calculation method can be kept secret by the resource server, with its specific content set by the developer on both the resource server and the authorization server. This further enhances the security of the identity authentication in this application and further proves the authenticity of the user's identity.

[0069] Here, the specific implementation of the SM9 digital signature algorithm in verifying the signature information extracted from the JWT and the message to be sent can be understood by referring to relevant technical explanations.

[0070] Based on the above embodiments, this application provides a schematic diagram of a JWT generation process, as shown in the application example. Figure 4 As shown, it can be understood that for the header and payload content, the first string Sh = Hsm3(Cheader, iat) and the second string SP = Hsm3(Cpayload, iat) are calculated respectively. Then, based on the first operation method, namely XOR, the first string and the second string are converted into a message Msg of the same length as the first string and the second string. The message Msg is then substituted into the SM9 message M to be signed to obtain the signature information. Further, the header, payload, and signature information are converted using the base64 algorithm, and then merged to obtain the final JWT.

[0071] This application also provides a flowchart illustrating the workflow of an identity authentication scheme, as shown in the application example. Figure 5 As shown in the diagram, the identity authentication scheme executes the following steps in sequence: 1. User A accesses client C; 2. User A submits user credentials to authorization server S1 through client C; Here, user credentials refer to the account and password used by the user to log in to the authorization server.

[0072] 3. The authorization server S1 verifies the user credentials. If the verification is successful, it generates the user private key dsA using the master private key ks and the user A's identity identifier userId, and generates a JWT using the national cryptographic SM9 algorithm. Otherwise, the verification fails and a "login failed" response is returned to the client C. 4. The authorization server S1 returns a JWT to the client; 5. Client C sends a resource request to resource server S2, carrying a JWT. 6. Resource server S2 verifies the JWT based on the master public key Ppub-s and user A's identity identifier userId; 7. If the verification passes, return the corresponding resource requested by the user to client C; otherwise, return a failure response.

[0073] In order to implement the method of the embodiments of this application, the embodiments of this application also provide an identity authentication device, which corresponds to the above-described identity authentication method. The steps in the embodiments of the above-described identity authentication method are also fully applicable to the embodiments of this device.

[0074] like Figure 6 As shown in the figure, this application provides an identity authentication device applied to an authorization server, the device comprising: The first determining module 601 is used to determine the header information of the JWT as an authentication token and the user's identity information in response to a login request from the client. The second determining module 602 is used to determine the load information of the JWT based on the identity information; The third determining module 603 is used to determine the message to be sent based on the header information and the payload information; The fourth determining module 604 is used to determine signature information based on the message to be sent and the SM9 digital signature algorithm; The first generation module 605 is used to generate the JWT based on the header information, the payload information and the signature information, and send the JWT to the client.

[0075] In some embodiments, the load information includes time information, the time information representing the time at which the JWT generation begins, and the third determining module 603 is specifically used for: A first string is determined based on the header information and the time information, and a second string is determined based on the payload information and the time information; the first string and the second string have the same length. The message to be sent is determined based on the first string and the second string.

[0076] In some embodiments, the third determining module 603 is specifically used for: Based on the SM3 cryptographic hash algorithm, the header information and the time information are converted into a first string; Based on the SM3 cryptographic hash algorithm, the payload information and the time information are converted into a second string.

[0077] In some embodiments, the fourth determining module 604 is specifically used for: The message to be signed by the SM9 digital signature algorithm is determined based on the message to be sent; The signature information is determined based on the message to be signed and the SM9 digital signature algorithm.

[0078] In some embodiments, the fourth determining module 604 is specifically used for: Generate user private key and master public key based on the SM9 digital signature algorithm; Generate a first random number, and determine a third string based on the first random number and the master public key; The first sub-signature information is determined based on the message to be signed and the third string; The second sub-signature information is determined based on the first sub-signature information, the first random number, and the user's private key; The signature information is determined based on the first sub-signature information and the second sub-signature information.

[0079] In some embodiments, the first generation module 605 is specifically used for: The fourth string is determined based on the header information and the base64 algorithm; The fifth string is determined based on the aforementioned load information and the base64 algorithm; The sixth string is determined based on the signature information and the base64 algorithm; The JWT is generated based on the fourth string, the fifth string, and the sixth string.

[0080] like Figure 7 As shown in the figure, this application provides an identity authentication device applied to a resource server, the device comprising: The acquisition module 701 is used to respond to a resource acquisition request from the client, acquire the JWT from the client, and acquire the master public key from the authorization server; The fifth determining module 702 is used to determine the user's identity information, first sub-signature information, and second sub-signature information based on the JWT; the first sub-signature information and the second sub-signature information are determined by the authorization server based on the message to be signed and the SM9 digital signature algorithm to constitute signature information; The sixth determining module 703 is used to determine the first information based on the master public key and the first sub-signature information; The seventh determining module 704 is used to determine the second information based on the master public key, the identity information and the second sub-signature information; The eighth determining module 705 is used to determine the third sub-signature information based on the first information and the second information; The second generation module 706 is used to compare whether the first sub-signature information and the third sub-signature information are the same. If they are the same, a verification result indicating successful verification is generated; if they are different, a verification result indicating failed verification is generated.

[0081] It should be noted that the identity authentication device provided in the above embodiments is only illustrated by the division of the above program modules during identity authentication. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device can be divided into different program modules to complete all or part of the processing described above. In addition, the identity authentication device provided in the above embodiments belongs to the same concept as the embodiments, and its specific implementation process can be found in the method embodiments, which will not be repeated here.

[0082] Based on the hardware implementation of the above program modules, and in order to implement the identity authentication method of this application embodiment, this application embodiment also provides an authorization server, such as... Figure 8 As shown, the authorization server 800 includes at least one processor 801, a memory 802, a user interface 803, and at least one network interface 804. The various components in the authorization server 800 are coupled together via a bus system 805. It can be understood that the bus system 805 is used to implement communication between these components. In addition to a data bus, the bus system 805 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 8 The general labeled all buses as Bus System 805.

[0083] The user interface 803 may include a monitor, keyboard, mouse, trackball, click wheel, buttons, touchpad, or touch screen.

[0084] The memory 802 in this embodiment is used to store various types of data to support the operation of the authorization server 800. Examples of such data include any computer program used to operate on the authorization server 800.

[0085] The embodiments of this application disclose methods applicable to or implemented by processor 801. Processor 801 may be an integrated circuit chip with signal processing capabilities. During implementation, each step can be completed by integrated logic circuits in the hardware of processor 801 or by instructions in software form. The aforementioned processor 801 may be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Processor 801 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. A general-purpose processor may be a microprocessor or any conventional processor, etc. The steps of the methods disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software modules may be located in a storage medium, specifically memory 802. Processor 801 reads information from memory 802 and, in conjunction with its hardware, completes the steps provided in the embodiments of this application.

[0086] In an exemplary embodiment, the authorization server 800 may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), FPGAs, general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned methods.

[0087] It is understood that memory 802 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), EEPROM, ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), Sync Link Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM). The memory 801 described in this application embodiment is intended to include, but is not limited to, these and any other suitable types of memory.

[0088] Based on the hardware implementation of the above program modules, and in order to implement the identity authentication method of this application embodiment, this application embodiment also provides a resource server, such as... Figure 9 As shown, the resource server 900 includes at least one processor 901, a memory 902, a user interface 903, and at least one network interface 904. The various components in the resource server 900 are coupled together via a bus system 905. It can be understood that the circuit structure of the resource server 900 is the same as that of the authorization server 800, and will not be described further here.

[0089] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 802 storing a computer program. This computer program can be executed by the processor 801 of the authorization server 800, or by the processor 901 of the resource server 900, to complete the steps described in the authentication method of this application embodiment. The computer-readable storage medium can be a ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM, etc.

[0090] In an exemplary embodiment, this application also provides a computer program product, including a computer program that can be executed by the processor 801 of an authorization server 800 or by the processor 901 of a resource server 900 to complete the steps described in the method of this application embodiment.

[0091] It should be noted that terms such as "first" and "second" are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. In this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0092] Furthermore, the technical solutions described in the embodiments of this application can be combined arbitrarily without conflict.

[0093] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.

Claims

1. An identity authentication method, characterized in that, Applied to authorization servers, including: In response to a login request from a client, determine the header information of the JWT used as an authentication token and the user's identity information; The payload information of the JWT is determined based on the identity information; The message to be sent is determined based on the header information and the payload information; The signature information is determined based on the message to be sent and the SM9 digital signature algorithm; The JWT is generated based on the header information, the payload information, and the signature information, and then sent to the client.

2. The method according to claim 1, characterized in that, The load information includes time information, which represents the time when the JWT generation begins.

3. The method according to claim 2, characterized in that, The step of determining the message to be sent based on the header information and the payload information includes: A first string is determined based on the header information and the time information, and a second string is determined based on the payload information and the time information; the first string and the second string have the same length. The message to be sent is determined based on the first string and the second string.

4. The method according to claim 3, characterized in that, The step of determining the first string based on the header information and the time information, and determining the second string based on the payload information and the time information, includes: Based on the SM3 cryptographic hash algorithm, the header information and the time information are converted into a first string; Based on the SM3 cryptographic hash algorithm, the payload information and the time information are converted into a second string.

5. The method according to claim 1, characterized in that, The process of determining the signature information based on the message to be sent and the SM9 digital signature algorithm includes: The message to be signed by the SM9 digital signature algorithm is determined based on the message to be sent; The signature information is determined based on the message to be signed and the SM9 digital signature algorithm.

6. The method according to claim 5, characterized in that, The step of determining the signature information based on the message to be signed and the SM9 digital signature algorithm includes: Generate user private key and master public key based on the SM9 digital signature algorithm; Generate a first random number, and determine a third string based on the first random number and the master public key; The first sub-signature information is determined based on the message to be signed and the third string; The second sub-signature information is determined based on the first sub-signature information, the first random number, and the user's private key; The signature information is determined based on the first sub-signature information and the second sub-signature information.

7. The method according to claim 1, characterized in that, The process of generating the JWT based on the header information, the payload information, and the signature information includes: The fourth string is determined based on the header information and the base64 algorithm; The fifth string is determined based on the aforementioned load information and the base64 algorithm; The sixth string is determined based on the signature information and the base64 algorithm; The JWT is generated based on the fourth string, the fifth string, and the sixth string.

8. An identity authentication method, characterized in that, Applied to resource servers, including: In response to a resource acquisition request from the client, obtain the JWT from the client and the master public key from the authorization server; Based on the JWT, the user's identity information, first sub-signature information, and second sub-signature information are determined; The first sub-signature information and the second sub-signature information are determined by the authorization server based on the message to be signed and the SM9 digital signature algorithm to form the signature information; The first information is determined based on the master public key and the first sub-signature information; The second information is determined based on the master public key, the identity information, and the second sub-signature information; The third sub-signature information is determined based on the first information and the second information; Compare the first sub-signature information with the third sub-signature information. If they are the same, generate a verification result indicating successful verification; otherwise, generate a verification result indicating failed verification.

9. An identity authentication device, characterized in that, Applied to authorization servers, including: The first determination module is used to determine the header information of the JWT, which serves as the authentication token, and the user's identity information in response to a login request from the client. The second determining module is used to determine the load information of the JWT based on the identity information; The third determining module is used to determine the message to be sent based on the header information and the payload information; The fourth determining module is used to determine signature information based on the message to be sent and the SM9 digital signature algorithm; The first generation module is used to generate the JWT based on the header information, the payload information and the signature information, and send the JWT to the client.

10. An identity authentication device, characterized in that, Applied to resource servers, including: The acquisition module is used to respond to resource acquisition requests from clients, acquire the JWT from the client, and acquire the master public key from the authorization server; The fifth determining module is used to determine the user's identity information, first sub-signature information, and second sub-signature information based on the JWT; the first sub-signature information and the second sub-signature information are determined by the authorization server based on the message to be signed and the SM9 digital signature algorithm to constitute signature information; The sixth determining module is used to determine the first information based on the master public key and the first sub-signature information; The seventh determining module is used to determine the second information based on the master public key, the identity information, and the second sub-signature information; The eighth determining module is used to determine the third sub-signature information based on the first information and the second information; The second generation module is used to compare whether the first sub-signature information and the third sub-signature information are the same. If they are the same, a verification result indicating successful verification is generated; if they are different, a verification result indicating failed verification is generated.

11. An authorization server, comprising a processor and a memory for storing computer programs capable of running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 7.

12. A resource server, comprising a processor and a memory for storing computer programs capable of running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in claim 8.

13. A computer storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.

14. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Method for performing JWT signature through national cryptographic algorithm

    CN118250007A