API gateway and client encryption and decryption interaction method

The API gateway generates an exclusive key for the client and supports dynamic updates, which solves the problems of low encryption and decryption interaction efficiency and security risks between the API gateway and the client in the existing technology, and achieves efficient key management and security protection.

CN118748613AActive Publication Date: 2024-10-08SHENZHEN LANYOU TECHNOLOGY CO LTD

Patent Information

Application Number
CN202410900890.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-10-08
Estimated Expiration
2044-07-05

AI Technical Summary

Technical Problem

In the existing technology, there are problems of low efficiency and security risks when the API gateway interacts with client encryption and decryption, especially when there are a large number of back-end application services, and dynamic updating of client keys cannot be achieved.

Method used

Generate unique keys for each client through the API gateway, including front-end encryption and decryption keys and gateway encryption and decryption keys, and support dynamic updates of keys. Encryption and decryption interactions are performed between the client and the API gateway, and the API gateway determines Whether the key is expired or disabled, if expired, update the key.

Benefits of technology

It improves the efficiency of development and debugging, realizes the exclusive use and dynamic update of client keys, provides a higher level of security protection, and avoids security risks caused by key leaks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118748613A_ABST
    Figure CN118748613A_ABST
Patent Text Reader

Abstract

The invention discloses an encryption and decryption interaction method for an API gateway and a client, and belongs to the technical field of API gateways. In the scheme, an API gateway distributes a secret key and an APPID for a client according to a UID of the client, the client encrypts message content by using an encryption secret key and then sends the encrypted message content to the API gateway, if the secret key of the client is expired or forbidden, the API gateway prompts the client to send a secret key updating request, and after receiving the secret key updating request, the API gateway generates a new secret key and an APPID for the client; and if the key of the client is still valid, the API gateway decrypts the message of the client, sends the decrypted message to the back-end application service, encrypts a response message returned by the back-end application service, and sends the encrypted response message back to the client. According to the scheme of the invention, encryption and decryption interaction is carried out through the API gateway and the client, so that the development and debugging efficiency is improved, exclusive use and dynamic update of the client key are realized, and higher-level security protection is provided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of API gateways, and in particular to an encryption and decryption interaction method between an API gateway and a client. Background Art

[0002] The microservice system includes multiple backend application services and an API (Application Programming Interface) gateway. The backend application service is responsible for processing the client's business requests, and the API gateway is responsible for forwarding data between the client and each backend application service. For message security considerations, the message interaction between the client and the backend application service often needs to be encrypted.

[0003] In the prior art, encryption and decryption are usually performed directly between the client and the backend application service. The client and the backend application service negotiate the encryption and decryption solution, develop them independently, and then conduct joint debugging between the client and the backend application service. For systems with a large number of backend application services, since all backend application services need to develop encryption and decryption functions and conduct joint debugging with the client respectively, the overall progress of the project cannot be guaranteed. When the encryption algorithm needs to be changed, the key needs to be modified, or the key is leaked, all backend application services also need to be modified, which is inefficient and easily introduces security risks.

[0004] There are also solutions in the prior art that use API gateways to interact with clients for encryption and decryption, so that backend application services no longer participate in encryption and decryption operations, which improves development efficiency. However, in these solutions, clients usually share keys, and it is impossible to dynamically update client keys, which still poses a great security risk. Summary of the invention

[0005] The technical problem to be solved by the present invention is: in view of the above-mentioned defects of the prior art, a method for encryption and decryption interaction between an API gateway and a client is provided, a unique key is generated for each client, and dynamic update of the key is supported.

[0006] To achieve the above object, the present invention provides an API gateway and client encryption and decryption interaction method, the method comprising the following steps:

[0007] Step S1, after the client logs in for the first time, it sends a message to the API gateway with UID and APPID_INIT; the UID is the client user ID, and the APPID_INIT is the value of the unified initial APPID set after the client is installed;

