Gateway system dynamic authentication method and system based on SM3 algorithm, and medium

By introducing random numbers and timestamps into the gateway system, combined with the SM3 algorithm and caching mechanism, the deficiencies of the existing authentication solutions in preventing replay attacks and timeliness verification are solved, and an efficient and secure authentication system is achieved. , suitable for a variety of application scenarios.

CN118631467APending Publication Date: 2024-09-10FUJIAN E-GOVERNMENT CONSTR & OPERATION CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410697139.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-31
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

Existing gateway system authentication solutions have deficiencies in preventing replay attacks and request timeliness verification, and international common algorithms may face regional regulatory restrictions and cannot effectively guarantee security and adaptability.

Method used

Adopting a dynamic authentication method based on the SM3 algorithm, by introducing random numbers and millisecond-level timestamps into each request, combined with the caching mechanism and the national secret algorithm, signatures are generated and verified to ensure the uniqueness and timeliness of the request, and Use application keys as core elements to participate in signature calculations.

Benefits of technology

It effectively resists replay attacks, guarantees the timeliness of requests, ensures that only legitimate applications can generate correct signatures, meets the security standards of the National Cryptozoology Administration, and improves the authentication efficiency of the gateway system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118631467A
    Figure CN118631467A
Patent Text Reader

Abstract

The invention discloses a gateway system dynamic authentication method and system based on an SM3 algorithm, and a medium, and relates to the technical field of gateway authentication. According to the method disclosed by the invention, the replay attack is effectively resisted through the use of the random number and the verification mechanism of the cache; a millisecond-level timestamp is combined with a preset effective time window, so that the timeliness of the request is guaranteed, and the expired request is prevented from being illegally utilized; the secret key of the application serves as a core element to participate in signature calculation, and it is ensured that only legal application can generate a correct signature; and the SM3 algorithm is adopted to perform signature calculation, so that the security standard of the State Cryptographic Administration is met, efficient calculation performance is achieved, and the authentication efficiency of the gateway system is greatly improved. According to the gateway system dynamic authentication method and system based on the SM3 algorithm and the medium provided by the invention, the advantages of the dynamic parameters and the national cryptographic algorithm are fused, a high-efficiency and safe authentication system is constructed, and the method and the system are suitable for various application scenes and have good adaptability and expandability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of gateway authentication, and in particular to a gateway system dynamic authentication method, system and medium based on SM3 algorithm. Background Art

[0002] With the rapid development of Internet technology, the security of gateway systems, as key components connecting multiple applications, has received increasing attention.

[0003] Most existing authentication schemes rely on simple mechanisms such as static key verification and basic IP whitelist checks. These methods have obvious deficiencies in preventing replay attacks and request timeliness verification: 1. The client can forge an IP to bypass the server's whitelist restrictions; 2. When the attacker intercepts the request information initiated by the client, it will be replayed directly, and the server cannot determine whether it is a real and valid request; 3. Failure to set the request validity will lead to a large amount of request information leakage, and the attacker can use the current request information to launch unlimited attacks on the server; 4. In the selection of encryption algorithms, the use of international general algorithms may face regional regulatory restrictions. Summary of the invention

[0004] The technical problem to be solved by the present invention is to provide a gateway system dynamic authentication method, system and medium based on the SM3 algorithm, integrating the advantages of dynamic parameters and national secret algorithms, and constructing an authentication system that is both efficient and secure, suitable for a variety of application scenarios, and has good adaptability and scalability.

[0005] In a first aspect, the present invention provides a gateway system dynamic authentication method based on the SM3 algorithm, comprising: Application access process: When each application that accesses the gateway system applies for access, it obtains the corresponding key, which is only stored by the gateway system and the application; Signature request process: Generate two key parameters, a random number and a millisecond timestamp, during the application request process. Then use the key and the two key parameters together to generate the first signature using the SM3 algorithm. Then, the signature is combined with the two key parameters to form a signature, and the request carrying the signature is sent to the gateway system. Request authentication process: the gateway system parses the request to obtain the first signature and two key parameters; determines whether the request is expired based on the millisecond timestamp and whether the random number already exists in the cache; if the millisecond timestamp has not expired and the random number does not exist in the cache, the random number is saved in the cache and the saved key corresponding to the application is used together with the two key parameters to generate the second signature using the SM3 algorithm; compares the second signature with the first signature to see if they are consistent. If they are consistent, the gateway system authentication is passed and the corresponding request is released. The request will be forwarded to the specified downstream service.

