CN110531957B - On-line detection method of random number generator - Google Patents

On-line detection method of random number generator Download PDF

Info

Publication number
CN110531957B
CN110531957B CN201910859038.7A CN201910859038A CN110531957B CN 110531957 B CN110531957 B CN 110531957B CN 201910859038 A CN201910859038 A CN 201910859038A CN 110531957 B CN110531957 B CN 110531957B
Authority
CN
China
Prior art keywords
random number
detection
square
detected
bit pattern
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910859038.7A
Other languages
Chinese (zh)
Other versions
CN110531957A (en
Inventor
包蕾
甘杰
成嵩
胡晓波
姜明刚
李娜
李建阳
毛嵘
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
State Grid Corp of China SGCC
State Grid Information and Telecommunication Co Ltd
Beijing Smartchip Microelectronics Technology Co Ltd
Original Assignee
State Grid Corp of China SGCC
State Grid Information and Telecommunication Co Ltd
Beijing Smartchip Microelectronics Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by State Grid Corp of China SGCC, State Grid Information and Telecommunication Co Ltd, Beijing Smartchip Microelectronics Technology Co Ltd filed Critical State Grid Corp of China SGCC
Priority to CN201910859038.7A priority Critical patent/CN110531957B/en
Publication of CN110531957A publication Critical patent/CN110531957A/en
Application granted granted Critical
Publication of CN110531957B publication Critical patent/CN110531957B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/58Random or pseudo-random number generators
    • G06F7/588Random number generators, i.e. based on natural stochastic processes

Abstract

The invention discloses an online detection method of a random number generator, which comprises the following steps: receiving a random number to be detected through a shift register, wherein the random number to be detected is 128 bits; after receiving the random number to be detected, carrying out chi-square detection on the received random number according to a formula, wherein the formula I is as follows:
Figure DDA0002199166430000011
wherein, OiThe occurrence frequency of a 4-bit pattern i in a 128-bit random number to be detected; and if the chi-square detection result meets the formula I, judging that the random number to be detected passes the detection. According to the online detection method of the random number generator, online detection of the random number is realized by chi-square detection according to the formula I, the complexity is sufficient, the consumption of hardware resources is reduced, the expenses of area and power consumption are reduced, and the detection performance is obviously improved compared with software implementation.

Description

On-line detection method of random number generator
Technical Field
The invention relates to random numbers, in particular to an online detection method of a random number generator.
Background
With the development and wide application of information technology and computer technology, information security is more and more emphasized by people. The information security architecture needs to use a large number of random numbers, such as keys of a cryptographic algorithm, initiated challenge responses, padded random number bits or used masks, and the like, so that the random numbers are an important part of the information security system, the quality of the random numbers directly affects the security of the whole information security system, and the performance of the whole system is also directly affected by the quality of the random numbers.
The random number is generated by a random number generator, and the random number generator generally consists of an entropy source, post-processing and online detection. The entropy source part provides the required randomness, namely the most initial entropy; the post-processing part generally has two functions, one is to compress and raise the entropy value of each bit, and the other is to mix up sufficiently and average the entropy value into each bit. The on-line detection part detects the quality of the random number in real time and checks the quality of the random number.
Based on this, the inventors of the present application found that all current random number online detection methods are designed based on mathematical probability statistics theory, and mainly face two problems: in order to realize the simplicity of design consideration, the detection of each detection mechanism may not be achieved; for safety and over-inspection, the design is complex enough, and because the mathematical expression is complex, the calculations such as division, squaring, averaging, summation and the like are generally needed, and the calculations are expensive in area and power consumption for hardware implementation, while the performances are low when the calculations are implemented by software.
Based on this, the inventor of the present application found that, for the online detection part, there is no unified standard regulation all the time, and all people are respectively researched and developed, but they are built based on the mathematical probability statistics theory. The most common method is chi-square detection, which is complex in chi-square detection operation, large in resource consumption by hardware implementation, and low in software implementation performance.
The information disclosed in this background section is only for enhancement of understanding of the general background of the invention and should not be taken as an acknowledgement or any form of suggestion that this information forms the prior art already known to a person skilled in the art.
Disclosure of Invention
The invention aims to provide an online detection method of a random number generator, which can simplify the consumption of hardware resources on the premise of not reducing the implementation performance.
In order to achieve the above object, the present invention provides an online detection method for a random number generator, comprising: receiving a random number to be detected through a shift register, wherein the random number to be detected is 128 bits; after receiving the random number to be detected, carrying out chi-square detection on the received random number according to a formula, wherein the formula I is as follows:
Figure GDA0002913832240000021
wherein, OiThe occurrence frequency of a 4-bit pattern i in a 128-bit random number to be detected; and if the chi-square detection result meets the formula I, judging that the random number to be detected passes the detection.
In a preferred embodiment, the shift register is a 4-bit shift register.
In a preferred embodiment, the chi-squared detection of the received random numbers according to the formula includes: counting the occurrence times of a 4-bit pattern i in 128bits, wherein the 4-bit pattern i comprises 0000, 0001, 0010 … … 1111; respectively calculating the occurrence times O of each 4-bit pattern iiSquare of (A) Oi 2(ii) a Number of occurrences O for each 4-bit pattern iiSquare of (A) Oi 2Summing is carried out; the result of the summation is compared to 194.
In a preferred embodiment, if the result of the chi-square detection satisfies the formula one, determining that the random number to be detected passes the detection includes: and if the summation result is less than or equal to 194, the random number to be detected passes the detection.
In a preferred embodiment, the comparing the summation result with 194 includes: subtract 194 from the sum; if the chi-square detection result meets the formula one, judging that the random number to be detected passes the detection, wherein the detection comprises the following steps: and if the subtraction of the summation result and 194 does not borrow, judging that the random number to be detected passes the detection.
In a preferred embodiment, after subtracting the sum result from 194, the method further includes: and if the subtraction of the summation result and 194 has borrow, judging that the random number to be detected does not pass the detection.
In a preferred embodiment, the number of occurrences O of each 4-bit pattern i is calculated separatelyiSquare of (A) Oi 2The method comprises the following steps: calculating the occurrence number O of 4-bit pattern 0000 by a multiplier0Square of (A) O0 2(ii) a The number of occurrences O of 4-bit pattern 0001 is calculated by a multiplier1Square of (A) O1 2The number of occurrences O of the 4-bit pattern i is repeatediSquare of (A) Oi 2Until the occurrence times O of all 4-bit patterns i are completediSquare of (A) Oi 2And (4) calculating.
In a preferred embodiment, the number of occurrences O for each 4-bit pattern iiSquare of (A) Oi 2The summing comprises:
the occurrence times O of all the bit patterns i are counted by an adderiSquare of (A) Oi 2The summation is performed.
In a preferred embodiment, the number of multipliers is 1.
Compared with the prior art, the online detection method of the random number generator realizes online detection of the random number by carrying out chi-square detection according to the formula I, has enough complexity, reduces consumption of hardware resources, reduces expenses of area and power consumption, and obviously improves detection performance compared with software implementation.
Drawings
FIG. 1 is a flow diagram of a method for online detection of a random number generator according to one embodiment of the invention.
FIG. 2 is a flow diagram of a method for online detection of a random number generator according to another embodiment of the invention.
FIG. 3 is a flow chart of one implementation of online detection according to one embodiment of the invention.
Detailed Description
The following detailed description of the present invention is provided in conjunction with the accompanying drawings, but it should be understood that the scope of the present invention is not limited to the specific embodiments.
Throughout the specification and claims, unless explicitly stated otherwise, the word "comprise", or variations such as "comprises" or "comprising", will be understood to imply the inclusion of a stated element or component but not the exclusion of any other element or component.
Referring to FIG. 1, a flow chart of a method for online testing of a random number generator according to a preferred embodiment of the present invention comprises: steps S1-S3.
In step S1, a random number to be detected is received through the shift register, where the random number to be detected is 128 bits.
Wherein, the shift register can be a 4-bit shift register. The 4-bit shift register is used for receiving random numbers generated by the random number generator, and the random numbers are generated by one bit and one bit, and the patterns of the 4-bit random numbers need to be counted, so that only the 4-bit shift register is needed, each beat is subjected to shift storage, the patterns of the 4-bit random numbers just meet after 4 beats, the old 4-bit random numbers just are pushed down in the next 4 beats, and the new 4-bit random numbers are stored.
In step S2, after the random number to be detected is received, chi-square detection is performed on the received random number according to the formula one:
Figure GDA0002913832240000041
wherein Oi is the occurrence frequency of a 4-bit pattern i in a 128-bit random number to be detected;
and after all the 128-bit random numbers are registered, carrying out card party detection on the received random numbers.
Specifically, the most common method for on-line detection is chi-square detection, and the mathematical expression of the principle is
Figure GDA0002913832240000051
The method comprises four basic operations of subtraction, square, division and summation, is relatively complex, and is realized by hardware, so that the resource consumption is relatively high, a software implementation mode is generally adopted, and the performance of the software implementation is relatively low.
In the embodiment, the 128bits random number is subjected to online detection and significance level selection of 3.8 multiplied by 10 according to the recommendation of AIS20/31 standard-74 bits are in one group, then EiWhen the judgment condition is 2: chi shape2Less than or equal to 65. The formula translates to:
Figure GDA0002913832240000052
the above formula is optimally derived, and the steps are as follows:
Figure GDA0002913832240000053
Figure GDA0002913832240000054
Figure GDA0002913832240000055
further, a formula one is obtained:
Figure GDA0002913832240000056
in the formula I, only the calculation of the statistical square sum is reserved, so that the implementation structure of hardware can be simplified.
In step S3, if the chi-square detection result satisfies the formula one, it is determined that the random number to be detected passes the detection.
Specifically, it can be determined by comparing the sum with 194, and if the sum is less than or equal to 194, the random number to be detected passes the detection.
Therefore, the online detection of the random number is realized by carrying out chi-square detection according to the formula I, the complexity is enough, the consumption of hardware resources is reduced, the expenses of area and power consumption are reduced, and the detection performance is obviously improved compared with the software implementation.
Fig. 2 is a flow chart of an online detection method of a random number generator according to another preferred embodiment of the present invention, and fig. 3 is a flow chart of an implementation method of online detection provided in this embodiment. In this embodiment, steps S2 and S3 are further defined on the basis of embodiment one. Step S2 in the present embodiment may include steps S21 to S24, and step S3 may include steps S31 to S32.
In step S21, the number of occurrences O of the 4-bit pattern i in 128bits is countediWherein the 4-bit pattern i includes 0000, 0001, 0010 … … 1111.
In step S22, the number of occurrences O of each 4-bit pattern i is calculated separatelyiSquare of (A) Oi 2
Specifically, the number O of occurrences of the 4-bit pattern 0000 may be calculated by a multiplier0Square of (A) O0 2(ii) a The number of occurrences O of 4-bit pattern 0001 is calculated by a multiplier1Square of (A) O1 2Repeating the output of the 4-bit pattern iNumber of present times OiSquare of (A) Oi 2Until the occurrence times O of all 4-bit patterns i are completediSquare of (A) Oi 2And (4) calculating.
The number of multipliers is 1-16. Preferably, in order to save resources, the number of the multipliers is 1, and when the above calculation is implemented, 16 multipliers are called to save hardware resources.
In step S23, the number of occurrences O for each 4-bit pattern iiSquare of (A) Oi 2The summation is performed.
Specifically, the occurrence times O of all the bit patterns i can be counted by an adderiSquare of (A) Oi 2Summing, in other words, the calculation results of the 16-time multipliers are summed by the adder to realize the sum in the formula
Figure GDA0002913832240000061
And (4) calculating.
In step S24, the above summation result is compared with 194.
Among them, it may be specifically: the comparison with 194 may be achieved by subtracting the sum from 194.
The corresponding step S3 may include: step S31-step S32.
In step S31, if the result of the summation is subtracted from 194 without borrowing, it is determined that the random number to be detected passes the detection.
In step S32, if the sum is subtracted from 194 by a borrow, it is determined that the random number to be detected has not passed the detection.
In this embodiment, the card-out side detection can be realized only by controlling one 4-bit shift register, one multiplication module, one addition module, one subtraction module and a small number of counters.
Therefore, in the implementation process, all random number seeds do not need to be stored, and only 4bit patterns need to be counted; instead of calculating the cumulative sum of all squares in a beat, only one squaring module is used to repeatedly invoke 16 cumulative sums to calculate the sum of squares. The consumption of hardware resources is reduced, the expenses of area and power consumption are reduced, and compared with software implementation, the detection performance is obviously improved.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The foregoing descriptions of specific exemplary embodiments of the present invention have been presented for purposes of illustration and description. It is not intended to limit the invention to the precise form disclosed, and obviously many modifications and variations are possible in light of the above teaching. The exemplary embodiments were chosen and described in order to explain certain principles of the invention and its practical application to enable one skilled in the art to make and use various exemplary embodiments of the invention and various alternatives and modifications as are suited to the particular use contemplated. It is intended that the scope of the invention be defined by the claims and their equivalents.

Claims (9)

1. A method for online detection of a random number generator, comprising:
receiving a random number to be detected through a shift register, wherein the random number to be detected is 128 bits;
after receiving the random number to be detected, carrying out chi-square detection on the received random number according to a formula, wherein the formula I is as follows:
Figure FDA0002913832230000011
wherein, OiThe occurrence frequency of a 4-bit pattern i in a 128-bit random number to be detected;
and if the chi-square detection result meets the formula I, judging that the random number to be detected passes the detection.
2. The on-line detection method of claim 1, wherein the shift register is a 4-bit shift register.
3. The on-line detection method of claim 1, wherein said chi-squared detection of the received random numbers according to the formula comprises:
counting the occurrence times O of the 4-bit pattern i in 128bitsiWherein the 4-bit pattern i includes 0000, 0001, 0010 … … 1111;
respectively calculating the occurrence times O of each 4-bit pattern iiSquare of (A) Oi 2
Number of occurrences O for each 4-bit pattern iiSquare of (A) Oi 2Summing is carried out;
the result of the summation is compared to 194.
4. The on-line detection method of claim 3, wherein if the chi-square detection result satisfies the formula one, determining that the random number to be detected passes the detection comprises:
and if the summation result is less than or equal to 194, the random number to be detected passes the detection.
5. The on-line testing method of claim 4 wherein said comparing said summation result with 194 comprises:
subtract 194 from the sum;
if the chi-square detection result meets the formula one, judging that the random number to be detected passes the detection, wherein the detection comprises the following steps:
and if the subtraction of the summation result and 194 does not borrow, judging that the random number to be detected passes the detection.
6. The on-line detection method as claimed in claim 5, wherein after subtracting 194 from the summation result, further comprising:
and if the subtraction of the summation result and 194 has borrow, judging that the random number to be detected does not pass the detection.
7. The on-line detection method as claimed in claim 3, wherein said calculating the number of occurrences O of each 4-bit pattern i separatelyiSquare of (A) Oi 2The method comprises the following steps:
calculating the occurrence number O of 4-bit pattern 0000 by a multiplier0Square of (A) O0 2
The number of occurrences O of 4-bit pattern 0001 is calculated by a multiplier1Square of (A) O1 2The number of occurrences O of the 4-bit pattern i is repeatediSquare of (A) Oi 2Until the occurrence times O of all 4-bit patterns i are completediSquare of (A) Oi 2And (4) calculating.
8. The on-line detection method as claimed in claim 7, wherein said number of occurrences O for each 4-bit pattern iiSquare of (A) Oi 2The summing comprises:
the occurrence times O of all the 4-bit patterns i are calculated by an adderiSquare of (A) Oi 2The summation is performed.
9. The on-line detection method of claim 7, wherein the number of multipliers is 1.
CN201910859038.7A 2019-09-11 2019-09-11 On-line detection method of random number generator Active CN110531957B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910859038.7A CN110531957B (en) 2019-09-11 2019-09-11 On-line detection method of random number generator

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910859038.7A CN110531957B (en) 2019-09-11 2019-09-11 On-line detection method of random number generator

Publications (2)

Publication Number Publication Date
CN110531957A CN110531957A (en) 2019-12-03
CN110531957B true CN110531957B (en) 2021-04-23

Family

ID=68668139

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910859038.7A Active CN110531957B (en) 2019-09-11 2019-09-11 On-line detection method of random number generator

Country Status (1)

Country Link
CN (1) CN110531957B (en)

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6798883B1 (en) * 2000-09-18 2004-09-28 The United States Of America As Represented By The National Security Agency Method of testing a randomizer
CN104834499A (en) * 2014-02-12 2015-08-12 韩国电子通信研究院 Apparatus and method for stabilizing output sequence of real random number generator
CN108491318A (en) * 2018-02-07 2018-09-04 深圳市洛酷信息科技有限公司 A kind of sequence detecting method, electronic equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108462205B (en) * 2018-03-27 2021-08-17 华北电力大学 Interconnected power system damping control method adapting to wind power random fluctuation
CN110502208B (en) * 2019-08-16 2021-05-25 兆讯恒达科技股份有限公司 Multi-random source management method of random number generator

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6798883B1 (en) * 2000-09-18 2004-09-28 The United States Of America As Represented By The National Security Agency Method of testing a randomizer
CN104834499A (en) * 2014-02-12 2015-08-12 韩国电子通信研究院 Apparatus and method for stabilizing output sequence of real random number generator
CN108491318A (en) * 2018-02-07 2018-09-04 深圳市洛酷信息科技有限公司 A kind of sequence detecting method, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于基尼指标和卡方检验的特征选择方法;陈谌;《计算机工程与设计》;20190816;全文 *

Also Published As

Publication number Publication date
CN110531957A (en) 2019-12-03

Similar Documents

Publication Publication Date Title
US11017036B2 (en) Publicly verifiable proofs of space
CN112260818B (en) Side channel curve enhancement method, side channel attack method and side channel attack device
US10721056B2 (en) Key processing method and device
Liu et al. Security in approximate computing and approximate computing for security: Challenges and opportunities
CN107508678A (en) The side-channel attack method of RSA masks defence algorithm based on machine learning
CN106487512A (en) A kind of RSA key is to quick-speed generation system and method
CN111985411A (en) Energy trace preprocessing method based on Sinc convolution noise reduction self-encoder
CN111934852A (en) AES password chip electromagnetic attack method and system based on neural network
CN114722700A (en) Short-term personal load prediction method, system, equipment and terminal for privacy protection
CN110807484B (en) Privacy protection VGG-based dense image recognition method and system
Jang et al. Quantum gate pattern recognition and circuit optimization for scientific applications
CN110531957B (en) On-line detection method of random number generator
CN112733458B (en) Engineering structure signal processing method based on self-adaptive variational modal decomposition
CN107437005B (en) Code obfuscation method and device based on chaotic opaque predicates
CN104811295A (en) Side channel energy analysis method for ZUC cryptographic algorithm with mask protection
CN112685788A (en) Data processing method and device
CN115801253B (en) Multi-party secret sharing method for secure multi-party calculation and electronic equipment
CN114095182B (en) Dynamic response and security authentication method and system based on strong PUF
CN114647824B (en) Active protection method and system for neural network, storage medium and computing equipment
CN115719094A (en) Model training method, device, equipment and storage medium based on federal learning
CN109559269A (en) A kind of method and terminal of image encryption
Elliott Nash equilibrium of multiple, non-uniform bitcoin block withholding attackers
Dayal et al. Coalescence of Neural Networks and Blockchain
CN111817847B (en) Bypass defense method and device based on SIKE algorithm, electronic equipment and readable medium
CN112134679B (en) Combined high-order side channel attack method, device, equipment and medium for SM4

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant