Disclosure of Invention
Therefore, it is necessary to provide a random number generator, a self-checking module, and a self-checking method of the random number generator, aiming at the problem that the monitoring result given by the existing monitoring method often has hysteresis.
On one hand, the embodiment of the invention provides a random number generator, which comprises a random source generating circuit, a post-processing circuit and a random number hardware self-checking module;
the random source generating circuit is used for generating a plurality of paths of initial random numbers, combining the plurality of paths of initial random numbers into a preliminary random number sequence, and outputting the preliminary random number sequence to the post-processing circuit;
the post-processing circuit is used for carrying out equalization processing on the input preliminary random number sequence and outputting a final random number sequence;
the random number hardware self-checking module corresponds to random number channels in the random number generator one by one and is used for monitoring whether random number sequences in the random number channels meet set conditions or not;
wherein the random number channel comprises: the output channels of the plurality of paths of initial random numbers, the output channel of the random source generating circuit and the output channel of the post-processing circuit; the setting conditions include: can be monitored by correct randomness, is unpredictable, and cannot be reproduced.
In one embodiment, the random source generating circuit includes: the chaotic power system comprises a plurality of chaotic power systems, a plurality of exclusive-OR chains and a first exclusive-OR logic circuit;
the output ends of the chaotic power systems are connected with the input end of an exclusive or chain; the output ends of the plurality of XOR chains are connected with the input end of the first XOR logic circuit; the output end of the first exclusive-or logic circuit is connected with the output end of the random source generating circuit;
the output channels of the plurality of initial random numbers comprise: the output channels of the chaotic power system and the output channels of the XOR chains.
In one embodiment, the post-processing circuit comprises: a second exclusive-or logic circuit and a plurality of D flip-flops; the plurality of D triggers are cascaded, and the input end of the D trigger positioned at the head is connected with the input end of the post-processing circuit; the output ends of the plurality of D flip-flop stages are also respectively connected with the input end of the second exclusive-OR logic circuit; and the output end of the second exclusive-OR logic circuit is connected with the output end of the random number generator.
In one embodiment, in the random source generating circuit, each two chaotic power systems are connected with the input end of an exclusive-or chain.
In one embodiment, four xor chains are included in the random source generation circuit, and outputs of the four xor chains are all connected to the input of the first xor logic circuit.
In one embodiment, the post-processing circuit includes 128D flip-flops, and the 128D flip-flops are connected in cascade.
In one embodiment, the random number hardware self-checking module comprises a startup monitoring module and an online monitoring module;
the startup monitoring module is operated when the random number generator is just powered on or the random number generator turns from off to enable, and is used for monitoring whether a random number sequence output by a corresponding random number channel meets the set condition;
when the random number generator normally operates, the online monitoring module operates, and the startup monitoring module stops operating; the online monitoring module is used for monitoring whether a random number sequence output by a corresponding random number channel meets the set condition; and the random number generator enters a normal operation stage when the monitoring of the startup monitoring module passes.
In one embodiment, the startup monitoring module comprises a monitoring module based on poker monitoring principle;
the online monitoring module comprises a monitoring module based on a single-bit frequency monitoring principle, a total run number monitoring principle or a matrix rank monitoring principle.
On the other hand, the random number hardware self-checking module of the random number generator is provided, and comprises a startup monitoring module and an online monitoring module;
the startup monitoring module is operated when the random number generator is just powered on or the random number generator is switched from off to enabled, and is used for monitoring whether a random number sequence output by a random number channel connected with the random number hardware self-checking module meets the set condition or not;
when the random number generator normally operates, the online monitoring module operates, and the startup monitoring module stops operating; the online monitoring module is used for monitoring the data output by the corresponding random number channel.
In another aspect, a self-checking method for a random number generator is provided, where the random number generator is as described in any of the above embodiments, and the self-checking method includes:
when the random number generator is powered on or turns to an enabling state from a closing state, a plurality of random number hardware self-checking modules are started; carrying out first-stage monitoring on data output by a plurality of random number channels in the random number generator through a plurality of random number hardware self-checking modules;
if the first-stage monitoring results of each random number channel in the random number generator pass, the random number generator enters a normal operation stage; otherwise, outputting an abnormal prompt signal through a corresponding random number hardware self-checking module;
in the normal operation stage of the random number generator, performing second-stage monitoring on data output by a plurality of random number channels in the random number generator through the plurality of random number hardware self-checking modules; if the second-stage monitoring result of any random number channel in the random number generator does not pass, outputting an abnormal prompt signal through a random number hardware self-checking module corresponding to any random number channel;
the first-stage monitoring and the second-stage monitoring are used for monitoring whether the random number sequence in the random number channel meets a set condition: can be monitored by correct randomness, is unpredictable, and cannot be reproduced.
One of the above technical solutions has the following advantages or beneficial effects: a random number hardware self-checking module is additionally arranged in the random number generator so as to carry out two hardware automatic monitoring of startup monitoring and online monitoring on the randomness of a data source in the random number generator; and the method is divided into a power-on initial stage and real-time monitoring in the working process, and different stages of different monitoring are carried out on the random number generator. Hardware self-inspection is carried out on the random number generator, so that a software monitoring platform required in a software monitoring mode is omitted; and the real-time monitoring function of the random number generator in the using process is added, so that the random number generator can be ensured to output a normal random number sequence, the safety of a chip to which the random number generator belongs is improved, and the requirement of monitoring environment is simplified.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment can be included in at least one embodiment of the application. The appearances of the phrase in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. It is explicitly and implicitly understood by one skilled in the art that the embodiments described herein can be combined with other embodiments.
The security monitoring method of the random number generator can be applied to the application environment shown in fig. 1. The random number generator includes: the random number self-checking circuit comprises a random source generating circuit, a post-processing circuit and a random number hardware self-checking module. Each part is mainly responsible for: the random source generating circuit is used for generating a plurality of paths of initial random numbers, combining the plurality of paths of initial random numbers into a preliminary random number sequence and outputting the preliminary random number sequence to the post-processing circuit; the post-processing circuit is used for carrying out equalization processing on the input preliminary random number sequence and outputting a final random number sequence; the random number hardware self-checking module corresponds to the random number channels in the random number generator one by one and is used for monitoring whether the random number sequence in each random number channel meets set conditions.
In the embodiment of the invention, the random number channel not only comprises a final random number output channel of the random number generator (namely an output channel of the post-processing circuit), but also comprises a plurality of initial random number output channels; therefore, in the random number generator, there are a plurality of random number channels, and correspondingly, there are a plurality of random number hardware self-checking modules, and the random number hardware self-checking modules correspond to the random number channels one to one. It can be understood that, in the embodiment of the present invention, in the random number generator, the random number hardware self-checking module exists in a hardware manner, and in the security monitoring process of the random number generator, a corresponding software monitoring platform does not need to be additionally arranged.
Referring to fig. 1, in some embodiments, the random source generation circuit may further include: the chaotic power system comprises a plurality of chaotic power systems, a plurality of exclusive-OR chains and a first exclusive-OR logic circuit. The output ends of the chaotic power systems are connected with the input end of an exclusive or chain; the output ends of the plurality of XOR chains are connected with the input end of the first XOR logic circuit; the output end of the first exclusive-OR logic circuit is connected with the output end of the random source generating circuit. Correspondingly, the output channels of the multiple initial random numbers may specifically include: the output channels of the chaotic power system and the output channels of the XOR chains.
As further shown with reference to fig. 1, in some embodiments, the post-processing circuitry may further include: a second exclusive-or logic circuit and a plurality of D flip-flops; the plurality of D triggers are cascaded, and the input end of the D trigger positioned at the head is connected with the input end of the post-processing circuit; the output ends of the plurality of D flip-flop stages are also respectively connected with the input end of the second exclusive-OR logic circuit; and the output end of the second exclusive-or logic circuit is connected with the output end of the random number generator and is used for outputting a random number sequence.
Referring to fig. 2, in some embodiments, the post-processing circuit includes 128D flip-flops (i.e., DFFs) that are connected in cascade, so that the resulting random number can meet the requirements of the national code agency.
Further, the following is a description of the parts of the random number generator:
the chaotic power systems are used as random sources, and each chaotic power system is used for generating a path of initial random numbers;
and the XOR chain is used for merging the initial random numbers generated by the plurality of chaotic power systems connected with the XOR chain to obtain a path of initial random numbers.
Generally, the power factor of the chaotic power system is 1.54, which is far smaller than an ideal power factor 2 of the bernoulli shift mapping, so that the information quantity is lost, and the initial random numbers generated by a plurality of chaotic power systems are combined through an exclusive-or chain, so that the information quantity of an output path of random numbers is improved, and meanwhile, the correlation between adjacent positions in the initial random number data generated by the chaotic power systems is removed. In some embodiments, referring to fig. 2, in the random source generating circuit, two chaotic power systems with the same mechanism are connected to an xor chain, and initial random numbers generated by the two chaotic power systems are processed through the xor chain to obtain a path of preliminary random numbers.
The first exclusive-OR logic circuit is used for exclusive-OR-ing a plurality of paths of preliminary random numbers output by the random source generating circuit into one path; and also for removing correlation between adjacent bits in the preliminary random number sequence output by the random source generation circuit.
The multistage D trigger and the second exclusive-OR logic circuit are used for ensuring the distribution uniformity of 0 and 1 in the final random number sequence output by the random number generator, namely ensuring the balanced distribution of the output final random numbers and simultaneously achieving the purpose of removing the correlation between adjacent bits in the random number sequence output by the multistage D trigger.
In some embodiments, referring to fig. 2, in the random source generation circuit, two chaotic power systems with the same mechanism are connected to one xor chain, and 4 xor chains are provided, so that in a corresponding random number generator, there are 14 random number channels (i.e. data sources to be monitored) and the random number channels are classified into 4 types:
the first type is that the output of 8 chaotic power systems is totally 8 paths;
in the second category, the number of the initial random numbers obtained after data processing of every two chaotic power systems is 1-4, and 4 paths are counted;
in the third category, after 4 paths of data are merged into one path through a first exclusive OR logic circuit, the initial random number before entering a post DFF module is counted into 1 path;
and in the fourth type, the final true random number sequence output by the random number generator totals 1 path.
Compared with a common random number generator, the random number generator shown in fig. 2 is additionally provided with a post-processing circuit, four paths of preliminary random numbers are combined into one path of data, the distribution uniformity of 0 and 1 in a random number sequence is guaranteed through a multi-stage D trigger, and finally the four paths of preliminary random numbers are combined into one path through a second exclusive-or logic circuit to obtain the final random number output.
In the embodiment of the invention, under a normal condition, each path of data source to be monitored meets the following conditions: can be monitored by correct randomness, is unpredictable, and cannot be reproduced.
In addition, in the embodiment of the present invention, the random number generator is further provided with a plurality of random number hardware self-checking modules, and the random number hardware self-checking modules correspond to the data sources to be monitored one by one and are respectively used for monitoring whether each path of data source to be monitored meets the set requirement. The data source to be monitored not only comprises the final random number sequence, but also comprises a plurality of intermediate data sources in the random number generator, so that the instantaneity of monitoring is improved.
Referring to fig. 3, in an embodiment, the random number hardware self-inspection module includes a startup monitoring module and an online monitoring module, when the random number generator is just powered on or the random number generator turns from off to enable, the startup monitoring modules of the multiple random number hardware self-inspection modules respectively monitor the multiple paths of data sources to be monitored simultaneously, and only after startup monitoring of the multiple paths of data sources to be monitored passes, a final random number sequence generated by the random number generator is allowed. After the random number generator is monitored by the startup, in the normal working process, the online monitoring modules of the random number hardware self-checking modules are further used for monitoring all the paths of data sources to be monitored simultaneously, and once a certain path of data source to be monitored is monitored to be not meeting set conditions, abnormal monitoring results of the random number generator are given.
Specifically, the startup monitoring module may specifically include a monitoring module based on the poker monitoring principle; the online monitoring module may specifically include a monitoring module based on a single-bit frequency monitoring principle, a run total monitoring principle, or a matrix rank monitoring principle. The specific monitoring modes of poker monitoring, single-bit frequency monitoring, total run number monitoring or matrix rank monitoring of the random number sequence can be carried out according to recorded related monitoring modes by combining with actual scene requirements, and the monitoring modes are not limited.
Compared with the traditional software monitoring method, the monitoring method provided by the embodiment of the invention can eliminate the hysteresis of the monitoring result, is convenient for discovering the abnormity of the random number generator in time, and simplifies the requirement of monitoring environment.
In one embodiment, as shown in FIG. 4, a method for security monitoring of a random number generator is provided, which is illustrated by way of example as applied to the random number generator of FIG. 1, and comprises the steps of:
s110, when the random number generator is monitored to be electrified or switched from the off state to the enabled state, a random number hardware self-checking module in the random number generator is started. And carrying out first-stage monitoring on data output by a plurality of random number channels in the random number generator through a plurality of random number hardware self-checking modules.
S120, after each random number hardware self-checking module is started, firstly, a startup monitoring module is operated; and monitoring each path of data source to be monitored in the random number generator through the startup monitoring module.
S130, if the monitoring results of the startup monitoring modules of all the random number hardware self-checking modules are passed, namely each path of data source to be monitored in the random number generator meets the set conditions, the random number generator enters a normal operation stage and enters the step S140, and otherwise, the step S160 is entered.
In some embodiments, the startup monitoring module may monitor each path of data source to be monitored by using a poker monitoring principle, and according to actual conditions, the startup monitoring module may also monitor each path of data source to be monitored by using other monitoring principles which need to meet a random number monitoring standard promulgated by the national crypto authority.
S140, in the normal operation stage of the random number generator, an online monitoring module in each random number hardware self-checking module operates, and a startup monitoring module stops monitoring; and monitoring each path of data source to be monitored in the random number generator through the online monitoring modules of all the random number hardware self-checking modules.
In the embodiment of the invention, the data output by a plurality of random number channels in the random number generator is monitored in the second stage through the startup monitoring module of the plurality of random number hardware self-checking modules.
S150, if the online monitoring result of any random number channel in the random number generator does not pass, outputting an abnormal prompt signal through a random number hardware self-checking module corresponding to any random number channel.
In the normal operation stage of the random number generator, if a certain online monitoring module monitors that the corresponding data source to be monitored does not accord with the set condition, outputting a prompt signal of the abnormality of the corresponding data source to be monitored through a random number hardware self-checking module where the online monitoring module is located.
In some embodiments, the online monitoring module may monitor each path of data source to be monitored by using a single-bit frequency monitoring principle, a total run number monitoring principle, or a matrix rank monitoring principle, and according to an actual situation, the online monitoring module may also monitor each path of data source to be monitored by using another monitoring principle that needs to meet a random number monitoring standard issued by the national crypto-administration.
And S160, if the startup monitoring result of any random number channel in the random number generator does not pass through, outputting an abnormal prompt signal through a random number hardware self-checking module corresponding to any random number channel.
The abnormal prompt signal output by the random number hardware self-checking module can be a sound signal or an indicator light signal.
According to the safety monitoring method of the random number generator, the random number hardware self-checking module is additionally arranged in each random number channel in the random number generator, so that hardware automatic monitoring of two stages of startup monitoring and online monitoring is performed on the randomness of data sources of a plurality of random number channels in the random number generator; and the method is divided into a power-on initial stage and real-time monitoring in the working process, and different stages of different monitoring are carried out on the random number generator. Hardware self-inspection is carried out on the random number generator, so that a software monitoring platform required in a software monitoring mode is omitted; and the real-time monitoring function of the random number generator in the using process is added, so that the random number generator can be ensured to output a normal random number sequence, and the safety of the chip to which the random number generator belongs is improved.
It should be understood that for the foregoing method embodiments, although the steps in the flowcharts are shown in order indicated by the arrows, the steps are not necessarily performed in order indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a portion of the steps in the flow charts of the method embodiments may include multiple sub-steps or multiple stages that are not necessarily performed at the same time, but may be performed at different times, and the order of performance of the sub-steps or stages is not necessarily sequential, but may be performed in turn or alternating with other steps or at least a portion of the sub-steps or stages of other steps.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
The terms "comprises" and "comprising," as well as any variations thereof, of the embodiments herein are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or modules is not limited to the listed steps or modules but may alternatively include other steps or modules not expressly listed or inherent to such process, method, article, or apparatus.
Reference herein to "a plurality" means two or more. "and/or" describes the association relationship of the associated objects, meaning that there may be three relationships, e.g., a and/or B, which may mean: a exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship.
References to "first \ second" herein are merely to distinguish between similar objects and do not denote a particular ordering with respect to the objects, it being understood that "first \ second" may, where permissible, be interchanged with a particular order or sequence. It should be understood that "first \ second" distinct objects may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced in sequences other than those illustrated or described herein.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present patent shall be subject to the appended claims.