[0006] In a second aspect, the present invention provides a gateway system dynamic authentication system based on the SM3 algorithm, comprising: The application access module is used to obtain the corresponding key when each application accessing the gateway system applies for access. The key is only stored by the gateway system and the application; The signature request module is used to generate two key parameters, a random number and a millisecond timestamp, during the application request process, and then use the key and the two key parameters together to generate the first signature using the SM3 algorithm, and then use the two key parameters together to form a signature, and send the request carrying the signature to the gateway system; The request authentication module is used to parse the request in the gateway system to obtain the first signature and two key parameters; determine whether the request is expired according to the millisecond timestamp, and determine whether the random number already exists in the cache; if the millisecond timestamp has not expired and the random number does not exist in the cache, the random number is saved in the cache and the saved key corresponding to the application is used together with the two key parameters to generate the second signature using the SM3 algorithm; compare the second signature with the first signature to see if they are consistent. If they are consistent, the gateway system authentication is passed and the corresponding request is released. The request will be forwarded to the specified downstream service.

[0007] In a third aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect.

[0008] The technical solution provided in the embodiments of the present invention has at least the following technical effects: The use of random numbers and cache verification mechanisms can effectively resist replay attacks; millisecond timestamps are used to ensure the timeliness of requests and prevent expired requests from being illegally used; the application's key is used as a core element in the signature calculation to ensure that only legitimate applications can generate correct signatures; the SM3 algorithm is used for signature calculation, which not only meets the security standards of the National Cryptography Administration, but also has efficient computing performance, greatly improving the authentication efficiency of the gateway system.

[0009] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0010] The present invention will be further described below in conjunction with embodiments with reference to the accompanying drawings.

[0011] Figure 1 is an overall flow chart of the method in Embodiment 1 of the present invention; Figure 2 is a flowchart of the execution of the method in Embodiment 1 of the present invention; Figure 3 It is a structural diagram of the system in the second embodiment of the present invention; Figure 4 Schematic diagram of the structure of the medium in the third embodiment of the present invention. DETAILED DESCRIPTION

[0012] The embodiment of the present invention provides a gateway system dynamic authentication method, system and medium based on the SM3 algorithm, integrates the advantages of dynamic parameters and national secret algorithms, and constructs an authentication system that is both efficient and secure. The system is suitable for a variety of application scenarios and has good adaptability and scalability.

[0013] The technical solution in the embodiment of the present invention has the following general idea: Integrate the advantages of dynamic parameters and national secret algorithms to build an authentication system that is both efficient and secure.

[0014] 1. Dynamic parameter generation and verification: Two key parameters, random number (nonce) and millisecond timestamp (timestamp), are introduced in the request process. Nonce is the unique identifier of each request and is stored in the cache for anti-replay control. Timestamp is used to indicate the time when the request was generated. The gateway system will perform a timeliness check on it and only allow requests within the set time range to pass. Therefore, the introduction of two key parameters, random number and millisecond timestamp, combined with real-time verification in the cache can ensure the uniqueness and timeliness of the request.

[0015] 2. Key (appSecret) management: Each application that accesses the gateway system will obtain a unique key (appSecret) during the access application stage. The key is only held by the gateway system and the corresponding application, and is strictly confidential and not disclosed to the public. AppSecret participates in the signature calculation as a core element, ensuring that only legitimate applications can generate correct signatures.

[0016] 3. Application of SM3 signature algorithm: Use the national secret SM3 hash algorithm to concatenate and encrypt key authentication information (nonce, timestamp, and appSecret) to generate a signature to achieve information integrity verification and non-repudiation. The request side and the gateway side independently perform the same operation, and the authentication process is completed by comparing the consistency of the signature results calculated by both parties. Embodiment 1

[0017] This embodiment provides a gateway system dynamic authentication method based on the SM3 algorithm. Figure 1 and Figure 2 As shown, including; Application access process: When each application that accesses the gateway system applies for access, it obtains the corresponding key (appSecret). The key is only saved by the gateway system and the application. Signature request process: Generate two key parameters, a random number (nonce) and a millisecond timestamp (timestamp), during the application request process. Then use the key and the two key parameters together to generate the first signature (SM3 (appSecret+nonce+timestamp)) using the SM3 algorithm. Then, the signature is combined with the two key parameters to form a signature, and the request carrying the signature is sent to the gateway system. Request authentication process: The gateway system parses the request to obtain the first signature and two key parameters; determines whether the request is expired based on the millisecond timestamp and whether the random number already exists in the cache; if the millisecond timestamp is expired, it returns "expired request"; if the random number already exists in the cache, it returns "duplicate request"; if the millisecond timestamp has not expired and the random number does not exist in the cache, the random number is saved in the cache and the saved key corresponding to the application is used together with the two key parameters to generate the second signature (SM3 (appSecret+nonce+timestamp)) using the SM3 algorithm; compares the second signature with the first signature to see if they are consistent. If they are consistent, the gateway system authenticates and releases the corresponding request, and the request will be forwarded to the specified downstream service. If they are inconsistent, "illegal request" is returned.