[0008] Step S2, the API gateway assigns keys to the client according to the UID, the keys include the front-end encryption key, the front-end decryption key, the gateway encryption key, and the gateway decryption key, and generates a unique APPID corresponding to the key, and then returns the APPID, the front-end encryption key, and the front-end decryption key to the client;

[0009] Step S3, the client stores the APPID, front-end encryption key, and front-end decryption key sent by the API gateway locally, encrypts the message content using the front-end encryption key, and then sends the encrypted message to the API gateway with the UID and APPID;

[0010] Step S4, the API gateway determines whether the key corresponding to the APPID is expired or disabled. If it is expired or disabled, jump to step S8, otherwise the API gateway uses the gateway decryption key corresponding to the APPID to decrypt the message content sent by the client, and then sends the decrypted message content to the backend application service with the UID and APPID;

[0011] Step S5, the backend application service receives and processes the message sent by the API gateway, and sends a plaintext response message to the API gateway, wherein the response message carries the UID and APPID in the message received by the backend application service;

[0012] Step S6: The API gateway encrypts the message content sent by the backend application service based on the UID and APPID in the response message using the gateway encryption key corresponding to the APPID, and then sends the encrypted message content to the client with the UID and APPID.

[0013] Step S7, the client uses the locally stored front-end decryption key to decrypt the received encrypted response message to obtain the plain text content of the response message of the back-end application service. If it needs to continue to communicate with the back-end application service, jump to step S3, otherwise end this communication process;

[0014] In step S8, the API gateway sends a key expiration message to the client, and the client sends a key update request to the API gateway, which carries the UID and APPID; the API gateway determines whether the key update request sent by the client is legal. If it is legal, it regenerates a new key for the client according to the method of step S2, and encrypts the new key with the gateway encryption key corresponding to the APPID sent by the client and sends it to the client; then jumps to step S3.

[0015] Preferably, in step S2, before returning the APPID, the front-end encryption key, and the front-end decryption key to the client, the step further includes:

[0016] The API gateway stores UID, APPID, front-end encryption key, front-end decryption key, gateway encryption key, gateway decryption key, key status, and key validity period as a piece of key information; wherein the key status is set to "enabled" and the key validity period is set to the key expiration time.

[0017] Preferably, before step S4, the step further includes:

[0018] The API gateway determines whether the UID sent by the client matches the APPID. If they do not match, a key error prompt message is returned to the client, and the message sent by the client is not forwarded to the backend application service. If they match, the corresponding key information is found according to the APPID.

[0019] Preferably, the API gateway and client encryption and decryption interaction method also includes support for different key types, and the specific method is as follows:

[0020] Set key type rules in API Gateway;

[0021] The API gateway parses the key type rule, assigns a key to the client based on the key type rule, associates the key type with the key and stores it locally, and sends the key type to the client;

[0022] Both the client and API gateway have built-in encryption and decryption algorithms corresponding to different key types. Select the corresponding encryption and decryption algorithm based on the key type.

[0023] Preferably, the client is in a non-logged-in state and carries APPID_INIT to interact with the backend application service. The API gateway does not distribute keys and transparently transmits messages between the client and the backend application service.

[0024] Preferably, the API gateway provides a key management function through a visual configuration interface, and the key management function includes disabling a key and modifying a key expiration time.

[0025] Preferably, in step S8, the method in which the API gateway sends a key expiration message to the client is: the API gateway sends an abnormal error code indicating that the key has expired to the client.

[0026] Preferably, in step S8, the method by which the API gateway sends a key expiration message to the client is: the API gateway uses the gateway encryption key corresponding to the APPID sent by the client to encrypt the message indicating the key expiration and then sends it to the client, and the client uses the locally stored front-end decryption key to decrypt the message sent by the API gateway.

[0027] Preferably, after the client and API gateway encrypt the message content, they perform hash calculation on the ciphertext and send the ciphertext and the hash calculation result together to the message recipient; after receiving the message, the message recipient first performs hash calculation on the message content, and compares the hash calculation result with the hash calculation result sent by the message sender. If the two are inconsistent, a message indicating a hash calculation error is returned to the message sender.

