Entropy pool creation method, chip, electronic equipment and storage medium
By creating an entropy pool and detecting and filtering random data, the problem of insufficient quality of random numbers is solved, the security of passwords is improved, and the security of session key generation is ensured.
Patent Information
- Application Number
- CN202411134526.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2024-12-06
AI Technical Summary
The quality of random numbers in the prior art is insufficient, which affects the security of the password. In particular, the generation of session keys is easily calculated in confidential communication, resulting in unsafe communication.
By creating an entropy pool, random data are collected and detected and filtered, to ensure that the extracted random data meets certain entropy values and length requirements, it is added to the entropy pool to generate high-quality random numbers through the entropy mixing algorithm.
Improve the quality of random numbers, enhance the security of passwords, ensure the security of the generation of session keys, and prevent the key from being calculated.
Smart Images

Figure CN119088346A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security technology, and in particular to an entropy pool creation method, chip, electronic device and storage medium. Background Art
[0002] Random numbers provide basic security for many cryptographic applications such as cryptographic algorithms and security protocols. They are at the core of cryptography and play a vital role. Therefore, the quality of random numbers will affect the security of cryptography. For example, session keys are widely used in confidential communications, and the generation of session keys requires the participation of random numbers. If the randomness of a random sequence is poor, the session key may be deduced, and the encryption algorithm is usually a public standard algorithm, so confidential communications will become insecure communications. Summary of the invention
[0003] The present application provides an entropy pool creation method, chip, electronic device and storage medium, which help to improve the quality of random numbers.
[0004] In a first aspect, the present application provides an entropy pool creation method, comprising: creating a first entropy pool, the first entropy pool comprising collected random data; extracting random data from the first entropy pool; if the length of the extracted random data is greater than or equal to a first threshold, determining that the extracted random data is first random data; performing a qualification test on the first random data; if the first random data is qualified, adding the first random data to a second entropy pool, wherein the second entropy pool is used to output a random number.
[0005] The embodiments of the present application can help improve the quality of random numbers.
[0006] In one possible implementation, the method further includes: if the first random data is qualified, determining whether the entropy value of the first random data is greater than or equal to a second threshold; if the entropy value of the first random data is greater than or equal to the second threshold, post-processing the first random data to obtain second random data, wherein the length of the second random data is greater than the length of the first random data; and adding the second random data to the second entropy pool.
[0007] In one possible implementation, the qualification detection of the first random data includes: dividing the first random data into blocks to obtain multiple blocks; detecting the multiple blocks of the first random data; and determining whether the first random data is qualified based on the detection results of the multiple blocks of the first random data.
[0008] In one possible implementation, after detecting multiple blocks of the first random data, the method further includes: determining whether the multiple blocks of the first random data meet preset requirements; retaining the blocks that meet the preset requirements, and discarding the blocks that do not meet the preset requirements; performing a qualified judgment on the first random data based on the detection results of the multiple blocks of the first random data includes: if the number of blocks that meet the preset requirements is the same as the number of blocks of the first random data, performing a qualified judgment on the first random data based on the detection results of the multiple blocks of the first random data.
[0009] In one possible implementation manner, the method also includes: if the number of blocks that meet the preset requirements is different from the number of blocks of the first random data, obtaining third random data, the third random data being a random data in the first entropy pool; blocking the third random data to obtain multiple blocks; merging the blocks that meet the preset requirements to obtain fourth random data, wherein the number of blocks that meet the preset requirements in the fourth random data is the same as the number of blocks in the first random data; and performing a qualified judgment on the fourth random data based on the detection results of multiple blocks in the fourth random data.
[0010] In one possible implementation manner, the randomness data at least includes system environment noise data.
[0011] In a second aspect, the present application provides a chip, comprising one or more functional modules, wherein the one or more functional modules are used to execute the entropy pool creation method as described in the first aspect.
[0012] In a third aspect, the present application provides an electronic device, comprising: a processor and a memory, the memory being used to store a computer program; the processor being used to run the computer program to implement the entropy pool creation method as described in the first aspect.
[0013] In a fourth aspect, the present application provides a readable storage medium, which stores a program. When the program is run on an electronic device, the electronic device implements the entropy pool creation method as described in the first aspect.
[0014] In a fifth aspect, the present application provides a program, which, when executed on a processor of an electronic device, enables the electronic device to execute the entropy pool creation method as described in the first aspect.
[0015] In one possible design, the program in the fifth aspect may be stored in whole or in part on a storage medium packaged together with the processor, or may be stored in whole or in part on a memory not packaged together with the processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 A schematic diagram of a process flow of an embodiment of the entropy pool creation method provided in this application;
[0017] Figure 2 A schematic diagram of a flow chart of another embodiment of the entropy pool creation method provided by the present application;
[0018] Figure 3 A schematic diagram of the structure of a chip provided in an embodiment of the present application;
[0019] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0020] In the embodiments of the present application, unless otherwise specified, the character " / " indicates that the objects before and after the association are in an or relationship. For example, A / B can represent A or B. "And / or" describes the association relationship of the associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone.
[0021] It should be pointed out that the words "first", "second", etc. involved in the embodiments of the present application are only used to distinguish the description purpose, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated, nor can they be understood as indicating or implying order.
[0022] In the embodiments of the present application, "at least one" refers to one or more, and "plurality" refers to two or more. In addition, "at least one of the following" or similar expressions refers to any combination of these items, which may include any combination of single items or plural items. For example, at least one of A, B, or C may represent: A, B, C, A and B, A and C, B and C, or A, B and C. Among them, each of A, B, and C may be an element itself, or a set containing one or more elements.
[0023] In the embodiments of the present application, "exemplary", "in some embodiments", "in another embodiment", etc. are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present concepts in a concrete way.
[0024] In the embodiments of the present application, "of", "corresponding", and "corresponding" can sometimes be used interchangeably. It should be noted that when the distinction between them is not emphasized, the meanings to be expressed are consistent. In the embodiments of the present application, communication and transmission can sometimes be used interchangeably. It should be noted that when the distinction between them is not emphasized, the meanings to be expressed are consistent. For example, transmission can include sending and / or receiving, which can be a noun or a verb.
[0025] The equal to involved in the embodiments of the present application can be used in conjunction with greater than, and is applicable to the technical solution adopted when greater than, and can also be used in conjunction with less than, and is applicable to the technical solution adopted when less than. It should be noted that when equal to is used in conjunction with greater than, it cannot be used in conjunction with less than; when equal to is used in conjunction with less than, it cannot be used in conjunction with greater than.
[0026] Random numbers provide basic security for many cryptographic applications such as cryptographic algorithms and security protocols. They are at the core of cryptography and play a vital role. Therefore, the quality of random numbers will affect the security of cryptography. For example, session keys are widely used in confidential communications, and the generation of session keys requires the participation of random numbers. If the randomness of a random sequence is poor, the session key may be deduced, and the encryption algorithm is usually a public standard algorithm, so confidential communications will become insecure communications.
[0027] It can be understood that random numbers are data generated by a random number generator, which uses entropy to describe the randomness of the data. Entropy is a physical quantity that describes the chaotic program of a system. The greater the entropy of a system, the worse the order of the system, that is, the greater the uncertainty.
[0028] An entropy pool can be maintained inside the random number generator of the operating system, and the entropy pool can be used to collect environmental noise from device drivers and other sources. For example, the operating system can create a main entropy pool after the system starts, and the main entropy pool can include multiple sub-entropy pools, each of which can serve as an entropy source and can collect random events according to specific event trigger conditions. For example, an interrupt entropy source can collect randomness data when an interrupt event occurs and add the randomness data to the interrupt entropy source.
[0029] In addition, the operating system can provide a series of output interfaces to output random numbers. These output interfaces can extract random data from the entropy pool and use appropriate entropy mixing algorithms to generate random numbers of specific lengths.
[0030] Based on the above problems, an embodiment of the present application proposes an entropy pool creation method, which helps to improve the quality of random numbers.
[0031] The entropy pool creation method provided in the present application is applied to an electronic device. The electronic device may be a fixed terminal, such as a desktop computer, a server, etc. Alternatively, the electronic device may be a mobile terminal, such as a mobile phone, a tablet, etc. The embodiment of the present application does not specifically limit the type of electronic device.
[0032] It is understandable that the electronic devices in the embodiments of the present application may use different operating systems, for example, Linux system, Andriod system, IOS system and Windows system, etc., and the embodiments of the present application do not specifically limit this.
[0033] Now combined Figure 1 and Figure 2 The entropy pool creation method provided in the embodiment of the present application is exemplified.
[0034] Figure 1 The schematic diagram of an embodiment of the entropy pool creation method provided in this application specifically includes the following steps:
[0035] Step 101: Create a first entropy pool, where the first entropy pool includes collected random data.
[0036] Specifically, the first entropy pool can be understood as an input entropy pool, and the first entropy pool can include collected random data.
[0037] Exemplarily, the first entropy pool may include multiple sub-entropy pools, wherein each sub-entropy pool may serve as an entropy source, and each entropy source may be used to collect random events according to specific event triggering conditions, and may collect random data corresponding to the random events. For example, an interrupt entropy source may collect random data when an interrupt event occurs, and add the random data to the interrupt entropy source.
[0038] It can be understood that the sub-entropy pool in the first entropy pool can continuously collect random data, that is, new random data can be continuously added to the first entropy pool.
[0039] The random data may include but are not limited to system environment noise data. It is understandable that the system environment noise data may be data generated by driving or random events.
[0040] Step 102: Obtain random data from the first entropy pool and add the random data to a queue.
[0041] Specifically, after the first entropy pool contains the collected randomness data, the randomness data can be obtained from the first entropy pool.
[0042] Among them, the randomness data obtained from the first entropy pool may be part of the data collected in the first entropy pool, or the randomness data obtained from the first entropy pool may be all the data collected in the first entropy pool, and the embodiment of the present application does not specifically limit this.
[0043] Next, after obtaining random data from the first entropy pool, the random data may be added to the queue.
[0044] Step 103, extract a random data from the queue.
[0045] It can be understood that step 102 and step 103 are optional steps. In some optional embodiments, random data can be directly extracted from the first entropy pool.
[0046] Step 104, determining the length of the extracted random data.
[0047] Specifically, after the random data is extracted from the queue, the length of the extracted random data may be determined.
[0048] The length of the random data may refer to the byte length of the random data.
[0049] In some optional embodiments, random data may be directly extracted from the first entropy pool, and the length of the extracted random data may be determined.
[0050] In some optional embodiments, the length of the random data may refer to the bit length of the random data, or the length of the random data may refer to the length of other units of the random data, which is not particularly limited in the embodiments of the present application.
[0051] If the length of the extracted random data is greater than or equal to the first threshold, it is determined that the extracted random data is the first random data, and step 105 is executed. Or,
[0052] If the length of the extracted random data is less than the first threshold, step 103 is executed.
[0053] Step 105: Perform a qualification test on the first random data.
[0054] Specifically, the qualification test is used to detect whether the first random data meets the requirements of the entropy pool.
[0055] Among them, the qualified testing methods can include the following two types:
[0056] Method 1: Detection based on commercial encryption detection standards.
[0057] First, 15 tests can be performed in sequence, including single-bit frequency detection, intra-block frequency detection, poker detection, overlapping subsequence detection, total run detection, run distribution detection, maximum run detection in block, binary derivation detection, autocorrelation detection, matrix rank detection, cumulative sum detection, approximate entropy detection, linear complexity detection, Maurer general statistics detection, and discrete Fourier detection.
[0058] Among them, some detection items can use different detection parameters, different detection modes or have multiple statistical values, and will be detected and determined as separate randomness detection items. For example, poker detection is tested twice, overlapping subsequence detection is tested four times, maximum run detection within a block is tested twice, binary derivation detection is tested twice, autocorrelation detection is tested four times, cumulative sum detection is tested twice, approximate entropy detection is tested twice, and linear complexity detection is tested twice.
[0059] Therefore, the detection of the first random data may include 27 detections, and each detection of each detection may save its statistical value P and statistical value Q.
[0060] Then, the sample pass rate and distribution uniformity of each test item can be qualified. It can be understood that the qualified test of the first random data can be completed through the above test and qualified judgment.
[0061] For each test item, we can count the number of samples whose statistical value P is greater than or equal to the significance level among all samples, and the significance level is defined as α = 0.01. Let the number of samples be s. When the number of samples passing a test item is greater than or equal to , the sample set is considered to have passed this test.
[0062] Alternatively, for each test item, the statistical value Q of all samples should be uniformly distributed in the interval [0,1]. Let the number of samples be s, and the interval is divided into k uniform sub-intervals. The actual number of statistical values Q of each sample in all samples in the k sub-intervals is counted as F. i , and use the chi-square distribution to compare with the theoretical value s / k to calculate the statistical value And calculate the statistical value When P τ ≥α τ , the sample set is considered to have passed this test, and the significance level α for sample uniformity distribution is defined τ =0.0001, the number of subintervals k=10.
[0063] Method 2: Detection based on the NIST SP800-22 standard.
[0064] First, 15 tests can be performed in sequence, including single-bit frequency detection, intra-block frequency detection, run detection, longest run detection in a block, binary matrix rank detection, discrete Fourier detection, non-overlapping module matching detection, overlapping module matching detection, Maurer general statistics detection, linear complexity detection, sequence detection, approximate entropy detection, cumulative sum detection, random walk detection, and random walk state frequency detection.
[0065] The detection item parameters may use standard default parameters. Each detection of each detection item may save its statistical value P.
[0066] It can be understood that the qualification determination method of method 2 can specifically refer to the qualification determination method in method 1, and will not be repeated here.
[0067] If the first random data is qualified, execute step 106. Or,
[0068] If the first random data is unqualified, step 103 is executed.
[0069] It can be seen that through qualified detection of random data, random data that does not meet the randomness requirements can be excluded, and only random data that meets the randomness requirements can be retained in the entropy pool, thereby improving the entropy value of the entropy pool, thereby improving the quality of random number generation, and further ensuring the security of key generation.
[0070] Step 106: Add the first random data to the second entropy pool.
[0071] Specifically, the second entropy pool can be understood as an output entropy pool. For example, the random number generator can obtain randomness data from the second entropy pool and generate the required random number through the entropy mixing algorithm.
[0072] In the present application, by detecting and screening the data in the input entropy pool, the qualified data is added to the output entropy pool, thereby improving the entropy pool of the output entropy pool, thereby improving the quality of random numbers, and further improving the security of the password.
[0073] In some optional embodiments, before step 106, the following steps may also be included:
[0074] Step 107: Compare the entropy value of the first random data with the second threshold.
[0075] Specifically, in order to improve the entropy value of the output entropy pool, after the first random data passes the qualified detection, the entropy value of the first random data can be compared with the second threshold value so as to screen out the first random data that meets the entropy value requirement.
[0076] If the entropy value of the first random data is greater than or equal to the second threshold, step 106 is executed. Or,
[0077] If the entropy value of the first random data is less than the second threshold, step 108 is executed.
[0078] Step 108: post-process the first random data to obtain second random data.
[0079] Specifically, by post-processing the first random data, the length of the first random data can be extended, that is, the data volume of the first random data is increased.
[0080] The length of the second random data is greater than the length of the first random data.
[0081] It is understandable that for certain specific scenarios, for example, scenarios with a large demand for random numbers. In the above scenarios, random numbers are consumed in large quantities. If the number of random numbers generated cannot meet the demand, services that rely on random numbers, such as certificate generation services, key generation services, TCP sequence number services, etc., will be blocked due to the lack of random numbers. This application reduces the probability of the entropy pool being exhausted by extending the length of random data, and can improve the efficiency of replenishing the entropy pool.
[0082] The post-processing methods for the first random data may include the following two methods:
[0083] Method 1: Use SM3 algorithm or SM4 algorithm for post-processing.
[0084] For the detection method of method 1, the SM3 algorithm or the SM4 algorithm can be used for post-processing.
[0085] Method 2: Use the SHA256 hash algorithm or the AES advanced encryption algorithm for post-processing.
[0086] For detection method 2, the SHA256 hash algorithm or the AES advanced encryption algorithm can be used for post-processing.
[0087] Step 109: Add the second random data to the second entropy pool.
[0088] In some optional embodiments, in order to more accurately evaluate the quality of the first random data, the first random data may also be processed in blocks.
[0089] Figure 2 This is a flow chart of another embodiment of the entropy pool creation method provided by the present application. Step 105 may include the following steps:
[0090] Step 1051, divide the first random data into blocks to obtain multiple blocks.
[0091] Specifically, the blocks may be uniform blocks, that is, the first random data may be divided into a plurality of blocks of uniform size.
[0092] Among them, the preset size of each block can be determined by the detection standard, or the preset size of each block can be set by the user according to actual needs, and the embodiment of the present application does not make any special limitation on this.
[0093] For example, taking the preset size of each block as 125 bytes, assuming that the first random data is 1000 bytes, the first random data can be divided into 8 blocks, wherein each block is 125 bytes. It can be understood that the above values are only exemplary and do not constitute a limitation on the embodiments of the present application. In some embodiments, other values may also be used.
[0094] In some optional embodiments, the blocks may also be uneven, which is not particularly limited in the embodiments of the present application.
[0095] Step 1052: Detect each block in the first random data.
[0096] The specific method of detecting each block may refer to the related description of detecting the first random data in the above embodiment, which will not be repeated here.
[0097] It can be understood that after detecting each block, a statistical value corresponding to each block can be obtained.
[0098] Step 1053: Perform qualification determination on the first random data based on the detection result of each block in the first random data.
[0099] Specifically, after all blocks in the first random data are detected, the first random data can be judged as qualified based on the detection result of each block in the first random data.
[0100] Among them, the method of performing qualification determination on the first random data based on the detection result of each block in the first random data can specifically refer to the relevant description on qualification determination in the above embodiment, which will not be repeated here.
[0101] In some optional embodiments, after step 1052, the following steps may also be included:
[0102] Step 1054, determining whether each block in the first random data meets a preset requirement.
[0103] Specifically, after detecting the blocks in the first random data, it can be determined whether each block in the first random data meets the preset requirements.
[0104] The preset requirement may be a significance level indicator, for example, whether the statistical value of each block in the first random data is greater than or equal to the significance level.
[0105] In some optional embodiments, the preset requirements may also be other indicators, which are not particularly limited in the embodiments of the present application.
[0106] Among them, the preset requirements can be determined by the indicators in the detection standards, or the preset requirements can be set by the user according to actual needs, and the embodiments of the present application do not make special limitations on this.
[0107] If the blocks in the first random data meet the preset requirements, execute step 1055. Or,
[0108] If the blocks in the first random data do not meet the preset requirements, execute step 1056.
[0109] Step 1055: retain the blocks in the first random data that meet the preset requirements.
[0110] Step 1056: discard the blocks in the first random data that do not meet the preset requirements.
[0111] Step 1057: Whether the number of blocks that meet the preset requirement is the same as the number of blocks of the first random data.
[0112] Specifically, the number of divided blocks of the first random data refers to the total number of blocks obtained after dividing the first random data into blocks.
[0113] Exemplarily, taking the size of the first random data as 1000 bytes and the block size as 125 bytes, the number of blocks of the first random data is 8.
[0114] If after judging each block in the first random data, the number of blocks that meet the preset requirement is the same as the number of blocks in the first random data, step 1053 is executed. Or,
[0115] If, after determining each block in the first random data, the number of data blocks that meet the preset requirement is different from the number of blocks in the first random data, step 1058 is executed.
[0116] Step 1058, obtaining third random data.
[0117] Specifically, the third random data may be any random data in the queue. The specific method for obtaining the third random data may refer to the method for obtaining the first random data, which will not be repeated here.
[0118] It can be understood that, as the first entropy pool continuously collects random data and continuously adds it to the queue, third random data can be obtained from the queue, and the third random data is random data different from the first random data.
[0119] In some optional embodiments, the third randomness data may be obtained directly from the first entropy pool.
[0120] Step 1059, divide the third random data into blocks to obtain multiple blocks.
[0121] Specifically, the method of dividing the third random data into blocks may refer to the method of dividing the first random data into blocks, which will not be described in detail here.
[0122] Step 105A, merging the blocks that meet the preset requirements to obtain fourth random data.
[0123] Specifically, after obtaining multiple blocks of the third random data, the multiple blocks of the third random data can be detected, wherein the method of detecting the multiple blocks of the third random data can specifically refer to the method of detecting the multiple blocks of the first random data, and will not be repeated here.
[0124] It can be understood that after detecting multiple blocks of the third random data, blocks that meet the preset requirements can be screened out from the multiple blocks of the third random data, and the blocks in the third random data that meet the preset requirements can be merged with the blocks in the first random data that meet the preset requirements, thereby obtaining fourth random data, in the expectation that the number of blocks of the fourth random data is the same as the number of blocks of the first random data.
[0125] Exemplarily, assuming that the first random data is divided into 8 blocks, 5 blocks meet the preset requirements and 3 blocks do not meet the preset requirements, then 3 blocks that meet the preset requirements can be screened out from the blocks of the third random data, and the 3 blocks in the third random data that meet the preset requirements can be merged with the 5 blocks in the first random data that meet the preset requirements to obtain the fourth random data. Therefore, it can be expected that the fourth random data can contain 8 blocks that meet the preset requirements.
[0126] It can be understood that in some scenarios, if the blocks in the fourth random data that meet the preset requirements are different from the blocks in the first random data, the third random number in the queue can continue to be obtained, and the third random numbers that meet the preset requirements can be separately merged into the fourth random data until the number of blocks in the fourth random data is the same as the number of blocks in the first random data.
[0127] Step 105B: whether the number of blocks of the fourth random data is the same as the number of blocks of the first random data.
[0128] If the number of blocks of the fourth random data is the same as the number of blocks of the first random data, step 105C is executed. Or,
[0129] If the number of blocks of the fourth random data is different from the number of blocks of the first random data, execute step 1058.
[0130] Step 105C: performing qualification determination on the fourth random data based on the detection result of each block in the fourth random data.
[0131] Figure 3 A schematic diagram of the structure of the chip provided in the embodiment of the present application, such as Figure 3 As shown, the chip 30 may include: a first creation module 31, an acquisition module 32, a detection module 33 and a second creation module 34; wherein,
[0132] A first creation module 31, used to create a first entropy pool, wherein the first entropy pool includes the collected randomness data;
[0133] An acquisition module 32, configured to extract randomness data from the first entropy pool;
[0134] The detection module 33 is used to determine that the extracted random data is first random data if the length of the extracted random data is greater than or equal to a first threshold; and perform a qualified detection on the first random data;
[0135] The second creation module 34 is used to add the first random data into a second entropy pool if the first random data is qualified, wherein the second entropy pool is used to output a random number.
[0136] In one possible implementation, the second creation module 34 is further configured to determine whether the entropy value of the first random data is less than a second threshold if the first random data is qualified;
[0137] If the entropy value of the first random data is less than a second threshold, post-processing the first random data to obtain second random data, wherein the length of the second random data is greater than the length of the first random data;
[0138] The second randomness data is added to the second entropy pool.
[0139] In one possible implementation, the detection module 33 is specifically used to divide the first random data into blocks to obtain a plurality of blocks;
[0140] Detecting multiple blocks of the first random data;
[0141] The first random data is judged to be qualified based on the detection results of multiple blocks of the first random data.
[0142] In one possible implementation, the detection module 33 is further used to determine whether the multiple blocks of the first random data meet preset requirements;
[0143] Keep the blocks that meet the preset requirements and discard the blocks that do not meet the preset requirements;
[0144] If the number of blocks that meet the preset requirements is the same as the number of blocks of the first random data, a qualification determination is performed on the first random data based on the detection results of multiple blocks of the first random data.
[0145] In one possible implementation, the detection module 33 is further configured to obtain third random data if the number of blocks that meet the preset requirement is different from the number of blocks of the first random data, where the third random data is a random data in the queue;
[0146] Divide the third random data into blocks to obtain a plurality of blocks;
[0147] Merging the blocks that meet the preset requirements to obtain fourth random data, wherein the number of blocks that meet the preset requirements in the fourth random data is the same as the number of blocks in the first random data;
[0148] The fourth random data is judged to be qualified based on the detection results of multiple blocks in the fourth random data.
[0149] In one possible implementation manner, the randomness data at least includes system environment noise data.
[0150] Figure 3 The chip 30 provided in the illustrated embodiment can be used to execute the technical solution of the method embodiment illustrated in the present application, and its implementation principle and technical effects can be further referred to the relevant description in the method embodiment.
[0151] It should be understood that the division of the various modules of the above chip 30 is only a division of logical functions. In actual implementation, they can be fully or partially integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software calling through processing elements; they can also be all implemented in the form of hardware; some modules can also be implemented in the form of software calling through processing elements, and some modules can be implemented in the form of hardware. For example, the detection module can be a separately established processing element, or it can be integrated in a chip of the terminal device. The implementation of other modules is similar. In addition, all or part of these modules can be integrated together, or they can be implemented independently. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.
[0152] For example, the above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more microprocessors (DSP), or one or more field programmable gate arrays (FPGA). For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0153] Figure 4 The present invention provides a schematic diagram of the structure of an electronic device 400 provided in an embodiment of the present invention. The electronic device 400 may include: at least one processor; and at least one memory connected to the processor in communication. The memory stores program instructions that can be executed by the processor. The processor in the electronic device 400 calls the program instructions to execute the actions performed in the storage access method provided in the embodiment of the present invention.
[0154] like Figure 4 As shown, the electronic device 400 is in the form of a general computing device. The components of the electronic device 400 may include, but are not limited to: one or more processors 410, a memory 420, a communication bus 440 connecting different system components (including the memory 420 and the processor 410), and a communication interface 430.
[0155] The communication bus 440 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor or a local bus using any of a variety of bus structures. For example, these architectures include but are not limited to Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MAC) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus and Peripheral Component Interconnection (PCI) bus.
[0156] The electronic device 400 typically includes a variety of computer system readable media, which can be any available media that can be accessed by the terminal device, including volatile and non-volatile media, removable and non-removable media.
[0157] The memory 420 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) and / or cache memory. The terminal device may further include other removable / non-removable, volatile / non-volatile computer system storage media. Figure 4 Not shown, a disk drive for reading and writing a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing a removable non-volatile optical disk (e.g., a compact disc read only memory (CD-ROM), a digital versatile disc read only memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to the communication bus 440 via one or more data medium interfaces. The memory 420 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present application.
[0158] A program / utility having a set (at least one) of program modules may be stored in memory 420, such program modules including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules typically perform the functions and / or methods of the embodiments described herein.
[0159] The electronic device 400 may also communicate with one or more external devices (e.g., keyboard, pointing device, display, etc.), one or more devices that enable a user to interact with the terminal device, and / or any device that enables the terminal device to communicate with one or more other computing devices (e.g., network card, modem, etc.). Such communication may be performed through the communication interface 430. In addition, the electronic device 400 may also communicate with the network adapter ( Figure 4 The network adapter can communicate with one or more networks (such as a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through the communication bus 440. It should be understood that although Figure 4 Not shown, other hardware and / or software modules may be used in conjunction with the electronic device 400, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, disk arrays (Redundant Arrays of Independent Drives; hereinafter referred to as: RAID) systems, tape drives, and data backup storage systems.
[0160] The processor 410 executes various functional applications and data processing by running the programs stored in the memory 420, such as implementing the method provided in the embodiment of the present application.
[0161] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 400. In other embodiments of the present application, the electronic device 400 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0162] In the above embodiments, the processor involved may include, for example, a CPU, a DSP, a microcontroller or a digital signal processor, and may also include a GPU, an embedded neural network processor (Neural-network Process Units; hereinafter referred to as: NPU) and an image signal processor (Image Signal Processing; hereinafter referred to as: ISP). The processor may also include necessary hardware accelerators or logic processing hardware circuits, such as ASIC, or one or more integrated circuits for controlling the execution of the program of the technical solution of the present application. In addition, the processor may have the function of operating one or more software programs, and the software programs may be stored in a storage medium.
[0163] An embodiment of the present application also provides a readable storage medium, which stores a program. When the program is run on a terminal device, the terminal device executes the method provided by the embodiment shown in the present application.
[0164] An embodiment of the present application also provides a program product, which includes a program. When the program product is run on a terminal device, the terminal device executes the method provided by the embodiment shown in the present application.
[0165] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent the existence of A alone, the existence of A and B at the same time, and the existence of B alone. Among them, A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" and similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one of a, b and c can be represented by: a, b, c, a and b, a and c, b and c, or a and b and c, where a, b, c can be single or multiple.
[0166] Those of ordinary skill in the art will appreciate that the various units and algorithm steps described in the embodiments disclosed herein can be implemented in a combination of electronic hardware, computer software, and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0167] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0168] In several embodiments provided in the present application, if any function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory; hereinafter referred to as: ROM), random access memory (Random Access Memory; hereinafter referred to as: RAM), disk or optical disk, and other media that can store program codes.
[0169] The above is only a specific implementation of the present application. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. The protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for creating an entropy pool, characterized in that: The method comprises: Creating a first entropy pool, wherein the first entropy pool includes the collected randomness data; Extracting randomness data from the first entropy pool; If the length of the extracted random data is greater than or equal to a first threshold, determining that the extracted random data is first random data; Performing a qualification test on the first random data; If the first randomness data is qualified, the first randomness data is added to a second entropy pool, wherein the second entropy pool is used to output a random number.
2. The method according to claim 1, characterized in that The method further comprises: If the first random data is qualified, determining whether the entropy value of the first random data is less than a second threshold; If the entropy value of the first random data is less than a second threshold, post-processing the first random data to obtain second random data, wherein the length of the second random data is greater than the length of the first random data; The second randomness data is added to the second entropy pool.
3. The method according to claim 1 or 2, characterized in that: The performing qualification detection on the first random data comprises: Divide the first random data into blocks to obtain a plurality of blocks; Detecting multiple blocks of the first random data; The first random data is judged to be qualified based on the detection results of multiple blocks of the first random data.
4. The method according to claim 3, characterized in that After detecting the multiple blocks of the first random data, the method further includes: Determining whether the multiple blocks of the first random data meet preset requirements; Keep the blocks that meet the preset requirements and discard the blocks that do not meet the preset requirements; The step of determining the first random data to be qualified based on the detection results of the plurality of blocks of the first random data includes: If the number of blocks that meet the preset requirements is the same as the number of blocks of the first random data, a qualification determination is performed on the first random data based on the detection results of multiple blocks of the first random data.
5. The method according to claim 4, characterized in that The method further comprises: If the number of blocks that meet the preset requirement is different from the number of blocks of the first random data, obtaining third random data, where the third random data is a random data in the first entropy pool; Divide the third random data into blocks to obtain a plurality of blocks; Merging the blocks that meet the preset requirements to obtain fourth random data, wherein the number of blocks that meet the preset requirements in the fourth random data is the same as the number of blocks in the first random data; The fourth random data is judged to be qualified based on the detection results of multiple blocks in the fourth random data.
6. The method according to any one of claims 1 to 5, characterized in that: The randomness data at least includes system environment noise data.
7. A chip, characterized in that: include: A first creation module, used to create a first entropy pool, wherein the first entropy pool includes the collected randomness data; An acquisition module, used for extracting random data from the first entropy pool; A detection module, configured to determine that the extracted random data is first random data if the length of the extracted random data is greater than or equal to a first threshold; Performing a qualification test on the first random data; The second creation module is used to add the first randomness data into a second entropy pool if the first randomness data is qualified, wherein the second entropy pool is used to output a random number.
8. An electronic device, characterized in that: include: A processor and a memory, wherein the memory is used to store a program; and the processor is used to run the program to implement the entropy pool creation method as described in any one of claims 1 to 6.
9. A readable storage medium, characterized in that: The readable storage medium stores a program, and when the program is run on an electronic device, the entropy pool creation method as described in any one of claims 1-6 is implemented.
