Method for realizing high-concurrency dynamic encryption

Through the random number cache and circular linked list mechanism, serial calls of the crypto machine interface are reduced, concurrent performance of data encryption is improved, and the problem that encryption performance is affected by network I/O in the prior art is solved.

CN119051853APending Publication Date: 2024-11-29YUEZHI ARTIFICIAL INTELLIGENCE (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411084819.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-08
Publication Date
2024-11-29

AI Technical Summary

Technical Problem

In the prior art, when encrypting data, the serial call to the cipher machine interface causes network I/O to affect the encryption performance, especially when the number of processing connections is large during peak periods, the performance is significantly reduced.

Method used

Using the random number cache method, call the password machine random number interface through independent threads and create a circular linked list, write random numbers regularly, and give priority to obtaining ciphertext from the cache or using cached ciphertext to reduce cipher interface calls and according to network congestion Adjust parameters.

Benefits of technology

Effectively reduces the number of password machine calls, improves encryption efficiency and performance, and avoids performance bottlenecks caused by serial calls, especially when handling large numbers of connections during peak periods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119051853A_ABST
    Figure CN119051853A_ABST
Patent Text Reader

Abstract

The invention discloses a method for realizing high-concurrency dynamic encryption. According to the method disclosed by the invention, a random number caching method is firstly adopted, so that a random number'random 'interface and an encryption'encryption' interface of the cipher machine are prevented from being serially called in an encryption process; the method comprises the following steps: firstly, encrypting a cache map, then directly obtaining a ciphertext of the encrypted cache map through a certain probability, reducing calling of an'encryption 'interface of the cipher machine, and when reading the cache, performing temporary adjustment according to the network congestion condition of the cipher machine, thereby effectively reducing the conditions of low encryption efficiency and low encryption performance caused by calling of the cipher machine.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of electronic data information security, and in particular to a method for realizing high-concurrency dynamic encryption. Background Art

[0002] As the government industry has higher and higher requirements for data confidentiality, the third level of security protection has also issued corresponding confidentiality evaluation requirements. The data encryption methods used in the prior art mainly include: calling the cipher machine through a fixed key and a fixed initial vector (IV) to perform the corresponding encryption operation. Or by calling the cipher machine to obtain a random number as the initial vector (IV) each time encryption is performed, and then calling the cipher machine for encryption. The prior art calls the cipher machine interface twice in series each time encryption is performed. First, the random number returned by the random number interface of the cipher machine is called as the initial vector (IV), and then the cipher machine encryption interface is called to encrypt the data. Moreover, the two calls to the cipher machine interface are performed in a serial manner. Since the cipher machine is called through the network I / O, the encryption performance is seriously affected. Generally, only one set of cipher machines is provided in a project, and the cipher machine connected to the project is connected to many systems. During peak hours, the number of connections to be processed by the cipher machine is large, thereby affecting the overall data encryption performance.

[0003] Therefore, the prior art has defects and needs to be improved. Summary of the invention

[0004] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a method for realizing high-concurrency dynamic encryption.

[0005] The technical solution of the present invention is as follows: a method for realizing high-concurrency dynamic encryption is provided, comprising the following steps:

[0006] Random number cache:

[0007] Step 1: Call the random number interface of the cryptographic machine to run as an independent thread;

[0008] Step 2: When the independent thread is running, create a circular linked list of the specified length;

[0009] Step 3: The independent thread periodically calls the random number interface of the cryptographic machine to write into the circular linked list;

[0010] Encryption process:

[0011] Step 4: Calculate the random number. If the random number is greater than the specified parameter CacheProbability, the ciphertext in the map cache is taken first, otherwise it is encrypted by the cipher machine;

[0012] Step 5: Calculate the md5 value of the data to be encrypted as the key, and randomly read the value in the map cache. If the corresponding key exists in the map cache, directly return the value as the ciphertext, otherwise encrypt it through the cipher machine;

[0013] Step 6: If it is determined in step 4 and step 5 that encryption needs to be performed by a cipher machine, a random number is taken from the circular linked list as an initial vector;

[0014] Step 7: Call the data encryption interface of the cipher machine and record the ciphertext returned by the cipher machine into the map cache.

[0015] Furthermore, in step 2, the specified length of the circular linked list is 50-200.

[0016] Furthermore, in step 3, the independent thread will periodically call the random number interface of the cryptographic machine to write into the circular linked list, and when the circular linked list reaches a specified length, the oldest random number will be deleted.

[0017] Furthermore, in step 4, the value of the parameter CacheProbability is 0.8-1.

[0018] Furthermore, if network congestion of the cryptographic machine is detected, the value of the parameter CacheProbability is reduced.

[0019] By adopting the above scheme, the present invention firstly avoids serial calls to the random number "random" interface and the encryption "encryption" interface of the cipher machine during the encryption process by using the random number cache method. Then, the ciphertext of the encryption cache map is directly obtained with a certain probability, reducing the calls to the "encryption" interface of the cipher machine. When reading the cache, temporary adjustments will be made according to the congestion of the cipher machine network, thereby effectively reducing the calls to the cipher machine, resulting in low encryption efficiency and encryption performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 This is the underlying logical architecture diagram of the present invention. DETAILED DESCRIPTION

[0021] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments.

[0022] See also Figure 1 The present invention provides a method for implementing high-concurrency dynamic encryption, comprising the following steps:

[0023] Random number cache: In order to avoid the need to serially call the cipher machine random number "random" interface and the cipher machine encryption "encryption" interface for each encryption, the cipher machine random number interface is called as an independent thread.

[0024] Step 1: Call the cryptographic machine random number interface to run as an independent thread.

[0025] Step 2: When the independent thread is running, create a circular linked list of a specified length. Generally, the length of the circular linked list specified by "CircularListLength" is 100.

[0026] Circular list: Change the pointer field of the end node of the singly linked list from "null pointer" to "pointing to the head node", so that the entire linked list forms a ring. In this way, the single linked list connected from head to tail becomes a single circular linked list, also known as a circular linked list.

[0027] Step 3: The independent thread will periodically call the random number interface of the cryptographic machine to write into the circular linked list. When the circular linked list reaches the specified length, the oldest random number will be deleted to update the circular linked list.

[0028] Encryption process: Determine whether the ciphertext of the data to be encrypted can be selected in the cache. If not, select a random number from the circular list as the initial vector for encryption. Specifically:

[0029] Step 4: Calculate the random number. If the random number is greater than the specified parameter CacheProbability, the ciphertext in the map cache is preferred, otherwise encryption is performed through the cipher machine. Generally, the value of the parameter CacheProbability is set to 0.8, so that the ciphertext in the map cache can be quickly specified for the random number, thereby reducing the call to the data interface of the cipher machine. If network congestion is detected in the cipher machine, the value of the parameter CacheProbability is lowered, thereby effectively alleviating the working pressure of the cipher machine, thereby effectively improving the efficiency of encryption work.

[0030] Step 5: Calculate the md5 value of the data to be encrypted as the key, randomly read the value of the map cache, if the corresponding key exists in the map cache, directly return the value as the ciphertext, otherwise encrypt it through the cipher machine.

[0031] Step 6: If it is determined in step 4 and step 5 that encryption needs to be performed by a cipher machine, a random number is taken from the circular linked list as an initial vector.

[0032] Step 7: Call the data encryption interface of the cipher machine and record the ciphertext returned by the cipher machine into the map cache.

[0033] In a specific embodiment, the random number caching method is first used to avoid serial calls to the cipher machine random number "random" interface and the cipher machine encryption "encryption" interface during the encryption process. The call to the cipher machine random interface is run as an independent thread, and when this thread runs, a circular linked list with a specified length "CircularListLength" set to 100 is created. The thread will periodically call the cipher machine random number interface to write to the circular linked list, and when the linked list reaches the length of "CircularListLength", the oldest one will be deleted. During the encryption process, a random number needs to be calculated (in the range of 0-1). If the random number is greater than the specified parameter "CacheProbability", the ciphertext is preferentially taken from the cache map.

[0034] When taking ciphertext from the cache map, the md5 value of the "data" to be encrypted is calculated as the key to read the value of the cache map. If the cached key exists, the value is directly returned as the ciphertext, otherwise it needs to be encrypted by a cipher machine.

[0035] When it is determined that encryption is required through a cipher machine, a random number is obtained as the initial vector (IV) through the next node of the circular linked list, and then the cipher machine's data encryption interface "encryption(iv, data)" is called, where iv is the initial vector (IV), data is the original data to be encrypted, and finally the md5 value of data is used as the key, and the cipher machine's ciphertext is used as the value and recorded in the cache map.

[0036] By directly obtaining the ciphertext of the encryption cache map with a certain probability, the calls to the "encryption" interface of the cipher machine are reduced. When reading the cache, temporary adjustments will be made according to the congestion of the cipher machine network, thereby effectively reducing the calls to the cipher machine and resulting in lower encryption efficiency and performance.

[0037] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A method for implementing high-concurrency dynamic encryption, characterized in that: The steps include: Random number cache: Step 1: Call the random number interface of the cryptographic machine to run as an independent thread; Step 2: When the independent thread is running, create a circular linked list of a specified length; Step 3: The independent thread periodically calls the random number interface of the cryptographic machine to write into the circular linked list; Encryption process: Step 4: Calculate the random number. If the random number is greater than the specified parameter CacheProbability, the ciphertext in the map cache is taken first, otherwise it is encrypted by the cipher machine; Step 5: Calculate the md5 value of the data to be encrypted as the key, and randomly read the value in the map cache. If the corresponding key exists in the map cache, directly return the value as the ciphertext, otherwise encrypt it through the cipher machine; Step 6: If it is determined in step 4 and step 5 that encryption needs to be performed by a cipher machine, a random number is taken from the circular linked list as an initial vector; Step 7: Call the data encryption interface of the cipher machine and record the ciphertext returned by the cipher machine into the map cache.

2. The method for implementing high-concurrency dynamic encryption according to claim 1, characterized in that: In step 2, the specified length of the circular linked list is 50-200.

3. The method for implementing high-concurrency dynamic encryption according to claim 1, characterized in that: In step 3, the independent thread will periodically call the random number interface of the cryptographic machine to write into the circular linked list, and when the circular linked list reaches the specified length, the oldest random number will be deleted.

4. The method for implementing high-concurrency dynamic encryption according to claim 1, characterized in that: In step 4, the value of the parameter CacheProbability is 0.8-1.

5. The method for high-concurrency dynamic encryption of sight lines according to claim 4, characterized in that: If network congestion is detected on the cipher machine, the value of the parameter CacheProbability is lowered.