[0028] Preferably, carrying UID and APPID_INIT, carrying UID and APPID refers to carrying through the header of an HTTP message.

[0029] The present invention has the following beneficial effects: In the scheme of the present invention, the API gateway allocates a key and an APPID corresponding to the key to the client according to the UID of the client. The client uses the encryption key in the key to encrypt the message content and then sends it to the API gateway. The API gateway determines whether the client's key is expired or disabled. If it is expired or disabled, the client is prompted to send a key update request. After receiving the key update request, the API gateway generates a new key and APPID for the client; if the client key is still valid, the API gateway decrypts the client's message and sends it to the backend application service, and when receiving the response message from the backend application service, it encrypts the response message and sends it back to the client. The scheme of the present invention improves the development and debugging efficiency by performing encryption and decryption interaction with the client through the API gateway, realizes exclusive use and dynamic update of the client key, and provides a higher level of security protection. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0031] Figure 1 A schematic diagram of the steps of the API gateway and client encryption and decryption interaction method provided in an embodiment of the present invention.

[0032] Figure 2 A schematic diagram of a multi-client processing scenario provided by an embodiment of the present invention.

[0033] Figure 3 A schematic diagram of the interaction process between the client, API gateway, and backend application services provided in an embodiment of the present invention.

[0034] Figure 4 A schematic diagram of the key information structure of the API gateway side provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0035] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0036] The embodiments of the present invention are further described in detail below in conjunction with the accompanying drawings of the specification. It should be understood that the embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.

[0037] In the microservice architecture, the API gateway serves as the entry point for the interaction between the front-end and back-end application services, and is responsible for the security logic processing of the front-end and back-end interactions. The present invention provides a solution in which the front-end encrypts and the gateway decrypts when the front-end and back-end application services interact; when the back-end returns data, the gateway encrypts and the front-end decrypts. This does not affect the business logic of the back-end service, does not require the back-end service to connect to the encryption and decryption service, and ensures the decoupling of the overall architecture.

[0038] like Figure 1 As shown, an embodiment of the present invention provides an API gateway and client encryption and decryption interaction method, the method comprising the following steps:

[0039] Step S1, after the client logs in for the first time, it sends a message to the API gateway with UID and APPID_INIT; the UID is the client user identifier, and the APPID_INIT is the unified initial APPID value set after the client is installed.

[0040] In the embodiment of the present invention, UID is the client user ID, which can be assigned by the backend application service when the client performs user registration, or a system ID or other value that can identify the client can be used; APPID_INIT is a unified initial APPID value set after the client is installed, which is shared by all clients. After the client logs in for the first time, when sending a message to the API gateway with UID and APPID_INIT, a preset fixed encryption key and encryption algorithm can be used, and the API gateway uses the corresponding decryption key and decryption algorithm to decrypt the message.

[0041] In some embodiments of the present invention, carrying UID and APPID_INIT means carrying them through the header of an HTTP message, for example, by extending the uid and appid fields in the HTTP Header and filling in the values ​​of UID and APPID_INIT respectively. In addition, the values ​​of UID and APPID_INIT can be passed to the API gateway by customizing the HTTP body data structure and extending the uid and appid fields. The present invention does not impose any special restrictions on the specific method.

[0042] In some embodiments of the present invention, the client is in a non-logged-in state and carries APPID_INIT to interact with the backend application service. The API gateway does not distribute keys and transparently transmits messages between the client and the backend application service.

[0043] In step S2, the API gateway assigns keys to the client according to the UID, wherein the keys include the front-end encryption key, the front-end decryption key, the gateway encryption key, and the gateway decryption key, and generates a unique APPID corresponding to the keys, and then returns the APPID, the front-end encryption key, and the front-end decryption key to the client.

