Network communication method based on encryption mechanism
By combining AES and RSA encryption mechanisms, the problem of slow computing speed of existing encryption mechanisms during data encryption is solved, fast and secure network communication is achieved, and user experience is improved.
Patent Information
- Application Number
- CN202410989171.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-23
- Publication Date
- 2024-11-26
AI Technical Summary
The existing encryption mechanisms are slow to compute when encrypting data, resulting in low network communication efficiency, poor user experience, and easy to crack static keys, and insufficient security.
The data is encrypted using AES symmetric keys and the AES key is encrypted with RSA public keys to ensure the security and performance of transmitted data, thereby improving network communication efficiency.
It realizes fast computing and high-security data transmission, avoiding the problem of slow network communication speed and improving user experience.
Smart Images

Figure CN119030690A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network communication, and in particular to a network communication method based on encryption mechanism. Background Art
[0002] With the increasing breadth and depth of network applications, the scope of information and resource sharing will continue to expand, the application environment will become increasingly complex, and data security issues will become increasingly important. Encrypted data transmission is an important means of traffic security. When encrypting and transmitting source data, there are generally two encryption and decryption methods, namely symmetric encryption and asymmetric encryption. Symmetric encryption uses the encryption method of a single-key cryptographic system, and the same key can be used for data encryption and decryption at the same time; asymmetric encryption algorithms require a pair of keys: a public key and a private key. If the public key is used to encrypt the data, it can only be decrypted with the corresponding private key. If the private key is used to encrypt the data, it can only be decrypted with the corresponding public key.
[0003] However, static keys and encryption algorithms are single and fixed for a long time, and may be cracked by brute force, which reduces the security of data transmission. In addition, both the sending device and the receiving device need to determine the encryption and decryption keys in advance, the interaction process is cumbersome, and the data encryption transmission efficiency is low.
[0004] For example, a network communication method and system based on data encryption disclosed in Chinese patent CN113824728B establishes a key database and an encryption and decryption algorithm database on the server side. The data sending end can select one or more keys and encryption algorithms from the server side to encrypt the source data according to its own needs. On this basis, the ciphertext is re-encrypted by the respective identifiers of the selected keys and encryption algorithms. In the process of secondary encryption, the randomness of the keys and encryption algorithms selected for different data blocks is used to increase the complexity of the secondary encryption, thereby improving the security of data transmission. The public data interaction between the data sending end and the data receiving end is completed through the server side. The data sending end and the data receiving end can realize data encryption transmission only through a single interaction, which greatly simplifies the interaction process between the data sending end and the data receiving end and improves the efficiency of data encryption transmission.
[0005] However, the encryption mechanism has a slow operation speed when encrypting data, which will lead to slow network communication and bring a bad experience to users.
[0006] To this end, we urgently need to provide a network communication method based on encryption mechanism. Summary of the invention
[0007] To achieve the above objectives, the present invention is implemented through the following technical solutions: a network communication method based on encryption mechanism, comprising the following steps:
[0008] S1: The client and server support TCP / IP protocol;
[0009] S2: The client generates an AES key and saves the AES key;
[0010] S3: The client encrypts the AES key using the RSA public key and then puts the value into a custom request;
[0011] S4: The client initiates a request to the server;
[0012] S5: The server obtains the custom request header value, and then decrypts it using the RSA private key to obtain the AES key;
[0013] S6: The server uses the AES key to decrypt the request data;
[0014] S7: The server encrypts the response data using the AES key;
[0015] S8: The server sends a response to the client;
[0016] S9: The client obtains the encrypted data from the server and decrypts it using the previously saved AES key.
[0017] Preferably, the TCP / IP in S1 includes a link layer, a network layer, a transport layer and an application layer.
[0018] Preferably, the link layer includes a device driver in the operating system and a network interface card corresponding to the computer, and is responsible for processing the physical interface with the cable.
[0019] Preferably, the network layer is responsible for the activities of packets in the network.
[0020] Preferably, the transport layer provides end-to-end data communication between the client and the server.
[0021] Preferably, the transport layer includes TCP and UDP protocols, the TCP protocol provides end-to-end quality-assured data transmission, and the UDP protocol sends data from one end to another.
[0022] Preferably, the application layer is responsible for handling actual application program details.
[0023] Preferably, the TCP protocol connection-oriented comprises the following steps:
[0024] S101: The server process creates a socket;
[0025] S102: Bind the local address to the created socket to identify the socket on the network;
[0026] S103: Put the socket into listening mode and prepare to accept connection requests;
[0027] S104: The client process calls the Socket function to create a client socket;
[0028] S105: The client sends a connection request to the service process;
[0029] S106: When a connection request arrives, the blocked service process generates a new socket to establish a connection with the client socket, and returns an acceptance signal to the client;
[0030] S107: The client's socket receives an acceptance signal from the server, indicating that the client and the server are connected, and data transmission can be performed;
[0031] S108: Close the socket. After the connection is established, the server and the client can communicate.
[0032] Preferably, in the blocking mode of S106, the function for sending and receiving data is called again and can return only after the transmission is completed or an error occurs. At the same time, the blocked function will continuously call the system function to keep the message loop running normally.
[0033] The present invention provides a network communication method based on encryption mechanism. It has the following beneficial effects:
[0034] 1. The network communication method based on the encryption mechanism adopts AES in the symmetric key cryptographic system with fast operation speed and high security to encrypt all transmitted data, and then uses RSA to encrypt the AES key, which can ensure both security and performance, thereby avoiding slow network communication and improving user experience. It solves the problem that the encryption mechanism proposed in the background technology has slow operation speed when encrypting data, which will lead to slow network communication and bring a bad experience to users. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 This is a diagram of the encrypted outflow of data from the client requesting the server of the present invention;
[0036] Figure 2 This is a flow chart of encrypted transmission between the server and the client of the present invention. DETAILED DESCRIPTION
[0037] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. The embodiments of the present invention are provided for the purpose of illustration and description, and are not intended to be exhaustive or to limit the present invention to the disclosed forms. Many modifications and variations will be apparent to those of ordinary skill in the art. The embodiments are selected and described in order to better illustrate the principles and practical applications of the present invention, and to enable those of ordinary skill in the art to understand the present invention and thereby design various embodiments with various modifications suitable for specific uses.
[0038] Embodiment 1:
[0039] like Figure 1-Figure 2 As shown, the present invention provides a technical solution: a network communication method based on an encryption mechanism, comprising the following steps:
[0040] S1: The client and the server support TCP / IP protocol. TCP / IP includes link layer, network layer, transport layer and application layer. The link layer includes the device driver in the operating system and the network interface card corresponding to the computer, which is responsible for handling the physical interface with the cable. The network layer is responsible for the activities of packets in the network. The transport layer provides end-to-end data communication for the client and the server. The transport layer includes TCP and UDP protocols. The TCP protocol provides end-to-end quality guaranteed data transmission. The UDP protocol sends data from one end to the other. The application layer is responsible for handling the actual application details.
[0041] S2: The client generates an AES key and saves the AES key.
[0042] S3: The client encrypts the AES key using the RSA public key and then puts the value into a custom request.
[0043] S4: The client initiates a request to the server.
[0044] S5: The server obtains the custom request header value, and then decrypts it using the RSA private key to obtain the AES key.
[0045] S6: The server uses the AES key to decrypt the request data.
[0046] S7: The server encrypts the response data using the AES key.
[0047] S8: The server sends a response to the client.
[0048] S9: The client obtains the encrypted data from the server and decrypts it using the previously saved AES key.
[0049] The TCP connection-oriented protocol includes the following steps:
[0050] S101: The server process creates a socket.
[0051] S102: Bind the local address to the created socket to identify the socket on the network.
[0052] S103: Put the socket into listening mode and prepare to accept connection requests.
[0053] S104: The client process calls the Socket function to create a client socket.
[0054] S105: The client sends a connection request to the service process.
[0055] S106: When a connection request arrives, the blocked service process generates a new socket to establish a connection with the client socket and returns an acceptance signal to the client. In the blocking mode, the function for sending and receiving data is called again and will not return until the transmission is completed or an error occurs. At the same time, the blocked function will continuously call the system function to keep the message loop running normally.
[0056] S107: When the socket of the client receives an acceptance signal from the server, it indicates that the client and the server are connected, and data transmission can be performed.
[0057] S108: Close the socket. After the connection is established, the server and the client can communicate.
[0058] The algorithm process of the RSA system is as follows:
[0059] Suppose the large integer n is the product of two different large prime numbers p and q. q and p are kept secret, that is, n = pq. n is public. According to Euler's theorem, the number of integers that are relatively prime to n and less than n is in It is confidential.
[0060] Randomly select one with A mutually prime integer e is used as a public encryption key, satisfying Public. From e, we can find the secret decryption key d, satisfying Keep it confidential.
[0061] Before encrypting data M, first decompose M into data bit string groups, and the group length is guaranteed to be 2 l ≤n, use m to represent the decimal representation of a certain grouped data, then 0≤m≤n.
[0062] When encrypting, the encryptor performs the following operation: c = E (m) =m e modn, the result c is the ciphertext obtained by encrypting with the RSA cryptographic system.
[0063] When decrypting, the decryptor needs to perform a similar operation as when encrypting: m = D (c) =c d modn
[0064] Due to c d modn=(m d modn) d modn=(m ed )modn
[0065] again
[0066] set up k is an integer and k ≥ 1,
[0067] From this we can get
[0068]
[0069] In the RSA system, the encryption key e and the large integer n are public, while the decryption key d and the large prime numbers p and q are kept secret. Although p and q are no longer needed after the RSA encryption and decryption keys are established, they must never be leaked.
[0070] Because p and q are both large prime numbers, the complexity is: Therefore, the confidentiality performance is good. When n is decomposed, e and d can be calculated, that is, RSA is deciphered.
[0071] Embodiment 2:
[0072] S1: The client and the server support TCP / IP protocol. TCP / IP includes link layer, network layer, transport layer and application layer. The link layer includes the device driver in the operating system and the network interface card corresponding to the computer, which is responsible for handling the physical interface with the cable. The network layer is responsible for the activities of packets in the network. The transport layer provides end-to-end data communication for the client and the server. The transport layer includes TCP and UDP protocols. The TCP protocol provides end-to-end quality guaranteed data transmission. The UDP protocol sends data from one end to the other. The application layer is responsible for handling the actual application details.
[0073] S2: The client generates an RSA key, saves the RSA key, and then puts the value into a custom request.
[0074] S3: The client initiates a request to the server.
[0075] S4: The server obtains the custom request header value and then decrypts it using the RSA private key.
[0076] S5: The server encrypts the response data using the RSA key.
[0077] S6: The server sends a response to the client.
[0078] S7: The client obtains the encrypted data from the server and decrypts it using the RSA key.
[0079] The TCP connection-oriented protocol includes the following steps:
[0080] S101: The server process creates a socket.
[0081] S102: Bind the local address to the created socket to identify the socket on the network.
[0082] S103: Put the socket into listening mode and prepare to accept connection requests.
[0083] S104: The client process calls the Socket function to create a client socket.
[0084] S105: The client sends a connection request to the service process.
[0085] S106: When a connection request arrives, the blocked service process generates a new socket to establish a connection with the client socket and returns an acceptance signal to the client. In the blocking mode, the function for sending and receiving data is called again and will not return until the transmission is completed or an error occurs. At the same time, the blocked function will continuously call the system function to keep the message loop running normally.
[0086] S107: When the socket of the client receives an acceptance signal from the server, it indicates that the client and the server are connected, and data transmission can be performed.
[0087] S108: Close the socket. After the connection is established, the server and the client can communicate.
[0088] The algorithm process of the RSA system is as follows:
[0089] Suppose the large integer n is the product of two different large prime numbers p and q. q and p are kept secret, that is, n = pq. n is public. According to Euler's theorem, the number of integers that are relatively prime to n and less than n is in It is confidential.
[0090] Randomly select one with A mutually prime integer e is used as a public encryption key, satisfying Public. From e, we can find the secret decryption key d, satisfying Keep it confidential.
[0091] Before encrypting data M, first decompose M into data bit string groups, and the group length is guaranteed to be 2 l≤n, use m to represent the decimal representation of a certain grouped data, then 0≤m≤n.
[0092] When encrypting, the encryptor performs the following operation: c = E (m) =m e modn, the result c is the ciphertext obtained by encrypting with the RSA cryptographic system.
[0093] When decrypting, the decryptor needs to perform a similar operation as when encrypting: m = D (c) =c d modn
[0094] Due to c d modn=(m d modn) d modn=(m ed )modn
[0095] again
[0096] set up k is an integer and k ≥ 1,
[0097] From this we can get
[0098]
[0099] In the RSA system, the encryption key e and the large integer n are public, while the decryption key d and the large prime numbers p and q are kept secret. Although p and q are no longer needed after the RSA encryption and decryption keys are established, they must never be leaked.
[0100] Because p and q are both large prime numbers, the complexity is: Therefore, the confidentiality performance is good. When n is decomposed, e and d can be calculated, that is, RSA is deciphered.
[0101]
[0102] Compared with using RSA encryption system alone, the combination of RSA encryption system and AES system has faster computing speed and network communication, which improves the user's communication experience.
[0103] Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field and related fields without creative work should fall within the scope of protection of the present invention. The structures, devices and operating methods not specifically described and explained in the present invention are implemented according to the conventional means in the field unless otherwise specified and limited.
Claims
1. A network communication method based on encryption mechanism, The following steps are involved: S1: The client and server support TCP / IP protocol; S2: The client generates an AES key and saves the AES key; S3: The client encrypts the AES key using the RSA public key and then puts the value into a custom request; S4: The client initiates a request to the server; S5: The server obtains the custom request header value, and then decrypts it using the RSA private key to obtain the AES key; S6: The server uses the AES key to decrypt the request data; S7: The server encrypts the response data using the AES key; S8: The server sends a response to the client; S9: The client obtains the encrypted data from the server and decrypts it using the previously saved AES key.
2. A network communication method based on an encryption mechanism according to claim 1, Features: The TCP / IP in S1 includes a link layer, a network layer, a transport layer and an application layer.
3. A network communication method based on encryption mechanism according to claim 2, Features: The link layer includes the device driver in the operating system and the network interface card corresponding to the computer, and is responsible for processing the physical interface with the cable.
4. A network communication method based on encryption mechanism according to claim 2, Features: The network layer is responsible for the movement of packets in the network.
5. A network communication method based on encryption mechanism according to claim 2, Features: The transport layer provides end-to-end data communication between the client and the server.
6. A network communication method based on encryption mechanism according to claim 2, Features: The transport layer includes TCP and UDP protocols. The TCP protocol provides end-to-end quality-assured data transmission, and the UDP protocol sends data from one end to another.
7. A network communication method based on encryption mechanism according to claim 2, Features: The application layer is responsible for handling the actual application details.
8. A network communication method based on encryption mechanism according to claim 1, Features: The TCP protocol connection-oriented comprises the following steps: S101: The server process creates a socket; S102: Bind the local address to the created socket to identify the socket on the network; S103: Put the socket into listening mode and prepare to accept connection requests; S104: The client process calls the Socket function to create a client socket; S105: The client sends a connection request to the service process; S106: When a connection request arrives, the blocked service process generates a new socket to establish a connection with the client socket, and returns an acceptance signal to the client; S107: The client's socket receives an acceptance signal from the server, indicating that the client and the server are connected, and data transmission can be performed; S108: Close the socket. After the connection is established, the server and the client can communicate.
9. A network communication method based on encryption mechanism according to claim 8, Features: In the blocking mode of S106, the function for sending and receiving data is called again and can only return after the transmission is completed or an error occurs. At the same time, the blocked function will continuously call the system function to keep the message loop running normally.
10. A network communication method based on encryption mechanism according to claim 1, Features: S1: The client and the server support TCP / IP protocol; S2: The client generates an RSA key, saves the RSA key, and then puts the value into a custom request; S3: The client initiates a request to the server; S4: The server obtains the custom request header value and then decrypts it using the RSA private key; S5: The server encrypts the response data using the RSA key; S6: The server sends a response to the client; S7: The client obtains the encrypted data from the server and decrypts it using the RSA key.
Citation Information
Patent Citations
Data transmission method and system based on hybrid encryption algorithm
CN110535868A
Secure file transmission method and system based on HTTPS protocol
CN116074039A
