A data transmission method, system, apparatus, and storage medium
By employing a replay protection mechanism that combines one-time token verification and timestamp verification in web applications, along with cryptographic algorithms and WebAssembly technology, the problem that HTTP/HTTPS protocols cannot protect against attacks on terminal and server request data is solved, thereby improving the security of data transmission and system security.
Patent Information
- Application Number
- CN202211703670.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-29
- Publication Date
- 2026-11-10
- Estimated Expiration
- 2042-12-29
AI Technical Summary
In existing web applications, the HTTP/HTTPS protocol cannot effectively protect against attackers from illegally requesting the same data between the terminal and the server, thus threatening the security of data transmission.
A one-time token verification mechanism is adopted, which combines a replay prevention token queue and timestamp verification with cryptographic algorithms and WebAssembly technology to achieve interface replay prevention and data encryption, thereby improving data transmission security.
It effectively mitigates the problem of attackers illegally requesting data again, improves the security of data transmission and the security performance of the system, and reduces the cost of system security protection.
Smart Images

Figure CN116094781B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data transmission method, system, apparatus, and storage medium. Background Technology
[0002] With the development of web application development technologies, cyberattacks targeting web applications are increasing daily, making web security a growing concern in the industry. While most web applications use the HTTP / HTTPS protocol, this protocol itself cannot provide effective protection against attacks and penetration. Specifically, data requested between a terminal and a server may be illegally re-requested by attackers, threatening the security of data transmission. Summary of the Invention
[0003] The purpose of this application is to at least partially solve one of the technical problems existing in the prior art.
[0004] Therefore, the purpose of this invention is to provide a safe and reliable data transmission method, system, device, and storage medium.
[0005] To achieve the above-mentioned technical objectives, the technical solutions adopted in the embodiments of this application include:
[0006] On one hand, embodiments of this application provide a data transmission method, including the following steps:
[0007] The data transmission method of this application embodiment includes: responding to a first request from a first terminal, determining whether a first token in the first request is valid; the first token is determined based on a first anti-replay token queue; the first anti-replay token queue corresponds to the first terminal; if the first token is valid, sending first response data to the first terminal and deleting the first token; the first response data includes a second token newly allocated to the first terminal; and updating the first anti-replay token queue according to the second token. This application embodiment implements one-time token verification through the first anti-replay token queue, thereby achieving interface replay protection, mitigating the problem of attackers illegally requesting previously initiated request data again, and improving data transmission security.
[0008] In addition, the data transmission method according to the above embodiments of this application may also have the following additional technical features:
[0009] Furthermore, the data transmission method of this application embodiment further includes:
[0010] If the timestamp of the first token is not within the preset timestamp validity period, clear the first anti-replay token queue.
[0011] If the first anti-replay token queue is empty, in response to the first terminal's request to obtain the anti-replay token queue, the second response data is sent to the first terminal; the second response data includes the third token allocated to the first terminal.
[0012] Furthermore, in one embodiment of this application, the method further includes:
[0013] Based on the preset identifier in the first request, query whether the first token exists in the second anti-replay token queue; the second anti-replay token queue corresponds to the first server, and the first server is the responding end of the first request;
[0014] If the first token exists in the second anti-replay token queue, return to the step of determining whether the first token in the first request is valid;
[0015] If the first token is not present in the second anti-replay token queue, an authentication failure message will be sent to the first terminal.
[0016] Furthermore, in one embodiment of this application, the method further includes the following steps:
[0017] A data transmission architecture is constructed, which includes a terminal scripting language unit, a terminal interceptor unit, and a terminal network unit.
[0018] The terminal scripting language unit is used to send first plaintext data, which represents a session request sent by the first terminal to the first server.
[0019] The terminal interceptor unit is used to intercept terminal requests and responses;
[0020] The terminal network unit is used to encrypt data sent by the terminal and decrypt data responded by the terminal.
[0021] Furthermore, in one embodiment of this application, the method includes:
[0022] The terminal network unit randomly generates a first key and a first initial vector according to a symmetric encryption algorithm;
[0023] According to the asymmetric encryption algorithm, the first key and the first initial vector are encrypted using the public key to obtain the second key and the second initial vector;
[0024] The first plaintext data is encrypted using a symmetric encryption algorithm to obtain the first ciphertext data.
[0025] The terminal network unit sends the second key, the second initialization vector, and the first ciphertext data to the terminal interceptor unit;
[0026] The terminal interceptor unit adds the second key, the second initialization vector, and the first ciphertext data to the first request and sends it to the first server.
[0027] Furthermore, in one embodiment of this application, the method further includes:
[0028] The terminal network unit randomly generates a first key and a first initialization vector based on the SM4 encryption algorithm and WebAssembly technology.
[0029] According to the SM2 encryption algorithm, the first key and the first initial vector are encrypted using the public key to obtain the second key and the second initial vector.
[0030] Furthermore, in one embodiment of this application, the method further includes:
[0031] The terminal interceptor unit determines whether the anti-replay switch is turned on;
[0032] If the anti-replay switch is turned on, obtain the first anti-replay token queue.
[0033] On the other hand, embodiments of this application propose a data transmission system, including:
[0034] The first module is used to respond to a first request from the first terminal and determine whether the first token in the first request is valid; the first token is determined based on a first anti-replay token queue; the first anti-replay token queue corresponds to the first terminal;
[0035] The second module is configured to send first response data to the first terminal and delete the first token if the first token is valid; the first response data includes a second token newly allocated to the first terminal.
[0036] The third module is used to update the first anti-replay token queue based on the second token.
[0037] On the other hand, embodiments of this application provide a data transmission apparatus, including:
[0038] At least one processor;
[0039] At least one memory for storing at least one program;
[0040] When the at least one program is executed by the at least one processor, the at least one processor implements any of the above-described data transmission methods.
[0041] On the other hand, embodiments of this application provide a storage medium storing a processor-executable program, which, when executed by a processor, is used to implement any of the above-described data transmission methods.
[0042] The embodiments of this application can alleviate the problem of attackers illegally requesting data that has already been initiated, thereby improving the security of data transmission. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the following description is provided with accompanying drawings of the relevant technical solutions in the embodiments of this application or the prior art. It should be understood that the accompanying drawings described below are only for the purpose of clearly illustrating some embodiments of the technical solutions in this application. For those skilled in the art, other drawings can be obtained based on these drawings without any creative effort.
[0044] Figure 1 A flowchart illustrating one embodiment of the data transmission method provided in this application;
[0045] Figure 2 A flowchart illustrating an embodiment of data transmission when the first anti-replay token queue provided in this application is empty;
[0046] Figure 3 A flowchart illustrating an embodiment of data transmission when the first anti-replay token queue provided in this application is not empty;
[0047] Figure 4 A schematic diagram of one embodiment of the data transmission architecture provided in this application;
[0048] Figure 5 A flowchart illustrating one embodiment of the terminal interceptor unit processing logic provided in this application;
[0049] Figure 6 A schematic diagram of the structure of one embodiment of the data transmission system provided in this application;
[0050] Figure 7 This is a schematic diagram of one embodiment of the data transmission device provided in this application. Detailed Implementation
[0051] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain this application, and should not be construed as limiting this application. The step numbers in the following embodiments are set only for ease of explanation, and there is no limitation on the order between the steps. The execution order of each step in the embodiments can be adaptively adjusted according to the understanding of those skilled in the art.
[0052] With the development of web application development technologies, network attacks targeting web applications are increasing daily, making web security a growing concern. Most web applications use the HTTP / HTTPS protocol, but the HTTP / HTTPS protocol itself cannot provide effective protection against attacks and penetration. Therefore, this application designs a data transmission method based on WebAssembly, which effectively protects against malicious user attacks and penetration, greatly ensuring server-side security.
[0053] Understandably, server-side web applications constitute a major component of an enterprise's internet exposure surface and are a primary target for attackers seeking to breach the isolation between the enterprise's internal and external networks. Therefore, multiple security measures are urgently needed to ensure the security of server-side web applications. This application addresses web transmission security, effectively guaranteeing the security of server-side web applications and ensuring data transmission is protected against leakage, tampering, and replay attacks. For penetration attackers, this significantly increases the cost of attacks and the difficulty of vulnerability discovery. For enterprise security administrators, it can greatly reduce system security protection costs and system upgrade and maintenance costs.
[0054] The data transmission method and system proposed according to the embodiments of this application will now be described in detail with reference to the accompanying drawings. First, the data transmission method proposed according to the embodiments of this application will be described with reference to the accompanying drawings.
[0055] Reference Figure 1This application provides a data transmission method, which can be applied to a terminal, a server, or software running on a terminal or server. The terminal can be a tablet, laptop, desktop computer, etc., but is not limited to these. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms. The data transmission method in this application mainly includes the following steps:
[0056] S100: In response to the first request from the first terminal, determine whether the first token in the first request is valid; the first token is determined based on the first anti-replay token queue; the first anti-replay token queue corresponds to the first terminal;
[0057] In some possible implementations, the data communication between the client (terminal) and the server incorporates an interface replay protection mechanism to prevent attackers from illegally requesting data that has already been initiated. Specifically, the server uses one-time token verification to implement interface replay protection. The server responds to the first request from the first terminal, checks the validity of the first token, and mitigates the problem of unauthorized attacks. It is understood that... (See also...) Figure 2 As shown, the first request may include data such as the request URL, request parameters, the first token, and the current timestamp. After receiving the first request, the server performs anti-replay token verification. For example, the server also associates a token queue, which can be stored in Redis. Verifying the validity of the first token using the server-side token queue in Redis helps improve the system's security performance.
[0058] S200: If the first token is valid, send the first response data to the first terminal and delete the first token; the first response data includes a second token newly assigned to the first terminal;
[0059] In some possible implementations, if the first token is valid, the anti-replay token verification succeeds. The server deletes the first token, adds a new token (the second token), sends it to the first terminal, and updates the validity period of the first anti-replay token queue. It is understood that the terminal also verifies the token's validity using a timestamp during communication with the server. See [link to details]. Figure 3 In one embodiment shown, the validity period of the token queue can be set to 10 minutes in the new token, and the validity of the token can be determined based on the timestamp. Of course, those skilled in the art can set appropriate timestamps according to actual needs, and there are no restrictions on the application.
[0060] S300: Update the first anti-replay token queue based on the second token.
[0061] In some possible implementations, the newly allocated second token is placed into the first anti-replay token queue, while the first token in the queue is deleted. Therefore, the server uses one-time token verification and timestamp difference verification to implement interface anti-replay. To ensure that anti-replay detection does not affect the efficiency of normal business requests, both the client and server establish one-time token pools (queues). Furthermore, because the server requires timestamp verification, time correction processing is required between the client and server. Specifically, the server establishes a one-time token queue (i.e., the first anti-replay token queue) for all client request sessions and assigns the one-time token queues to the corresponding client sessions. Each time a client initiates a request, it obtains a one-time token from the one-time token queue along with its current timestamp. Upon receiving the request, the server verifies the validity of the one-time token and the validity period of the requested timestamp. If the verification passes, the current one-time token becomes invalid and is deleted, and a new token is allocated to the client in the response header (ensuring a sufficient number of tokens in the client / server one-time token queues).
[0062] In some possible implementations, embodiments of this application also employ cryptographic integrity verification mechanisms or other integrity verification mechanisms with corresponding security strength to ensure the integrity and security of transmitted data, preventing attackers from illegally tampering with the transmitted data under unauthorized circumstances. The client uses WebAssembly technology to implement a hash algorithm or message authentication code algorithm as the signature algorithm, signing the client request URL, the current timestamp of the request, the symmetric encryption algorithm key, the one-time token, and the plaintext request data. The server uses the same mechanism to verify the signature, thereby determining whether the transmitted data has been illegally tampered with during transmission.
[0063] In some possible implementations, the cryptographic algorithm is implemented according to the corresponding cryptographic algorithm specification, using C language to complete the algorithm implementation and interface encapsulation. The server-side programming language is Java, which calls the compiled binary file of the C-language cryptographic algorithm via Java Native Interface (JNI) technology. The client-side programming language is JavaScript, which uses Axios to intercept all request and response, and uses WebAssembly technology to encapsulate the C-language cryptographic algorithm interface, ultimately compiling it into a .wasm file for JavaScript to call, enabling client-side data encryption / decryption and data signing. The use of WebAssembly technology increases the difficulty for attackers and improves the system's security performance.
[0064] Optionally, in one embodiment of this application, the method further includes:
[0065] If the timestamp of the first token is not within the preset timestamp validity period, clear the first anti-replay token queue.
[0066] If the first anti-replay token queue is empty, in response to the first terminal's request to obtain the anti-replay token queue, the second response data is sent to the first terminal; the second response data includes the third token allocated to the first terminal.
[0067] In this step, see Figure 2 In one embodiment, a timestamp is set when the token is established. If the first terminal needs to transmit data, it checks whether the timestamp of the first token is valid. If it has expired, there is no usable token in the first anti-replay token queue. Specifically, if the first anti-replay token queue is empty, the first terminal sends a request to obtain the anti-replay token queue (i.e., obtain the anti-replay token queue by specifying a URL). After receiving this instruction, the server generates an anti-replay queue in the corresponding Redis, generates a third token, sends the third token to the first terminal, and stores the third token in Redis. Through the above process, the anti-replay process is completed when the anti-replay token queue is empty, improving the system's security performance.
[0068] Optionally, in one embodiment of this application, the method further includes:
[0069] Based on the preset identifier in the first request, query whether the first token exists in the second anti-replay token queue; the second anti-replay token queue corresponds to the first server, which is the responding end of the first request;
[0070] If the first token exists in the second anti-replay token queue, return to the step of determining whether the first token in the first request is valid;
[0071] If the first token is not present in the second anti-replay token queue, an authentication failure message will be sent to the first terminal.
[0072] In this step, see Figure 3As shown, a preset identifier is used to implement the data transmission process of the anti-replay token queue. The preset identifier determines the validity of the first token. For example, the preset identifier can be a SessionId. The one-time token queue is uniformly generated, allocated, and destroyed by the server based on the SessionId identifier, and the client synchronizes the one-time token queue in real time. The server-side one-time token queue is stored in a Redis cache, with the SessionId used as the key for differentiation, ensuring that each request session uses an independent one-time token queue. If the client does not request within a predetermined time, the one-time token queue stored in Redis will be destroyed periodically. The client-side one-time token queue is stored in the browser's LocalStorage and synchronized with the server in real time. Token authentication is implemented through the preset identifier. If authentication fails, an authentication failure message is sent to the first terminal. Secure data transmission between the server and the terminal is achieved through the preset identifier.
[0073] Optionally, in one embodiment of this application, the method further includes the following steps:
[0074] Construct a data transmission architecture, which includes a terminal scripting language unit, a terminal interceptor unit, and a terminal network unit;
[0075] The terminal scripting language unit is used to transmit first plaintext data, which represents a session request sent by the first terminal to the first server.
[0076] The terminal interceptor unit is used to intercept terminal requests and responses;
[0077] The terminal network unit is used to encrypt data sent by the terminal and decrypt data responded to by the terminal.
[0078] In this step, see Figure 4The architecture shown includes a terminal scripting language unit (i.e., a client-side JavaScript framework), a terminal interceptor unit (i.e., a client-side Axios interceptor), and a terminal network unit (i.e., a client-side WebAssembly). This embodiment utilizes WebAssembly technology to convert data and algorithms, improving system security. Specifically, the terminal scripting language unit is written in JavaScript, and related data is intercepted by the terminal interceptor unit and sent to the terminal network unit for data conversion. WebAssembly technology is then used to complete the data conversion, and the converted data is transmitted to the server unit via the terminal. It is understood that JavaScript is an interpreted language and lacks source code protection features, making it easier to reverse engineer compared to compiled languages. This embodiment employs WebAssembly technology for calling cryptographic algorithms. The cryptographic algorithm implemented in C language is compiled into a wasm file using the Emscripten tool, which is a binary file. Compared to encryption algorithms implemented in native JavaScript, this has better source code protection, significantly increasing the difficulty of cracking the algorithm. Attackers need to reverse engineer the wasm file to have a chance to crack the algorithm itself. Using WebAssembly technology on the client side will significantly increase the cost of attacks. Furthermore, this application's embodiments implement the cryptographic algorithm in C and ultimately compile it into a binary file. Whether on the client or server side, the encryption and decryption execution efficiency will be far higher than the execution efficiency of encryption and decryption algorithms natively implemented in Java on the server and JavaScript on the client.
[0079] Optionally, in one embodiment of this application, the method further includes:
[0080] The terminal network unit randomly generates a first key and a first initialization vector according to a symmetric encryption algorithm;
[0081] According to the asymmetric encryption algorithm, the first key and the first initial vector are encrypted using the public key to obtain the second key and the second initial vector;
[0082] The first plaintext data is encrypted using a symmetric encryption algorithm to obtain the first ciphertext data.
[0083] The terminal network unit sends the second key, the second initialization vector, and the first ciphertext data to the terminal interceptor unit;
[0084] The terminal interceptor unit adds the second key, the second initialization vector, and the first ciphertext data to the first request and sends it to the first server.
[0085] In this step, see Figure 3 In one embodiment, the terminal network unit randomly generates a first key and a first initialization vector according to a symmetric encryption algorithm. The public and private keys of the asymmetric encryption algorithm are stored in the terminal network unit. According to the asymmetric encryption algorithm, the first key and the first initialization vector are encrypted using the public key to obtain a second key and a second initialization vector; simultaneously, the plaintext data is encrypted and sent to the terminal interceptor unit. The terminal interceptor unit packages the data and sends it to a first server. Upon receiving the data, the first server decrypts it using the same encryption algorithm. Specifically, according to the asymmetric encryption algorithm, the first key and the first initialization vector are decrypted using the private key; simultaneously, the first ciphertext data is decrypted using a symmetric encryption algorithm. The decrypted data is processed to obtain corresponding data. The response data is then encrypted using the same encryption method and sent to the first terminal. A cryptographic integrity verification mechanism or other integrity verification mechanisms with appropriate security strength are employed to ensure the integrity and security of the transmitted data, preventing unauthorized tampering of the transmitted data by attackers. Meanwhile, in some possible implementations, the client uses WebAssembly technology to implement a hash algorithm or message authentication code algorithm as the signature algorithm to sign the client request URL, the current timestamp of the request, the symmetric encryption algorithm key, the one-time token, and the plaintext request data. The server uses the same mechanism to verify the signature, thereby determining whether the transmitted data has been illegally tampered with during transmission.
[0086] Optionally, in one embodiment of this application, the method further includes:
[0087] The terminal network unit randomly generates a first key and a first initialization vector based on the SM4 encryption algorithm and WebAssembly technology;
[0088] According to the SM2 encryption algorithm, the first key and the first initial vector are encrypted using the public key to obtain the second key and the second initial vector.
[0089] In this step, the client uses WebAssembly technology to encrypt the data transmitted in the request body and URL using a symmetric encryption algorithm. To ensure the security of the symmetric encryption key and initialization vector (iv), the symmetric encryption key and initialization vector are randomly generated on the client side each time a request is initiated, and then encrypted using an asymmetric encryption algorithm with the public key. Finally, the ciphertext data encrypted with the symmetric encryption algorithm, as well as the key and initialization vector encrypted with the asymmetric encryption algorithm, are all sent to the server for decryption. Simultaneously, the server's response data is returned to the client in the same way, and the client decrypts it using WebAssembly technology to obtain the plaintext response data. It is understandable that through the above process, comprehensive dynamic encryption is achieved. The symmetric encryption algorithm loses its encryption security when the key is leaked. However, in this embodiment, by adopting a comprehensive dynamic encryption system, the encryption key and initialization vector that affect the encryption result are generated using random numbers, and all encryption keys and initialization vectors are used only once. This ensures that the encryption algorithm key and initialization vector used in each client request and server response are different, and the ciphertext itself has no fixed format.
[0090] Optionally, in one embodiment of this application, the method further includes:
[0091] The terminal interceptor unit determines whether the anti-replay switch is turned on;
[0092] If the anti-replay switch is enabled, obtain the first anti-replay token queue.
[0093] In this step, see Figure 5 As shown in one embodiment, this application can implement a protection switch and interface whitelist mechanism through flexible configuration, which helps to reduce the impact of encryption and anti-replay protection on normal business operations. The protection switch and interface whitelist are divided into a general protection switch / whitelist, an anti-replay protection switch / whitelist, a request encryption switch / whitelist, and a response encryption switch / whitelist. Developers can flexibly configure them according to the system's business interfaces to minimize the impact of transmission security protection on system business operations.
[0094] In summary, the above methods alleviate the problem of attackers illegally requesting data that has already been initiated, thereby improving the security of data transmission.
[0095] Secondly, refer to the appendix Figure 6 This application describes a data transmission system proposed according to an embodiment.
[0096] Figure 6 This is a schematic diagram of a data transmission system structure according to an embodiment of this application. The system specifically includes:
[0097] The first module 610 is used to respond to a first request from the first terminal and determine whether the first token in the first request is valid; the first token is determined based on a first anti-replay token queue; the first anti-replay token queue corresponds to the first terminal;
[0098] The second module 620 is used to send first response data to the first terminal and delete the first token if the first token is valid; the first response data includes a second token newly allocated to the first terminal;
[0099] The third module 630 is used to update the first anti-replay token queue based on the second token.
[0100] It is evident that the content of the above method embodiments is applicable to this system embodiment. The specific functions implemented in this system embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0101] Reference Figure 7 This application provides a data transmission device, including:
[0102] At least one processor 710;
[0103] At least one memory 720 is used to store at least one program;
[0104] When at least one program is executed by at least one processor 710, the at least one processor 710 implements a data transfer method.
[0105] Similarly, the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented by this device embodiment are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0106] This application also provides a computer-readable storage medium storing a program executable by a processor 710, which, when executed by the processor 710, is used to perform the data transmission method described above.
[0107] Similarly, the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.
[0108] In some alternative embodiments, the functions / operations mentioned in the block diagrams may not occur in the order shown in the operation diagrams. For example, depending on the functions / operations involved, two consecutively shown blocks may actually be executed substantially simultaneously, or the blocks may sometimes be executed in reverse order. Furthermore, the embodiments presented and described in the flowcharts of this application are provided by way of example to provide a more comprehensive understanding of the technology. The disclosed methods are not limited to the operations and logic flows presented herein. Alternative embodiments are contemplated in which the order of various operations is changed and sub-operations described as part of a larger operation are executed independently.
[0109] Furthermore, although this application is described in the context of functional modules, it should be understood that, unless otherwise stated to the contrary, one or more of the functions and / or features may be integrated into a single physical device and / or software module, or one or more functions and / or features may be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding this application. Rather, given the properties, functions, and internal relationships of the various functional modules in the apparatus disclosed herein, the actual implementation of the module will be understood within the scope of conventional technology for an engineer. Therefore, those skilled in the art can implement the application set forth in the claims using ordinary techniques without excessive experimentation. It is also understood that the specific concepts disclosed are merely illustrative and not intended to limit the scope of this application, which is determined by the full scope of the appended claims and their equivalents.
[0110] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several programs to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0111] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequential list of executable programs for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, a program execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can retrieve and execute a program from or in conjunction with such a program execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can mean any means that can contain, store, communicate, propagate, or transmit a program for use by or in conjunction with a program execution system, apparatus, or device.
[0112] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0113] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable program execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0114] In the foregoing description of this specification, the references to terms such as "one embodiment," "another embodiment," or "some embodiments," etc., indicate that a specific feature, structure, material, or characteristic described in connection with an embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0115] Although embodiments of this application have been shown and described, those skilled in the art will understand that various changes, modifications, substitutions and variations can be made to these embodiments without departing from the principles and spirit of this application, the scope of which is defined by the claims and their equivalents.
[0116] The above is a detailed description of the preferred embodiments of this application, but this application is not limited to the embodiments described. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of this application, and these equivalent modifications or substitutions are all included within the scope defined by the claims of this application.
Claims
1. A data transmission method, characterized in that, Applied to a server, the method includes the following steps: In response to a first request from the first terminal, it is determined whether the first token in the first request is valid; the first token is determined based on a first anti-replay token queue; the first anti-replay token queue corresponds to the first terminal. If the first token is valid, first response data is sent to the first terminal, and the first token is deleted; the first response data includes a second token newly allocated to the first terminal; Based on the second token, update the validity period of the first anti-replay token queue; wherein, the tokens in the first anti-replay token queue share the same validity period; In response to the first terminal's request to obtain the anti-replay token queue, the server sends second response data to the first terminal. The second response data includes a third token allocated to the first terminal. When the first terminal needs to transmit data, it determines whether the timestamp of the first token is within the preset timestamp validity period. If the timestamp of the first token is not within the preset timestamp validity period, the server clears the first anti-replay token queue, and the first terminal sends the request to obtain the anti-replay token queue.
2. The data transmission method according to claim 1, characterized in that, The method further includes: Based on the preset identifier in the first request, query whether the first token exists in the second anti-replay token queue; the second anti-replay token queue corresponds to the first server, and the first server is the responding end of the first request; If the first token exists in the second anti-replay token queue, return to the step of determining whether the first token in the first request is valid; If the first token is not present in the second anti-replay token queue, an authentication failure message will be sent to the first terminal.
3. The data transmission method according to claim 1, characterized in that, The method further includes the following steps: A data transmission architecture is constructed, which includes a terminal scripting language unit, a terminal interceptor unit, and a terminal network unit. The terminal scripting language unit is used to send first plaintext data, which represents a session request sent by the first terminal to the first server. The terminal interceptor unit is used to intercept terminal requests and responses; The terminal network unit is used to encrypt data sent by the terminal and decrypt data responded to by the terminal.
4. The data transmission method according to claim 3, characterized in that, The method further includes: The terminal network unit randomly generates a first key and a first initial vector according to a symmetric encryption algorithm; According to the asymmetric encryption algorithm, the first key and the first initial vector are encrypted using the public key to obtain the second key and the second initial vector; The first plaintext data is encrypted using a symmetric encryption algorithm to obtain the first ciphertext data. The terminal network unit sends the second key, the second initialization vector, and the first ciphertext data to the terminal interceptor unit; The terminal interceptor unit adds the second key, the second initialization vector, and the first ciphertext data to the first request and sends it to the first server.
5. The data transmission method according to claim 4, characterized in that, The method further includes: The terminal network unit randomly generates a first key and a first initialization vector based on the SM4 encryption algorithm and WebAssembly technology. According to the SM2 encryption algorithm, the first key and the first initial vector are encrypted using the public key to obtain the second key and the second initial vector.
6. The data transmission method according to claim 3, characterized in that, The method further includes: The terminal interceptor unit determines whether the anti-replay switch is turned on; If the anti-replay switch is turned on, obtain the first anti-replay token queue.
7. A data transmission system, characterized in that, The system, applied to a server, includes: The first module is used to respond to a first request from the first terminal and determine whether the first token in the first request is valid; the first token is determined based on a first anti-replay token queue; the first anti-replay token queue corresponds to the first terminal; The second module is configured to send first response data to the first terminal and delete the first token if the first token is valid; the first response data includes a second token newly allocated to the first terminal. The third module is used to update the validity period of the first anti-replay token queue based on the second token; wherein the tokens in the first anti-replay token queue share the validity period; The data transmission system is also used for: In response to the first terminal's request to obtain the anti-replay token queue, the server sends second response data to the first terminal. The second response data includes a third token allocated to the first terminal. When the first terminal needs to transmit data, it determines whether the timestamp of the first token is within the preset timestamp validity period. If the timestamp of the first token is not within the preset timestamp validity period, the server clears the first anti-replay token queue, and the first terminal sends the request to obtain the anti-replay token queue.
8. A data transmission device, characterized in that, include: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the data transmission method as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing a processor-executable program, characterized in that: The processor-executable program, when executed by the processor, is used to implement the data transmission method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Network communication safety protection method and device
CN105450587A
Http request parameter encryption scheme based on national cryptographic algorithm
CN114401102A
Client application assisted automatic user log in
US20140223527A1