[0044] When the client sends a message to the API gateway, the message content is encrypted using the front-end encryption key. The API gateway receives the message from the client, decrypts the message using the gateway decryption key, and sends the plaintext message content to the back-end application service. The back-end application service processes the message and returns a plaintext response message to the API gateway. The API gateway encrypts the plaintext response message using the gateway encryption key and sends the encrypted response message to the client. The client decrypts the encrypted response message using the front-end decryption key to obtain a plaintext response message. For asymmetric encryption algorithms, the front-end encryption key is the public key and the gateway decryption key is the corresponding private key; the gateway encryption key is the public key and the front-end decryption key is the corresponding private key, and the four keys are different. For symmetric encryption algorithms, the front-end encryption key is the same as the gateway decryption key, the gateway encryption key is the same as the front-end decryption key, and the front-end encryption key is different from the gateway encryption key.

[0045] like Figure 2 As shown, in an embodiment of the present invention, the API gateway allocates keys to the client according to the UID, so that each client has its own key, and each client is isolated from each other, thereby improving security. In some embodiments of the present invention, the API gateway uses the SM2 algorithm to generate a new key for the client according to the UID. The SM2 algorithm generates keys in combination with the current time, ensuring a low repetition rate of the key.

[0046] In the embodiment of the present invention, APPID is used as an identification code of the key, and the APPID can be generated according to the key content. The present invention does not impose any special limitation on the specific method for generating the APPID.

[0047] In the embodiment of the present invention, in order to facilitate the management of the client's key, the API gateway further includes:

[0048] The API gateway stores UID, APPID, front-end encryption key, front-end decryption key, gateway encryption key, gateway decryption key, key status, and key validity period as a piece of key information; wherein the key status is set to "enabled" and the key validity period is set to the key expiration time.

[0049] In the embodiment of the present invention, the key status has three values: "Enable", "Update", and "Disable". For a newly generated key, the key status is set to "Enable"; after the API gateway detects that the key has expired, it changes the key status to "Update". After the API gateway sends a new key, the key status of the old key is set to "Disable".

[0050] In the embodiment of the present invention, the key validity period is set to 90 days. After the API gateway allocates a new key to the client, the current time is pushed back 90 days as the expiration time and filled in the key validity period field. After receiving the request from the client, the current time is compared with the time in the key validity period field. If the current time is after the time in the key validity period field, it is determined that the client key has expired.

[0051] In some embodiments of the present invention, the API gateway provides a key management function through a visual configuration interface, and the key management function includes disabling keys and modifying key expiration time. For example, if a client's key is found to be leaked, the client's valid key is found through the visual configuration interface, and its key status is changed to "disabled". When the API gateway receives a message from the client and finds that its key status is "disabled", it prompts the client to send a key update request.

[0052] In step S3, the client stores the APPID, front-end encryption key, and front-end decryption key sent by the API gateway locally, encrypts the message content using the front-end encryption key, and then sends the encrypted message to the API gateway carrying the UID and APPID.

[0053] In some embodiments of the present invention, carrying UID and APPID refers to carrying through the header of the HTTP message, for example, extending the uid and appid fields in the HTTP Header, and filling in the values ​​of UID and APPID respectively. In addition, the values ​​of UID and APPID can be passed to the API gateway by customizing the HTTP body data structure and extending the uid and appid fields. The present invention does not impose special restrictions on the specific method. Because the client, API gateway, and back-end application services all need to pass the values ​​of UID and APPID, for convenience, a unified method can be agreed upon, such as passing through specific fields in the HTTP Header.

[0054] If the client obtains the key for the first time through step S1, the API gateway may not forward the client's message to the backend application service after returning the key to the client. After the client receives the key, it may encrypt the message with the key and resend the previous message.

[0055] In step S4, the API gateway determines whether the key corresponding to the APPID is expired or disabled. If it is expired or disabled, jump to step S8. Otherwise, the API gateway uses the gateway decryption key corresponding to the APPID to decrypt the message content sent by the client, and then sends the decrypted message content to the backend application service with the UID and APPID.

