A post-processing method of a true random number generator based on an encryption algorithm
By optimizing the post-processing of the true random number generator and adjusting the data using dynamic pseudo-random sources and encryption algorithms, the problem of insufficient randomness in the generated random numbers was solved, achieving higher randomness and information security.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TIH MICROELECTRONIC TECH CO LTD
- Filing Date
- 2023-02-13
- Publication Date
- 2026-05-26
AI Technical Summary
Existing true random number generators, when using encryption algorithms in post-processing, produce random numbers with poor randomness, especially when the entropy value generated by the physical random source is not high, making it difficult to meet standard requirements.
A post-processing method based on a true random number generator using encryption algorithms is adopted, including preprocessing, encryption, permutation, and scrambling. By dynamically selecting the pseudo-random source and encryption algorithm mode, adjusting the data order, and introducing new pseudo-random sources, the post-processing process is optimized.
It improves the randomness of generated random numbers, meets information security requirements, and enhances information protection capabilities.
Smart Images

Figure CN116107541B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of random number generation technology, and in particular to a post-processing method for a true random number generator based on an encryption algorithm. Background Technology
[0002] In today's information age, information security is becoming increasingly important and attracting more and more attention. Random numbers, as the foundation of information encryption and secure communication protocols, are primarily characterized by randomness and unpredictability. Random numbers are typically generated using random number generators. Pseudo-random number generators (PRNGs) use algorithms as a random source, but the pseudo-random numbers they generate are not completely random; they exhibit periodicity and predictability within a certain period. True random number generators (TRNGs), on the other hand, utilize non-deterministic physical phenomena, such as electronic noise, frequency jitter, radiative decay, single-photon emission / detection, and quantum effects, as a random source, generating random numbers that are unpredictable and uncopyable. Compared to pseudo-random numbers, true random number generators, by utilizing physical phenomena to generate unpredictable and uncopyable random numbers, can better protect information security.
[0003] In circuit design, there are three common methods for generating true random numbers: (1) direct amplification method, which directly utilizes physical noise such as resistor thermal noise in the amplifier circuit and obtains a random number sequence by comparing it with a comparator; (2) oscillatory sampling method, which uses a slow oscillator with jitter and obtains a random number sequence by sampling a fast oscillator with a fixed period through a D flip-flop; (3) discrete-time chaotic method, which uses the unpredictable nature of chaotic circuits and their sensitivity to initial conditions to generate random number sequences. Generally speaking, based on the structure of analog circuits, the statistical distribution of entropy sources is more ideal, and the noise of entropy sources does not change with the sampling period; based on the structure of digital circuits, the integration is high, and it is easy to implement on general-purpose programmable platforms such as FPGA (Field Programmable Gate Array), but the statistical characteristics of entropy sources are not as ideal as those of analog circuits.
[0004] A true random number generator generates random numbers in two parts. The first part is entropy generation, which involves generating random entropy using various noise sources, including physical entropy sources and entropy acquisition. The second part is post-processing, which processes the generated entropy data to improve the randomness of the generated numbers. Theoretically, data generated by physical random sources is completely random. However, in practical applications, due to noise and design limitations, the generated random numbers are not completely random, and their randomness can be very poor, even under conditions of guesswork. Therefore, further processing is needed to improve the randomness of the generated numbers. Common post-processing methods include using existing cryptographic encryption algorithms, such as symmetric algorithms, asymmetric algorithms, hash functions, and message authentication codes.
[0005] Using encryption algorithms directly as post-processing algorithms for random numbers is not feasible because they are not specifically designed for post-processing. Furthermore, the repetitive nature of the algorithms in processing data results in poor randomness in the generated random numbers. This is especially true when the entropy value generated by the physical random source is low, making it difficult for the generated random numbers to meet the standard requirements. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to provide a post-processing method for a true random number generator based on an encryption algorithm, thereby improving the randomness of the generated random numbers.
[0007] To solve the above-mentioned technical problems, the present invention provides the following technical solution:
[0008] A post-processing method for a true random number generator based on an encryption algorithm, comprising:
[0009] Step 1: Scramble the input entropy data using a preset pseudo-random source;
[0010] Step 2: Encrypt the calculated entropy data;
[0011] Step 3: Perform permutation processing on the encrypted entropy data to adjust the data order and reduce the correlation of data within the group;
[0012] Step 4: Introduce a new pseudo-random source into the permutation-processed entropy data and perform scrambling.
[0013] Furthermore, the true random number generator has at least two sets of mutually independent pseudo-random sources preset;
[0014] Step 1 further comprises:
[0015] Dynamically select one set of pseudo-random sources from the preset pseudo-random sources to perform an XOR operation on the input entropy data.
[0016] Furthermore, the true random number generator presets a set of independent pseudo-random sources as the encryption key for the encryption process, and the encryption key is updated periodically.
[0017] Furthermore, the encryption algorithm used in the encryption process is the SM4 algorithm.
[0018] Furthermore, the encryption operation process of the encryption processing includes at least two modes, and the number of round iterations is different in each mode;
[0019] Step 2 further comprises:
[0020] Dynamically select one of the at least two modes to encrypt the processed entropy data.
[0021] Furthermore, the encryption operation process includes eight modes: in the first mode, the encryption operation performs only four rounds of iteration; in the second mode, the encryption operation performs only eight rounds of iteration; in the third mode, the encryption operation performs only twelve rounds of iteration; in the fourth mode, the encryption operation performs only sixteen rounds of iteration; in the fifth mode, the encryption operation performs only twenty rounds of iteration; in the sixth mode, the encryption operation performs only twenty-four rounds of iteration; in the seventh mode, the encryption operation performs only twenty-eight rounds of iteration; and in the eighth mode, the encryption operation performs a complete 32 rounds of iteration.
[0022] Furthermore, step 3 further comprises:
[0023] The encrypted entropy data is divided into equal parts to form an n x n matrix. New data is output through matrix permutation to adjust the data order and reduce the correlation of data within the group.
[0024] Furthermore, n is an integer greater than or equal to 4.
[0025] Furthermore, step 4 further involves: calculating the proportion of 0 and 1 in the original input entropy data; when the number of 0 and 1 is greater than a preset threshold, introducing a new pseudo-random source to perform another scrambling operation on the permutation-processed entropy data.
[0026] The present invention has the following beneficial effects:
[0027] The post-processing method of the true random number generator based on the encryption algorithm of the present invention includes four major steps: preprocessing, encryption processing, permutation processing, and scrambling processing. Based on the encryption algorithm, the post-processing process of random number generation is optimized, which can improve the randomness of the generated random numbers and better protect the security of information. Attached Figure Description
[0028] Figure 1 This is a flowchart illustrating the post-processing method of the true random number generator based on encryption algorithm of the present invention;
[0029] Figure 2 for Figure 1 A block diagram illustrating the principle of preprocessing. Detailed Implementation
[0030] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.
[0031] As mentioned earlier, the process of generating random numbers using a true random number generator consists of two parts: the first part is the generation of entropy, and the second part is the post-processing part, which processes the entropy data generated earlier to improve the randomness of the random numbers. This invention mainly improves the post-processing part.
[0032] The post-processing method of the true random number generator based on the encryption algorithm of the present invention, such as... Figure 1 As shown, it includes:
[0033] Step 101: Preprocessing
[0034] The input entropy data is scrambled using a pre-defined pseudo-random source;
[0035] In this step, the input entropy data comes from the first part of the random number generation process of the true random number generator (entropy generation).
[0036] Step 102: Encryption Processing
[0037] The entropy data after calculation is encrypted;
[0038] Step 103: Replacement Process
[0039] The encrypted entropy data is permuted to adjust the data order and reduce the correlation between data within the group.
[0040] Step 104: Scrambling Processing
[0041] The permuted entropy data is then scrambled again by introducing a new pseudo-random source to further reduce the correlation of the data.
[0042] After this step is completed, you can generate random numbers using the scrambled entropy data, following the standard process of generating random numbers with a true random number generator.
[0043] The post-processing method of the true random number generator based on the encryption algorithm of the present invention includes four major steps: preprocessing, encryption processing, permutation processing, and scrambling processing. Based on the encryption algorithm, the post-processing process of random number generation is optimized, which can improve the randomness of the generated random numbers and better protect the security of information.
[0044] The four steps of this invention are described one by one below.
[0045] 1. Pretreatment
[0046] To further improve the randomness of the generated random numbers, the true random number generator can preset at least two sets of independent pseudo-random sources. In this case, step 101 further involves dynamically selecting one set of pseudo-random sources from the preset sources to perform an XOR operation on the input entropy data. The true random number generator can also preset a set of independent pseudo-random sources as the encryption key for the encryption process, and this encryption key is updated periodically.
[0047] In practice, this step can be achieved through a preprocessing component, such as... Figure 2As shown, the preprocessing unit contains multiple sets of independent pseudo-random sources (LFSR_1, LFSR_2...LFSR_n). One set of pseudo-random sources can be dynamically selected to perform an XOR operation with the input entropy, which can be done through the MUX (multiplexer, data selector) in the figure. It also contains a set of independent pseudo-random sources (LFSR_KEY) used as the encryption key for subsequent encryption processing, and the key is changed every once in a while. The control unit CONTROL is used to control the number of pseudo-random sources, the timing of switching, and the key update.
[0048] 2. Encryption processing
[0049] In this step, the encryption algorithm used for encryption processing can be any algorithm in this field, such as the SM4 algorithm. The following explanation uses the SM4 algorithm as an example.
[0050] The SM4 algorithm encryption process outputs 128-bit ciphertext from 128-bit plaintext data through 32 rounds of iterative computation, with each iteration producing 32 bits of data. Since this invention is not intended for data encryption, for better randomness, the encryption process in this step can include at least two modes, each with a different number of iterations. Step 102 further involves dynamically selecting one of the at least two modes to encrypt the resulting entropy data. Thus, this invention modifies the SM4 algorithm process, changing it from having only one mode to having at least two modes that can be dynamically switched, avoiding data correlation introduced by using a single processing mode, thereby further improving the randomness of generated random numbers.
[0051] Furthermore, the encryption process can include eight modes: in the first mode, the encryption operation performs only four iterations; in the second mode, it performs only eight iterations; in the third mode, it performs only twelve iterations; in the fourth mode, it performs only sixteen iterations; in the fifth mode, it performs only twenty iterations; in the sixth mode, it performs only twenty-four iterations; in the seventh mode, it performs only twenty-eight iterations; and in the eighth mode, it performs a full thirty-two iterations. These eight modes significantly increase the range of options and improve the randomness of the generated random numbers.
[0052] 3. Replacement treatment
[0053] Step 103 can be further described as follows: Divide the encrypted entropy data into equal parts to form an n x n matrix, and output new data through matrix permutation to adjust the data order and reduce the correlation of data within the group. Here, n can be an integer greater than or equal to 4.
[0054] Since SM4 encryption is a block cipher, the encryption process cannot effectively eliminate the correlation between data within a block. Therefore, this step uses a permutation process to adjust the order of the data, which can effectively reduce the correlation between data within a block.
[0055] In practice, for example, the encrypted 128-bit entropy data can be divided into 16 8-bit data to form a 4x4 matrix. After matrix permutation, a new 128-bit data can be output.
[0056] The matrix before the permutation is as follows:
[0057]
[0058] The matrix after permutation is as follows:
[0059]
[0060] 4. Scrambling processing
[0061] Step 104 can be further defined as follows: Calculate the proportion of 0 and 1 in the original input entropy data. When the number of 0 and 1 is greater than the preset threshold, introduce a new pseudo-random source to perform another scrambling operation on the permutation-processed entropy data.
[0062] In this step, the statistical properties of the data can be used to find a relatively uniform distribution, and then a new pseudo-random source can be introduced (this new pseudo-random source can be generated independently or with the help of...). Figure 2 The preprocessing component shown intervenes by scrambling the data, disrupting this distribution and thus increasing randomness. In practice, this can be achieved by counting the number of 0 / 1 values in the original input entropy data and analyzing the distribution of 0 / 1 values. When a preset threshold is reached, a new pseudo-random source is introduced for scrambling. If the preset threshold is not reached, no processing is performed.
[0063] In summary, this invention proposes a post-processing algorithm for a true random number generator. Based on the SM4 algorithm, the post-processing procedure for random number generation is optimized, with the key feature being the ability to dynamically adjust the post-processing steps to maximize the randomness of the generated random numbers. Specifically, this algorithm uses a modified SM4 encryption algorithm as its core. By introducing multiple independent external entropy sources into the input entropy source data, modifying the SM4 encryption algorithm's flow, and incorporating permutation operations, the sampled physical random entropy source data is processed to obtain truly random numbers that meet the randomness requirements.
[0064] Results of the test comparison
[0065] The results of this invention were tested using the 21 test standards specified in the national standard GM / T 0005 "Randomness Testing Specification".
[0066] The test first uses a true random number generator to generate 50 groups of test data. Each group of test data contains 1000 files, and each file is a binary file with a size of 128 kb. The test standard is that the 1000 files in each group are respectively tested with 21 specified test standards. It is required that the pass rate of each item is not less than 98%, that is, for each test item of the 1000 files, more than 980 files need to pass the test to be considered qualified. Then, the pass rate of the 50 groups of test data is checked.
[0067] The test respectively tests 50 groups of source random numbers without post - processing, 50 groups of random numbers processed by the SM4 algorithm, and 50 groups of random numbers processed by the present invention, and then compares the passing situations.
[0068] The final test results are as follows: 20 groups of the 50 groups of random numbers without post - processing pass the test; 25 groups of the 50 groups of random numbers processed by the SM4 algorithm pass the test; 37 groups of the 50 groups of random numbers processed by the present invention pass the test.
[0069] In summary, the beneficial effects of the present invention are at least as follows: (1) The present invention is applicable to most true random number generators. For most physical random sources, the present invention can well improve the randomness of the generated random numbers. (2) The present invention can effectively improve the randomness of the generated random numbers without reducing the performance. (3) The present invention can adjust parameters according to the situation of the random source to improve the randomness.
[0070] The above is the preferred embodiment of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the principle described in the present invention, several improvements and refinements can be made, and these improvements and refinements should also be regarded as the protection scope of the present invention.
Claims
1. A post-processing method of a true random number generator based on an encryption algorithm, characterized in that, include: Step 1: Scramble the input entropy data using a preset pseudo-random source; Step 2: Encrypt the calculated entropy data; Step 3: Perform permutation processing on the encrypted entropy data to adjust the data order and reduce the correlation of data within the group; Step 4: Introduce a new pseudo-random source into the permutation-processed entropy data and perform scrambling operations; In step 1, the true random number generator presets at least two sets of mutually independent pseudo-random sources; Dynamically select one set of pseudo-random sources from the preset pseudo-random sources and perform an XOR operation on the input entropy data; The encryption algorithm used in the encryption process is the SM4 algorithm; the encryption operation process of the encryption process includes at least two modes, and the number of round iterations in each mode is different; in step 2, one of the at least two modes is dynamically selected to encrypt the entropy data after the operation.
2. The method of claim 1, wherein, The true random number generator presets a set of independent pseudo-random sources as the encryption key for the encryption process, and the encryption key is updated periodically.
3. The method of claim 1, wherein, The encryption operation process includes eight modes: in the first mode, the encryption operation performs only four iterations; in the second mode, it performs only eight iterations; in the third mode, it performs only twelve iterations; in the fourth mode, it performs only sixteen iterations; in the fifth mode, it performs only twenty iterations; in the sixth mode, it performs only twenty-four iterations; in the seventh mode, it performs only twenty-eight iterations; and in the eighth mode, it performs a complete 32 iterations.
4. The method of claim 1, wherein, Step 3 further comprises: The encrypted entropy data is divided into equal parts to form an n x n matrix. New data is output through matrix permutation to adjust the data order and reduce the correlation of data within the group.
5. The method of claim 4, wherein, n is an integer greater than or equal to 4.
6. The method of claim 1, wherein, Step 4 further comprises: The proportion of 0 and 1 in the original input entropy data is counted. When the number of 0 and 1 is greater than the preset threshold, a new pseudo-random source is introduced to perform another scrambling operation on the permutation-processed entropy data.