[0018] Preferably, the gateway system determines whether it is expired based on the millisecond timestamp, specifically including: performing timeliness check based on the millisecond timestamp and the current time, and the request within the preset valid time window is a non-expired request, and the request beyond the preset valid time window is an expired request. The millisecond timestamp combined with the preset valid time window ensures the timeliness of the request and prevents the expired request from being illegally used.

[0019] Preferably, determining whether the random number already exists in the cache specifically includes: The random number is matched with the random number list in the cache. If no match is obtained, the random number does not exist in the cache. If a match is obtained, the random number already exists in the cache.

[0020] The cache is a local cache and / or any one of a Redis cache, a Memcached cache, an Ehcache cache, and a MongoDB cache. For example, when the gateway system includes only one server, a local cache can be used to store and compare the random number list. When the gateway system includes more than one server, a separately deployed cache service or a cloud cache (such as a Redis cache, a Memcached cache, an Ehcache cache, or a MongoDB cache) can be used. A local cache + a separately deployed cache service or a cloud cache can also be used. First, obtain from the local cache. If it cannot be obtained, then obtain from a separately deployed cache service or a cloud cache. The nonce storage strategy and the effective time range of the timestamp can be flexibly adjusted according to actual business needs. It is suitable for a variety of application scenarios and has good adaptability and scalability.

[0021] Based on the same inventive concept, the present application also provides a system corresponding to the method in Example 1, see Example 2 for details. Embodiment 2

[0022] In this embodiment, a gateway system dynamic authentication system based on the SM3 algorithm is provided. Figure 3 As shown, including: The application access module is used to obtain the corresponding key when each application accessing the gateway system applies for access. The key is only stored by the gateway system and the application; The signature request module is used to generate two key parameters, a random number and a millisecond timestamp, during the application request process, and then use the key and the two key parameters together to generate the first signature using the SM3 algorithm, and then use the two key parameters together to form a signature, and send the request carrying the signature to the gateway system; The request authentication module is used to parse the request in the gateway system to obtain the first signature and two key parameters; determine whether the request is expired according to the millisecond timestamp, and determine whether the random number already exists in the cache; if the millisecond timestamp has not expired and the random number does not exist in the cache, the random number is saved in the cache and the saved key corresponding to the application is used together with the two key parameters to generate the second signature using the SM3 algorithm; compare the second signature with the first signature to see if they are consistent. If they are consistent, the gateway system authentication is passed and the corresponding request is released. The request will be forwarded to the specified downstream service.

[0023] Preferably, in the request authentication module, the gateway system determines whether it is expired based on the millisecond timestamp, specifically including: performing a timeliness check based on the millisecond timestamp and the current time, a request within a preset valid time window is a non-expired request, and a request beyond the preset valid time window is an expired request.

[0024] Preferably, in the request authentication module, determining whether the random number already exists in the cache specifically includes: The random number is matched with the random number list in the cache. If no match is obtained, the random number does not exist in the cache. If a match is obtained, the random number already exists in the cache.

[0025] Preferably, the cache is a local cache and / or any one of a Redis cache, a Memcached cache, an Ehcache cache and a MongoDB cache.

[0026] Since the system introduced in the second embodiment of the present invention is a system used to implement the method of the first embodiment of the present invention, those skilled in the art can understand the specific structure and deformation of the system based on the method introduced in the first embodiment of the present invention, so it is not described here in detail. All systems used in the method of the first embodiment of the present invention belong to the scope of protection of the present invention.

[0027] Based on the same inventive concept, the present application provides a storage medium corresponding to Example 1, see Example 3 for details. Embodiment 3

[0028] This embodiment provides a computer-readable storage medium, such as Figure 4 As shown, a computer program is stored thereon, and when the computer program is executed by a processor, any implementation method in Example 1 can be implemented.