[0056] In some embodiments of the present invention, before step S4, the step further includes:

[0057] The API gateway determines whether the UID sent by the client matches the APPID. If they do not match, a key error prompt message is returned to the client, and the message sent by the client is not forwarded to the backend application service. If they match, the corresponding key information is found according to the APPID.

[0058] If a client steals the APPID and key information of another client and sends it to the API gateway along with its own UID, the API gateway can identify this situation by determining whether the UID sent by the client matches the APPID, and return a key error prompt to the client. For security reasons, it will not forward the message to the backend.

[0059] Step S5, the backend application service receives and processes the message sent by the API gateway, and sends a plaintext response message to the API gateway. The response message carries the UID and APPID in the message received by the backend application service.

[0060] The backend application service receives plain text messages and does not need to encrypt or decrypt them.

[0061] Step S6: The API gateway encrypts the message content sent by the backend application service based on the UID and APPID in the response message using the gateway encryption key corresponding to the APPID, and then sends the encrypted message content to the client with the UID and APPID.

[0062] Step S7, the client uses the locally stored front-end decryption key to decrypt the received encrypted response message to obtain the plaintext content of the response message of the back-end application service. If it needs to continue communicating with the back-end application service, jump to step S3, otherwise end the communication process.

[0063] After the client receives the response message sent by the API gateway, it can compare the UID and APPID in the message with the locally stored APPID. If they do not match, the client reports the exception to the API gateway.

[0064] In step S8, the API gateway sends a key expiration message to the client, and the client sends a key update request to the API gateway, which carries the UID and APPID; the API gateway determines whether the key update request sent by the client is legal. If it is legal, it regenerates a new key for the client according to the method of step S2, and encrypts the new key with the gateway encryption key corresponding to the APPID sent by the client and sends it to the client; then jumps to step S3.

[0065] In the embodiment of the present invention, after the API gateway detects that the key has expired, it changes the stored key status to "update", and after the key is successfully updated, it changes the key status of the old key to "disable".

[0066] In some embodiments of the present invention, in step S8, the method in which the API gateway sends a key expiration message to the client is: the API gateway sends an abnormal error code indicating key expiration to the client. After the client recognizes the abnormal error code indicating key expiration, it sends a key update request to the API gateway.

[0067] In some other embodiments of the present invention, in step S8, the method in which the API gateway sends a key expiration message to the client is: the API gateway uses the gateway encryption key corresponding to the APPID sent by the client to encrypt the message indicating the key expiration and sends it to the client, and the client uses the locally stored front-end decryption key to decrypt the message sent by the API gateway. After the client obtains the key expiration message from the decrypted data, it sends a key update request to the API gateway.

[0068] In some embodiments of the present invention, the API gateway and client encryption and decryption interaction method also includes support for different key types, and the specific method is as follows:

[0069] Set the key type rule in the API gateway; the key type can be an asymmetric key, a symmetric key, or a specific encryption and decryption algorithm. You can set the application of asymmetric keys, symmetric keys, or a specific encryption and decryption algorithm to all clients in the visual configuration interface of the API gateway, or you can apply different key types to different clients according to certain rules. Preferably, asymmetric keys are applied to all clients.

[0070] The API gateway parses the key type rule, assigns a key to the client based on the key type rule, associates the key type with the key and stores it locally, and sends the key type to the client;

[0071] Both the client and API gateway have built-in encryption and decryption algorithms corresponding to different key types. Select the corresponding encryption and decryption algorithm based on the key type.

