Method for generating random numbers
The method leverages processor registers to generate random numbers efficiently, addressing complexity and speed issues in existing methods by iteratively extracting bits, achieving high entropy and rapid generation without additional hardware.
Patent Information
- Application Number
- FR2021005603
- Authority / Receiving Office
- FR · FR
- Patent Type
- Patents
- Current Assignee / Owner
- Filing Date
- 2021-05-28
- Publication Date
- 2024-10-04
- Estimated Expiration
- 2041-05-28
AI Technical Summary
Existing methods for generating random numbers, particularly for high-security encryption, are complex, require hardware circuitry, and struggle to produce long random numbers with high entropy quickly.
A method utilizing the internal register of a processor, such as a clock register, to extract bits for generating random numbers without additional hardware, ensuring high entropy and rapid generation by iteratively extracting bits from the register, with variations including random or pseudo-random selection of bits and registers.
Generates random numbers with high entropy and no deterministic links, requiring no additional hardware, allowing for very long numbers in a short time, adaptable to various processor architectures.
Smart Images

Figure 00000009_0000 
Figure 00000009_0001 
Figure 00000010_0000
Abstract
Description
Title of the invention: Method for generating random numbers Technical field of the invention
[0001] The invention relates to the generation of random numbers.
[0002] Many techniques require random numbers, particularly in the field of cryptography when it comes to implementing high-security encryption algorithms such as AES, RSA, Diffie-Hellman, etc. But the use of random number draws occurs in many other fields, in particular games of chance, or even probabilistic modeling techniques or the selection of samples for statistical purposes. State of the prior art
[0003] There are multiple ways to generate random numbers, with varying levels of entropy, with entropy being defined as the measure of the effective degree of randomness (absence of deterministic character and predictability in the drawing) of the generated value.
[0004] In certain cases, the generation of "pseudo-random" numbers may be sufficient, that is to say numbers which are obtained by a process which is deterministic, but which produces values sufficiently independent of each other to satisfy the needs of the applications considered: for example modeling algorithms using probabilistic techniques, or sampling methods for statistical purposes.
[0005] On the other hand, in the case of data encryption in particular, it is essential that the series of random numbers delivered by the generator do not present any detectable link between the successive numbers, that is to say that the numbers produced are absolutely impossible to predict.
[0006] The methods for generating random numbers (and not simply pseudo-random numbers) used until now are mainly based on physical, material phenomena (for example thermal or electromagnetic noise) or on an unpredictable interaction with a user, for example the erratic movements of a mouse, which are neither cyclical nor deterministic.
[0007] These generators deliver random numbers with very high entropy but they have the disadvantage of being relatively complex, because they require hardware circuitry for collecting the physical phenomenon or interaction with the user, analog / digital converter circuits, an algorithmic module for generating the random digital value, etc.
[0008] Furthermore, they are poorly suited to the generation of very large random numbers (several tens or hundreds of bits), except at the cost of a time of excessively long response between the request to obtain the random number and the actual delivery of the result by the generator.
[0009] However, the most recent applications of high security encryption require the very rapid generation of long random numbers with high entropy.
[0010] The aim of the invention is to remedy these difficulties and limitations, by proposing a technique for generating random numbers offering, simultaneously: • very simple to implement, without the need for any hardware circuitry; • the ability to deliver random numbers as long as desired at a very high rate; • maximum entropy of the generated numbers, these having no deterministic link between them; and • the possibility, in certain implementations, of making the specific operation of the random generator depend on a higher level parameter, itself modified randomly at each iteration of the process, i.e. with a double degree of randomness for each number obtained. Statement of the invention
[0011] These aims are achieved according to the invention, by a method comprising the following successive steps: a. querying an internal register of the processor, the contents of the register being evolving content which changes over time; b. extraction at a given instant of n bits from the register, n > 1; c. using the n bits extracted in step b) as constituent bit(s) of a random number of N bits to be generated; d. repeating steps a) to c) until the N bits of the random number are obtained; and e. delivery of the random number to an application circuit or software.
[0012] According to various advantageous subsidiary implementation forms: • the register is a register for counting the pulses of a processor sequencing clock, in particular a register for counting the pulses directly coming from a clock oscillator; • the register is an event counting register of the; • steps a) to d) are performed within a processor firmware; • the n bits extracted in step b) are the least significant bit(s) of the register; • the given instant of extraction of the n bits in step b) is an instant determined by a random or pseudo-random process; • the given time of extraction of the n bits in step b) is a time determined in response to a request received from the application circuit or software; • the processor comprises a plurality of potentially interrogable internal registers, and the method further comprises, before step a), a prior step of selecting, by a random or pseudo-random process, one of the registers of the plurality of potentially interrogable internal registers and the selection of the n bits of the selected register, in particular the selection by a random or pseudo-random process of at least one of the bits of the selected register; and / or • the method further comprises, before step b), a preliminary step of selecting, by a random or pseudo-random process, those of the n bits of the register which will be extracted in step b). Brief description of the drawings
[0013] Examples of implementation of the invention will now be set out, with reference to the appended drawings where the same references designate identical or functionally similar elements from one figure to another.
[0014] [Fig-1] schematically illustrates a digital processor with the various blocks to which it is interfaced, the assembly being used for the implementation of the method of the invention.
[0015] [Fig.2] explains how to generate a random number by querying a system register of [Fig.l].
[0016] [Fig.3] is a flowchart showing the successive stages of implementation of the method of the invention.
[0017] [Fig.4] is a diagram describing an improved mode of implementation of the invention, combining several random selection techniques to obtain the value to be generated. Detailed description of the invention
[0018] [Fig.l] schematically represents an architecture of a digital processor system, which is conventional in itself.
[0019] A microprocessor or microcomputer 10 is interfaced by data buses 12, addresses 14 and control 16 respectively to memory circuits 18, to external peripherals 20 and to internal resources 22.
[0020] The general sequencing of the processor 10 is ensured by a clock circuit 24 comprising an oscillator 26 controlled by a quartz 28. The periods of the oscillator 26 feed a register 30 for counting the pulses defining the rate of the cycles successive CPUs of the processor 10, possibly after reduction of the frequency by a divider 32. The content of the clock register 30 is an evolving content, constantly varying at the rate of the pulses of the sequencing clock 24.
[0021] The principle of the invention, shown diagrammatically [Fig.2], consists of reading one or more bits (n bits, with n > 1) from a rapidly evolving register of the processor, in particular (but not limited to) the clock register 30, and using these n bits to constitute the N bits of a random number 34 of N bits (N > n).
[0022] If n < N, the process is repeated until the A bits of the number 34 are completed.
[0023] It is possible to extract, indifferently, for example one bit at a time (n = 1), a half-byte (n = 4), a byte (n = 8), etc., to obtain the A bits of the random number 34, without specific limitation on the number N, and therefore on the length of the random number obtained.
[0024] In most microprocessors, the clock register is an accessible and queryable register. For example, in Intel (registered trademark) processors this clock register is a 64-bit register called TSC (TimeStamp Counter), and it can be queried by a low-level RDTCP (Read TSC and Processor ID) instruction. This counter reflects the number of pulses produced by the timing clock since the initial reset of the register.
[0025] Advantageously, the extracted bit(s) are the least significant bits (LSB) of the register, which are bits whose value is totally unpredictable at a given instant given the very high clock frequencies of current processors, typically several gigahertz, i.e. every nanosecond the last bits of the clock register are modified several times.
[0026] Furthermore, the execution time of the register interrogation instruction is itself subject to unpredictable randomness, which increases the randomness on the value of the bit(s) read when this interrogation is actually carried out. Indeed, the architecture of microcomputers at the hardware level induces irregularities in the sequencing of the execution of micro-instructions due to hardware interruptions (external events which trigger the execution of specific software and which interrupt the execution of other software imperatively), but also due to the necessary coordination of several cores which execute tasks in parallel.
[0027] In addition, above the hardware layer are added several software layers which themselves execute with different priority levels and in permanent competition with external events and other software running concurrently.
[0028] It is therefore impossible to predict when a particular micro-instruction of an application software will actually be executed and, consequently, when determine in advance the value of the bits in the clock register at that time, especially the least significant bits, at the time when the register read instruction will actually be executed.
[0029] [Fig. 3] presents a flowchart 100 schematically illustrating the successive steps of the method for obtaining the random number 34 following the reception (block 110) of a request for generation of a random number: a. interrogation of clock register 30 (block 120); b. extraction of the n bits from the register (block 130); c. use of this or these bits to constitute the random number (block 140); d. if the random number is not complete (test 150), repeat steps 120 to 130; and finally e. issuing the random number (block 160) as a response to the request received in step 110.
[0030] It should be noted that the process just described has several particularly significant advantages: • no addition of hardware to the pre-existing circuits of the digital processor, since no interaction with the outside (to use a physical phenomenon) or with the user is necessary; • simple and universal implementation, the clock register existing on all digital processors; • very high degree of entropy; and • possibility of obtaining very long random numbers in a very short time.
[0031] In practice, the generation method can be implemented at several levels: • entirely and directly within the processor firmware; • from this firmware to supply a higher level application software layer, therefore from the processor to the application layer (which avoids difficulties due to access protections to the microprocessor, since in this case it is the latter which internally generates and delivers the random number); or • conversely, from the application layer to the processor, upon request from the application. Since a high-level application (User Mode) generally does not have the privileges to directly access the processor registers, the implementation can be carried out at two levels with i) a module running at a high privilege level to access the processor registers and ii) a second module communicating with the first and interfaced to the high-level program by an appropriate API.
[0032] The embodiment described above, by repeated extractions of n bits from the clock register and concatenation of the n successive bits until the Masts of the random number are obtained, can be the subject of numerous variants.
[0033] These variants, which in particular make it possible to further increase the degree of entropy of the generated random number, are not exclusive and can be combined with each other.
[0034] A first variant consists of controlling the instant of extraction of the n bits of the register in such a way that this instant results from a process which is itself random or pseudo-random. The delivery of the register reading instruction command can thus be carried out under the control of a pseudo-random generator included in the internal software of the processor, and which introduces an unpredictable waiting time between each reading of the register.
[0035] A second variant consists of using an internal register of the processor which is a register other than the clock register supplied by the oscillator of the sequencing clock. There are in fact other internal registers of the processor whose contents evolve rapidly and unpredictably over time, for example an event counting register of the processor.
[0036] A third variant consists of selecting, also randomly or pseudo-randomly, at each iteration the position of the n bits which will be extracted from the internal register(s) (instead of systematically taking, as in the example described above, the least significant bits).
[0037] A fourth variant consists in varying the number n and / or the order of the bits extracted from the interrogated register, also randomly or pseudo-randomly, at each interrogation step. In other words, the value n is in this case itself random instead of being predefined, as is the order in which the n bits (if more than one bit) are used to constitute the random number.
[0038] A fifth variant consists, instead of simply copying the n bits extracted to constitute the N bits of the random number, in using these n bits by modifying them, for example by inverting them or by permuting them according to a random or pseudo-random process, by summing them all or by summing some of them, etc.
[0039] A sixth variant, derived from the second variant above, consists of using several of the processor's internal registers to extract bits from them, with a process for selecting the register used at each extraction which itself depends on a random or pseudo-random process, i.e. the register from which the n bits are extracted can change from one iteration to another, in a non-deterministic manner.
[0040] [Fig.4] presents a diagram 200 describing a universal and improved mode of implementation of this sixth variant, combining several random selection techniques to obtain the value to be generated.
[0041] The first step (block 210) consists of determining the type of processor used with which it is desired to generate random numbers. Once this processor is recognized, a table of registers usable for implementing the method is established (block 220), with the number of registers usable for this purpose, and for each its address and length. These registers are illustrated in RI, R2, R3,... R(n) in [Fig.4], each of them being made up of a series of bits b0, bl, b2,... b(n).
[0042] The generation process can then begin, with first of all a first random or pseudo-random selection of one of the registers referenced in the table (block 230), then a second selection, also random or pseudo-random, of one of the bits of the register thus selected (block 240) - or of several bits of this register, with the different variants explained above.
[0043] These steps 230 and 240 are repeated (block 250) until the random number to be generated is completed (block 250), which can then be output to the requesting application.
[0044] A seventh variant, which can possibly be combined with the previous variants, consists of using several of the internal registers of the processor to extract one or more bits, and applying a combinational process, for example an XOR, between the bits extracted from the different registers interrogated.
Claims
Claims
1. A method for generating a random number implemented by means of a digital processor (10), characterized in that it comprises: a. interrogating (120) an internal register (30) for counting the pulses of a sequencing clock (24) of the processor; b. extracting (130) at a given instant n bits of the least significant bits of the register, n > 1; c. using (140) the n bits extracted in step b) as constituent bit(s) of a random number of N bits (34) to be generated; d. repeating steps a) to c) until obtaining the TV bits of the random number; and e. delivering (160) the random number to an application circuit or software.
2. The method of claim 1, wherein the register (30) is a register for counting pulses directly from an oscillator (26) of the clock (24).
3. The method of claim 1, wherein steps a) to d) are performed within firmware of the processor.
4. The method of claim 1, wherein n = 1 and the bit extracted in step b) is the least significant bit of the register.
5. The method of claim 1, wherein the given instant of extraction of the n bits in step b) is an instant determined by a random or pseudo-random process.
6. The method of claim 1, wherein the given time of extraction of the n bits in step b) is a time determined in response to a request received from the application circuit or software.