[0029] Since the computer-readable storage medium introduced in this embodiment is a computer-readable storage medium used to implement the method in the first embodiment of the present application, based on the method introduced in the first embodiment of the present application, a person skilled in the art can understand the specific implementation of the computer-readable storage medium of the present embodiment and its various variations, so how the computer-readable storage medium implements the method in the embodiment of the present application is not described in detail here. As long as a person skilled in the art implements the computer-readable storage medium used in the method in the embodiment of the present application, it belongs to the scope of protection of the present application.

[0030] The present invention effectively resists replay attacks through the use of random numbers and a cache verification mechanism; uses a millisecond timestamp combined with a preset effective time window to ensure the timeliness of requests and prevent expired requests from being illegally used; uses the application's key as a core element in signature calculation to ensure that only legitimate applications can generate correct signatures; uses the SM3 algorithm for signature calculation, which not only meets the security standards of the National Cryptography Administration, but also has efficient computing performance, greatly improving the authentication efficiency of the gateway system.

[0031] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0032] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0033] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0034] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0035] Although the specific implementation modes of the present invention are described above, those skilled in the art should understand that the specific implementation modes described are only illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included in the scope of protection of the claims of the present invention.

Claims

1. A gateway system dynamic authentication method based on SM3 algorithm, characterized in that: include: Application access process: When each application that accesses the gateway system applies for access, it obtains the corresponding key, which is only stored by the gateway system and the application; Signature request process: Generate two key parameters, a random number and a millisecond timestamp, during the application request process. Then use the key and the two key parameters together to generate the first signature using the SM3 algorithm. Then, the signature is combined with the two key parameters to form a signature, and the request carrying the signature is sent to the gateway system. Request authentication process: The gateway system parses the request and obtains the first signature and two key parameters; Determine whether the request has expired based on the millisecond timestamp and whether the random number already exists in the cache; If the millisecond timestamp has not expired and the random number does not exist in the cache, the random number is stored in the cache and a second signature is generated using the stored key corresponding to the application and the two key parameters using the SM3 algorithm; The second signature is compared with the first signature to see if they are consistent. If they are consistent, the gateway system authentication is passed and the corresponding request is released. The request will be forwarded to the specified downstream service.

2. The method according to claim 1, characterized in that: The gateway system determines whether it is expired based on the millisecond timestamp, specifically including: performing timeliness check based on the millisecond timestamp and the current time. Requests within the preset valid time window are non-expired requests, and requests beyond the preset valid time window are expired requests.

3. The method according to claim 1, characterized in that: Determine whether the random number already exists in the cache, including: The random number is matched with the random number list in the cache. If no match is obtained, the random number does not exist in the cache. If a match is obtained, the random number already exists in the cache.

4. The method according to claim 1 or 3, characterized in that: The cache is any one of a local cache and / or a Redis cache, a Memcached cache, an Ehcache cache, and a MongoDB cache.

5. A gateway system dynamic authentication system based on SM3 algorithm, characterized in that: include: The application access module is used to obtain the corresponding key when each application accessing the gateway system applies for access. The key is only stored by the gateway system and the application; The signature request module is used to generate two key parameters, a random number and a millisecond timestamp, during the application request process, and then use the key and the two key parameters together to generate the first signature using the SM3 algorithm, and then use the two key parameters together to form a signature, and send the request carrying the signature to the gateway system; The request authentication module is used to parse the request in the gateway system and obtain the first signature and two key parameters; Determine whether the request has expired based on the millisecond timestamp and whether the random number already exists in the cache; If the millisecond timestamp has not expired and the random number does not exist in the cache, the random number is stored in the cache and a second signature is generated using the stored key corresponding to the application and the two key parameters using the SM3 algorithm; The second signature is compared with the first signature to see if they are consistent. If they are consistent, the gateway system authentication is passed and the corresponding request is released. The request will be forwarded to the specified downstream service.

6. The system according to claim 5, characterized in that: In the request authentication module, the gateway system determines whether it is expired based on the millisecond timestamp, specifically including: performing a timeliness check based on the millisecond timestamp and the current time, and requests within the preset valid time window are non-expired requests, and requests beyond the preset valid time window are expired requests.

7. The system according to claim 5, characterized in that: In the request authentication module, determining whether the random number already exists in the cache specifically includes: The random number is matched with the random number list in the cache. If no match is obtained, the random number does not exist in the cache. If a match is obtained, the random number already exists in the cache.

8. The system according to claim 5 or 7, characterized in that: The cache is any one of a local cache and / or a Redis cache, a Memcached cache, an Ehcache cache, and a MongoDB cache.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 4 is implemented.

Citation Information

Cited By

  • Dynamic encryption transmission method for interface data based on symmetric and asymmetric modes

    CN119341838A