Commercial password random number security detection method and system
By grouping and exorbitant calculations of random numbers generated by commercial password random number generators, combined with Z tests, the problem of failure to fully consider time and correlation in the prior art is solved, and more accurate random number security detection is achieved.
Patent Information
- Application Number
- CN202510751260.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-06
- Publication Date
- 2025-07-25
- Estimated Expiration
- 2045-06-06
AI Technical Summary
The existing random number security detection technology fails to fully consider the time factor and the correlation between different random numbers, resulting in the inability to accurately verify the security of random numbers.
By connecting the random number generator for commercial passwords, generating random numbers, grouping bit data, building a bit calculation model, performing XOR calculations and performing Z-tests to determine whether XOR data meets the random probability expectations.
It improves the accuracy and comprehensiveness of random number security detection, ensures the true randomness of commercial password random numbers, and prevents the generation of the same random number and the correlation between different random numbers.
Smart Images

Figure CN120378100A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of random number security detection, and specifically provides a method and system for commercial cipher random number security detection. Background Art
[0002] Random number security detection technology refers to a technical system that evaluates whether the sequence generated by a random number generator meets cryptographic security requirements through systematic methods and tools, ensuring its unpredictability, statistical randomness, and anti-attack capabilities. Its core goal is to verify the reliability of random numbers in security scenarios such as key generation and authentication protocols, and prevent security vulnerabilities caused by insufficient randomness.
[0003] Existing random number security detection technologies usually perform security detection on random numbers according to the parameter limits of random number detection specifications, including frequency detection, that is, verifying whether the number of 0s and 1s in the random number is close. However, it does not clearly stipulate the specific ratio of the number of 0s and 1s that can be considered close. Moreover, in existing computer random number generation, most are pseudo-random, and the generated data actually has a certain relationship with time. At a certain fixed time, the computer will always output the same random number. Existing random number security detection technologies do not consider the influence of time on the generated random numbers. At the same time, existing random number security detection technologies only perform security detection on the random numbers themselves. There may be a certain correlation between different random numbers, and it is necessary to further verify that different random numbers are also random. For example, in the patent application with the publication number CN110531957A, an online detection method for a random number generator is disclosed. This solution only performs online detection on the random numbers themselves, cannot verify whether there is a correlation between different random numbers, and does not consider the influence of time on the generated random numbers. Existing random number security detection technologies also have the problem that the security detection of random numbers is not comprehensive enough, resulting in the inability to accurately verify whether the random numbers are secure. Summary of the Invention
[0004] The present invention aims to solve at least one of the technical problems in the existing technology to some extent. By connecting a commercial cipher random number generator, the commercial cipher random number generator randomly generates a first test quantity of random numbers according to time, named test random numbers. Then, the bit data within the same test random number is grouped to obtain bit groups, a bit calculation model is constructed, the bit groups are calculated through the bit calculation model to obtain first exclusive-OR data, and at the same time, different test random numbers are calculated through the bit calculation model to obtain second exclusive-OR data. Then, a Z-test is performed on the exclusive-OR data to determine whether the exclusive-OR data meets the random probability expectation, so as to solve the problem that the existing random number security detection technology is not comprehensive enough in the security detection of random numbers, resulting in the inability to accurately verify whether the random numbers are secure.
[0005] To achieve the above object, in a first aspect, the present application provides a method for secure detection of commercial cryptographic random numbers, including the following steps:
[0006] Connect to a commercial cryptographic random number generator, and randomly generate a first test quantity of random numbers according to time by the commercial cryptographic random number generator, named test random numbers;
[0007] Group the bit data within the same test random number to obtain bit groups;
[0008] Construct a bit calculation model, calculate the bit groups and different test random numbers to obtain exclusive-or data;
[0009] Perform a Z-test on the exclusive-or data to determine whether the exclusive-or data meets the random probability expectation.
[0010] Further, connecting to a commercial cryptographic random number generator and randomly generating a first test quantity of random numbers according to time by the commercial cryptographic random number generator, named test random numbers includes the following sub-steps:
[0011] Connect to a commercial cryptographic random number generator;
[0012] Set a first test time, a first test period, and a first test quantity;
[0013] At the first test time every day, start the commercial cryptographic random number generator, and randomly generate a first test quantity of test random numbers through the commercial cryptographic random number generator. The number of bits of the test random numbers is fixed to a first bit number, and the first bit number is a multiple of 4;
[0014] After generation, turn off the commercial cryptographic random number generator, start the commercial cryptographic random number generator again at the first test time of the next day and generate test random numbers, and repeat the first test period;
[0015] Add a start instruction and a generation instruction to the commercial cryptographic random number generator to ensure that the time when the commercial cryptographic random number generator is started and starts to generate test random numbers is exactly the same each time.
[0016] Further, grouping the bit data within the same test random number to obtain bit groups includes the following sub-steps:
[0017] In the same test random number, every 4-bit data is a bit group;
[0018] Number the bit groups in order from left to right, and represent them by the symbol B n where n is a positive integer and n is the serial number of B.
[0019] Further, a bit calculation model is constructed to calculate the bit group and different test random numbers, and the obtained exclusive-or data includes the following sub-steps:
[0020] Construct a bit calculation model;
[0021] Calculate the bit group through the bit calculation model to obtain the first exclusive-or data;
[0022] Calculate different test random numbers through the bit calculation model to obtain the second exclusive-or data.
[0023] Further, constructing the bit calculation model includes the following sub-steps:
[0024] Name the two pieces of data input into the bit calculation model as the first data and the second data respectively;
[0025] Number the bit data in the first data and mark them as A1 in order from left to right m , number the bit data in the second data and mark them as A2 in order from left to right m , where m is a positive integer and m is the serial number of A1 and A2;
[0026] Starting from m = 1, perform exclusive-or calculation on A1 m and A2 m , mark the calculation result as H m , add 1 to m and perform exclusive-or calculation again until the maximum value of m is reached;
[0027] Combine H m in ascending order of m to obtain the exclusive-or data.
[0028] Further, calculating the bit group through the bit calculation model to obtain the first exclusive-or data includes the following sub-steps:
[0029] Starting from n = 1, input B n and B n+1 into the bit calculation model, and mark the output exclusive-or data as C n , add 1 to n and execute again until max(n)-1 is reached, where max() is the maximum value operator;
[0030] Finally, obtain C n to C max(n)-1 , combine C n in ascending order of n to obtain the first exclusive-or data;
[0031] Mark the first test period and the first test quantity as P1 and P2 respectively, analyze each test random number, and a total of P1×P2 pieces of first exclusive-or data are obtained.
[0032] Further, calculating different test random numbers through a bit calculation model to obtain second exclusive-OR data includes the following sub-steps:
[0033] Input any two test random numbers into the bit calculation model for calculation, and name the output exclusive-OR data as second exclusive-OR data;
[0034] Each test random number needs to be calculated P1×P2 - 1 times, and a total of (P1×P2)×(P1×P2 - 1) pieces of second exclusive-OR data are obtained.
[0035] Further, performing a Z-test on the exclusive-OR data to determine whether the exclusive-OR data meets the random probability expectation includes the following sub-steps:
[0036] Both the first exclusive-OR data and the second exclusive-OR data belong to exclusive-OR data. For any exclusive-OR data, count the number of 1s and the number of 0s in the exclusive-OR data, and mark them as K1 and K2 respectively. Calculate K1 / (K1 + K2), and name the calculation result as the exclusive-OR one-zero ratio. Count the exclusive-OR one-zero ratio of each exclusive-OR data, number the exclusive-OR one-zero ratio, and use the symbol X j to represent it, where j is a positive integer and j is the serial number of X;
[0037] Calculate the overall standard deviation of the exclusive-OR one-zero ratio through the formula where S is the overall standard deviation of the exclusive-OR one-zero ratio, max(j) is the maximum value of j, is the average value of X j ;
[0038] Determine whether the exclusive-OR data meets the random probability expectation through a Z-test.
[0039] Further, performing a Z-test on the exclusive-OR data to determine whether the exclusive-OR data meets the random probability expectation includes the following sub-steps:
[0040] The random probability expectation includes an exclusive-OR probability expectation, which is represented by the symbol μ;
[0041] Calculate the Z value of the exclusive-OR data through the formula where Z is the Z value of the exclusive-OR data;
[0042] Set the significance level α, find the rejection region of the significance level α, and compare whether Z is within the rejection region. If Z is within the rejection region, mark that the test random number does not meet the random probability expectation. If Z is not within the rejection region, mark that the test random number meets the random probability expectation.
[0043] Second aspect, the present application provides a commercial cryptographic random number security detection system, including a test random number generation module, a bit grouping module, a bit calculation module, and a random number security verification module; the test random number generation module, the bit grouping module, and the random number security verification module are respectively connected to the bit calculation module for data connection;
[0044] The test random number generation module is used to connect to a commercial cryptographic random number generator, and the commercial cryptographic random number generator randomly generates a first test quantity of random numbers according to time, named test random numbers;
[0045] The bit grouping module is used to group the bit data within the same test random number to obtain bit groups;
[0046] The bit calculation module is used to construct a bit calculation model, calculate the bit groups and different test random numbers to obtain exclusive-or data;
[0047] The random number security verification module is used to perform a Z-test on the exclusive-or data to determine whether the exclusive-or data meets the random probability expectation.
[0048] Advantageous effects of the present invention: By connecting to a commercial cryptographic random number generator, the commercial cryptographic random number generator randomly generates a first test quantity of random numbers according to time, named test random numbers. The advantage is that the time factor is considered when generating test random numbers, preventing the random number generator from outputting the same random numbers at the same moment, thus threatening the security of commercial cryptography, and improving the effectiveness and rationality of random number samples in random number security detection.
[0049] The present invention groups the bit data within the same test random number to obtain bit groups, constructs a bit calculation model, calculates the bit groups through the bit calculation model to obtain first exclusive-or data, and at the same time calculates different test random numbers through the bit calculation model to obtain second exclusive-or data, and then performs a Z-test on the exclusive-or data to determine whether the exclusive-or data meets the random probability expectation. The advantage is that it not only considers whether the zero-one quantity of the test random number itself is reasonable, but also considers whether different random numbers conform to the random law, preventing patterns from existing between different random numbers, ensuring the true randomness of commercial cryptographic random numbers, and improving the accuracy and comprehensiveness of random number security detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] Figure 1 is the principle block diagram of the system of the present invention;
[0051] Figure 2 is the step flow chart of the random number security verification of the present invention;
[0052] Figure 3It is a flowchart of the steps of the method of the present invention;
[0053] Figure 4 It is a schematic structural diagram of the electronic device of the present invention. Detailed implementation manners
[0054] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0055] Embodiment 1, please refer to Figure 1 As shown, the present application provides a commercial cipher random number security detection system, including a test random number generation module, a bit grouping module, a bit calculation module, and a random number security verification module; the test random number generation module, the bit grouping module, and the random number security verification module are respectively connected to the bit calculation module for data connection;
[0056] Please refer to Figure 2 As shown, the test random number generation module is used to connect to a commercial cipher random number generator, and the commercial cipher random number generator randomly generates a first test quantity of random numbers according to time, named test random numbers;
[0057] The test random number generation module is configured with a test random number generation strategy, and the test random number generation strategy includes:
[0058] Connect to the commercial cipher random number generator;
[0059] Set a first test time, a first test period, and a first test quantity;
[0060] At the first test time every day, start the commercial cipher random number generator, and randomly generate a first test quantity of test random numbers through the commercial cipher random number generator. The number of bits of the test random numbers is fixed to a first bit number, and the first bit number is a multiple of 4;
[0061] After the generation is completed, turn off the commercial cipher random number generator, start the commercial cipher random number generator again at the first test time of the next day and generate test random numbers, and repeat the first test period;
[0062] Add a start instruction and a generation instruction to the commercial cipher random number generator to ensure that the time when the commercial cipher random number generator starts and begins to generate test random numbers each time is exactly the same;
[0063] In practical applications, the first test time, the first test period, the first test quantity, and the first number of bits are all set by the tester himself. The first test time and the first test period are for obtaining test random numbers at the same moment, the first test quantity is for obtaining a sufficient number of test random numbers as samples, and the first number of bits is for ensuring that the test random numbers have sufficient length to eliminate the influence of contingency. In this embodiment, the first test time is set to 14:00, the first test period is set to 3 days, the first test quantity is set to 10, and the first number of bits is set to 256 bits, that is, the computer code composed of 256 - bit binary digits. Start instructions and generation instructions are added to the commercial cipher random number generator to ensure that the commercial cipher random number generator starts and begins to generate test random numbers at exactly the same time each time. By mechanically controlling the start time, the error caused by manual start can be eliminated. Since the computer may generate random numbers based on the computer time or based on the device start time, it is necessary to consider both in combination, and 30 test random numbers are generated through this method.
[0064] The bit grouping module is used to group the bit data within the same test random number to obtain bit groups.
[0065] The bit grouping module is configured with a bit grouping strategy, and the bit grouping strategy includes:
[0066] In the same test random number, every 4 - bit data forms a bit group.
[0067] The bit groups are numbered in the order from left to right, and are represented by the symbol B n where n is a positive integer and n is the serial number of B.
[0068] In practical applications, since there are 256 - bit data in the test random number, and every 4 bits form a bit group, after numbering, we get B n , 1 ≤ n ≤ 256, and the bit data is either 0 or 1.
[0069] The bit calculation module is used to construct a bit calculation model, calculate the bit groups and different test random numbers to obtain exclusive - OR data. The bit calculation module includes a calculation model construction unit, a bit group calculation unit, and a random number calculation unit.
[0070] The calculation model construction unit is used to construct a bit calculation model.
[0071] The calculation model construction unit is configured with a calculation model construction strategy, and the calculation model construction strategy includes:
[0072] The two pieces of data input into the bit calculation model are respectively named the first data and the second data.
[0073] Number the bit data in the first data and label them as A1 in the order from left to right m Number the bit data in the second data and label them as A2 in the order from left to right m m is a positive integer and m is the serial number of A1 and A2;
[0074] Starting from m = 1, perform exclusive OR calculation on A1 m and A2 m Mark the calculation result as H m Increment m by one and perform the exclusive OR calculation again until the maximum value of m is reached;
[0075] Combine H m in ascending order of m to obtain the exclusive OR data;
[0076] In practical applications, since the number of bits of the test random number is too large and it is inconvenient to specifically show in the embodiments, this embodiment uses part of the data of the test random number for illustration, aiming to elaborate on the specific calculation processes of the exclusive OR data and the homomorphic data; assume that the first data is 0101001011010010 and the second data is 1001101101001011, and obtain A1 m and A2 m , 1 ≤ m ≤ 16, starting from m = 1, A11 and A21 are 0 and 1 respectively, perform exclusive OR calculation on A11 and A21, and obtain H1 as 0. Then increment m by 1, at this time m = 2, A12 and A22 are 1 and 0 respectively, perform exclusive OR calculation on A12 and A22, and obtain H2 as 0, and so on until H 16 is obtained. Finally, the exclusive OR data is 1100100110011001;
[0077] The bit group calculation unit is used to calculate the bit group through the bit calculation model to obtain the first exclusive OR data;
[0078] The bit group calculation unit is configured with a bit group calculation strategy, and the bit group calculation strategy includes:
[0079] Starting from n = 1, input B n and B n+1 into the bit calculation model, and mark the output exclusive OR data as C n , increment n by one and execute again until max(n) - 1 is reached, where max() is the maximum value operator;
[0080] Finally obtain C n to C max(n)-1 Combine C n in ascending order of n to obtain the first exclusive OR data;
[0081] Mark the first test cycle and the first test quantity as P1 and P2 respectively, analyze each test random number, and a total of P1×P2 pieces of first exclusive-OR data are obtained;
[0082] In practical applications, assume that the test random number on a certain day is 0101001011010010, which contains a total of 16-bit data. Thus, 4 groups of bit groups are obtained. B1 to B4 are 0101, 0010, 1101, and 0010 respectively. Input B1 and B2 into the bit calculation model to obtain C1 as 0111. Then input B2 and B3 into the bit calculation model for calculation. Similarly, C2 and C3 are obtained as 1111 and 1111 respectively. Finally, the first exclusive-OR data is 011111111111, and P1×P2 is 30. A total of 30 pieces of first exclusive-OR data are obtained;
[0083] The random number calculation unit is used to calculate different test random numbers through the bit calculation model to obtain the second exclusive-OR data;
[0084] The random number calculation unit is configured with a random number calculation strategy, and the random number calculation strategy includes:
[0085] Input any two test random numbers into the bit calculation model for calculation, and name the output exclusive-OR data as the second exclusive-OR data;
[0086] Each test random number needs to be calculated P1×P2 - 1 times, and a total of (P1×P2)×(P1×P2 - 1) pieces of second exclusive-OR data are obtained;
[0087] In practical applications, there are a total of 30 test random numbers. Each test random number needs to be calculated 29 times, that is, each test data needs to be calculated with all other test random numbers except itself. A total of 29×30 = 870 pieces of first exclusive-OR data are obtained.
[0088] The random number security inspection module is used to perform a Z-test on the exclusive-OR data to determine whether the exclusive-OR data meets the random probability expectation; the random number security inspection module includes a standard deviation calculation unit and a security detection unit;
[0089] The standard deviation calculation unit is configured with a standard deviation calculation strategy, and the standard deviation calculation strategy includes:
[0090] Both the first exclusive-OR data and the second exclusive-OR data belong to the exclusive-OR data. For any exclusive-OR data, count the number of 1s and 0s in the exclusive-OR data, and mark them as K1 and K2 respectively. Calculate K1 / (K1 + K2), and name the calculation result as the exclusive-OR one-zero ratio. Count the exclusive-OR one-zero ratio of each exclusive-OR data, number the exclusive-OR one-zero ratio, and represent it by the symbol X j It is represented, where j is a positive integer and j is the serial number of X;
[0091] Calculate the overall standard deviation of the exclusive - OR one - zero ratio through the formula where \(S\) is the overall standard deviation of the exclusive - OR one - zero ratio, \(\max(j)\) is the maximum value of \(j\), is the average value of \(X\) j ;
[0092] In practical applications, the first exclusive - OR data and the second exclusive - OR data together form 900 pieces of exclusive - OR data. Taking the first exclusive - OR data 011111111111 as an example, it is statistically obtained that \(K1\) and \(K2\) are 1 and 11 respectively, and the calculated exclusive - OR one - zero ratio is 1 / 12. Calculate the exclusive - OR one - zero ratio of each piece of exclusive - OR data to obtain \(X\) j , \(1\leq j\leq900\), and it is calculated that is 7 / 16. Due to the large amount of data, in this embodiment, the specific values of \(X\) j are not shown, and only the final calculation result is given. The calculated overall standard deviation \(S\) is 1 / 6;
[0093] The security detection unit is used to judge whether the exclusive - OR data meets the random probability expectation through the Z - test;
[0094] The security detection unit is configured with a security detection strategy, and the security detection strategy includes:
[0095] The random probability expectation includes the exclusive - OR probability expectation, which is represented by the symbol \(\mu\);
[0096] Calculate the Z - value of the exclusive - OR data through the formula where \(Z\) is the Z - value of the exclusive - OR data;
[0097] Set the significance level \(\alpha\), find the rejection region of the significance level \(\alpha\), and compare whether \(Z\) is within the rejection region. If \(Z\) is within the rejection region, mark that the test random number does not meet the random probability expectation. If \(Z\) is not within the rejection region, mark that the test random number meets the random probability expectation;
[0098] In practical applications, when performing the exclusive - OR calculation, \(A1\) m and \(A2\) m have a total of four combinations, including 00, 01, 10, and 11. Among them, the exclusive - OR of 0 and 0 is 0, the exclusive - OR of 1 and 1 is 0, and the exclusive - OR of 0 and 1 or 1 and 0 is 1. That is, the probability of the exclusive - OR result being 0 is 0.5, and the probability of being 1 is also 0.5. Therefore, the exclusive - OR probability expectation \(\mu\) is set to 0.5, and the formula was originally After simplification, it is obtained Finally, after simplification, it is where 7 / 16, μ is 0.5, S is 1 / 6, P1×P2 = 30, and finally Z is calculated to be -11.25. In the Z-test, the significance level α is usually set to 0.05, and the rejection region corresponding to 0.05 is {Z ≤ -1.96} ∪ {Z ≥ 1.96}. By comparison, Z is in the rejection region, so it is marked that the test random numbers do not meet the random probability expectation, and the rejection region is a fixed value. Thus, although the number of 0s and 1s in the test random numbers themselves is close, there is a certain correlation between the bit groups or different test random numbers, and they are not truly random.
[0099] Example 2, please refer to Figure 3 As shown, this application provides a method for security detection of commercial cryptographic random numbers, including the following steps:
[0100] Step S1, connect the commercial cryptographic random number generator, and the commercial cryptographic random number generator randomly generates a first test quantity of random numbers according to time, named test random numbers; Step S1 includes the following sub-steps:
[0101] Step S101, connect the commercial cryptographic random number generator;
[0102] Step S102, set the first test time, the first test period, and the first test quantity;
[0103] Step S103, start the commercial cryptographic random number generator at the first test time every day, and the commercial cryptographic random number generator randomly generates a first test quantity of test random numbers. The number of bits of the test random numbers is fixed to the first bit number, and the first bit number is a multiple of 4;
[0104] Step S104, after generation, turn off the commercial cryptographic random number generator, start the commercial cryptographic random number generator again at the first test time of the next day and generate test random numbers, and repeat the first test period;
[0105] Step S105, add a start instruction and a generation instruction to the commercial cryptographic random number generator to ensure that the time when the commercial cryptographic random number generator starts and begins to generate test random numbers each time is exactly the same;
[0106] Step S2, group the bit data within the same test random number to obtain bit groups; Step S2 includes the following sub-steps:
[0107] Step S201, in the same test random number, every 4-bit data is a group of bit groups;
[0108] Step S202, number the bit groups in the order from left to right, represented by the symbol B n where n is a positive integer and n is the serial number of B;
[0109] Step S3, construct a bit calculation model, calculate the bit group and different test random numbers to obtain exclusive-OR data; Step S3 includes the following sub-steps:
[0110] Step S301, construct a bit calculation model;
[0111] Step S301 includes the following sub-steps:
[0112] Step S301.1, name the two pieces of data input into the bit calculation model as the first data and the second data respectively;
[0113] Step S301.2, number the bit data in the first data, and mark it as A1 in the order from left to right m , number the bit data in the second data, and mark it as A2 in the order from left to right m , where m is a positive integer and m is the serial number of A1 and A2;
[0114] Step S301.3, starting from m = 1, perform exclusive-OR calculation on A1 m and A2 m , mark the calculation result as H m , add 1 to m and perform exclusive-OR calculation again until the maximum value of m is reached;
[0115] Step S301.4, combine H m in ascending order of m to obtain exclusive-OR data;
[0116] Step S302, calculate the bit group through the bit calculation model to obtain the first exclusive-OR data;
[0117] Step S302 includes the following sub-steps:
[0118] Step S302.1, starting from n = 1, input B n and B n+1 into the bit calculation model, and mark the output exclusive-OR data as C n , add 1 to n and execute again until max(n)-1 is reached, where max() is the maximum operator;
[0119] Step S302.2, finally obtain C n to C max(n)-1 , combine C n in ascending order of n to obtain the first exclusive-OR data;
[0120] Step S302.3, mark the first test cycle and the first test quantity as P1 and P2 respectively, analyze each test random number, and obtain a total of P1×P2 pieces of first exclusive-OR data;
[0121] Step S303: Calculate different test random numbers through the bit calculation model to obtain the second exclusive-or data;
[0122] Step S303 includes the following sub-steps:
[0123] Step S303.1: Input any two test random numbers into the bit calculation model for calculation, and name the output exclusive-or data as the second exclusive-or data;
[0124] Step S303.2: Each test random number needs to be calculated P1×P2 - 1 times, and a total of (P1×P2)×(P1×P2 - 1) pieces of second exclusive-or data are obtained;
[0125] Step S4: Conduct a Z-test on the exclusive-or data to determine whether the exclusive-or data meets the random probability expectation; Step S4 includes the following sub-steps:
[0126] Step S401: Both the first exclusive-or data and the second exclusive-or data belong to the exclusive-or data. For any exclusive-or data, count the number of 1s and 0s in the exclusive-or data, mark them as K1 and K2 respectively, calculate K1 / (K1 + K2), name the calculation result as the exclusive-or one-zero ratio, count the exclusive-or one-zero ratio of each exclusive-or data, number the exclusive-or one-zero ratio, and represent it through the symbol X j where j is a positive integer and j is the serial number of X;
[0127] Step S402: Calculate the overall standard deviation of the exclusive-or one-zero ratio through the formula where S is the overall standard deviation of the exclusive-or one-zero ratio, max(j) is the maximum value of j, is the average value of X j ;
[0128] Step S403: Determine whether the exclusive-or data meets the random probability expectation through a Z-test;
[0129] Step S403 includes the following sub-steps:
[0130] Step S403.1: The random probability expectation includes the exclusive-or probability expectation, which is represented by the symbol μ;
[0131] Step S403.2: Calculate the Z value of the exclusive-or data through the formula where Z is the Z value of the exclusive-or data;
[0132] Step S403.3: Set the significance level α, find the rejection region of the significance level α, compare whether Z is within the rejection region. If Z is within the rejection region, mark that the test random number does not meet the random probability expectation. If Z is not within the rejection region, mark that the test random number meets the random probability expectation.
[0133] Example 3. Please refer to Figure 4 as shown Figure 4 which illustrates a schematic structural diagram of an electronic device. The electronic device may include: a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus. The memory stores computer-readable instructions. The processor can call the instructions in the memory. When the computer-readable instructions are executed by the processor, the steps in a commercial cryptographic random number security detection method are run to achieve the following functions: connect to a commercial cryptographic random number generator, and the commercial cryptographic random number generator randomly generates a first test quantity of random numbers according to time, named test random numbers; group the bit data within the same test random number to obtain bit groups; construct a bit calculation model, calculate the bit groups and different test random numbers to obtain exclusive-or data; perform a Z-test on the exclusive-or data to determine whether the exclusive-or data meets the random probability expectation.
[0134] In addition, when the logical instructions in the above-mentioned memory are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a part of this 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 instructions to enable a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of this application. The foregoing storage medium includes: USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs, etc., which can store program codes.
[0135] Example 4. This application also provides a computer-readable storage medium. This application provides a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned commercial cryptographic random number security detection method are run to achieve the following functions: connect to a commercial cryptographic random number generator, and the commercial cryptographic random number generator randomly generates a first test quantity of random numbers according to time, named test random numbers; group the bit data within the same test random number to obtain bit groups; construct a bit calculation model, calculate the bit groups and different test random numbers to obtain exclusive-or data; perform a Z-test on the exclusive-or data to determine whether the exclusive-or data meets the random probability expectation.
[0136] Through the description of the above embodiments, the embodiments of the present invention can be provided as a method, a system or a computer program product. Based on such understanding, the above technical solution, in essence, or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0137] In the embodiments provided in the present application, it should be understood that the disclosed system or method can be implemented in other ways. The above-described embodiments are merely illustrative. For example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation. For another example, multiple modules or units can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some communication interfaces, and the indirect coupling or communication connection of the system, module and unit can be electrical, mechanical or other forms.
[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A security detection method for commercial cryptographic random numbers, characterized in that It includes the following steps: Connect to a commercial cryptographic random number generator, and randomly generate a first test quantity of random numbers according to time by the commercial cryptographic random number generator, named test random numbers; Group the bit data within the same test random number to obtain bit groups; Construct a bit calculation model, calculate the bit groups and different test random numbers to obtain exclusive-or data; Perform a Z-test on the exclusive-or data to determine whether the exclusive-or data meets the random probability expectation.
2. The commercial cipher random number security detection method according to claim 1, wherein Connect to a commercial cryptographic random number generator, and randomly generate a first test quantity of random numbers according to time by the commercial cryptographic random number generator, named test random numbers, which includes the following sub-steps: Connect to a commercial cryptographic random number generator; Set the first test time, the first test period, and the first test quantity; Start the commercial cryptographic random number generator at the first test time every day, and randomly generate a first test quantity of test random numbers through the commercial cryptographic random number generator. The number of bits of the test random numbers is fixed at the first bit number, and the first bit number is a multiple of 4; After the generation is completed, turn off the commercial cryptographic random number generator, start the commercial cryptographic random number generator again at the first test time of the next day and generate test random numbers, and repeat the first test period; Add a start instruction and a generation instruction to the commercial cryptographic random number generator to ensure that the time when the commercial cryptographic random number generator starts and begins to generate test random numbers each time is exactly the same.
3. A commercial cryptographic random number security detection method according to claim 2, characterized in that Group the bit data within the same test random number to obtain bit groups, which includes the following sub-steps: In the same test random number, every 4-bit data is a bit group; Number the bit groups in order from left to right, indicated by the symbol B n where n is a positive integer and n is the sequence number of B.
4. A commercial cipher random number security detection method according to claim 3, characterized in that Construct a bit calculation model, calculate the bit groups and different test random numbers to obtain exclusive-or data, which includes the following sub-steps: Construct a bit calculation model; Calculate the bit groups through the bit calculation model to obtain the first exclusive-or data; Calculate different test random numbers through the bit calculation model to obtain the second exclusive-or data.
5. A commercial cipher random number security detection method according to claim 4, characterized in that Construct a bit calculation model, which includes the following sub-steps: Name the two pieces of data input into the bit calculation model as the first data and the second data respectively; Number the bit data in the first data and label it as A1 in the order from left to right m , number the bit data in the second data and label it as A2 in the order from left to right m , where m is a positive integer and m is the serial number of A1 and A2; Start with m = 1 and perform exclusive OR calculations on A1 m and A2 m and mark the calculation result as H m , increment m by one and perform the exclusive OR calculation again until the maximum value of m is reached; Combine H in ascending order of m m to obtain exclusive-or data.
6. A method for secure detection of commercial cryptographic random numbers according to claim 5, characterized in that, Calculate the bit groups through the bit calculation model to obtain the first exclusive-or data, which includes the following sub-steps: Start with n = 1 and take B n and B n+1 input bit calculation model, and mark the output exclusive-or data as C n , increment n by one and execute again until max(n)-1 is reached, where max() is the maximum operator; Finally, C is obtained n to C max(n)-1 , and C is combined in ascending order of n n to obtain the first exclusive-OR data; Mark the first test period and the first test quantity as P1 and P2 respectively, analyze each test random number, and a total of P1×P2 pieces of first exclusive-or data are obtained.
7. A commercial cryptography random number security detection method according to claim 6, characterized in that, Calculate different test random numbers through the bit calculation model to obtain the second exclusive-or data, which includes the following sub-steps: Input any two test random numbers into the bit calculation model for calculation, and name the output exclusive-or data as the second exclusive-or data; Each test random number needs to be calculated P1×P2 - 1 times, and a total of (P1×P2)×(P1×P2 - 1) pieces of second exclusive-or data are obtained.
8. A commercial cipher random number security detection method according to claim 7, characterized in that Perform a Z-test on the exclusive-or data to determine whether the exclusive-or data meets the random probability expectation, which includes the following sub-steps: The first exclusive-OR data and the second exclusive-OR data both belong to exclusive-OR data. For any exclusive-OR data, count the number of 1s and the number of 0s in the exclusive-OR data, and mark them as K1 and K2 respectively. Calculate K1 / (K1 + K2), and name the calculation result as the exclusive-OR one-zero ratio. Count the exclusive-OR one-zero ratio of each exclusive-OR data, number the exclusive-OR one-zero ratio, and represent it by the symbol X j where j is a positive integer and j is the serial number of X; Through the formula Calculate the overall standard deviation of the XOR one-zero ratio, where S is the overall standard deviation of the XOR one-zero ratio, max(j) is the maximum value of j, is the mean value of X j ; Judge whether the exclusive-or data meets the random probability expectation through the Z-test.
9. A commercial cryptographic random number security detection method according to claim 8, characterized in that Judge whether the exclusive-or data meets the random probability expectation through the Z-test, which includes the following sub-steps: The random probability expectation includes the exclusive-or probability expectation, which is represented by the symbol μ; Calculate the Z value of the exclusive-OR data through the formula where Z is the Z value of the exclusive-OR data; Set the significance level α, find the rejection region of the significance level α, and compare whether Z is within the rejection region. If Z is within the rejection region, mark that the test random number does not meet the random probability expectation. If Z is not within the rejection region, mark that the test random number meets the random probability expectation.
10. A commercial cryptographic random number security detection system for implementing a commercial cryptographic random number security detection method according to any one of claims 1-9, characterized in that, It includes a test random number generation module, a bit grouping module, a bit calculation module, and a random number security verification module; The test random number generation module, the bit grouping module, and the random number security verification module are respectively connected to the bit calculation module for data connection; The test random number generation module is used to connect to a commercial cryptographic random number generator, and the commercial cryptographic random number generator randomly generates a first test quantity of random numbers according to time, named test random numbers; The bit grouping module is used to group the bit data within the same test random number to obtain bit groups; The bit calculation module is used to construct a bit calculation model, calculate the bit groups and different test random numbers to obtain exclusive-OR data; The random number security verification module is used to perform a Z-test on the exclusive-OR data to determine whether the exclusive-OR data meets the random probability expectation.
Citation Information
Patent Citations
Online detection method of random number generator
CN110531957A
Random number verification method and device, storage medium and electronic equipment
CN117093983A
Randomness quantitative test method of random function and terminal
CN118519891A
Method and device for protecting quantum random number and quantum security module
CN119011134A
Random number slip and swap generators
US20040205095A1