[0072] In some embodiments of the present invention, a set of asymmetric encryption algorithms and a set of symmetric encryption algorithms are built into the client and the API gateway. For example, SM2 is selected as the asymmetric encryption algorithm and SM4 is selected as the symmetric encryption algorithm. If the API gateway is set to apply asymmetric keys to all clients, the API gateway generates an asymmetric key and sets the key type to "asymmetric". Both the client and the API gateway use the SM2 algorithm for encryption and decryption; if the API gateway is set to apply symmetric keys to all clients, the API gateway generates a symmetric key and sets the key type to "symmetric". Both the client and the API gateway use the SM4 algorithm for encryption and decryption.

[0073] In some embodiments of the present invention, in order to further improve the security of communication, the client and API gateway perform hash calculation on the ciphertext after encrypting the message content, and send the ciphertext and the hash calculation result together to the message recipient; after receiving the message, the message recipient first performs hash calculation on the message content, and compares the hash calculation result with the hash calculation result sent by the message sender. If the two are inconsistent, a message indicating a hash calculation error is returned to the message sender.

[0074] Figure 3 The flowchart of encryption and decryption message interaction is to use asymmetric keys and perform hash calculation on the encryption results.

[0075] Figure 4 Schematic diagram of the key information structure stored for the API Gateway, with the key type field expanded.

[0076] The present invention has the following beneficial effects: In the scheme of the present invention, the API gateway allocates a key and an APPID corresponding to the key to the client according to the UID of the client. The client uses the encryption key in the key to encrypt the message content and then sends it to the API gateway. The API gateway determines whether the client's key is expired or disabled. If it is expired or disabled, the client is prompted to send a key update request. After receiving the key update request, the API gateway generates a new key and APPID for the client; if the client key is still valid, the API gateway decrypts the client's message and sends it to the back-end application service, and when receiving the response message from the back-end application service, it encrypts the response message and sends it back to the client. The scheme of the present invention performs encryption and decryption interaction with the client through the API gateway. Because the API gateway is centrally set, the API gateway only needs to perform joint debugging with the client. Compared with the encryption and decryption method between the back-end application service and the client, the efficiency and security are significantly improved. The scheme of the present invention realizes exclusive use and dynamic update of client keys, providing a higher level of security protection.

[0077] In addition, the graphical setting interface provided by the API gateway enables direct management of client keys, which is more convenient and quick.

[0078] The above are only specific implementations of the present invention, which cannot be used to limit the scope of the present invention. Equivalent changes made by ordinary technicians in this technical field based on this creation, as well as changes known to technicians in this field, should still fall within the scope of the present invention.

Claims

1. A method for encryption and decryption interaction between an API gateway and a client, characterized in that: The method comprises the following steps: Step S1, after the client logs in for the first time, it sends a message to the API gateway with UID and APPID_INIT; the UID is the client user ID, and the APPID_INIT is the value of the unified initial APPID set after the client is installed; Step S2, the API gateway assigns keys to the client according to the UID, the keys include the front-end encryption key, the front-end decryption key, the gateway encryption key, and the gateway decryption key, and generates a unique APPID corresponding to the key, and then returns the APPID, the front-end encryption key, and the front-end decryption key to the client; Step S3, the client stores the APPID, front-end encryption key, and front-end decryption key sent by the API gateway locally, encrypts the message content using the front-end encryption key, and then sends the encrypted message to the API gateway with the UID and APPID; Step S4, the API gateway determines whether the key corresponding to the APPID is expired or disabled. If it is expired or disabled, jump to step S8, otherwise the API gateway uses the gateway decryption key corresponding to the APPID to decrypt the message content sent by the client, and then sends the decrypted message content to the backend application service with the UID and APPID; Step S5, the backend application service receives and processes the message sent by the API gateway, and sends a plaintext response message to the API gateway, wherein the response message carries the UID and APPID in the message received by the backend application service; Step S6: The API gateway encrypts the message content sent by the backend application service based on the UID and APPID in the response message using the gateway encryption key corresponding to the APPID, and then sends the encrypted message content to the client with the UID and APPID. Step S7, the client uses the locally stored front-end decryption key to decrypt the received encrypted response message to obtain the plain text content of the response message of the back-end application service. If it needs to continue to communicate with the back-end application service, jump to step S3, otherwise end this communication process; In step S8, the API gateway sends a key expiration message to the client, and the client sends a key update request to the API gateway, which carries the UID and APPID; the API gateway determines whether the key update request sent by the client is legal. If it is legal, it regenerates a new key for the client according to the method of step S2, and encrypts the new key with the gateway encryption key corresponding to the APPID sent by the client and sends it to the client; then jumps to step S3.

