A random number generator and a random number generation method
By introducing a configuration circuit and an entropy source sampling circuit into the random number generator, online detection and multi-standard detection are realized, which solves the problems of poor generation quality and inflexible design of traditional random number generators, and improves the flexibility of the random number generator. sex and safety.
Patent Information
- Application Number
- CN202410931347.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-07-12
AI Technical Summary
The entropy source generation quality of traditional random number generators is easily affected by the environment and external factors, and lacks a random number quality self-check function, resulting in poor quality of generated random numbers, reducing the security of the cryptographic system, and the design is not flexible enough to adapt to a variety of Usage scenarios.
A random number generator is designed, including a configuration circuit, an entropy source sampling circuit and a random number reading circuit. Through the AMBA bus interface configuration and polling interrupt register, online detection of random numbers and flexible configuration and management of the oscillation ring are realized. Supports AES-CBC-MAC post-processing and multi-standard detection (NIST and AIS31), with a high degree of configuration freedom and portability.
It realizes online detection of the credibility of random numbers and efficient re-starting of the oscillation ring, supports a variety of usage environments and chip processes, has flexibility and reliability, and ensures random number quality and system security.
Smart Images

Figure CN118466903B
Abstract
Description
Technical Field
[0001] The present invention relates to random number generation, and in particular to a random number generator and a random number generation method. Background Art
[0002] In order to generate true random numbers, traditional random number generators first generate random numbers from an entropy source, then perform sampling, and finally post-process the sampled data. Since the quality of random numbers generated by the entropy source will be affected by factors such as ambient temperature drift, external attacks, and circuit aging, and most random number generators do not have a random number quality self-check function, it is possible to generate random numbers of poor quality, and the use of unqualified random numbers will reduce the security of the entire cryptographic system. At the same time, the existing random number generator design is not flexible enough to meet the needs of various scenarios. Summary of the invention
[0003] In view of the above-mentioned shortcomings of the prior art, the present invention provides a random number generator and a random number generation method, which can effectively overcome the defects of the prior art that it cannot be flexibly applied to a variety of usage environments and has a single function.
[0004] To achieve the above objectives, the present invention is implemented through the following technical solutions:
[0005] A random number generator comprises a configuration circuit, an entropy source sampling circuit and a random number reading circuit;
[0006] Configuration circuit, configure registers through AMBA bus interface, and poll interrupt registers to clear their enable by using AMBA bus interface;
[0007] The entropy source sampling circuit configures the oscillation ring according to the register configuration to generate random numbers, and chooses whether to post-process the generated random numbers. At the same time, the generated random numbers are tested online. If the test passes, the random numbers are written into the random number reading circuit. If the test fails, the currently generated random numbers are discarded, the oscillation ring is turned off, and an interrupt is reported.
[0008] The random number reading circuit stores and reads random numbers for use by subsequent circuits.
[0009] Preferably, the configuration circuit comprises a register configuration module and a first single-bit signal synchronization module in an asynchronous cross-clock domain module;
[0010] A register configuration module configures registers through the AMBA bus interface and uses the AMBA bus interface to poll the interrupt register to clear its enable;
[0011] A first single-bit signal synchronization module synchronizes the oscillation ring invalidation signal loops_disable in the sampling clock domain to the synchronized oscillation ring invalidation signal loops_disable_asynced in the AMBA clock domain;
[0012] The oscillation ring invalid signal loops_disable and the synchronized oscillation ring invalid signal loops_disable_asynced are both used to indicate that the oscillation ring stops oscillating due to a failure in random number online detection.
[0013] Preferably, the entropy source sampling circuit includes a synchronization module from the AMBA domain to the sampling clock domain in the asynchronous cross-clock domain module, and a random number entropy source and detection module, and the random number entropy source and detection module includes a random number entropy source module, a CBC_MAC top-level module and a data test and selection module;
[0014] A synchronization module from the AMBA domain to the sampling clock domain, using a second single-bit signal synchronization module to synchronize the signal in the AMBA clock domain to the signal in the sampling clock domain;
[0015] The random number entropy source module is built with a flexible random number generator entropy source to generate random numbers according to the register configuration;
[0016] The CBC_MAC top-level module selectively turns on the random number randomization processing function, i.e., the AES-CBC-MAC post-processing function, turns on the clock of the CBC_MAC module through the first gated clock module to turn on the AES-CBC-MAC post-processing function, and turns off the clock of the CBC_MAC module through the first gated clock module to turn off the AES-CBC-MAC post-processing function;
[0017] The data test and selection module performs online random number detection on the generated random number. If the detection passes, the random number is written into the random number reading circuit. If the detection fails, the currently generated random number is discarded, the oscillation ring is turned off, and an interrupt is reported.
[0018] Preferably, the data testing and selection module includes a data stream selection module, a NIST standard detection module, an AIS31 standard detection module and a detection result selection module;
[0019] The data stream selection module selects the random number generated by the random number entropy source module or the random number processed by the CBC_MAC top-level module according to the register configuration, and sends it to the NIST standard detection module and the AIS31 standard detection module for random number online detection;
[0020] NIST standard detection module, completes NIST random number online detection. When the system is working normally, the NIST random number online detection function is always turned on;
[0021] AIS31 standard detection module, selectively turning on the AIS31 random number online detection function, turning on the clock of the AIS31 detection core module through the second gated clock module to turn on the AIS31 random number online detection function, and turning off the clock of the AIS31 detection core module through the second gated clock module to turn off the AIS31 random number online detection function;
[0022] The detection result selection module writes a group of random numbers into the random number reading circuit when a group of random numbers passes the NIST random number online detection, or passes the NIST random number online detection and the AIS31 random number online detection. Otherwise, the group of random numbers is discarded, and the online detection failure interrupt information is reported. At the same time, the oscillation ring invalid signal loops_disable is immediately set to 1 through the oscillation ring error indication module to turn off the oscillation ring.
[0023] Preferably, the random number entropy source and detection module also includes a linear shift register module, in which a pseudo-random number generator based on a linear shift register LFSR is constructed. The code of the linear shift register module is only enabled when the system is in LFSR simulation mode and is not hardened during tape-out.
[0024] Preferably, the random number reading circuit comprises an asynchronous FIFO module, and the asynchronous FIFO module stores and reads the random numbers that pass the detection for use by the subsequent circuit.
[0025] Preferably, the configuration circuit operates in an AMBA clock domain, the entropy source sampling circuit operates in a sampling clock domain, the random number reading circuit operates in a FIFO read clock domain, and the clock frequencies of the AMBA clock domain, the sampling clock domain and the FIFO read clock domain are relatively independently and flexibly configured.
[0026] Preferably, the configuration circuit is reset using a first reset signal amba_resetn of an AMBA bus interface;
[0027] The synchronization module from the AMBA domain to the sampling clock domain, the oscillation ring error indication module and the input side of the asynchronous FIFO module are reset using the second reset signal sample_resetn corresponding to the sampling clock domain clock;
[0028] The output side of the asynchronous FIFO module is reset using a third reset signal rd_rstn corresponding to the FIFO read clock domain clock;
[0029] All modules in the entropy source sampling circuit except the synchronization module from the AMBA domain to the sampling clock domain and the oscillation ring error indication module are reset using the fourth reset signal wr_resetn generated by the reset signal generation circuit. When the oscillation ring error indication module sets the oscillation ring invalid signal loops_disable to 1 and turns off the oscillation ring, the reset signal generation circuit generates the fourth reset signal wr_resetn based on the oscillation ring invalid signal loops_disable to drive all modules in the entropy source sampling circuit except the synchronization module from the AMBA domain to the sampling clock domain and the oscillation ring error indication module to automatically reset immediately, so as to wait for the oscillation ring to restart.
[0030] The reset signal generating circuit includes a D flip-flop, a first inverter, a first AND gate, a second inverter and a second AND gate, the input end of the D flip-flop is connected to the oscillation ring invalid signal loops_disable, the direct set end of the D flip-flop is connected to the fourth reset signal wr_resetn, the output end of the D flip-flop outputs the oscillation ring invalid delay signal loops_disable_d1 to the input end of the first inverter, the input end of the first AND gate is connected to the output end of the first inverter and the oscillation ring invalid signal loops_disable, the output end of the first AND gate outputs the oscillation ring invalid rising edge detection signal loops_dis_rising_edge to the input end of the second inverter, the input end of the second AND gate is connected to the output end of the second inverter and the second reset signal sample_resetn, and the output end of the second AND gate outputs the fourth reset signal wr_resetn.
[0031] A random number generation method, the system in normal working mode, includes the following steps:
[0032] S1, the system is powered on, the AMBA clock signal, sampling clock signal and FIFO read clock signal work, and according to the principle of asynchronous reset and synchronous release, the reset action of the AMBA clock domain, sampling clock domain and FIFO read clock domain registers is completed;
[0033] S2. Configure the control register through the AMBA bus interface. The user enables the oscillation ring and chooses to turn on or off the AES-CBC-MAC post-processing function, and also chooses to turn on or off the AIS31 random number online detection function.
[0034] S3, start the oscillation ring through the AMBA bus interface configuration, the oscillation ring starts to oscillate and generate random numbers;
[0035] S4. Perform NIST random number online detection, or NIST random number online detection and AIS31 random number online detection on the generated random number or the random number processed by the AES-CBC-MAC post-processing function;
[0036] S5. When a group of random numbers passes the NIST random number online detection, or passes the NIST random number online detection and the AIS31 random number online detection, the group of random numbers is written into the FIFO for use by the subsequent circuit, otherwise it goes to S6;
[0037] S6, discarding the group of random numbers, reporting online detection failure interrupt information, and turning off the oscillation ring at the same time, and the reset signal generation circuit generates a fourth reset signal wr_resetn to drive the corresponding module in the system to automatically reset;
[0038] S7, after the AMBA bus interface polls and finds that the interrupt register corresponding to the online detection failure interrupt information is enabled, it enters S3, reconfigures and starts the oscillation ring.
[0039] A random number generation method, the system is in LFSR simulation mode, comprising the following steps:
[0040] S1, the system is powered on, the AMBA clock signal, sampling clock signal and FIFO read clock signal work, and according to the principle of asynchronous reset and synchronous release, the reset action of the AMBA clock domain, sampling clock domain and FIFO read clock domain registers is completed;
[0041] S2. Configure the control register through the AMBA bus interface. The user enables the linear shift register LFSR, turns off the oscillation ring, and chooses to turn on or off the AES-CBC-MAC post-processing function, and also chooses to turn on or off the AIS31 random number online detection function.
[0042] S3, the linear shift register LFSR is turned on through the AMBA bus interface configuration, and the pseudo-random number generator based on the linear shift register LFSR starts to work and generates pseudo-random numbers;
[0043] S4. Perform NIST random number online detection, or NIST random number online detection and AIS31 random number online detection on the generated pseudo-random number or the pseudo-random number processed by the AES-CBC-MAC post-processing function;
[0044] S5. When a group of pseudo-random numbers passes the NIST random number online detection, or passes the NIST random number online detection and the AIS31 random number online detection, the group of pseudo-random numbers is written into the FIFO for use by the subsequent circuit, otherwise, enter S6;
[0045] S6, discarding the group of pseudo-random numbers, reporting online detection failure interrupt information, and closing the linear shift register LFSR at the same time, and the reset signal generation circuit generates a fourth reset signal wr_resetn to drive the corresponding module in the system to automatically reset;
[0046] S7, after the AMBA bus interface polls and finds that the interrupt register corresponding to the online detection failure interrupt information is enabled, it enters S3, reconfigures and starts the linear shift register LFSR.
[0047] Compared with the prior art, the random number generator and random number generation method provided by the present invention have the following beneficial effects:
[0048] 1) It has a high degree of configuration freedom and can be flexibly applied to different usage environments and chip processes, with excellent flexibility and portability;
[0049] 2) Ability to support both LFSR-based behavioral simulation and actual tape-out hardening functions;
[0050] 3) Supports on-chip online detection of random number credibility. When online detection failure interrupt information appears, it supports parameter reconfiguration and efficient restart of the oscillation ring. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0052] Figure 1 It is a schematic diagram of the overall structure of the present invention;
[0053] Figure 2 A schematic diagram of a clock architecture of the present invention;
[0054] Figure 3 It is a schematic diagram of the reset architecture of the present invention;
[0055] Figure 4 is a circuit structure schematic diagram of a reset signal generating circuit in the present invention;
[0056] Figure 5 It is a schematic diagram of the working process of the system in the normal working mode of the present invention;
[0057] Figure 6 Schematic diagram of the working process of the system in the LFSR simulation mode of the present invention. DETAILED DESCRIPTION
[0058] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0059] A random number generator, such as Figure 1 As shown, it includes a configuration circuit, an entropy source sampling circuit and a random number reading circuit;
[0060] Configuration circuit, configure registers through AMBA bus interface, and poll interrupt registers to clear their enable by using AMBA bus interface;
[0061] The entropy source sampling circuit configures the oscillation ring according to the register configuration to generate random numbers, and chooses whether to post-process the generated random numbers. At the same time, the generated random numbers are tested online. If the test passes, the random numbers are written into the random number reading circuit. If the test fails, the currently generated random numbers are discarded, the oscillation ring is turned off, and an interrupt is reported.
[0062] The random number reading circuit stores and reads random numbers for use by subsequent circuits.
[0063] ① The configuration circuit includes a register configuration module and a first single-bit signal synchronization module in an asynchronous cross-clock domain module;
[0064] A register configuration module configures registers through the AMBA bus interface and uses the AMBA bus interface to poll the interrupt register to clear its enable;
[0065] A first single-bit signal synchronization module synchronizes the oscillation ring invalidation signal loops_disable in the sampling clock domain to the synchronized oscillation ring invalidation signal loops_disable_asynced in the AMBA clock domain;
[0066] The oscillation ring invalid signal loops_disable and the synchronized oscillation ring invalid signal loops_disable_asynced are both used to indicate that the oscillation ring stops oscillating due to a failure in random number online detection.
[0067] ② The entropy source sampling circuit includes a synchronization module from the AMBA domain to the sampling clock domain in the asynchronous cross-clock domain module, and a random number entropy source and detection module. The random number entropy source and detection module includes a random number entropy source module, a CBC_MAC top-level module and a data test and selection module;
[0068] A synchronization module from the AMBA domain to the sampling clock domain, using a second single-bit signal synchronization module to synchronize the signal in the AMBA clock domain to the signal in the sampling clock domain;
[0069] The random number entropy source module is built with a flexible random number generator entropy source to generate random numbers according to the register configuration;
[0070] The CBC_MAC top-level module selectively turns on the random number randomization processing function, i.e., the AES-CBC-MAC post-processing function, turns on the clock of the CBC_MAC module through the first gated clock module to turn on the AES-CBC-MAC post-processing function, and turns off the clock of the CBC_MAC module through the first gated clock module to turn off the AES-CBC-MAC post-processing function;
[0071] The data test and selection module performs online random number detection on the generated random number. If the detection passes, the random number is written into the random number reading circuit. If the detection fails, the currently generated random number is discarded, the oscillation ring is turned off, and an interrupt is reported.
[0072] Specifically, the data testing and selection module includes a data stream selection module, a NIST standard detection module, an AIS31 standard detection module and a detection result selection module;
[0073] The data stream selection module selects the random number generated by the random number entropy source module or the random number processed by the CBC_MAC top-level module according to the register configuration, and sends it to the NIST standard detection module and the AIS31 standard detection module for random number online detection;
[0074] NIST standard detection module, completes NIST random number online detection. When the system is working normally, the NIST random number online detection function is always turned on;
[0075] AIS31 standard detection module, selectively turning on the AIS31 random number online detection function, turning on the clock of the AIS31 detection core module through the second gated clock module to turn on the AIS31 random number online detection function, and turning off the clock of the AIS31 detection core module through the second gated clock module to turn off the AIS31 random number online detection function;
[0076] The detection result selection module writes a group of random numbers into the random number reading circuit when a group of random numbers (each group of data is 1024 bits) passes the NIST random number online detection, or passes the NIST random number online detection and the AIS31 random number online detection. Otherwise, the group of random numbers is discarded and the online detection failure interrupt information is reported. At the same time, the oscillation ring invalid signal loops_disable is immediately set to 1 through the oscillation ring error indication module to turn off the oscillation ring.
[0077] Specifically, the random number entropy source and detection module also includes a linear shift register module, in which a pseudo-random number generator based on a linear shift register LFSR is constructed. The code of the linear shift register module is only enabled when the system is in LFSR simulation mode and is not hardened during tape-out.
[0078] ③ The random number reading circuit includes an asynchronous FIFO module, which stores and reads the random numbers that pass the detection for use by the subsequent circuits.
[0079] ④ Such as Figure 2 As shown, the configuration circuit works in the AMBA clock domain, the entropy source sampling circuit works in the sampling clock domain, the random number reading circuit works in the FIFO read clock domain, and the clock frequencies of the AMBA clock domain, the sampling clock domain, and the FIFO read clock domain are relatively independent and flexibly configured.
[0080] In the technical solution of the present application, the configuration circuit, entropy source sampling circuit and random number reading circuit are carefully divided into clock domains, and the clock frequencies of the AMBA clock domain, sampling clock domain and FIFO read clock domain can be relatively independently and flexibly configured, so that the present application can be flexibly applied to usage scenarios with different operating frequencies.
[0081] ⑤ If Figure 3 As shown, the configuration circuit is reset using the first reset signal amba_resetn of the AMBA bus interface;
[0082] The synchronization module from the AMBA domain to the sampling clock domain, the oscillation ring error indication module and the input side of the asynchronous FIFO module are reset using the second reset signal sample_resetn corresponding to the sampling clock domain clock;
[0083] The output side of the asynchronous FIFO module is reset using the third reset signal rd_rstn corresponding to the FIFO read clock domain clock;
[0084] All modules in the entropy source sampling circuit except the synchronization module from the AMBA domain to the sampling clock domain and the oscillation ring error indication module are reset using the fourth reset signal wr_resetn generated by the reset signal generation circuit. When the oscillation ring error indication module sets the oscillation ring invalid signal loops_disable to 1 and turns off the oscillation ring, the reset signal generation circuit generates the fourth reset signal wr_resetn based on the oscillation ring invalid signal loops_disable to drive all modules in the entropy source sampling circuit except the synchronization module from the AMBA domain to the sampling clock domain and the oscillation ring error indication module to automatically reset and wait for the oscillation ring to restart.
[0085] Among them, Figure 4 As shown, the reset signal generating circuit includes a D flip-flop, a first inverter, a first AND gate, a second inverter and a second AND gate, the input end of the D flip-flop is connected to the oscillation ring invalid signal loops_disable, the direct set end of the D flip-flop is connected to the fourth reset signal wr_resetn, the output end of the D flip-flop outputs the oscillation ring invalid delay signal loops_disable_d1 to the input end of the first inverter, the input end of the first AND gate is connected to the output end of the first inverter and the oscillation ring invalid signal loops_disable, the output end of the first AND gate outputs the oscillation ring invalid rising edge detection signal loops_dis_rising_edge to the input end of the second inverter, the input end of the second AND gate is connected to the output end of the second inverter and the second reset signal sample_resetn, and the output end of the second AND gate outputs the fourth reset signal wr_resetn.
[0086] The above technical solution first constructs a rising edge detection circuit for the oscillation ring invalid signal loops_disable (the output is the oscillation ring invalid rising edge detection signal loops_dis_rising_edge). Whenever the oscillation ring invalid signal loops_disable jumps from 0 to 1, loops_dis_rising_edge=1; then the oscillation ring invalid rising edge detection signal loops_dis_rising_edge is inverted, and the fourth reset signal wr_resetn is obtained after logical AND with the second reset signal sample_resetn.
[0087] Through the design of the above reset architecture, when online detection fails and the oscillation ring is turned off, the system only needs to automatically reset some modules (such as Figure 3 The modules covered by purple, that is, the registers of all modules in the entropy source sampling circuit except the synchronization module from the AMBA domain to the sampling clock domain and the oscillation ring error indication module, are used to wait for the oscillation ring to restart. The benefits of this design are:
[0088] 1) Figure 3 The registers of the modules covered in red (i.e. the modules in the configuration circuit) do not need to be reconfigured separately, which improves the working efficiency of the system;
[0089] 2) The random numbers that have passed the detection and stored in the FIFO are not affected, and do not affect the normal operation of the subsequent circuits.
[0090] In the technical solution of this application, based on the above random number generator, a method for generating random numbers in a normal working mode of the system is also disclosed, such as Figure 5 As shown, the following steps are included:
[0091] S1, the system is powered on, the AMBA clock signal, sampling clock signal and FIFO read clock signal work, and according to the principle of asynchronous reset and synchronous release, the reset action of the AMBA clock domain, sampling clock domain and FIFO read clock domain registers is completed;
[0092] S2. Configure the control register through the AMBA bus interface. The user enables the oscillation ring and chooses to turn on or off the AES-CBC-MAC post-processing function, and also chooses to turn on or off the AIS31 random number online detection function.
[0093] S3, start the oscillation ring through the AMBA bus interface configuration, the oscillation ring starts to oscillate and generate random numbers;
[0094] S4. Perform NIST random number online detection, or NIST random number online detection and AIS31 random number online detection on the generated random number or the random number processed by the AES-CBC-MAC post-processing function;
[0095] S5. When a group of random numbers passes the NIST random number online detection, or passes the NIST random number online detection and the AIS31 random number online detection, the group of random numbers is written into the FIFO for use by the subsequent circuit, otherwise it goes to S6;
[0096] S6, discard the group of random numbers, report the online detection failure interrupt information, and turn off the oscillation ring at the same time. The reset signal generation circuit generates a fourth reset signal wr_resetn to drive the corresponding modules in the system (such as Figure 3 The modules covered by purple, i.e. all modules in the entropy source sampling circuit except the synchronization module from the AMBA domain to the sampling clock domain and the oscillation ring error indication module) are automatically reset;
[0097] S7, after the AMBA bus interface polls and finds that the interrupt register corresponding to the online detection failure interrupt information is enabled, it enters S3, reconfigures and starts the oscillation ring.
[0098] In the technical solution of this application, based on the above random number generator, a random number generation method of the system in LFSR simulation mode is also disclosed, such as Figure 6 As shown, the following steps are included:
[0099] S1, the system is powered on, the AMBA clock signal, sampling clock signal and FIFO read clock signal work, and according to the principle of asynchronous reset and synchronous release, the reset action of the AMBA clock domain, sampling clock domain and FIFO read clock domain registers is completed;
[0100] S2. Configure the control register through the AMBA bus interface. The user enables the linear shift register LFSR, turns off the oscillation ring, and chooses to turn on or off the AES-CBC-MAC post-processing function, and also chooses to turn on or off the AIS31 random number online detection function.
[0101] S3, the linear shift register LFSR is turned on through the AMBA bus interface configuration, and the pseudo-random number generator based on the linear shift register LFSR starts to work and generates pseudo-random numbers;
[0102] S4. Perform NIST random number online detection, or NIST random number online detection and AIS31 random number online detection on the generated pseudo-random number or the pseudo-random number processed by the AES-CBC-MAC post-processing function;
[0103] S5. When a group of pseudo-random numbers passes the NIST random number online detection, or passes the NIST random number online detection and the AIS31 random number online detection, the group of pseudo-random numbers is written into the FIFO for use by the subsequent circuit, otherwise, enter S6;
[0104] S6, discard the group of pseudo-random numbers, report the online detection failure interrupt information, and at the same time turn off the linear shift register LFSR, and the reset signal generation circuit generates a fourth reset signal wr_resetn to drive the corresponding modules in the system (such as Figure 3 The modules covered by purple, i.e. all modules in the entropy source sampling circuit except the synchronization module from the AMBA domain to the sampling clock domain and the oscillation ring error indication module) are automatically reset;
[0105] S7, after the AMBA bus interface polls and finds that the interrupt register corresponding to the online detection failure interrupt information is enabled, it enters S3, reconfigures and starts the linear shift register LFSR.
[0106] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements will not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A random number generator, characterized in that: It includes a configuration circuit, an entropy source sampling circuit and a random number reading circuit; Configuration circuit, configure registers through AMBA bus interface, and poll interrupt registers to clear their enable by using AMBA bus interface; The entropy source sampling circuit configures the oscillation ring according to the register configuration to generate random numbers, and chooses whether to post-process the generated random numbers. At the same time, the generated random numbers are tested online. If the test passes, the random numbers are written into the random number reading circuit. If the test fails, the currently generated random numbers are discarded, the oscillation ring is turned off, and an interrupt is reported. A random number reading circuit stores and reads random numbers for use by subsequent circuits; The entropy source sampling circuit includes a synchronization module from the AMBA clock domain to the sampling clock domain in the asynchronous cross-clock domain module, and a random number entropy source and detection module, wherein the random number entropy source and detection module includes a random number entropy source module, a CBC_MAC top-level module and a data test and selection module; A synchronization module from the AMBA clock domain to the sampling clock domain, using a second single-bit signal synchronization module to synchronize the signal in the AMBA clock domain to the signal in the sampling clock domain; The random number entropy source module is built with a flexible random number generator entropy source to generate random numbers according to the register configuration; The CBC_MAC top-level module selectively turns on the random number randomization processing function, i.e., the AES-CBC-MAC post-processing function, turns on the clock of the CBC_MAC module through the first gated clock module to turn on the AES-CBC-MAC post-processing function, and turns off the clock of the CBC_MAC module through the first gated clock module to turn off the AES-CBC-MAC post-processing function; The data test and selection module performs online random number detection on the generated random number. If the detection passes, the random number is written into the random number reading circuit. If the detection fails, the currently generated random number is discarded, the oscillation ring is turned off, and an interrupt is reported. The data testing and selection module includes a data stream selection module, a NIST standard detection module, an AIS31 standard detection module and a detection result selection module; The data stream selection module selects the random number generated by the random number entropy source module or the random number processed by the CBC_MAC top-level module according to the register configuration, and sends it to the NIST standard detection module and the AIS31 standard detection module for random number online detection; NIST standard detection module, completes NIST random number online detection. When the system is working normally, the NIST random number online detection function is always turned on; AIS31 standard detection module, selectively turning on the AIS31 random number online detection function, turning on the clock of the AIS31 detection core module through the second gated clock module to turn on the AIS31 random number online detection function, and turning off the clock of the AIS31 detection core module through the second gated clock module to turn off the AIS31 random number online detection function; The detection result selection module writes a group of random numbers into the random number reading circuit when a group of random numbers passes the NIST random number online detection, or passes the NIST random number online detection and the AIS31 random number online detection. Otherwise, the group of random numbers is discarded, and the online detection failure interrupt information is reported. At the same time, the oscillation ring invalid signal loops_disable is immediately set to 1 through the oscillation ring error indication module to turn off the oscillation ring.
2. The random number generator according to claim 1, characterized in that: The configuration circuit includes a register configuration module and a first single-bit signal synchronization module in an asynchronous cross-clock domain module; A register configuration module configures registers through the AMBA bus interface and uses the AMBA bus interface to poll the interrupt register to clear its enable; A first single-bit signal synchronization module synchronizes the oscillation ring invalidation signal loops_disable in the sampling clock domain to the synchronized oscillation ring invalidation signal loops_disable_asynced in the AMBA clock domain; The oscillation ring invalid signal loops_disable and the synchronized oscillation ring invalid signal loops_disable_asynced are both used to indicate that the oscillation ring stops oscillating due to a failure in random number online detection.
3. The random number generator according to claim 1, characterized in that: The random number entropy source and detection module also includes a linear shift register module, in which a pseudo-random number generator based on a linear shift register LFSR is constructed. The code of the linear shift register module is only enabled when the system is in LFSR simulation mode and is not hardened during tape-out.
4. The random number generator according to claim 3, characterized in that: The random number reading circuit comprises an asynchronous FIFO module, and the asynchronous FIFO module stores and reads the random numbers that pass the detection for use by the subsequent circuit.
5. The random number generator according to claim 4, characterized in that: The configuration circuit works in the AMBA clock domain, the entropy source sampling circuit works in the sampling clock domain, the random number reading circuit works in the FIFO read clock domain, and the clock frequencies of the AMBA clock domain, the sampling clock domain and the FIFO read clock domain are relatively independently and flexibly configured.
6. The random number generator according to claim 4, characterized in that: The configuration circuit is reset using the first reset signal amba_resetn of the AMBA bus interface; The synchronization module from the AMBA clock domain to the sampling clock domain, the oscillation ring error indication module and the input side of the asynchronous FIFO module are reset using the second reset signal sample_resetn corresponding to the sampling clock domain clock; The output side of the asynchronous FIFO module is reset using a third reset signal rd_rstn corresponding to the FIFO read clock domain clock; All modules in the entropy source sampling circuit except the synchronization module from the AMBA clock domain to the sampling clock domain and the oscillation ring error indication module are reset using the fourth reset signal wr_resetn generated by the reset signal generation circuit. When the oscillation ring error indication module sets the oscillation ring invalid signal loops_disable to 1 and turns off the oscillation ring, the reset signal generation circuit generates the fourth reset signal wr_resetn based on the oscillation ring invalid signal loops_disable to drive all modules in the entropy source sampling circuit except the synchronization module from the AMBA clock domain to the sampling clock domain and the oscillation ring error indication module to automatically reset immediately, so as to wait for the oscillation ring to restart. The reset signal generating circuit includes a D flip-flop, a first inverter, a first AND gate, a second inverter and a second AND gate, the input end of the D flip-flop is connected to the oscillation ring invalid signal loops_disable, the direct set end of the D flip-flop is connected to the fourth reset signal wr_resetn, the output end of the D flip-flop outputs the oscillation ring invalid delay signal loops_disable_d1 to the input end of the first inverter, the input end of the first AND gate is connected to the output end of the first inverter and the oscillation ring invalid signal loops_disable, the output end of the first AND gate outputs the oscillation ring invalid rising edge detection signal loops_dis_rising_edge to the input end of the second inverter, the input end of the second AND gate is connected to the output end of the second inverter and the second reset signal sample_resetn, and the output end of the second AND gate outputs the fourth reset signal wr_resetn.
7. A random number generation method, applied to the random number generator according to claim 6, characterized in that: The system is in normal working mode, including the following steps: S1, the system is powered on, the AMBA clock signal, sampling clock signal and FIFO read clock signal work, and according to the principle of asynchronous reset and synchronous release, the reset action of the AMBA clock domain, sampling clock domain and FIFO read clock domain registers is completed; S2. Configure the control register through the AMBA bus interface. The user enables the oscillation ring and chooses to turn on or off the AES-CBC-MAC post-processing function, and also chooses to turn on or off the AIS31 random number online detection function. S3, start the oscillation ring through the AMBA bus interface configuration, the oscillation ring starts to oscillate and generate random numbers; S4. Perform NIST random number online detection, or NIST random number online detection and AIS31 random number online detection on the generated random number or the random number processed by the AES-CBC-MAC post-processing function; S5. When a group of random numbers passes the NIST random number online detection, or passes the NIST random number online detection and the AIS31 random number online detection, the group of random numbers is written into the FIFO for use by the subsequent circuit, otherwise it goes to S6; S6, discarding the group of random numbers, reporting online detection failure interrupt information, and turning off the oscillation ring at the same time, and the reset signal generation circuit generates a fourth reset signal wr_resetn to drive the corresponding module in the system to automatically reset; S7, after the AMBA bus interface polls and finds that the interrupt register corresponding to the online detection failure interrupt information is enabled, it enters S3, reconfigures and starts the oscillation ring.
8. A random number generation method, applied to the random number generator according to claim 6, characterized in that: The system in LFSR simulation mode includes the following steps: S1, the system is powered on, the AMBA clock signal, sampling clock signal and FIFO read clock signal work, and according to the principle of asynchronous reset and synchronous release, the reset action of the AMBA clock domain, sampling clock domain and FIFO read clock domain registers is completed; S2. Configure the control register through the AMBA bus interface. The user enables the linear shift register LFSR, turns off the oscillation ring, and chooses to turn on or off the AES-CBC-MAC post-processing function, and also chooses to turn on or off the AIS31 random number online detection function. S3, the linear shift register LFSR is turned on through the AMBA bus interface configuration, and the pseudo-random number generator based on the linear shift register LFSR starts to work and generates pseudo-random numbers; S4. Perform NIST random number online detection, or NIST random number online detection and AIS31 random number online detection on the generated pseudo-random number or the pseudo-random number processed by the AES-CBC-MAC post-processing function; S5. When a group of pseudo-random numbers passes the NIST random number online detection, or passes the NIST random number online detection and the AIS31 random number online detection, the group of pseudo-random numbers is written into the FIFO for use by the subsequent circuit, otherwise, enter S6; S6, discarding the group of pseudo-random numbers, reporting online detection failure interrupt information, and closing the linear shift register LFSR at the same time, and the reset signal generation circuit generates a fourth reset signal wr_resetn to drive the corresponding module in the system to automatically reset; S7, after the AMBA bus interface polls and finds that the interrupt register corresponding to the online detection failure interrupt information is enabled, it enters S3, reconfigures and starts the linear shift register LFSR.
