Random number distribution method and device, electronic equipment, chip and storage medium
Patent Information
- Application Number
- CN202611284372.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-21
- Publication Date
- 2026-10-23
AI Technical Summary
[0009]本申请又一方面实施例提出了一种计算机程序产品,其上存储有计算机程序,所述程序被处理器执行时实现如前述一方面所述的随机数分发方法,和/或,实现如前述另一方面所述的随机数分发方法。
Smart Images

Figure CN122969878A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of chip technology, and more particularly to a random number distribution method, apparatus, electronic device, chip, and storage medium. Background Technology
[0002] A True Random Number Generator (TRNG) is an indispensable physical random entropy source core component in the security subsystem of a System-on-Chip (SoC). The unpredictable entropy source output by the TRNG forms the physical foundation for building a secure trust chain within the chip. With the widespread application of SoCs in automotive electronics, edge computing, and Trusted Execution Environments (TEEs), TRNGs have deeply penetrated the entire lifecycle of chip operation. Related technologies primarily focus on how TRNGs generate high-quality entropy, neglecting the issue of how to distribute this entropy to random number consumers. Summary of the Invention
[0003] This application proposes a random number distribution method, apparatus, electronic device, chip, and storage medium to at least partially solve one of the technical problems in the related art.
[0004] One embodiment of this application proposes a random number distribution method, including: Generate truly random numbers; Determine the distribution type of the true random number, where the requirements of the random number consumer are different under different application types; Based on the distribution type of the true random number, the true random number or the pseudo random number generated based on the true random number is distributed to the random number consumer.
[0005] Another embodiment of this application proposes a random number distribution apparatus for implementing the random number distribution method as described in the foregoing aspect.
[0006] Another aspect of this application provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements the random number distribution method as described in the foregoing aspect.
[0007] In another aspect of this application, a chip is provided, comprising an interface circuit and a processing circuit coupled to each other. The interface circuit is used to input or output signals, and the processing circuit is configured to perform a random number distribution method as described in one aspect above, and / or to perform a random number distribution method as described in another aspect above.
[0008] In another aspect, this application provides a non-transitory computer-readable storage medium storing computer program instructions that, when executed by a processor, implement the random number distribution method as described in the foregoing aspect, and / or, when executed, implement the random number distribution method as described in the foregoing other aspect.
[0009] Another aspect of this application provides a computer program product having a computer program stored thereon, which, when executed by a processor, implements the random number distribution method as described in the foregoing aspect, and / or implements the random number distribution method as described in the foregoing other aspect.
[0010] The random number distribution method, apparatus, electronic device, chip, and storage medium proposed in this application can distribute true random numbers in a differentiated manner for various random number consumers with high security requirements, one-time requirements, and high performance requirements. This enables the distribution of true random numbers to match the type of consumer, thereby improving the overall adaptability, security protection level, and distribution efficiency of true random number distribution and effectively expanding the compatibility of the true random number generation system with multiple types of consumers.
[0011] Additional aspects and advantages of this application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of this application. Attached Figure Description
[0012] The above and / or additional aspects and advantages of this application will become apparent and readily understood from the following description of the embodiments taken in conjunction with the accompanying drawings, wherein: Figure 1 A flowchart illustrating a random number distribution method provided for an exemplary embodiment of this application; Figure 2 A flowchart illustrating another random number distribution method provided for an exemplary embodiment of this application; Figure 3 A flowchart illustrating yet another random number distribution method provided for an exemplary embodiment of this application; Figure 4 A flowchart illustrating another random number distribution method provided for an exemplary embodiment of this application; Figure 5 A flowchart illustrating another random number distribution method provided for an exemplary embodiment of this application; Figure 6 A flowchart illustrating another random number distribution method provided for an exemplary embodiment of this application; Figure 7 A flowchart illustrating another random number distribution method provided for an exemplary embodiment of this application; Figure 8A flowchart illustrating another random number distribution method provided for an exemplary embodiment of this application; Figure 9 An interactive schematic diagram of another random number distribution method provided for an exemplary embodiment of this application; Figure 10 A schematic diagram of the architecture of a random number distribution method provided for an exemplary embodiment of this application; Figure 11 A schematic diagram of the structure of a random number distribution device provided for an exemplary embodiment of this application; Figure 12 A schematic diagram of the structure of an electronic device provided for an exemplary embodiment of this application; Figure 13 This is a schematic diagram of the structure of a chip proposed as an exemplary embodiment of this application. Detailed Implementation
[0013] The embodiments of this application are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and intended to explain this application, and should not be construed as limiting this application.
[0014] It should be noted that the acquisition, storage, use, and processing of data in this application comply with relevant laws and regulations and do not violate public order and good morals.
[0015] It should also be noted that all data processed in this application is data that has been explicitly authorized by the user or relevant parties, and has been de-identified or anonymized before collection and use, and does not contain any personally identifiable information or user privacy content; all data is used only for energy-saving purposes, ensuring that data security and user privacy rights are fully protected while achieving technical effects.
[0016] TRNGs are an indispensable core component of the security subsystem in SoCs (System-on-a-Chip), serving as a physical random entropy source. Their unpredictable entropy output forms the physical foundation for building a secure trust chain within the chip. With the widespread application of SoCs in automotive electronics, edge computing, and TEEs, TRNGs have deeply penetrated the entire lifecycle of chip operation. Related technologies primarily focus on how TRNGs generate high-quality entropy, neglecting the issue of how to distribute this entropy to random number consumers.
[0017] Therefore, in view of at least one of the problems existing in the above-mentioned related technologies, this application proposes a random number distribution method, apparatus, terminal, chip and storage medium.
[0018] The following description, with reference to the accompanying drawings, outlines a random number distribution method, apparatus, electronic device, chip, and storage medium according to embodiments of this application.
[0019] Figure 1 This is a flowchart illustrating a random number distribution method provided for an exemplary embodiment of this application.
[0020] It should be noted that the random number distribution method of this application embodiment can be applied to a random number distribution device. In some possible embodiments, the random number distribution device can be configured in an electronic device or chip so that the electronic device or chip can perform random number distribution function. In addition, in some possible embodiments, the random number distribution device can also be software in an electronic device or chip.
[0021] In any embodiment of this application, the chip can be integrated into a terminal. The chip includes a Central Processing Unit (CPU), Image Signal Processing (ISP), Application-Specific Integrated Circuit (ASIC), Digital Signal Processor (DSP), Field-Programmable Gate Array (FPGA), System-on-a-Chip (SoC), Reduced Instruction Set Computer (RISC), etc., which will not be listed here.
[0022] For ease of explanation, the following description will use an electronic device as the subject executing the random number distribution method.
[0023] like Figure 1 As shown, this random number distribution method may include, but is not limited to, the following steps: Step S101: Generate truly random numbers.
[0024] As one possible implementation, a true random number generation unit can generate unpredictable true random numbers through two stages: entropy source generation and post-processing.
[0025] As one possible implementation, the true random number generation unit can be a true random number generator (TRNG), a true random number generation module, etc.
[0026] The following explanation uses a pseudo-TRNG (True Random Number Generation Unit) as an example to illustrate the random number distribution method provided in the embodiments of this application.
[0027] As one possible implementation, TRNG uses a front-end physical entropy source circuit to convert the inherent physical random process within the chip into an unpredictable random bit sequence. Further, the original random bit sequence is fed into a post-processing module, where it undergoes bias removal, decorrelation, and statistical homogenization processing using a pre-defined random number post-processing algorithm. This eliminates biases and correlations present in the original bit sequence, resulting in high-quality truly random numbers that meet cryptographic security requirements. Understandably, the statistical characteristics of the truly random data output by the post-processing module tend towards a uniform and independent distribution.
[0028] As one possible implementation method, truly random numbers may originate from thermal noise, metastability, oscillator jitter, quantum effects, chaotic circuits, high-entropy seed files, etc. In other words, physical entropy source circuits can generate truly random data based on metastability, thermal noise, ring oscillator jitter, quantum effects, chaotic circuits, high-entropy seed files, etc. Typical scenarios for truly random numbers can be categorized into the following three main types: Secure boot and system initialization; Cryptographic operations and key derivation; Real-time security protection and resistance to side-channel attacks.
[0029] Optionally, for secure boot and system initialization, during the boot phase of Boot Read-Only Memory (Boot-ROM) and Unified Extensible Firmware Interface (UEFI), TRNG can provide unpredictable Pointer Authentication Code (PAC) for code signature verification to defend against fault injection attacks; at the same time, it provides high-quality seeds for the randomization of the address space layout of the operating system kernel and the early entropy pool to ensure that the system boot process is protected from deterministic prediction attacks.
[0030] Optionally, for cryptographic operations and key derivation, within the TEE or Secure Element (SE), the TRNG is responsible for generating temporary session keys, nonces, and salts. On the chip production line, the true random numbers generated by the TRNG can determine a unique Hardware Unique Key (HUK) and a unique Device Secret (UDS) for the chip, thereby ensuring the uniqueness of the device identity and the true randomness of the key derivation root node.
[0031] Optionally, for real-time security protection and resistance to side-channel attacks, the computational efficiency of cryptographic algorithms can be improved through hardware accelerators. During the operation of the hardware accelerator, the true random numbers generated by TRNG can be used to provide real-time random masks for the hardware accelerator, thereby obfuscating intermediate power consumption and resisting side-channel attacks such as differential power analysis. At the same time, during SoC operation, the true random numbers generated by TRNG can be used as stack canaries, which can effectively curb buffer overflow attacks.
[0032] Step S102: Determine the distribution type of the true random number.
[0033] As one possible implementation, the random number consumers associated with different distribution types have different requirements for true random numbers; that is, the types of random number consumers associated with different distribution types are different.
[0034] As one possible implementation, whenever TRNG generates a true random number, the distribution type of the currently generated true random number can be determined based on the true random number generation situation.
[0035] As one possible implementation, the true random number generation process of TRNG can be recorded, and the distribution type of the currently generated true random number can be determined based on the true random number generation record.
[0036] As one possible implementation, the distribution type of the currently generated true random numbers can be determined based on the generation order of the currently generated true random numbers.
[0037] As one possible implementation method, the distribution type can include one-time active distribution, distribution using pseudo-random numbers generated from true random numbers as seeds, and distribution via handshake between the random number consumer and the TRNG.
[0038] As one possible implementation, the generated true random numbers need to be used by the random number consumer. Different random number consumers have different requirements for true random numbers. Therefore, random number consumers can be classified according to their requirements for true random numbers.
[0039] One possible approach is to determine the requirement for truly random numbers from the random number consumer based on its security level and performance requirements.
[0040] As one possible implementation, the random number consumer's requirement for truly random numbers may be that it only needs to obtain truly random numbers once. In this disclosure, such a random number consumer is referred to as the first random number consumer. It can be understood that the first random number consumer refers to a consumer that performs a random number acquisition operation only once in the current SoC operating state or lifecycle stage.
[0041] As one possible implementation, the random number consumer's requirement for random numbers can be moderate, with a requirement for truly random numbers but the highest performance requirement for random numbers. In this disclosure, such a random number consumer can be referred to as a second random number consumer. It is understood that a second random number consumer refers to a consumer with moderate requirements for random number quality but the largest requirement for the quantity of random numbers.
[0042] As one possible implementation, the random number consumer's requirement for random numbers can be the highest level of demand for truly random numbers, requiring them to be available at any time. In this disclosure, such a random number consumer can be referred to as a third random number consumer. It is understood that a third random number consumer refers to one that has the highest cryptographic requirements for random number quality, where two truly random numbers obtained must be different, and the truly random numbers have an immediacy constraint, being able to obtain truly random numbers within a preset time, without queuing delays or preemption.
[0043] Step S103: Based on the distribution type of the true random number, distribute true random numbers or pseudo random numbers generated based on true random numbers to the random number consumer.
[0044] As one possible implementation, after determining the distribution type of true random numbers, a distribution strategy matching the distribution type of true random numbers can be determined. True random numbers can be distributed to random number consumers based on the matching distribution strategy, or pseudo-random numbers generated based on true random numbers can be distributed.
[0045] As one possible implementation, if the distribution type of the true random numbers is the first distribution type, then true random numbers can be actively distributed to the random number consumer in one go. In other words, the distribution strategy corresponding to the first distribution type is a one-time active distribution strategy. It can be understood that the first distribution type is suitable for distributing true random numbers to the first random number consumer in one go.
[0046] As one possible implementation, if the distribution type of the true random numbers is the second distribution type, pseudo-random numbers generated using the true random numbers as seeds can be distributed to the random number consumers. In other words, the distribution strategy corresponding to the second distribution type is to distribute pseudo-random numbers generated using the true random numbers as seeds. It can be understood that the second distribution type is suitable for distributing random numbers generated based on true random numbers to the second random number consumers.
[0047] As one possible implementation, if the distribution type of the true random numbers is the third distribution type, it can interact with the random number consumer to achieve the distribution of true random numbers. That is to say, the distribution strategy corresponding to the third distribution type is a two-way handshake distribution strategy. It can be understood that the third distribution type is suitable for distributing true random numbers to a third random number consumer.
[0048] The random number distribution method of this application embodiment can distribute true random numbers in a differentiated manner for various random number consumers with high security requirements, one-time requirements, and high performance requirements. This allows the distribution of true random numbers to match the type of consumer, thereby improving the overall adaptability, security protection level, and distribution efficiency of true random number distribution and effectively expanding the compatibility of the true random number generation system with multiple types of consumers.
[0049] As one possible implementation method, Figure 2 A flowchart illustrating another random number distribution method provided for an exemplary embodiment of this application.
[0050] It should be noted that the random number distribution method can be executed alone, or it can be executed together with any embodiment of this application or any possible implementation in the embodiment, or it can be executed together with any technical solution in related technologies. The embodiments of this application do not limit this.
[0051] like Figure 2 As shown, this random number distribution method may include, but is not limited to, the following steps: Step S201: Generate truly random numbers.
[0052] It should be noted that the aforementioned description of step S201 also applies to this embodiment, and will not be repeated here.
[0053] Step S202: Determine the generation record of true random numbers.
[0054] As one possible implementation, in response to the system's first power-on, the TRNG is started, and the TRNG's true random number generation process is recorded to determine the TRNG's true random number generation record. Optionally, the number of times the TRNG generates true random numbers, the generation time, etc., can be recorded. It should be noted that the recorded true random number generation process is the process within one system cycle.
[0055] Step S203: Generate records based on true random numbers and determine the distribution type of true random numbers.
[0056] One possible implementation is to determine the number of truly random numbers generated from system power-on to the current moment based on the truly random number generation record. Based on the number or quantity of truly random numbers generated, the distribution type of the truly random numbers can be determined.
[0057] As one possible implementation, TRNG pre-configures multiple types of random number consumers and the number of each type of random number consumer, thereby determining the number of truly random numbers required for each type of random number consumer.
[0058] One possible implementation is to configure the order in which true random numbers are distributed for different types of random number consumers. This allows for the determination of the distribution type of true random numbers based on the generated records.
[0059] One possible implementation is to first distribute truly random numbers to the first random number consumer, then to the second, and finally to the third. Following this distribution order, the required number of truly random numbers for each random number consumer can be set according to the number of consumers. Furthermore, a first threshold is set based on the number of first random number consumers, a second threshold is determined based on the number of second random number consumers, and a third threshold is determined based on the number of third random number consumers.
[0060] Optionally, if the current cumulative number of TRNG generation is less than or equal to a first preset threshold, the distribution type of the true random numbers can be determined as the first distribution type. Further, if the current cumulative number of TRNG generation is greater than the first preset threshold and less than or equal to a second preset threshold, the distribution type of the true random numbers can be determined as the second distribution type. Further, if the current cumulative number of TRNG generation is greater than the second preset threshold and less than or equal to a third preset threshold, the distribution type of the true random numbers can be determined as the third distribution type. It is understood that a third preset threshold may not be set, and if the current cumulative number of TRNG generation is greater than the second preset threshold, the distribution type of subsequently generated true random numbers can be directly determined as the third distribution type.
[0061] As one possible implementation, in response to the system's first power-on, a random number counting unit is synchronously started when the TRNG is launched. This random number counting unit records the current cumulative number of TRNG events generated. Optionally, the random number counting unit can be a counter.
[0062] One possible implementation is to count the cumulative number of TRNGs generated before the random number counting unit reaches the second preset threshold. That is, the counting stops when the count value of the random number counting unit reaches the second preset threshold, and the current count value, i.e., the second preset threshold, is maintained.
[0063] As one possible implementation, in response to the current cumulative number of TRNGs corresponding to true random numbers being less than or equal to a first set threshold, the distribution type of the true random numbers is determined to be the first distribution type. That is, from the first true random number generated by the TRNG after power-on to all true random numbers generated when the count reaches the first set threshold, the corresponding distribution type is the first distribution type.
[0064] As one possible implementation, in response to the current cumulative number of TRNGs corresponding to true random numbers reaching a second preset threshold, the distribution type of the true random numbers is determined to be the second distribution type. That is, starting from the next true random number corresponding to the first preset threshold of the TRNG, all true random numbers generated until the second preset threshold are distributed as the second distribution type.
[0065] It should be noted that the second random number consumer has moderate requirements for random numbers and can use pseudo-random numbers generated based on true random numbers. The pseudo-random number generation unit can generate a large number of pseudo-random numbers based on a true random number. Therefore, it is sufficient to set a seed for the pseudo-random number generation unit for true random numbers. Thus, the second set threshold can be set to a value that is 1 greater than the first set threshold.
[0066] As one possible implementation, in response to the current cumulative number of truly random numbers generated being TRNG reaching a second set threshold, the distribution type of the truly random numbers is determined to be the third distribution type.
[0067] For example, if the first random number generator requires 10 terminals, a first preset threshold of 10 can be pre-configured. After the system powers on, the distribution type of the 1st to 10th true random numbers generated by the TRNG will all be the first distribution type. If the second random number generator requires 1 terminal, a second preset threshold of 11 can be pre-configured. This ensures that the distribution type of the 11th true random number generated by the TRNG after power-on will all be the second distribution type. Furthermore, after the counter reaches 11, the current cumulative number of generated numbers by the TRNG is no longer updated, but the TRNG still generates true random numbers. The distribution type of the true random numbers generated after the counter reaches the second preset threshold can be determined as the third distribution type.
[0068] Step S204: Based on the distribution type of the true random number, distribute true random numbers or pseudo random numbers generated based on true random numbers to the random number consumer.
[0069] It should be noted that the aforementioned description of step S204 also applies to this embodiment, and will not be repeated here.
[0070] The random number distribution method in this application records the number of truly random numbers generated and uses this recorded information as the basis for determining the distribution type of the truly random numbers, thereby providing a foundation for differentiated distribution of truly random numbers. By recording in real time and dynamically determining which consumer terminal needs to distribute the current truly random number, it can avoid competition for truly random numbers among different types of consumers and ensure that each type of random number consumer terminal obtains the random number it needs.
[0071] As one possible implementation method, Figure 3This is a flowchart illustrating yet another random number distribution method provided for an exemplary embodiment of this application.
[0072] It should be noted that the random number distribution method can be executed alone, or it can be executed together with any embodiment of this application or any possible implementation in the embodiment, or it can be executed together with any technical solution in related technologies. The embodiments of this application do not limit this.
[0073] like Figure 3 As shown, this random number distribution method may include, but is not limited to, the following steps: Step S301: Receive a request sent by the random number consumer, wherein the request carries indication information related to the classification type.
[0074] As one possible implementation, the indication information can be used to indicate the security level and performance requirements of the random number consumer, thereby determining the random number consumer's demand for random numbers.
[0075] As one possible implementation, the random number consumer can send a distribution request to the TRNG through a transmission path between the consumer and the TRNG. For example, if the random number consumer and the TRNG are connected via a bus, the distribution request can be transmitted through the bus.
[0076] Step S302: In response to the request sent by the random number consumer, generate a true random number.
[0077] As one possible implementation, in response to the TRNG detecting a distribution request, the TRNG triggers a random number generation process to generate a truly random number.
[0078] Step S303: Determine the distribution type of the true random number based on the indication information related to the classification type.
[0079] As one possible implementation, the security level and performance requirements of the random number consumer can be determined based on the indication information, and then the distribution type of true random numbers can be determined based on the security level and performance requirements of the random number consumer.
[0080] Step S304: Based on the distribution type of the true random number, distribute true random numbers or pseudo random numbers generated based on true random numbers to the random number consumer.
[0081] It should be noted that the aforementioned description of step S304 also applies to this embodiment, and will not be repeated here.
[0082] The random number distribution method of this application embodiment can determine the type of the consumer based on the request, and then distribute true random numbers according to the distribution strategy matched with the consumer. This enables differentiated distribution of true random numbers to various random number consumers with different needs, such as high security requirements, one-time requirements, and high performance requirements. This allows the distribution of true random numbers to match the type of the consumer, and the method can proactively initiate requests to obtain true random numbers as needed. This allows the consumption of random numbers to be autonomously controlled by the upper-layer business logic, which can avoid the waste of computing power and power consumption caused by the continuous generation of true random numbers by the hardware, and can obtain true random numbers on demand when it is safe to do so.
[0083] As one possible implementation method, Figure 4 This is a flowchart illustrating yet another random number distribution method provided for an exemplary embodiment of this application.
[0084] It should be noted that the random number distribution method can be executed alone, or it can be executed together with any embodiment of this application or any possible implementation in the embodiment, or it can be executed together with any technical solution in related technologies. The embodiments of this application do not limit this.
[0085] like Figure 4 As shown, this random number distribution method may include, but is not limited to, the following steps: Step S401: Generate truly random numbers.
[0086] Step S402: Determine the distribution type of the true random number.
[0087] It should be noted that the foregoing description of steps S401 to 402 also applies to this embodiment, and will not be repeated here.
[0088] In step S403, in response to the distribution type of the true random number being the first distribution type, a first indication signal for the true random number is sent to the first random number consumer to trigger the first random number consumer to obtain the true random number.
[0089] One possible implementation involves using software workflows to ensure that truly random numbers are generated before the consumer begins operation. The first random number consumer detects a first indication signal for the truly random number on the bus. Upon detecting this signal, the consumer can acquire and use the truly random number. It should be noted that the generated truly random number and the first indication signal are transmitted together. After detecting the first indication signal, the consumer can determine that a usable truly random number exists and then acquire and use it on the signal line.
[0090] As one possible implementation, the first indicator signal of a true random number can be used to indicate whether the true random number is in an available or valid state.
[0091] As one possible implementation, the first indicator signal for a true random number can be a pulse signal or a level signal. Optionally, if the first indication signal of the true random number is a pulse signal, the first random number consumer can read the true random number from the random number storage location when it detects a rising edge (or falling edge).
[0092] Optionally, if the first indication signal of the true random number is a level signal, the first random number consumer can obtain and use the true random number from the signal line at any time during the active period of the level when it detects that the level is high (or low).
[0093] As one possible implementation, the first random number consumer has a timeout protection mechanism. If the first indication signal is not received within a certain period of time, it can be determined that the distribution has failed or the TRNG is abnormal and cannot generate random numbers normally. The first random number consumer can then perform fault tolerance processing.
[0094] As one possible implementation, the fault tolerance processing of the first random number consumer can include, but is not limited to, retries, error reporting, and using backup random numbers.
[0095] As one possible implementation, the first random number consumer can enable a pseudo-random number generator to calculate a pseudo-random number for use.
[0096] As one possible implementation, the first random number consumer can enable a system default random number.
[0097] As one possible implementation, there can be multiple first random number consumers, and true random numbers can be distributed to each of these multiple first random number consumers one by one.
[0098] As one possible implementation, based on the current cumulative number of TRNGs corresponding to the true random numbers, the first random number consumer to be distributed is determined from multiple first random number consumers, and a first indication signal is sent to the first random number consumer to be distributed.
[0099] For example, if there are 10 first random number consumers, including consumers A1 to A10, the random number counting unit counts the current cumulative number of TRNGs generated. If the current cumulative number of generated numbers is 1, the first generated true random number can be stored in the random number storage location corresponding to consumer A1, and the first indication signal of the first true random number can be sent to consumer A1. If the current cumulative number of generated numbers is 2, the second generated true random number can be stored in the random number storage location corresponding to consumer A2, and the first indication signal of the second true random number can be sent to consumer A2. And so on. If the current cumulative number of generated numbers is 10, the tenth generated true random number can be stored in the random number storage location corresponding to consumer A10, and the first indication signal of the tenth true random number can be sent to consumer A10, thereby completing the distribution of true random numbers to the 10 first random number consumers.
[0100] For the first dispatch type, as one possible implementation, Figure 5 This is a flowchart illustrating yet another random number distribution method provided for an exemplary embodiment of this application.
[0101] Step S501: TRNG generates true random numbers.
[0102] In step S502, TRNG writes the true random number into the random number storage location.
[0103] Step S503: In response to the first distribution of true random numbers after power-on, a first indication signal is sent to the first random consumer terminal.
[0104] Step S504: The first random number consumer determines whether it has received the first indication signal.
[0105] If it is determined that the first indication signal has been received, proceed to step S505; if it is determined that the first indication signal has not been received, proceed to step S506.
[0106] Step S505: The first random number consumer obtains and uses a true random number.
[0107] Step S506: The first random number consumer determines whether a timeout has occurred.
[0108] If the first indication signal is not received within the set time, proceed to step S507.
[0109] Step S507: Use a pseudo-random number or a default random number.
[0110] As one possible implementation, if the first random number consumer does not receive a true random number distributed by TRNG within a set time period, it needs to use a pseudo-random number or a default random number based on a pre-configured escape strategy to avoid the consumer continuously waiting for the arrival of a true random number. This ensures the continuity of subsequent verification, enabling verification to be completed more quickly and facilitating the activation of subsequent functions.
[0111] As one possible implementation, the first random number consumer source can embed a simple pseudo-random number generator, which can be triggered to generate a pseudo-random number locally.
[0112] As one possible implementation, some default random numbers can be pre-configured at the first random number consumer, and these default random numbers can be used. In this embodiment, for the first random number consumer, a distribution process is actively triggered after the system undergoes an electrolytic reset. That is, by actively pushing a first indication signal, the first random number consumer is triggered to quickly read true random numbers from the random number storage location, thereby improving the efficiency of distributing true random numbers to the random number consumer. At the same time, a timeout judgment mechanism is reserved at the random number consumer to achieve the timing reliability and fault tolerance capability of true random number distribution. Compared with the passive mode in the prior art, where the random number consumer initiates a request and then triggers random number generation, the power-on active distribution mechanism effectively avoids abnormal situations such as consumer startup blocking caused by the delay in true random number generation. Furthermore, the introduction of a timeout judgment mechanism at the consumer can actively execute a timeout handling strategy when random number generation fails or bus blocking occurs and distribution cannot be completed in time, preventing the consumer from falling into a suspended or deadlocked state while waiting for the distribution of true random numbers.
[0113] As one possible implementation method, Figure 6 This is a flowchart illustrating yet another random number distribution method provided for an exemplary embodiment of this application.
[0114] It should be noted that the random number distribution method can be executed alone, or it can be executed together with any embodiment of this application or any possible implementation in the embodiment, or it can be executed together with any technical solution in related technologies. The embodiments of this application do not limit this.
[0115] like Figure 6 As shown, this random number distribution method may include, but is not limited to, the following steps: Step S601: Generate truly random numbers.
[0116] Step S602: Determine the distribution type of the true random number.
[0117] It should be noted that the foregoing description of steps S601 to 602 also applies to this embodiment, and will not be repeated here.
[0118] In step S603, in response to the distribution type of the true random number being the second distribution type, the true random number is used as a seed and written into the pseudo random number generation unit.
[0119] As one possible implementation, the pseudo-random number generation unit may include, but is not limited to: Linear Feedback Shift Register (LFSR), Cryptographically Secure Pseudorandom Number Generator (CSPRNG), Mersenne rotation algorithm, and linear congruence generation unit.
[0120] As one possible implementation, the pseudo-random number generation unit can be an LFSR. Optionally, the LFSR can be a standard feedback polynomial type, which not only saves chip structure but also has good pseudo-random number operation efficiency.
[0121] Step S604: The pseudo-random number generation unit generates a pseudo-random number for the second random number consumer based on the seed, and distributes the pseudo-random number to the second random number consumer.
[0122] As one possible implementation, there can be multiple second random number consumers, and these consumers can share a single pseudo-random number generation unit to minimize the chip footprint of the pseudo-random number generation unit and thus save chip area.
[0123] As one possible implementation, data access requests for each second random number are monitored. In response to detecting at least one data access request from a second random number consumer (which can be referred to as the target second random number consumer), the pseudo-random number generation unit is triggered to generate a pseudo-random number for the target second random number consumer based on a seed. Based on the data access request, the random number storage location corresponding to the target second random number consumer is determined, and the generated pseudo-random number is written into the random number storage location corresponding to the target second random number consumer.
[0124] As one possible implementation, in response to the detection that one of the target second random number consumers is currently reading a specified address, a valid trigger signal is generated for the target second random number consumer. If no target second random number consumer is detected reading the specified address, an invalid trigger signal is generated for the target second random number consumer. Further, the trigger signals of each target second random number consumer are ORed to obtain a merged trigger signal. It is understood that as long as the trigger signal of any one host is valid, the resulting merged trigger signal is also valid. Further, this merged trigger signal triggers a pseudo-random number generation unit to generate pseudo-random numbers.
[0125] As one possible implementation, in response to satisfying the seed update condition of the pseudo-random number generation unit, true random numbers can be regenerated through TRNG, and the regenerated true random numbers can be used as the new seed to update the pseudo-random number generation unit.
[0126] As one possible implementation, a counter of the pseudo-random number generation unit can be started. The number of pseudo-random numbers generated by the pseudo-random number generation unit based on the same seed can be determined by the counter. In response to the count reaching a set number, it can be determined that the seed update condition of the pseudo-random number generation unit is met, and then the seed of the pseudo-random number generation unit is updated.
[0127] As one possible implementation, the seed update condition can be identified through the random number counting unit of the TRNG. Whenever the random number counting unit of the TRNG is cleared, the random number counting unit of the TRNG will recount to the second set threshold. When the number of cycles reaches the set number, it can be determined that the seed update condition of the pseudo-random number generation unit is met, and then the seed update of the pseudo-random number generation unit is performed.
[0128] As one possible implementation, the second random number consumer can be multiple hosts (masters). Each host can send a data access request to the bus. When the data access request of one or more hosts is heard, the pseudo-random number generation unit can synchronously perform pseudo-random number calculations on all hosts that have heard the data access request. The number of pseudo-random numbers counted is consistent with the number of data access requests heard. The data access request is written to the corresponding random number storage location. Each host that has heard the data access request reads the pseudo-random number generated for it from the corresponding random number storage location.
[0129] As one possible implementation, taking multiple hosts as the second random number consumer as an example, the random number distribution method provided in the above embodiment will be explained and illustrated. Figure 7The diagram shown is a flowchart illustrating another random number distribution method provided in an exemplary embodiment of this application.
[0130] Step S701: Generate truly random numbers.
[0131] Step S702: Write the true random number as a seed into the LFSR.
[0132] Step S703: Is the seed update condition met?
[0133] If the seed update condition is met, return to step S701.
[0134] In step S703, multiple hosts send data access requests.
[0135] As one possible implementation, a data access request could be an address read operation sent by the host.
[0136] As one possible implementation, multiple hosts can include Master A to Master N, and each Master can send an address read operation (rd_add) to the bus. For example, Master A sends rd_addA, Master B sends rd_addA, ..., Master N sends rd_addN.
[0137] Step S704: Monitor the data access request machines at each specified address.
[0138] One possible implementation is to use a bus monitoring and parsing unit to listen to the rd_add sent by each Master.
[0139] Step S705: Based on whether a data access request from the host is detected, generate a trigger signal corresponding to the host.
[0140] For example, if the monitoring unit detects that Master A is currently reading a specified address, it generates a valid trigger signal for Master A. If the monitoring unit detects that Master A is not currently reading a specified address, it generates an invalid trigger signal for Master A. For example, the trigger signal for Master A can be labeled as req_A. If the value of req_A is 1, it indicates a valid trigger signal; if the value of req_A is 0, it indicates an invalid trigger signal.
[0141] For example, if the monitoring unit detects that Master B is currently reading a specified address, it generates a req_B with a value of 1 corresponding to Master B; if the monitoring unit detects that Master B is not currently reading a specified address, it generates a req_B with a value of 0 corresponding to Master B.
[0142] For example, if the monitoring unit detects that Master N is currently reading a specified address, it generates a req_N with a value of 1 corresponding to Master N; if the monitoring unit detects that Master N is not currently reading a specified address, it generates a req_N with a value of 0 corresponding to Master N.
[0143] Step S706: Perform an OR operation on the trigger signals corresponding to each host to obtain a merged trigger signal.
[0144] It is understandable that as long as the trigger signal of one host is valid, the resulting merged trigger signal (Req) is also valid.
[0145] Step S707: The LFSR performs pseudo-random number calculation based on the merge trigger signal.
[0146] Step S708: Write the calculated pseudo-random number into the random number storage location corresponding to the host based on the address accessed by the host.
[0147] One possible implementation is to assign a corresponding random number storage location to each host, such as a register: Master A corresponds to register A, Master B to register B, ..., Master N to register N. The register corresponding to the Master can be determined based on the data access request, and then the calculated pseudo-random number can be written into the corresponding register of the host.
[0148] Step S709: The host reads a pseudo-random number from the corresponding random number storage location.
[0149] In the above embodiment, multiple Masters reuse a single LFSR, and each Master can pre-specify the random number storage location or register. When any Master needs to obtain random numbers, it initiates a data access request. At this time, the bus monitoring unit will detect an address hit. When the address of any channel is hit, an LFSR calculation will be triggered. Since multiple Masters time-share a single LFSR and the LFSR seed can support periodic refresh, security can be ensured.
[0150] In this embodiment, for the second random number consumer, using a true random number as a seed ensures the initial state of the LFSR is truly random, thereby making the final output pseudo-random number unpredictable. Furthermore, through the LFSR's extended generation capability, a single true random number seed can derive a large number of pseudo-random numbers, significantly reducing the number of high-cost true random number generation operations and lowering overall system energy consumption and hardware wear and tear on random number generation. Moreover, the LFSR's true random number seed can be updated periodically or on demand, ensuring that even with long-term LFSR operation, the pseudo-random numbers remain unpredictable, meeting the consumer's random number requirements.
[0151] As one possible implementation method, Figure 8 This is a flowchart illustrating yet another random number distribution method provided for an exemplary embodiment of this application.
[0152] It should be noted that the random number distribution method can be executed alone, or it can be executed together with any embodiment of this application or any possible implementation in the embodiment, or it can be executed together with any technical solution in related technologies. The embodiments of this application do not limit this.
[0153] like Figure 8 As shown, this random number distribution method may include, but is not limited to, the following steps: Step S801: Generate truly random numbers.
[0154] Step S802: Determine the distribution type of the true random number.
[0155] It should be noted that the aforementioned descriptions of steps S801 to S802 also apply to this embodiment, and will not be repeated here.
[0156] In step S803, in response to the distribution type of the true random number being the third distribution type, a second indication signal of the true random number is sent to the third random number consumer to trigger the third random number consumer to perform a query handshake.
[0157] As one possible implementation, after a true random number is generated, it can be written to the random number storage location, and a second indicator signal (Ready) can be generated for it. The third random number consumer retrieves the true random number by querying Ready. If the third random number consumer finds Ready, it can read the true random number from the random number storage location. Furthermore, after retrieving the true random number, the third random number consumer can return an acknowledgment signal (Ack) to the TRNG. Upon receiving the Ack, the TRNG begins preparing to generate the next true random number. Simultaneously, for security and leakage prevention, upon receiving the Ack, the TRNG can clear the true random number stored in the random number storage location and simultaneously pull Ready low. This process continues until the TRNG generates the next true random number, completing the update of the random number storage location (i.e., writing the next true random number to the random number storage location). Ready can then be pulled high again, and this cycle repeats, ensuring that each third random number consumer can obtain true random numbers in real time.
[0158] As one possible implementation, there are multiple third random number consumers. The generation order of the second indication signal is determined. Based on the generation order of the second indication signal, the third random number consumer to be distributed is determined from the multiple third random number consumers, and the second indication signal is sent to the third random number consumer to be distributed.
[0159] For example, the third random number consumer includes consumer B1 and consumer B2. After the random number counting unit of the TRNG reaches the second preset threshold, a newly generated true random number will trigger a "Ready" state. At this time, a "Ready" message can be sent to consumer B1. Consumer B1 can continuously poll the "Ready" message within a set time to find it. After reading the true random number, consumer B1 can send an "Ack" response. In response to the "Ack," the TRNG will regenerate a true random number and trigger a new "Ready" state. At this time, a "Ready" message can be sent to consumer B2. Consumer B2 can continuously poll the "Ready" message within a set time to find it. After reading the true random number, consumer B2 can send an "Ack" response. In response to the "Ack," the TRNG will regenerate a true random number and trigger a new "Ready" state. At this time, a "Ready" message can be sent to consumer B1 again, and so on, in a loop to obtain true random numbers in real time.
[0160] Step S804: Receive the confirmation signal sent by the third random number consumer after reading the true random number from the corresponding random number storage location.
[0161] In step S805, in response to the confirmation signal, the corresponding random number storage location is cleared and the second indication signal is set to an invalid state.
[0162] As one possible implementation, a third random number consumer can proactively initiate requests to obtain truly random numbers on demand. This allows the consumption of random numbers to be autonomously controlled by the upper-layer business logic, which can avoid the waste of computing power and power consumption caused by the continuous generation of truly random numbers by the hardware, and can obtain truly random numbers on demand in a safe and timely manner.
[0163] As one possible implementation method, Figure 9 An interactive schematic diagram of yet another random number distribution method provided for an exemplary embodiment of this application.
[0164] It should be noted that the random number distribution method can be executed alone, or it can be executed together with any embodiment of this application or any possible implementation in the embodiment, or it can be executed together with any technical solution in related technologies. The embodiments of this application do not limit this.
[0165] like Figure 9 As shown, this random number distribution method may include, but is not limited to, the following steps: Step S901: TRNG generates true random numbers.
[0166] In step S902, TRNG writes a true random number to the register.
[0167] In step S903, TRNG determines the distribution type of the true random number.
[0168] It should be noted that the aforementioned descriptions of steps S901 to 902 also apply to this embodiment, and will not be repeated here.
[0169] In step S904, in response to the distribution type of the true random number being the third distribution type, TRNG sends a Ready signal for the true random number to the third random number consumer to trigger the third random number consumer to perform a query handshake.
[0170] In step S905, the third random number consumer reads a true random number from the corresponding register.
[0171] In step S906, the third random consumer sends an Ack signal to the TRNG.
[0172] In step S907, in response to the Ack signal, the register is cleared and the Ready signal is set to an invalid state.
[0173] Optionally, delete the currently stored true random number in the register.
[0174] Optionally, if the Ready signal is active high, the Ready signal can be pulled low to disable it.
[0175] In this embodiment, for the third random number consumer, a Ready / Ack handshake mechanism is employed to achieve secure distribution of true random numbers. After each Ack response, the currently acquired random number is cleared, ensuring that the true random numbers obtained by the consumer are different between two handshake cycles, effectively preventing replay attacks caused by random number reuse. Furthermore, this embodiment can distinguish between true random numbers that need to be distributed all at once and those distributed multiple times, thereby reducing invalid broadcasts of true random numbers and lowering power consumption.
[0176] The random number distribution method in the above embodiments can be applied to TRNGs, such as... Figure 10 As shown, TRNG is used to generate true random numbers. True random numbers can have three distribution types, and each distribution type corresponds to its own distribution scheduling module. The distribution scheduling module can be understood as a distribution strategy. Based on different distribution scheduling modules, the true random numbers generated by TRNG are distributed to three types of random number consumers, namely the first random number consumer, the second random number consumer, and the third random number consumer in the above embodiment.
[0177] To implement the above embodiments, this application also proposes a random number distribution device.
[0178] To implement the above embodiments, this application proposes a random number distribution device, which is used to implement the aforementioned... Figures 1 to 9 The random number distribution method described in any embodiment. For example... Figure 11 As shown, the random number distribution device 1100 may include a true random number generation unit 1101 and a random number distribution unit 1102.
[0179] The true random number generation unit 1101 is used to generate true random numbers; The random number distribution unit 1102 is used to determine the distribution type of the true random number, wherein different distribution types are associated with different random number consumers with different needs for random numbers. Based on the distribution type of the true random number, the unit distributes the true random number or a pseudo-random number generated based on the true random number to the random number consumer.
[0180] As one possible implementation, the random number distribution unit 1102 is also used for: Determine the generation record of the true random number; Based on the generation record of the true random numbers, the distribution type of the true random numbers is determined.
[0181] As one possible implementation, the true random number generation record includes the current cumulative number of true random numbers. The random number distribution unit 1102 is further configured to: determine the distribution type of the true random number as a first distribution type in response to the current cumulative generation number being less than or equal to a first preset threshold. In response to the current cumulative number of generated numbers reaching a second preset threshold, the distribution type of the true random number is determined to be the second distribution type; In response to the fact that the true random number is a true random number generated after the current cumulative number of generated numbers reaches the second set threshold, the distribution type of the true random number is determined to be the third distribution type.
[0182] As one possible implementation, the random number distribution unit 1102 is further configured to: activate the random number statistics unit, wherein the random number statistics unit is configured to count the current cumulative number of generated numbers before reaching the second preset threshold; In response to the current cumulative number of generated numbers reaching the second set threshold, the update of the current cumulative number of generated numbers by the random number statistics unit is stopped, and the number is maintained at the second set threshold.
[0183] As one possible implementation, the random number generation unit 1101 is also used for: In response to a request from the random number consumer, the true random number is generated, the request including indication information related to the distribution type; As one possible implementation, the random number distribution unit 1102 is also used for: Based on the indicated information, the distribution type of the true random number is determined.
[0184] As one possible implementation, the random number distribution unit 1102 is also used for: Determine the distribution strategy that matches the distribution type of the true random number; Based on the matched distribution strategy, the true random number or the pseudo random number generated based on the true random number is distributed to the random number consumer.
[0185] As one possible implementation, the random number distribution unit 1102 is also used for: In response to the distribution type being the first distribution type, a first indication signal for the true random number is sent to the first random number consumer to trigger the first random number consumer to obtain the true random number.
[0186] As one possible implementation, the first random number consumer includes multiple random number distribution units 1102, which are also used for: Based on the current cumulative number of TRNGs generated corresponding to the true random number, the first random number consumer to be distributed is determined from multiple first random number consumers. The first indication signal is sent to the first random number consumer terminal to be distributed.
[0187] As one possible implementation, if the first random number consumer corresponding to the true random number does not obtain the true random number within a set time period, it obtains a locally generated pseudo-random number or a default random number.
[0188] As one possible implementation, the random number distribution unit 1102 is also used for: In response to the distribution type being the second distribution type, the true random number is used as a seed and written into the pseudo random number generation unit; The pseudo-random number generation unit generates pseudo-random numbers for the second random number consumer based on the seed, and distributes the pseudo-random numbers to the second random number consumer.
[0189] As one possible implementation, the second random number consumer includes multiple random number distribution units 1102, which are further used for: Detect the data access request for the second random number; In response to detecting a data access request sent by at least one second random number consumer, the pseudo-random number generation unit is triggered to generate a pseudo-random number for the at least one second random number consumer based on the seed; As one possible implementation, the random number distribution unit 1102 is also used for: Based on the data access request, determine the random number storage location corresponding to the at least one second random number consumer. The generated pseudo-random number is written into the random number storage location corresponding to the at least one second random number consumer.
[0190] As one possible implementation, the random number distribution unit 1102 is also used for: In response to satisfying the seed update condition of the pseudo-random number generation unit, a true random number is regenerated; The newly generated true random number is used as the new seed and updated in the pseudo-random number generation unit to trigger the pseudo-random number generation unit to generate the pseudo-random number using the newly generated true random number.
[0191] As one possible implementation, the random number distribution unit 1102 is also used for: In response to the distribution type being the third distribution type, a second indication signal of the true random number is sent to the third random number consumer to trigger the third random number consumer to perform a query handshake; The system receives an acknowledgment signal sent by the third random number consumer after reading the true random number from the corresponding random number storage location. In response to the confirmation signal, the corresponding random number storage location is cleared to zero, and the second indication signal is set to an invalid state.
[0192] As one possible implementation, the third random number consumer includes multiple random number distribution units 1102, which are further used for: Determine the generation order of the second indication signal; Based on the generation order, the third random number consumer to be distributed is determined from multiple third random number consumers. The second indication signal is sent to the third random number consumer terminal to be distributed.
[0193] As one possible implementation, the random number distribution unit 1102 is also used for: In response to the completion of clearing the corresponding random number storage location, the generation of the next true random number is triggered; In response to the generation and storage of the next true random number in the corresponding random number storage location, the second indication signal is reset to a valid state.
[0194] The random number distribution method of this application embodiment can distribute true random numbers in a differentiated manner for various random number consumers with high security requirements, one-time requirements, and high performance requirements. This allows the distribution of true random numbers to match the type of consumer, thereby improving the overall adaptability, security protection level, and distribution efficiency of true random number distribution and effectively expanding the compatibility of the true random number generation system with multiple types of consumers.
[0195] To implement the above embodiments, this application also proposes a terminal, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the aforementioned... Figures 1 to 9 The random number distribution method described in any embodiment.
[0196] Figure 12 This is a schematic diagram of the structure of an electronic device provided for an exemplary embodiment of this application. (Refer to...) Figure 12 The electronic device 1200 may include one or more of the following components: a processing component 1202, a memory 1204, a power component 1206, a multimedia component 1208, an audio component 1210, an input / output (I / O) interface 1212, a sensor component 1214, and a communication component 1216.
[0197] Processing component 1202 typically controls the overall operation of electronic device 1200, such as operations associated with display, telephone calls, data communication, camera operation, and recording operations. Processing component 1202 may include one or more processors 1220 to execute instructions to perform all or part of the steps of the methods described above. Furthermore, processing component 1202 may include one or more modules to facilitate interaction between processing component 1202 and other components. For example, processing component 1202 may include a multimedia module to facilitate interaction between multimedia component 1212 and processing component 1202.
[0198] The memory 1204 is configured to store various types of data to support the operation of the electronic device 1200. The memory 1204 can be implemented by any type of volatile or non-volatile storage device or a combination thereof.
[0199] Power component 1206 provides power to various components of electronic device 1200. Power component 1206 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device 1200.
[0200] The multimedia component 1212 includes a screen that provides an output interface between the electronic device 1200 and the user. In some embodiments, the multimedia component 1212 includes a front-facing camera and / or a rear-facing camera. Each front-facing and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0201] Audio component 1210 is configured to output and / or input audio signals. For example, audio component 1210 includes a microphone (MIC) configured to receive external audio signals when electronic device 1200 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory 1204 or transmitted via communication component 1216. In some embodiments, audio component 1210 also includes a speaker for outputting audio signals.
[0202] I / O interface 1212 provides an interface between processing component 1202 and peripheral interface modules, such as keyboards, click wheels, buttons, etc.
[0203] Sensor assembly 1214 includes one or more sensors for providing state assessments of various aspects of electronic device 1200. For example, sensor assembly 1214 can detect the on / off state of electronic device 1200, the relative positioning of components, changes in the position of electronic device 1200 or a component of electronic device 1200, the presence or absence of user contact with electronic device 1200, the orientation or acceleration / deceleration of electronic device 1200, temperature changes of electronic device 1200, the presence of nearby objects, etc.
[0204] Communication component 1216 is configured to facilitate wired or wireless communication between electronic device 1200 and other devices. Electronic device 1200 can access wireless networks based on communication standards, such as WiFi, 4G, or 5G, or combinations thereof. In one exemplary embodiment, communication component 1216 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component 1216 further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID), Infrared Data Association (IrDA), Ultra-Wideband (UWB), Bluetooth, and other technologies.
[0205] In an exemplary embodiment, the electronic device 1200 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0206] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 1204 including instructions, which can be executed by a processor 1220 of an electronic device 1200 to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage device, etc.
[0207] To implement the above embodiments, this application also proposes a chip, wherein the chip includes an interface circuit and a processing circuit coupled to each other. The interface circuit is used to input or output signals, and the processing circuit is configured to perform the random number distribution method provided in any of the foregoing embodiments.
[0208] Figure 13 This is a schematic diagram of a chip structure proposed as an exemplary embodiment of this application. See also... Figure 13 The diagram shown is a schematic representation of the structure of chip 1300, but it is not limited to this.
[0209] Chip 1300 includes processing circuitry 1301, which is configured to perform any of the above random number distribution methods.
[0210] In some embodiments, chip 1300 further includes one or more interface circuits 1302. Optionally, interface circuit 1302 is connected to memory 1303, and interface circuit 1302 can be used to receive signals from memory 1303 or other devices, and interface circuit 1302 can be used to send signals to memory 1303 or other devices. For example, interface circuit 1302 can read instructions stored in memory 1303 and send the instructions to processing circuit 1301.
[0211] In some embodiments, the interface circuit 1302 performs at least one of the communication steps such as sending and / or receiving in the above method, while the processing circuit 1301 performs other steps.
[0212] In some embodiments, the terms interface circuit, interface, transceiver pin, transceiver, etc., can be used interchangeably.
[0213] In some embodiments, chip 1300 further includes one or more memories 1303 for storing instructions. Optionally, all or part of the memories 1303 may be located outside of chip 1300.
[0214] To implement the above embodiments, this application also proposes a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the random number distribution method as described in any of the foregoing method embodiments.
[0215] To implement the above embodiments, this application also proposes a computer program product having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the random number distribution method as described in any of the foregoing method embodiments.
[0216] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0217] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified.
[0218] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing custom logic functions or processes, and the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as should be understood by those skilled in the art to which embodiments of this application pertain.
[0219] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and compact disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.
[0220] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0221] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0222] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0223] The storage medium mentioned above can be a read-only memory, a disk, or an optical disk, etc. Although embodiments of this application have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting this application. Those skilled in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of this application.
Claims
1. A method for distributing random numbers, characterized in that, The method includes: Generate truly random numbers; Determine the distribution type of the true random number, wherein different distribution types are associated with different random number consumers with different requirements for random numbers; Based on the distribution type of the true random number, the true random number or the pseudo random number generated based on the true random number is distributed to the random number consumer.
2. The method according to claim 1, characterized in that, Determining the distribution type of the true random number includes: Determine the generation record of the true random number; Based on the generation record of the true random numbers, the distribution type of the true random numbers is determined.
3. The method according to claim 2, characterized in that, The generation record includes the current cumulative number of truly random numbers generated. Determining the distribution type of the truly random numbers based on the generation record includes: In response to the current cumulative number of generated numbers being less than or equal to a first preset threshold, the distribution type of the true random number is determined to be the first distribution type; In response to the current cumulative number of generated numbers reaching a second preset threshold, the distribution type of the true random number is determined to be the second distribution type; In response to the true random number generated after the current cumulative number of generated numbers reaches the second set threshold, the distribution type of the true random number is determined to be the third distribution type.
4. The method according to claim 3, characterized in that, The method further includes: Activate the random number counting unit, wherein the random number counting unit is used to count the current cumulative number of generated numbers before the second set threshold is reached; In response to the current cumulative number of generated numbers reaching the second set threshold, the random number statistics unit stops updating the current cumulative number of generated numbers and maintains it at the second set threshold.
5. The method according to claim 1, characterized in that, Determining the distribution type of the true random number includes: In response to a request from the random number consumer, the true random number is generated, the request including indication information related to the distribution type; The distribution type of the true random data is determined based on the indication information related to the distribution type.
6. The method according to any one of claims 1-5, characterized in that, The distribution of the truly random number or pseudo-random number generated based on the truly random number to the random number consumer includes: Determine the distribution strategy that matches the distribution type of the true random number; Based on the matched distribution strategy, the true random number or the pseudo random number generated based on the true random number is distributed to the random number consumer.
7. The method according to claim 6, characterized in that, Based on the matched distribution strategy, the truly random number is distributed to the random number consumer, including: In response to the distribution type being the first distribution type, a first indication signal for the true random number is sent to the first random number consumer to trigger the first random number consumer to obtain the true random number.
8. The method according to claim 7, characterized in that, The first random number consumer includes multiple terminals, and sending the first indication signal of the true random number to the first random number consumer includes: Based on the current cumulative number of truly random numbers generated, the first random number consumer to which the truly random numbers are to be distributed is determined from multiple first random number consumers; The first indication signal is sent to the first random number consumer terminal to be distributed.
9. The method according to claim 7, characterized in that, If the first random number consumer to be distributed does not obtain the true random number within the set time period, it obtains a locally generated pseudo-random number or a default random number.
10. The method according to claim 6, characterized in that, Based on the matched distribution strategy, pseudo-random numbers generated from the true random numbers are distributed to the random number consumer, including: In response to the distribution type being the second distribution type, the true random number is used as a seed and written into the pseudo random number generation unit; The pseudo-random number generation unit generates pseudo-random numbers for the second random number consumer based on the seed, and distributes the pseudo-random numbers to the second random number consumer.
11. The method according to claim 10, characterized in that, The second random number consumer includes multiple terminals. The step of generating a pseudo-random number corresponding to the second random number consumer based on the seed using the pseudo-random number generation unit includes: The data access request for the second random number is detected; In response to detecting a data access request sent by at least one second random number consumer, the pseudo-random number generation unit is triggered to generate a pseudo-random number to be distributed to the at least one second random number consumer based on the seed.
12. The method according to claim 11, characterized in that, The distribution of the pseudo-random number to the second random number consumer includes: Based on the data access request, determine the random number storage location corresponding to the at least one second random number consumer. The generated pseudo-random number is written into the random number storage location corresponding to the at least one second random number consumer.
13. The method according to claim 11, characterized in that, The method further includes: In response to satisfying the seed update condition of the pseudo-random number generation unit, a true random number is regenerated; The newly generated true random number is used as the new seed and updated in the pseudo-random number generation unit to trigger the pseudo-random number generation unit to generate the pseudo-random number using the newly generated true random number.
14. The method according to claim 6, characterized in that, Based on the matched distribution strategy, the truly random number is distributed to the random number consumer, including: In response to the distribution type being the third distribution type, a second indication signal of the true random number is sent to the third random number consumer to trigger the third random number consumer to perform a query handshake; Receive an acknowledgment signal sent by a third random number consumer, wherein the acknowledgment signal is used to indicate that the third random number consumer has read the true random number from the corresponding random number storage location; In response to the confirmation signal, the random number storage location is cleared to zero, and the second indication signal is set to an invalid state.
15. The method according to claim 14, characterized in that, The third random number consumer includes multiple terminals, and sending the second indication signal of the true random number to the third random number consumer includes: Determine the generation order of the second indication signal; Based on the generation order, the third random number consumer to be distributed is determined from multiple third random number consumers. The second indication signal is sent to the third random number consumer terminal to be distributed.
16. The method according to claim 14, characterized in that, The method further includes: In response to the completion of clearing the random number storage location, the generation of the next true random number is triggered; In response to the generation and storage of the next true random number in the random number storage location, the second indication signal is reset to a valid state.
17. A random number distribution device, characterized in that, The device includes: The true random number generation unit is configured to generate true random numbers; The random number distribution unit is configured to determine the distribution type of the true random number, and based on the distribution type of the true random number, distribute the true random number or a pseudo-random number generated based on the true random number to the random number consumer. The random number consumers associated with different distribution types have different requirements for random numbers.
18. The apparatus according to claim 17, characterized in that, The random number distribution unit is further configured to: Determine the generation record of the true random number; Based on the generation record of the true random numbers, the distribution type of the true random numbers is determined.
19. The apparatus according to claim 17, characterized in that, The random number distribution unit is further configured to: In response to a request from the random number consumer, the true random number is generated, the request including indication information related to the distribution type; The distribution type of the true random data is determined based on the indication information related to the distribution type.
20. The apparatus according to claim 17, characterized in that, The random number distribution unit is further configured to: Determine the distribution strategy that matches the distribution type of the true random number; Based on the matched distribution strategy, the true random number or the pseudo random number generated based on the true random number is distributed to the random number consumer.
21. The apparatus according to claim 20, characterized in that, The random number distribution unit is further configured to: In response to the distribution type being the first distribution type, a first indication signal for the true random number is sent to the first random number consumer to trigger the first random number consumer to obtain the true random number.
22. The apparatus according to claim 20, characterized in that, The random number distribution unit is further configured to: In response to the distribution type being the second distribution type, the true random number is used as a seed and written into the pseudo random number generation unit; The pseudo-random number generation unit generates pseudo-random numbers for the second random number consumer based on the seed, and distributes the pseudo-random numbers to the second random number consumer.
23. The apparatus according to claim 20, characterized in that, The random number distribution unit is further configured to: In response to the distribution type being the third distribution type, a second indication signal of the true random number is sent to the third random number consumer to trigger the third random number consumer to perform a query handshake; Receive an acknowledgment signal sent by a third random number consumer, wherein the acknowledgment signal is used to indicate that the third random number consumer has read the true random number from the corresponding random number storage location; In response to the confirmation signal, the random number storage space is cleared and the second indication signal is set to an invalid state.
24. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, it implements the steps of the method as described in any one of claims 1 to 16.
25. A non-transitory computer-readable storage medium having computer program instructions stored thereon, characterized in that, When executed by a processor, the program instructions implement the steps of the method described in any one of claims 1 to 16.
26. A chip, characterized in that, The chip includes an interface circuit and a processing circuit that are coupled to each other. The interface circuit is used to input or output signals, and the processing circuit is used to implement the method of any one of claims 1 to 16.
27. A computer program product, characterized in that, Includes a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 16.