2. According to the API gateway and client encryption and decryption interaction method of claim 1, it is characterized in that: In the step S2, before returning the APPID, the front-end encryption key, and the front-end decryption key to the client, the step further includes: The API gateway stores UID, APPID, front-end encryption key, front-end decryption key, gateway encryption key, gateway decryption key, key status, and key validity period as a piece of key information; wherein the key status is set to "enabled" and the key validity period is set to the key expiration time.

3. The API gateway and client encryption and decryption interaction method according to claim 2 is characterized in that: Before step S4, the following steps are also included: The API gateway determines whether the UID sent by the client matches the APPID. If they do not match, a key error prompt message is returned to the client, and the message sent by the client is not forwarded to the backend application service. If they match, the corresponding key information is found according to the APPID.

4. The API gateway and client encryption and decryption interaction method according to claim 1 is characterized in that: The API gateway and client encryption and decryption interaction method also includes support for different key types, the specific method is as follows: Set key type rules in API Gateway; The API gateway parses the key type rule, assigns a key to the client based on the key type rule, associates the key type with the key and stores it locally, and sends the key type to the client; Both the client and API gateway have built-in encryption and decryption algorithms corresponding to different key types. Select the corresponding encryption and decryption algorithm based on the key type.

5. The API gateway and client encryption and decryption interaction method according to claim 1 is characterized in that: When the client is not logged in, it carries APPID_INIT to interact with the backend application service. The API gateway does not distribute keys and transparently transmits messages between the client and the backend application service.

6. The API gateway and client encryption and decryption interaction method according to claim 1 is characterized in that: The API gateway provides a key management function through a visual configuration interface, and the key management function includes disabling a key and modifying a key expiration time.

7. The API gateway and client encryption and decryption interaction method according to claim 1 is characterized in that: In step S8, the method in which the API gateway sends a key expiration message to the client is: the API gateway sends an abnormal error code indicating key expiration to the client.

8. The API gateway and client encryption and decryption interaction method according to claim 1 is characterized in that: In step S8, the method in which the API gateway sends a key expiration message to the client is as follows: the API gateway uses the gateway encryption key corresponding to the APPID sent by the client to encrypt the message indicating the key expiration and sends it to the client, and the client uses the locally stored front-end decryption key to decrypt the message sent by the API gateway.

9. The API gateway and client encryption and decryption interaction method according to claim 1 is characterized in that: After the client and API gateway encrypt the message content, they perform hash calculation on the ciphertext and send the ciphertext and the hash calculation result together to the message recipient; after receiving the message, the message recipient first performs hash calculation on the message content, and compares the hash calculation result with the hash calculation result sent by the message sender. If the two are inconsistent, a message indicating a hash calculation error is returned to the message sender.

10. The API gateway and client encryption and decryption interaction method according to claim 1 is characterized in that: The carrying of UID and APPID_INIT and carrying of UID and APPID refers to carrying through the header of the HTTP message.

Citation Information

Patent Citations

  • Group key server based key management method in sharing encryption file system

    CN101159556A

  • Encryption and decryption method, terminal device, gateway device and key management system

    CN103067158A

  • Cloud host login method, device and equipment and computer readable storage medium

    CN112272089A

  • Information processing method and system, front end, server side and storage medium

    CN113922974A

  • Method, equipment and system for realizing communication between VPN (Virtual Private Network) gateway and client

    CN114070672A

Cited By

  • Dynamic encryption and decryption and data processing system and method based on unified security gateway

    CN122372340A