Apparatus and method for testing a sequence generated by a random number generator
By applying statistical testing and dynamic threshold comparison in the test equipment of the hardware random number generator, the problems of insufficient test delay and error probability adaptability in the existing technology are solved, and flexible and efficient verification of the sequence generated by the random number generator is achieved. .
Patent Information
- Application Number
- CN201980090433.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2018-12-27
- Filing Date
- 2019-12-20
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2039-12-20
AI Technical Summary
Existing test methods and equipment used to test random number sequences generated by hardware random number generators have uncontrollable delays and cannot adapt to the target error probability, and cannot effectively evaluate the quality of the bit sequences generated by the random number generator.
Provides an apparatus and method for verifying the validity of a bit sequence generated by a random number generator by applying one or more statistical tests, comparing test parameters to thresholds, and determining the threshold based on a target error probability, including a comparator and a verification unit to determine the validity of a sequence and, if necessary, reject the sequence.
It realizes flexible and fully delay-controllable testing of the sequence generated by the random number generator, and can dynamically adjust test parameters according to application requirements, reduce false positives and improve test efficiency.
Smart Images

Figure CN113632063B_ABST
Abstract
Description
Technical Field
[0001] The present invention generally relates to apparatus and methods for testing sequences generated by a random number generator. Background Art
[0002] A random number generator is used to generate a set of random numbers (in the form of a bit stream) for use in many systems. For example, a random number generator can be used in a cryptographic system to generate random cryptographic keys for securely transmitting data.
[0003] Random number generators include: hardware random number generators, also called true random number generators (TNRGs), which generate a set of numbers from a physical process rather than a computer program (a non-deterministic source); and pseudo-random number generators, which generate numbers from a deterministic source (e.g., a deterministic algorithm).
[0004] TNRGs can be based on microscopic phenomena that generate low-level, statistically random "noise" signals, such as thermal or shot noise, photoelectric effects, involving beam splitters and other quantum phenomena. TNRGs typically include a transducer that converts quantities or data derived from physical phenomena into electrical signals, an amplifier, additional components configured to increase the amplitude of random fluctuations to a measurable level, and an analog-to-digital converter configured to convert the output thus obtained into a digital number (e.g., a binary number 0 or 1). The TRNG then repeatedly samples the randomly varying signal to obtain a series of random numbers.
[0005] The quality of random number generation is crucial for implementing cryptographic systems (e.g., key generation, authentication protocols, padding, digital signatures, encryption algorithms). In such applications, security closely depends on the quality of the generated random numbers.
[0006] In fact, many attacks target weaknesses in the way cryptographic systems are implemented. Such weaknesses can stem from the quality of the random numbers generated and can be exploited by attackers in an attempt to subvert the system.
[0007] There are several testing methods and systems for testing the quality (especially randomness) of generated random numbers, most of which are based on statistical tests.
[0008] This test is applied to check whether a sequence of randomly obtained numbers has two main statistical properties:
[0009] - the generated values should be evenly distributed, and
[0010] - Generated values should be independent of previously generated values.
[0011] Recognizing this, standardization bodies such as NIST and BSI have established statistical test suites given binary sequences of 20,000 bits. The purpose of this document is to provide a mathematical interpretation of the tests and to establish the general mathematical formula given an N-bit sequence, error probability, and other parameters.
[0012] There is a current requirement to test the set of random numbers generated by TNRG as it may impact the performance of systems that use such random numbers, such as AIS31, FIPS140-1, NIST, and DIEHARD tests.
[0013] Standardization bodies such as NIST and BSI have established statistical test suites for binary sequences given a fixed number of bits (20,000 bits).
[0014] In the existing method, a statistical test is therefore applied each time the TRNG generates a 20,000-bit sequence, which calculates different sums based on the sequence. These sums are then compared with predefined and fixed thresholds, and depending on the comparison result a decision is made whether the sequence is accepted or rejected. The threshold used to perform the comparison is predefined as a function of a fixed error probability.
[0015] Existing test methods and equipment introduce uncontrollable delays. Furthermore, they are not suitable for addressing the target error probability.
[0016] Therefore, there is a need for improved methods and apparatus for testing bit sequences generated by a random number generator. Summary of the invention
[0017] To address these and other problems, there is provided an apparatus for testing a bit sequence generated by a random number generator, the apparatus being configured to, in response to detecting N bits generated by the random number generator, apply one or more statistical tests to the bit sequence, each statistical test providing at least one sum value derived from the bits of the sequence. The testing apparatus may include:
[0018] - a comparator for comparing at least one test parameter associated with each statistical test to one or more threshold values;
[0019] - a verification unit configured to determine whether the bit sequence is valid or not depending on the comparison performed by the comparator for each statistical test;
[0020] Therein, at least one test parameter and at least one threshold are determined according to N and according to a target error probability.
[0021] In some embodiments, the at least one or more statistical tests applied to the sequence include a set of statistical tests that provide at least one sum value derived from bits of the sequence, the at least one sum value providing at least one test parameter for each statistical test, the apparatus further comprising:
[0022] a threshold determination unit for determining, for each statistical test of the set of statistical tests, a lower threshold and an upper threshold as a function of N and as a function of a target error probability associated with each sum value;
[0023] The comparator is configured to compare each sum value with an associated lower and upper threshold for each statistical test.
[0024] In such an embodiment, the comparator may be configured to output a validation bit for the statistical test if each sum value is strictly above an associated lower threshold and strictly below an upper threshold.
[0025] Furthermore, the verification unit may be configured to reject the bit sequence if at least one sum value for the statistical test is below or equal to an associated lower threshold value or above or equal to a corresponding upper threshold value.
[0026] In one embodiment, the statistical test may include an AIS unit test that provides a sum value T1, corresponding to a lower threshold L1 and an upper threshold H1 equal to:
[0027] as well as
[0028]
[0029] Where α represents the target error probability.
[0030] In one embodiment, the statistical test may include an AIS poker test, where the test device determines the sum value T2. The corresponding lower threshold L2 and upper threshold H2 are equal to:
[0031] as well as
[0032]
[0033] where M represents the length of consecutive blocks in the bit sequence and α represents the error probability.
[0034] In an embodiment, the statistical test may include an AIS run test, where the test device determines a sum value T for each run of length k. 3(N,k) , for each run of length k, the lower threshold L 3,k and upper threshold H 3,k equal:
[0035]
[0036]
[0037] where α represents the target error probability and
[0038] In some embodiments, the at least one or more statistical tests applied to the sequence include an additional set of statistical tests, for each statistical test the test device determines a test parameter determined as a function of N and as a function of the probability of error.
[0039] In particular, the statistical test includes an AIS longest run test, the test parameter is the run length k, and the length k is determined according to the following equation:
[0040]
[0041] where α represents the probability of a long run. The comparator then compares the test parameter k with the maximum length of the run.
[0042] In one embodiment, the bit sequence length N may be changed between one or more clock cycles.
[0043] New values for the error probability and the number N may be received at different times or simultaneously.
[0044] A system implemented on at least one integrated circuit is also provided, the system comprising a device for using a random bit sequence generated by a random number generator, wherein the device further comprises a testing device according to any of the preceding embodiments for testing each random bit sequence generated by the random number generator before use.
[0045] A method for testing a bit sequence generated by a random number generator is also provided, wherein the method includes, in response to detecting N bits generated by the random number generator, applying one or more statistical tests to the bit sequence, each statistical test providing at least one test parameter of bits from the sequence, the testing method including: comparing at least one test parameter associated with each statistical test to one or more thresholds; determining whether the bit sequence is valid depending on the comparison performed for each statistical test in the comparing step. At least one of the test parameter and the at least one threshold is determined based on N and based on a target error probability.
[0046] The present invention thus enables control of the delay / debit of a random number generator implemented in a given system.
[0047] Thus, embodiments of the present invention provide a flexible and fully delay controllable RNG throughout all phases of operation. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate various embodiments of the invention and, together with the general description of the invention given above and the detailed description of the embodiments given below, serve to explain embodiments of the invention:
[0049] - Figure 1 An apparatus for testing a random number sequence generated by a random number generator is depicted in accordance with some embodiments.
[0050] - Figure 2 The running probabilities used in the longest test according to some embodiments are shown.
[0051] - Figure 3 is a flow chart depicting a method of testing a random number sequence generated by a random number generator according to some embodiments.
[0052] Furthermore, the detailed description is supplemented by Exhibit E1. This exhibit is placed separately in order to clarify the detailed description and to facilitate reference. However, it forms an integral part of the description of the invention. DETAILED DESCRIPTION
[0053] Embodiments of the present invention provide a device and method for testing a random number sequence generated by a hardware random number generator, such as a TRNG (True Random Number Generator). In the following description, the random number generator will also be referred to as RNG.
[0054] refer to Figure 1 , shows an exemplary operating environment 100 of a test device 10 including a cryptographic system 12 that uses a random number sequence generated by a hardware random number generator 11 for generating keys, performing authentication, generating signatures, and / or performing encryption, among other things.
[0055] The test device 10 is configured to test the quality of the random number sequence generated by the random number generator 11. The set of statistical tests 103 includes one or more statistical tests T1, T2, ..., T P , where P is at least equal to one.
[0056] It should be noted that the present invention is not limited to use of test device 10 in cryptographic system 12, but may be generally used in any system or device that uses a random number sequence generated by hardware RNG 11. System 100 and / or system 12 may be implemented on one or more integrated circuits.
[0057] For purposes of illustration only, the following description of some embodiments will be made with reference to cryptographic system 12 .
[0058] The statistical test Test_j may be configured to test the statistical properties required by the cryptographic system, including the backward and forward unpredictability properties of the random number generator 11 .
[0059] Exemplary statistical tests Tj include, for example, AIS, tests that test the increase in entropy for each generated number, and the like.
[0060] More specifically, the test device 10 can be configured to receive an expected error probability α and a frequency number N during operation of the system 100, the frequency number N defining the number of bits of the sequence generated by the RNG 11. N can be lower than the maximum number of bits M that the RNG 11 can generate. In particular, N can be adjusted during operation of the system depending on a plurality of criteria. Thus, N can change between one or more clock cycles. Advantageously, the value N can be different from a predefined fixed value and can therefore adopt a value different from the value N'=20000 that is typically used to activate statistical tests. New values for the error probability α and the frequency number N can be received at different times or simultaneously.
[0061] As used herein, the expected error probability (also referred to herein as the "significance level" or "target error probability") refers to the error probability of a test performed on a sequence generated by the RNG 11, i.e., the probability that a test performed by a test device using a set of statistical tests 103 on a given sequence generated by the RNG 11 returns an erroneous result. Thus, the expected error probability α is defined as the probability that a test rejects a sequence generated by the RNG 11, assuming that the sequence is truly random.
[0062] The RNG 11 may be activated to generate a random number sequence comprising a plurality of bits from an entropy source (eg, for key generation) using the expected error probability τ and the current value of the frequency number N used by the cryptographic system 12 .
[0063] The test device 10 may be configured to test the bit sequence generated by the random number generator 11 by applying one or more statistical tests 103 to the bit sequence in response to detecting N bits generated by the random number generator. Advantageously, the number N and the target probability may vary depending on the application of the invention (N may be defined to be as small as possible if fast processing time is required, or may be defined to increase if testing is required to limit false positives as much as possible).
[0064] Each statistical test 103 provides at least one test parameter derived from the bits of the sequence.
[0065] The test device may include a comparator 102 configured to compare a test parameter associated with each statistical test with one or more thresholds and a random number sequence verification unit 105 configured to determine whether the N-bit sequence is valid depending on the comparison made by the comparator 102 for the statistical test.
[0066] The random number sequence verification unit 105 may be configured to reject or verify the N-bit random number sequence using the results of the statistical test 103 applied to the sequence. j Return to the random number sequence verification unit 105.
[0067] In one embodiment, the random number sequence verification unit 105 may be configured to verify the random number sequence only if, for all P statistical tests, for the considered N-bit sequence, condition (1) applied to each sum value obtained by performing the statistical test is satisfied (i.e., for j=1 to K, j =O j,2 ).
[0068] Each statistical test 103 may be a statistical test for testing the randomness in the N-bit binary sequence generated by the RNG 11 .
[0069] Advantageously, at least one of the test parameter and the threshold is determined as a function of N and as a function of a target error probability.
[0070] In response to the generation of the N-bit random number sequence (i.e., in response to detecting that the number of bits in the random number sequence is equal to N), the test device 10 thus performs a set of P statistical tests (P is at least equal to 1) as random bits are received from the random number generator 11. The set of P statistical tests may be stored in the storage unit 103.
[0071] In some embodiments, the set of statistical tests 103 includes a set of statistical tests each for determining one or more sum values (or multiple values if the test includes multiple runs) and an error probability α derived from N bits of a random number sequence.
[0072] The test device 10 may further include a threshold determination unit 101 configured to determine a threshold value including a lower threshold value L j and upper threshold H j At least one pair of thresholds, for each test Test_j, the lower threshold L j and upper threshold H j Depends on parameter N and depends on significance level parameter α.
[0073] The test device 10 may be configured to check, for each statistical test Test_j, whether each value (sum result) returned by the statistical test Test_j under consideration satisfies a corresponding threshold value pair (lower threshold value L j and upper threshold H j ) related conditions.
[0074] In such an embodiment, the comparator 105 may be configured to compare each sum result returned by the statistical test Test_j with the lower threshold L of the associated pair. j and upper threshold H j Make a comparison.
[0075] In one embodiment, the comparator 105 of the test device may be configured to determine whether each value Tj (sum result) returned by the statistical test Test_j is strictly above the lower threshold Lj of the associated threshold pair and strictly below the upper threshold Hj of the associated threshold pair. j Based on the corresponding threshold pair (lower threshold L j and upper threshold H i )The condition checked for the value Tj can be expressed as:
[0076] L j <T j <H j (1)
[0077] It should be noted that in some embodiments, multiple sum values may be determined for each statistical test (e.g., when the test includes multiple runs), and a corresponding threshold pair may be determined for each value, with condition (1) being tested for each sum value and each corresponding threshold pair.
[0078] Comparator 105 may return a result value of O for each test Test_j applied to an N-bit sequence. j , if the test condition of equation (1) is not met, it is set to the first value Oj ,1 , or if the test condition of equation (1) is satisfied, it is set to the second value Oj ,2 .
[0079] To facilitate understanding of some embodiments of the present invention, the following definitions are provided:
[0080] As used herein, "null hypothesis H0" refers to the statement that a provided sequence is truly random.
[0081] A "test statistic, S," is a numerical summary that reduces the observed data to a single value.
[0082] The "p-value" is the probability that, when H0 is true, the statistical test will produce the same or greater result than was actually observed.
[0083] The “significance level” α (also referred to herein as the “error probability”) refers to the probability of rejecting H0 when the hypothesis H0 is true.
[0084] Given these definitions, the following statistical tests are performed:
[0085] -If p-value ≥ α, accept H0;
[0086] -If p-value < α, reject H0.
[0087] Given a statistical model for the test statistic S, the p-value can be calculated.
[0088] This model can be applied to all statistical tests used to link empirical data from real-world RNGs to stochastic models.
[0089] The set of statistical tests 103 may include, for example, one or more tests of the AIS31 test suite, which includes:
[0090] -A Monobit Test;
[0091] -A Poker Test;
[0092] -A Runs Test;
[0093] -A Longest Run Test.
[0094] For illustrative purposes only, the following description of some embodiments will be made with reference to one or more tests of the AIS31 suite.
[0095] In the following description, consider including bit b i And have a random number sequence of length N.
[0096] In one embodiment, the set of statistical tests 103 may include unit tests. Unit tests are configured to determine the ratio of the number of 1s and 0s in a given bit sequence. For a random sequence, the average number of 1s (and therefore 0s) in the expected sequence is 1 / 2.
[0097] According to one embodiment, the AIS31 unit test checks the N-bit sequence by computing the sum T1 as follows:
[0098]
[0099] According to one embodiment of the present invention, a set of statistical parameters {H0, S N ,α} to run the unit tests:
[0100] -H0: Assumption is made: the generated bit sequence is random;
[0101] -Parameter S N Defined as:
[0102]
[0103] The error probability α is set to:
[0104] α=9.6×10 -7 (3)
[0105] -Observations to be tested:
[0106]
[0107] Considering (observation to be tested), for large values of N, the reference distribution for such observations is the half-normal distribution. As used herein, a half-normal distribution refers to a normal distribution with a mean of 0 (zero). A definition of a normal distribution is provided in Exhibit E1.1. If the sequence is random, then adding one and subtracting one will tend to cancel each other out, leaving the test statistic at approximately 0.
[0108] The p-value (the probability that the statistical test will be the same or greater than the actual observed result when H0 is true) is given by:
[0109] pvalue=erfc(S obs ) (5)
[0110] In equation (1), erfc(z) represents the complementary Gaussian error function:
[0111]
[0112] For a half-normally distributed random variable X, erfc(x) is the probability that X lies outside the range [-x, x].
[0113] According to the test method, H0 is accepted if:
[0114] pvalue≥α (7)
[0115] According to equations (4) and (5), equation (7) can be rewritten as:
[0116]
[0117] Thanks to erfc -1 is a decreasing function:
[0118]
[0119]
[0120] According to equation (2):
[0121]
[0122] Equation (10) can be rewritten as:
[0123]
[0124] By dividing equation (12) by two, we obtain the following inequality:
[0125]
[0126] Given N, the length of the sequence is:
[0127]
[0128] Therefore, for unit testing, the condition in equation (1) can be rewritten as:
[0129] L1<T1
[0130] in:
[0131] as well as
[0132]
[0133] The test device 10 may then be configured to perform a unit test on the N-bit random number sequence generated by the RNG 11 and test whether the resulting sum T1 is comprised between a lower threshold L1 and an upper threshold H1 , both depending on N and the error probability α.
[0134] The comparator 105 will return a result value O1 for the single bit test applied to the N-bit sequence. If the test condition of equation (1) is not satisfied, the result value O1 is set to the first value O. 1,1 , or if the test condition of equation (1) is satisfied, the result value O1 is set to the second value O 1,2 .
[0135] It should be noted that for N = 20000 and α = 9.6 × 10 -7 , the condition (1) for the unit test is:
[0136] 9653.54133637<T1<10346.4586636
[0137] In contrast, in the traditional approach, the AIS31 unit test calculates the sum T1 as A sequence of 20000 bits is checked taking into account a fixed lower threshold and a fixed upper threshold (such thresholds are statically defined, independent of the chosen value N and independent of the error probability α). In general, the test fails if T1 falls outside the range defined by the fixed thresholds.
[0138] In some embodiments, the set of statistical tests 103 may include a poker test.
[0139] In one embodiment, to estimate condition (1) for the poker test, the following statistical parameters for running the poker test are defined:
[0140] -H0: Assumption is made: the generated bit sequence is random;
[0141] -Test Statistic S N,M is defined as:
[0142]
[0143] In equation (17), N represents the length of the sequence, M represents the length of the contiguous block, and f(i) represents the number of occurrences of each of the possible M-bit values. Given a real number x, Represents the integer part of x.
[0144] In addition, for the poker test, the error probability α is defined as α = 1.014 × 10 -6 .
[0145] The poker test consists of determining the proportion of 1s in each M-bit block. The frequency of 1s in each M-bit block should be M / 2, as expected from a random sequence. The number of occurrences f(i) is normally distributed, so S N,M Following the freedom degree of 2 M -1 "chi square" (χ 2 ) distribution. Exhibit E1.2 provides the definition of the chi-square distribution.
[0146] To determine whether there is a significant difference between the expected and observed frequencies, the observed Restricted to DOF 2 M -1 Within the two critical values of , the error probability is given as α. In AIS31, the error probability can be chosen to be equal to 30%×α and 70%×α. Therefore, the lower bound is The upper bound is This gives the general formula for T2, given N and M:
[0147]
[0148] Chi-square 2 The distribution has only one parameter, which determines its degrees of freedom. This means that no matter what N is, the bounds are the same unless M changes.
[0149] Therefore, the condition of equation (1) for unit testing can be rewritten as:
[0150] L2<T2<H2
[0151] The lower threshold L2 and upper threshold H2 are defined as follows:
[0152] as well as
[0153]
[0154] As shown in equations (19) and (20), the lower threshold L2 and the upper threshold H2 also depend on N and on the error probability α. In the case of the poker test, the lower threshold L2 and the upper threshold H2 also depend on M (M represents the length of the continuous block).
[0155] The test device 10 may thus be configured to perform a poker test on the N-bit random number sequence generated by the RNG 11 and to test whether the resulting sum T2 is comprised between a lower threshold L2 and an upper threshold H2 , both depending on N and on the error probability α.
[0156] For the poker test applied to the N-bit sequence, the comparator 105 will return the result value O1. If the test condition of equation (1) is not satisfied, the result value O1 is set to the first value O. 1,1 , or if the test condition of equation (1) is satisfied, the result value O1 is set to the second value O 1,2 .
[0157] For example, according to the test apparatus and method applied to poker testing, for M=4 and α=1.014×10 -6 :
[0158]
[0159]
[0160] and:
[0161] 1 562 820,6684439≤T2(N,M)≤1 580 428,499198625
[0162] In contrast, in the traditional approach, the poker test:
[0163] - First divide the sequence of N=20000 bits into a fixed number of 5000 consecutive 4-bit segments, then count and store the number of occurrences of each possible 4-bit value.
[0164] - Calculate T2 sum:
[0165]
[0166] - Check whether the sum T2 is strictly comprised between a fixed lower threshold and a fixed upper threshold, both of which are statically defined independently of the chosen value N and the target error probability α.
[0167] Typically, if T2 falls outside the range defined by a fixed threshold, the test fails.
[0168] In some embodiments, the set of statistical tests 103 may include operational tests.
[0169] The purpose of running the test is to determine if the changes of 1s and 0s are too fast (0101010101) or too slow (0000011111).
[0170] A run is defined as the largest sequence of consecutive bits of either all ones or all zeros.
[0171] The occurrences of runs of all lengths (≥ 1) in the sample stream (for consecutive zeros and consecutive ones) can be counted and stored. The run test passes if each of the number of occurrences of a run (of length 1 to 6) is within the corresponding interval specified below. This is true for both zeros and ones; that is, all 12 counts must lie within the specified interval. For the purposes of this test, runs greater than 6 are considered to be of length 6.
[0172] T3(N,k) represents a run of length k of bits 0 or 1 occurring in a sequence of length N.
[0173] In order to estimate the conditions according to formula (1) for the run test, the following statistical parameters for applying the run test are defined:
[0174] -H0: Assumption is made: the generated bit sequence is random;
[0175] -S specifies the number of runs of length k, denoted by T3(N,k), where n is the sequence length; and
[0176] - Error probability α = k × 10 -6 , where k∈{3.25; 1.33; 0.85; 0.40; 0.10}.
[0177] Assuming that the sequence bits are identically distributed, the test statistic T3(n,k) for the test run is considered to be normally distributed. The mean of this distribution is Because the probability of zero or one is the same for each run. Therefore, in N / 2, there are k runs of 0 or 1, and each bit has a probability of 1 / 2 occurring. Therefore, the expected mean is If the experiment is run infinitely many times, the sum of all k runs is N / 2.
[0178] As a result can be written as:
[0179]
[0180] Consider observation The p-value is:
[0181]
[0182] The quantity from equation (22) can then be compared to the error probability α. The run test passes if:
[0183] p-value ≥ α (23)
[0184] According to equation (22), condition (23) can be rewritten as:
[0185]
[0186] Equation (23) can be further formulated as follows:
[0187]
[0188]
[0189] Therefore, for each run k, the condition of equation (1) for the run test can be rewritten as:
[0190] L 3,k <T 3(N,k) <H 3,k (27)
[0191] Among them, the lower threshold L 3,k and upper threshold H 3,k The definition is as follows:
[0192]
[0193]
[0194] As shown in equations (28) and (29), the lower threshold L 3,k and upper threshold H 3,k It also depends on N and on the error probability α (because The test device 10 may therefore be configured to perform a run test on the N-bit random number sequence generated by the RNG 11 and test that for each run of length k, the sum of the results T 3(N,k) Is it included in the lower threshold L 3,k and upper threshold H 3,k The comparator 105 will return the result value O1 of the run test applied to the N-bit sequence, and if the test condition of equation (1) is not satisfied for at least one run of length k, the result value O1 is set to the first value O. 1,1, or if the test condition of equation (1) is satisfied for each run of length k considered, the result value O1 is set to the second value O 1,2 .
[0195] For example, for N = 20000, k∈[1,2,3,4,5,6] and α = K×10 -6 , where k∈{3.25; 1.33; 0.85; 0.40; 0.10}, the results shown in Table 1 are obtained:
[0196] Run length Required interval 1 2267.04399878–2732.45600122 2 1078.99101268–1420.88398732 3 501.911931832–748.088068168 4 222.906024885–402.125225115 5 89.678247301–222.853002699 6+ 89.678247301–222.853002699
[0197] Table 1
[0198] In contrast, in the conventional approach, a run is defined as the largest sequence of consecutive bits of all 1s or all 0s that is part of a 20,000-bit sample stream with intervals given by Table 2 below:
[0199] Run length Required interval 1 2267–2733 2 1079–1421 3 502–748 4 223–402 5 90–223 6+ 90–223
[0200] Table 2
[0201] In some embodiments, statistical test 103 may include providing a sum value T i One or more additional statistical tests, but instead of testing the sum value T i , the test device 10 may be configured to test the N-bit sequence by comparing a test parameter determined according to the frequency number N and the error probability α with a threshold value.
[0202] For example, the set of statistical tests 103 may include the longest running test.
[0203] In the traditional method, for a sample of 20,000 bits, if there is no long run, the longest run test passes.
[0204] According to an embodiment of the present invention, the longest run test can be used to determine the run length k corresponding to the target error probability α (which in the case of the longest run test corresponds to the long run probability P N (k)), and then compares the value k with the threshold to test the bit sequence. If the integer part of the determined value k is less than the longest length of the run The test passes. Otherwise, the test fails.
[0205] More specifically, we can use the long run probability P N (k) to determine the index k, the long run probability P N (k) represents the probability that a run (zeros or ones) of length greater than or equal to k appears in the N-bit sequence under consideration.
[0206] P N (k) can be represented by the addition of two mutually exclusive event probabilities. One of the event probabilities represents the probability that a run longer than k appears in the N-1 position, while the other event probability represents the probability that a run not longer than k appears in the N-1 position but appears in the rightmost k positions of N, as Figure 2 This means:
[0207]
[0208]
[0209] Equations (30) and (31) yield the general expression for given k and N:
[0210]
[0211] This corresponds to arithmetic and geometric progressions of this type:
[0212] U N =a×U N-1 +b (33)
[0213] therefore:
[0214] U N =a N ×(U0-r)+r (34)
[0215] In equation (34), therefore:
[0216]
[0217] In equation (35), U0=0 and r=1.
[0218] Equation (35) can be rewritten as:
[0219]
[0220] In equation (36), k can therefore be found as follows:
[0221]
[0222]
[0223]
[0224]
[0225] When P N When (k) = α, Equation 36.4 can be rewritten as a function of N and α:
[0226]
[0227] For example, for N = 2000 and P N (k) = 10 -6 ,
[0228] The following table provides examples of test parameters calculated for the unit test (T1), the poker test (T2), the run test and the longest run test according to the previous equations, which provide the lower / upper thresholds Li and Hi as a function of N and α (for T1, T2, T3) or the longest run parameter k as a function of α for N∈{5000, 10000, 20000, 40000}, the value N=20000 being a fixed value commonly used for testing bit sequences generated by RNG 11 (defined by standards NIST FIPS 140-2 and BSI AIS 31). In the example tables below, given values of α are selected for illustration purposes, but α may vary:
[0229]
[0230] Table 3
[0231] Figure 3 is a flowchart of a method for testing a random bit sequence generated by RNG 11 using a set of tests according to some embodiments, wherein the tests provide a sum of tests Ti (e.g., T1, T2, and T3) against which condition (1) is checked, the condition being defined by a lower threshold Li and an upper threshold Hi, both of which depend on N and α.
[0232] In step 300, an error probability and a bit sequence length N are received.
[0233] In step 302, the random number sequence generated by the RNG 11 is detected.
[0234] In step 304, it is checked whether the RNG 11 has generated N bits.
[0235] If yes, then in step 306, each of the P statistical tests 103 is applied to the k-bit random number sequence received from the RNG 11. Otherwise, the process returns to step 302. The execution of each statistical test provides at least one sum Ti. In the case of a run test, each considered run k provides a sum T i,k .
[0236] In step 310, for each statistical test sum T obtained for the statistical test i (or for each run k of the test run Ti,k ), the lower threshold L is determined in association with the statistical test sum i (or L for each run k of the test i,k ) and upper threshold H i (or H for each run k of the test i,k ), the lower and upper thresholds depend on N and on the error probability α.
[0237] In step 312, the associated lower threshold L is used i (or L i,k ) and the associated upper threshold H i (or H i,k ), for each statistical test sum T provided by each statistical test i (or T for each run k of the test i,k ) to test condition (1).
[0238] In step 314, if at least one statistical test does not satisfy condition 1 (block 312), the random bit sequence may be rejected. Otherwise, steps 310 and 312 are repeated for the other statistical tests because not all statistical tests have been processed (step 313). In step 316, if the sum of all statistical tests satisfies condition 1, the random bit sequence is verified and the N random bits may be transmitted to the target system 12.
[0239] Exhibit E1.3 provides a test method for testing a bit sequence generated by a RNG when random bits arrive in microcode format using statistical testing according to one embodiment:
[0240] -Unit testing (T1);
[0241] - Poker Test (T2);
[0242] - Run the test (T3);
[0243] -The longest running test (T4).
[0244] The test method of Exhibit E.1.3 has an optimized delay and is particularly suitable for testing N-bit sequences in a chip-embedded test device 10 .
[0245] Embodiments of the invention are thus able to dynamically select a number N of raw bits to test given a target debit / delay. They also provide a dynamic error probability τ given a target application and (by waiting for a fixed number of raw bits) fully controllable delays at all stages (compared to prior art techniques which generate uncontrollable delays).
[0246] Embodiments of the present invention are applicable to embedded statistical testing (testing performed within a chip of a system or device using a random number sequence) and online statistical testing.
[0247] In some applications that require fast processing, the value of N can be chosen to be less than 20000, thereby reducing the overall time required to test the bit sequence. In contrast, for applications that require a more rigorous evaluation of the generated random numbers, the sequence size N can be increased in order to reduce the number of false positive detections.
[0248] Therefore, the embodiments of the present invention can flexibly adjust N according to application requirements.
[0249] The test device according to the embodiment of the present invention can be used in various applications, for example:
[0250] -Simulation applications, which simulate and model complex phenomena (e.g., Monte Carlo integration used in finance and engineering);
[0251] - Random sampling applications, which select random samples from a larger data set;
[0252] - Cryptographic applications, such as authentication, signing, encryption, digital signature generation, cryptographic key generation systems or Internet encryption protocol applications;
[0253] - Chip manufacturing and seeding of device-specific keys, e.g. for near field communication or device ID; - Machine learning and statistical learning applications (true random number generators can be used to obtain samples from a random distribution).
[0254] The exemplary target system 12 includes a cryptographic system that implements cryptographic functions based on one or more cryptographic keys to ensure data and / or signal security, authentication, protection, and privacy, such as:
[0255] - Smart cards, devices that store cryptographic keys (e.g. wallets), smart card readers (e.g., automated teller machines (ATMs) for financial applications);
[0256] -Digital electronic devices such as RFID tags;
[0257] -Embedded secure element;
[0258] - Computers (e.g., desktops and laptops), tablets;
[0259] - Routers, switches, printers;
[0260] - Mobile phones, such as smartphones, base stations, relay stations, satellites;
[0261] - Internet of Things (IoT) devices, robots, drones; and
[0262] - Recorders, multimedia players, removable storage devices (e.g. memory cards and hard disks), where login access is monitored by encryption mechanisms, etc.
[0263] In some alternative embodiments, the functions, actions and / or operations specified in the flow chart, sequence diagram and / or block diagram can be reordered, processed serially and / or processed concurrently in accordance with embodiments of the present invention. In addition, any one of the flow chart, sequence diagram and / or block diagram may include more or fewer frames than those shown in accordance with embodiments of the present invention.
[0264] In particular, it should be noted that the statistical tests 103 may be tested in any order, sequentially or in parallel.
[0265] Although the invention has been illustrated in its entirety by the description of various embodiments, and although these embodiments have been described in considerable detail, it is not the intention of the applicant to restrict or in any way limit the scope of the appended claims to such detail. Additional advantages and modifications will be readily apparent to those skilled in the art. Therefore, the invention in its broader aspects is not limited to the specific details, representative apparatus and methods, and illustrative examples shown and described. In particular, it should be noted that the invention is not limited to statistical tests on the AIS31 test set and other types of statistical tests for testing sequences generated by the RNG 11 may be used, such as:
[0266] - Other tests from the AIS31 complex, including, for example, the autocorrelation test (test 5), the uniform distribution test (test 6), the homogeneity test or the comparison test for multinomial distributions (test 8), the entropy estimation test (test 8).
[0267] - Tests from the NIST test suite, such as according to the NIST SP800-22 test suite, such as serial test, frequency (unit) test, etc.
[0268] Display E1
[0269] definition
[0270] E1.1. Normal distribution
[0271] If the probability density function of a (continuous) random variable X is 2 The normal distribution of:
[0272]
[0273] The density function of a continuous random variable X satisfies:
[0274] -(x)≥0 for all x∈]-∞,+∞[
[0275] -
[0276] -For all
[0277] E1.2 “Chi-square” χ 2 distributed
[0278] χ 2 The chi-squared distribution can be used to compare the observed frequency of an event with the expected frequency under its assumed distribution. The chi-squared distribution with k degrees of freedom occurs when the squares of k independent random variables with a standard normal distribution are added. 2 distributed.
[0279] Let k ≥ 1 be an integer. A continuous random variable X has k degrees of freedom if its density function is 2 distributed:
[0280]
[0281] where Γ(x) is the gamma function defined for t>0:
[0282]
[0283] E.1.3: Test methods
[0284]
Claims
1. A device (10) for testing a bit sequence generated by a random number generator (11), wherein: The device is configured to, in response to detecting N bits generated by the random number generator (11), apply one or more statistical tests (103) to the bit sequence, each statistical test configured to test the randomness in the N bits generated by the random number generator, each statistical test providing at least one sum value derived from the bits of the sequence, wherein the device comprises: - a comparator for comparing at least one test parameter associated with each statistical test to one or more threshold values; a verification unit (105) configured to determine whether the bit sequence is valid or not depending on the comparison performed by the comparator for each statistical test; wherein at least one of the test parameter and at least one threshold value is determined according to N and according to a target error probability, Wherein, the at least one test parameter corresponds to the sum value, and the device further comprises: a threshold determination unit (101) configured to determine, for each statistical test, at least one threshold pair, the at least one threshold pair comprising a lower threshold and an upper threshold, the lower threshold and the upper threshold depending on a parameter N and a target error probability, The comparator (102) is configured to compare each sum value with an associated lower threshold and an upper threshold for each statistical test.
2. The device according to claim 1, wherein: The comparator is configured to output a validation bit for a statistical test if each sum value is above the associated lower threshold and below the upper threshold.
3. The device according to claim 2, wherein: The verification unit is configured to reject the bit sequence if at least one sum value for a statistical test is below or equal to an associated lower threshold value or above or equal to a corresponding upper threshold value.
4. The device according to any one of claims 1 to 3, wherein: The statistical test (103) comprises an AIS unit test providing a sum value T1, corresponding to a lower threshold L1 and an upper threshold H1 equal to: as well as Wherein, α represents the target error probability.
5. The device according to any one of claims 1 to 3, wherein: The statistical test (103) comprises an AIS poker test providing a total value T2, corresponding to a lower threshold L2 and an upper threshold H2 equal to: as well as Wherein, M represents the length of consecutive blocks in the bit sequence, and α represents the error probability.
6. The device according to any one of claims 1 to 3, wherein: The statistical test (103) comprises an AIS run test which provides a sum value T for each run of length k. 3(N,k) , for each run of length k, the lower threshold L 3,k and upper threshold H 3,k equal: Where α represents the target error probability and 7. The device according to any one of claims 1 to 3, wherein: The length N of the bit sequence changes between one or more clock cycles.
8. The device according to any one of claims 1 to 3, wherein: New values for the error probability and the number N can be received at different times or simultaneously.
9. A device for testing a bit sequence generated by a random number generator, wherein: The device is configured to apply one or more statistical tests to the bit sequence in response to detecting N bits generated by the random number generator, each statistical test configured to test randomness in the N bits generated by the random number generator, each statistical test providing at least one sum value derived from bits of the sequence, the statistical tests comprising at least one statistical test comprising a plurality of runs, a run having a length k, wherein the device comprises: - a comparator for comparing at least one test parameter associated with said at least one statistical test with a threshold value; - a verification unit configured to determine whether the bit sequence is valid or not depending on the comparison performed by the comparator for the at least one statistical test; Therein, the at least one test parameter is related to the length of the run.
10. The device according to claim 9, wherein: The statistical test (103) comprises an AIS longest run test, wherein the test parameter corresponds to a run length k, and the run length k is determined according to the following equation: Among them, α represents the long run probability, Wherein, the threshold is the maximum run length.
11. A system implemented on at least one integrated circuit, the system comprising a device using a random bit sequence generated by a random number generator (11), wherein: The device further comprises a device according to any of the preceding claims 1-10 for testing a bit sequence generated by the random number generator.
12. A method for testing a bit sequence generated by a random number generator (11), wherein: The method comprises, in response to detecting N bits generated by the random number generator (11), applying one or more statistical tests (103) to the bit sequence, each statistical test being configured to test the randomness in the N bits generated by the random number generator, each statistical test providing at least one sum value based on the bits of the sequence, the method comprising: - comparing at least one test parameter associated with each statistical test to one or more threshold values; - determining whether the bit sequence is valid or not depending on the comparison performed for each statistical test in the comparing step; wherein the at least one test parameter corresponds to a sum value, The method further comprises the following steps: - for each statistical test, determining at least one threshold pair, said at least one threshold pair comprising a lower threshold and an upper threshold, said lower threshold and said upper threshold depending on a parameter N and a target error probability, The comparing step further comprises comparing each sum value with an associated lower threshold and upper threshold for each statistical test.
