Pseudo-random number generation method, device and equipment and storage medium

By generating initial keys and values ​​using HASH and AES algorithms, and combining them with AES-CTR encryption, the problems of slow pseudo-random number generation and high resource consumption are solved. This achieves efficient and high-quality pseudo-random number generation, simplifies algorithm complexity, and improves the encryption efficiency of electronic devices.

CN117573073BActive Publication Date: 2026-11-24SHANGHAI AISINOCHIP ELECTRONICS TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311569486.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-23
Publication Date
2026-11-24
Estimated Expiration
2043-11-23

AI Technical Summary

Technical Problem

In existing technologies, true random number generation is slow and requires specialized hardware, while pseudo-random number generation algorithms are highly complex and resource-intensive, making it difficult to meet the needs of efficient encryption.

Method used

The HASH algorithm is used to generate the initial key and initial value. Combined with AES-CTR encryption, a pseudo-random sequence is output. The key and initial value are updated iteratively through HASH, which simplifies the algorithm complexity and enables continuous output of efficient pseudo-random numbers.

Benefits of technology

It achieves efficient generation of high-quality pseudo-random numbers, reduces resource consumption, simplifies algorithm complexity, eliminates the need for periodic updates to the seed and derived functions, and improves the encryption efficiency of electronic devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117573073B_ABST
    Figure CN117573073B_ABST
Patent Text Reader

Abstract

This invention discloses a pseudo-random number generation method. It utilizes a hash algorithm to generate a key and initial value based on received entropy input and personalized data. These are then input into an AES module for encryption in CTR mode. The generated keystream is output as the generated pseudo-random number. Simultaneously, the output pseudo-random data is continuously input into the hash module for computation. Upon returning the desired random number, the hash value of the generated random number is used to update the key and initial value for the next computation. Since the key and initial value are updated with the hash value of the generated random data each time a random number is generated, this algorithm does not require periodic seed updates or derived functions, simplifying the algorithm's complexity. Both AES and hash functions are implemented in hardware, improving the speed of random number generation and enabling high-speed, high-quality pseudo-random numbers. This makes encryption of electronic devices more efficient and resource-efficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the technical field of electronic chip encryption, and particularly relates to a pseudo-random number generation method, apparatus, device and storage medium. Background Technology

[0002] When cryptography is mentioned, most people first think of encryption algorithms and keys. Different algorithms determine different levels of security, and keys are the core of security. However, besides these, there is another factor crucial to cryptography—random numbers. Random numbers are used in key distribution and authentication, session keys, and stream ciphers.

[0003] Random numbers are divided into pseudo-random numbers and true random numbers. Pseudo-random numbers are further divided into weak pseudo-random numbers and strong pseudo-random numbers.

[0004] Weak pseudo-random numbers

[0005] The characteristic is that it generates a random value according to a certain pattern using a pure software algorithm. However, as the name suggests, this type of random number only possesses a certain degree of randomness and cannot achieve unpredictability; that is, it is not a truly random number. For example, using the MCU's time as a seed to generate a random number will also result in a constantly changing random number, since time is a constantly changing variable. However, the changes in time ultimately follow certain patterns.

[0006] Strong pseudo-random numbers

[0007] As the name suggests, this type of random number has stronger randomness characteristics, satisfying the properties of randomness and unpredictability. For example, by obtaining keystroke data as a seed for generating a set of strong pseudo-random numbers, the generated random numbers are closer to true random numbers because of the uncertainty of keystrokes.

[0008] True random numbers

[0009] It possesses three fundamental characteristics: randomness, unpredictability, and non-repeatability. No one can know the next random number (or the next digit of a random number) through software algorithms or other methods. The generation of truly random numbers is based on physical phenomena, such as rolling dice or flipping a coin. In the embedded systems industry, truly random numbers require the use of a hardware random number generator.

[0010] random number generator

[0011] Random number generators can be categorized into true random number generators and pseudo random number generators. These can be further subdivided into hardware true random number generators and hardware pseudo random number generators. Of these, only hardware true random number generators are truly safe and effective for embedded system applications.

[0012] True random numbers are obtained by converting unpredictable entropy sources from the external physical environment into corresponding binary bit streams. A True Random Number Generator (TRNG) is responsible for this conversion process. Pseudo-random numbers, on the other hand, are binary bit streams obtained by applying a fixed value (or seed) to a deterministic random number generation algorithm. There are two different pseudo-random number generation tools: a Pseudo-Random Number Generator (PRNG), which generates bit sequences of unlimited length, and a Pseudo-Random Function (PRF), which generates bit sequences of fixed length.

[0013] TRNGs require sampling of real, unpredictable physical processes, such as thermal noise signals, quantum mechanical effects, and decay radiation of radioactive elements. Therefore, they require hardware support, and specialized equipment is necessary to generate truly random numbers. The main difference between PRNGs and TRNGs is that PRNGs are more efficient. They can be implemented entirely in software or in hardware. Therefore, designing an efficient and high-quality pseudo-random number generation algorithm is essential. Summary of the Invention

[0014] The purpose of this invention is to provide a pseudo-random number generation method. The entire generation process uses the HASH and AES algorithms (pure software algorithms). After initialization, it can continuously output pseudo-random number sequences and automatically update the key and initial value. It does not require periodic updates of the seed and derived function, which simplifies the algorithm complexity and can obtain high-speed and high-quality pseudo-random numbers, thereby making electronic device encryption more efficient and consuming fewer resources.

[0015] To solve the above problems, the technical solution of the present invention is as follows:

[0016] A pseudo-random number generation method, comprising:

[0017] Based on the input data, an initial key and initial value are generated using a HASH algorithm;

[0018] The initial value is encrypted using the initial key using AES-CTR encryption, and a pseudo-random sequence is output.

[0019] The pseudo-random sequence is hashed iteratively to update the key and initial value, which are then used to calculate and generate the next pseudo-random number.

[0020] According to an embodiment of the present invention, during the initialization phase, the input entropy and personalized data are hashed using a hash algorithm, and the high 128 bits of the 256-bit data of the hash result are used as the initial key of the encryption module, and the low 128 bits are used as the initial value of the encryption module.

[0021] According to an embodiment of the present invention, in the pseudo-random number generation stage, the initial value is encrypted using the initial key by the AES encryption engine to generate a key stream. In CTR mode, each block corresponds to a counter that is incremented sequentially. The initial value is used as the initial value of the counter, and the counter value is incremented by 1 after each encryption.

[0022] According to an embodiment of the present invention, in the pseudo-random number generation stage, the encrypted key stream is output as a pseudo-random sequence, and the pseudo-random sequence is subjected to HASH iteration. When the pseudo-random number generation ends, the HASH value of the generated pseudo-random sequence is obtained. The high 128 bits of the 256-bit data of the HASH value are used as the initial key for the next generation of pseudo-random numbers, and the low 128 bits are used as the initial value for the next generation of pseudo-random numbers.

[0023] A pseudo-random number generation device, comprising:

[0024] The initialization module generates an initial key and initial value based on the input data using a HASH algorithm;

[0025] The pseudo-random number generation module uses the initial key to perform AES-CTR encryption on the initial value and outputs a pseudo-random sequence. At the same time, it performs HASH iteration on the pseudo-random sequence to update the key and the initial value, which are used to calculate and generate the next pseudo-random sequence.

[0026] A pseudo-random number generation device includes a memory and a processor. The memory stores computer instructions, which, when executed by the processor, cause the processor to perform steps in a pseudo-random number generation method according to an embodiment of the present invention.

[0027] A storage medium storing computer instructions, which, when executed by one or more processors, cause the one or more processors to perform steps in a pseudo-random number generation method according to an embodiment of the present invention.

[0028] Because of the above technical solutions, this invention has the following advantages and positive effects compared with the prior art:

[0029] This invention discloses a pseudo-random number generation method that utilizes a hash algorithm to generate a key and initial value based on received entropy input and personalized data. These are then input into an AES module for encryption in CTR mode. The generated keystream is output as the generated pseudo-random number. Simultaneously, the output pseudo-random data is continuously input into the hash module for computation. Upon returning the desired random number, the hash value of the generated random number is used to update the key and initial value for the next computation. Since the key and initial value are updated with the hash value of the generated random data each time a random number is generated, this algorithm does not require periodic seed updates or derived functions, simplifying the algorithm's complexity. Both AES and hash functions in the algorithm can be implemented using hardware modules, improving the speed of random number generation and enabling the production of high-speed, high-quality pseudo-random numbers. This makes electronic device encryption more efficient and resource-efficient. Attached Figure Description

[0030] Figure 1 This is a flowchart of a pseudo-random number generation method according to an embodiment of the present invention;

[0031] Figure 2 This is a block diagram of modular random number generation in one embodiment of the present invention;

[0032] Figure 3 This is a schematic diagram of the pseudo-random number generation process in one embodiment of the present invention;

[0033] Figure 4 This is a flowchart of an electronic device calling a pseudo-random number in one embodiment of the present invention;

[0034] Figure 5 This is a schematic diagram of a pseudo-random number generation device according to an embodiment of the present invention. Detailed Implementation

[0035] The following detailed description, in conjunction with the accompanying drawings and specific embodiments, provides a method, apparatus, device, and storage medium for generating pseudo-random numbers according to the present invention. The advantages and features of the present invention will become more apparent from the following description and claims.

[0036] This embodiment addresses the drawbacks of slow true random number generation and the need for specialized hardware by providing a pseudo-random number generation method using a deterministic algorithm. Please refer to [link / reference]. Figure 1This pseudo-random number generation method uses a hash algorithm during initialization to generate an initial key KEY and an initial value V based on entropy input and personalized input. During the random number generation phase, the initial value V is encrypted using the AES algorithm with the initial key KEY in CTR mode. In CTR mode, V serves as the initial counting value, incrementing by 1 after each encryption. The keystream generated by AES-CTR is returned as the output pseudo-random sequence and simultaneously input into the hash module for synchronous iteration. At the end of the pseudo-random sequence generation, a new hash value is generated, and the key KEY and initial value V are updated for the next operation.

[0037] For details, please refer to Figure 2 The pseudo-random number generation method includes a HASH module and an AES module. During the initialization phase, the HASH module uses the HASH algorithm to perform HASH operations on the entropy input and the personalized input, and uses the high 128 bits of the 256-bit data of the result as the initial key KEY of the AES module in the generation algorithm, and uses the low 128 bits as the initial value V of the AES module in the generation algorithm.

[0038] Please refer to Figure 3 In the random number generation phase, the AES encryption engine uses the key KEY to encrypt the initial value V to generate a key stream. In CTR mode, each block corresponds to a counter that increments sequentially, with the initial value V serving as the initial count value. V increments by 1 after each encryption.

[0039] During the random number generation phase, the generated key stream is output as a pseudo-random sequence and simultaneously input into the HASH module for iteration. When the pseudo-random number generation ends, the HASH value of the generated pseudo-random sequence is generated. The high 128 bits of the 256-bit data of the result are used as the initial key KEY for the next pseudo-random number generation, and the low 128 bits are used as the initial value V for the next pseudo-random number generation.

[0040] Since the key and initial value are updated using the hash value of the generated random data each time a random number is generated, this algorithm does not need to update the seed periodically, nor does it need a derived function, thus simplifying the algorithm's complexity.

[0041] When applying the above pseudo-random number generation method to electronic encryption devices, such as key distribution and authentication, please refer to [link to relevant documentation]. Figure 4Electronic encryption devices require a pseudo-random sequence. Upon receiving an instruction to obtain the pseudo-random sequence, this method first determines whether it's the first time the pseudo-random sequence has been called. If so, it enters the initialization phase, using a hash algorithm to perform a hash operation on the entropy input and the personalized input. The high 128 bits of the resulting 256-bit data are used as the initial key KEY for the AES module in the generation algorithm, and the low 128 bits are used as the initial value V for the AES module. Then, the subsequent random number generation phase proceeds. If not, it directly enters the random number generation phase to obtain the required pseudo-random number.

[0042] Based on the same concept, this embodiment also provides a pseudo-random number generation device, including:

[0043] The initialization module generates an initial key and initial value based on the input data using a HASH algorithm;

[0044] The pseudo-random number generation module uses the initial key to perform AES-CTR encryption on the initial value and outputs a pseudo-random sequence. At the same time, it performs HASH iteration on the pseudo-random sequence to update the key and the initial value, which are used to calculate and generate the next pseudo-random number.

[0045] This pseudo-random number generator is used to implement the above-mentioned pseudo-random number generation method. Its principle and implementation method will not be described in detail here.

[0046] This embodiment also provides a pseudo-random number generation device. Please refer to [link / reference]. Figure 5 The pseudo-random number generator 500 can vary considerably depending on its configuration or performance. It may include one or more central processing units (CPUs) 510 (e.g., x86, ARM architecture processors, or FPGAs) and memory 520, and one or more storage media 530 (e.g., one or more mass storage devices) for storing application programs 533 or data 532. The memory 520 and storage media 530 can be temporary or persistent storage. The program stored in the storage media 530 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the pseudo-random number generator 500.

[0047] Furthermore, the processor 510 can be configured to communicate with the storage medium 530 and execute a series of instruction operations in the storage medium 530 on the pseudo-random number generation device 500.

[0048] The pseudo-random number generation device 500 may also include one or more power supplies 540, one or more wired or wireless network interfaces 550, one or more input / output interfaces 560, and / or one or more operating systems 531, such as Windows Server, Vista, etc.

[0049] Those skilled in the art will understand that Figure 5 The structure of the pseudo-random number generator shown does not constitute a limitation on the pseudo-random number generator. It may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0050] Another embodiment of the present invention also provides a computer-readable storage medium.

[0051] The computer-readable storage medium can be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores instructions that, when executed on a computer, cause the computer to perform the steps of the pseudo-random number generation device method in Embodiment 1.

[0052] If a pseudo-random number generation method is implemented as program instructions and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this embodiment, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in software. This computer software is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0053] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific identification content executed by the system and device described above can be referred to the corresponding process in the foregoing method embodiments.

[0054] The embodiments of the present invention have been described in detail above with reference to the accompanying drawings, but the present invention is not limited to the above embodiments. Even if various changes are made to the present invention, if these changes fall within the scope of the claims of the present invention and their equivalents, they shall still fall within the protection scope of the present invention.

Claims

1. A pseudo-random number generation method for electronic encryption devices; characterized in that, include: Based on the input data, an initial key and initial value are generated using a HASH algorithm; The initial value is encrypted using the initial key using AES-CTR encryption, and a pseudo-random sequence is output. The pseudo-random sequence is hashed iteratively to update the key and initial value, which are then used to calculate and generate the next pseudo-random sequence. During the initialization phase, the input entropy and user data are hashed using a hash algorithm. The high 128 bits of the 256-bit result are used as the initial key of the encryption module, and the low 128 bits are used as the initial value of the encryption module. In the pseudo-random number generation stage, the initial value is encrypted using the initial key through the AES encryption engine to generate a key stream. In CTR mode, each block corresponds to a counter that is incremented sequentially. The initial value is used as the initial value of the counter, and the counter value is incremented by 1 after each encryption. During the pseudo-random number generation stage, the encrypted key stream is output as a pseudo-random sequence, and the pseudo-random sequence is subjected to HASH iteration. When the pseudo-random number generation ends, the HASH value of the generated pseudo-random sequence is obtained. The high 128 bits of the 256-bit data of the HASH value are used as the initial key for the next generation of pseudo-random numbers, and the low 128 bits are used as the initial value for the next generation of pseudo-random numbers.

2. A pseudo-random number generation device, used to implement the pseudo-random number generation method as described in claim 1, characterized in that, include: The initialization module generates an initial key and initial value based on the input data using a HASH algorithm; The pseudo-random number generation module uses the initial key to perform AES-CTR encryption on the initial value and outputs a pseudo-random sequence. At the same time, it performs HASH iteration on the pseudo-random sequence to update the key and the initial value, which are used to calculate and generate the next pseudo-random number.

3. A pseudo-random number generation device, characterized in that, include: A memory and a processor, wherein the memory stores computer instructions that, when executed by the processor, cause the processor to perform the steps in the pseudo-random number generation method as described in claim 1.

4. A storage medium storing computer instructions, characterized in that, When the computer instructions are executed by one or more processors, the one or more processors perform the steps in the pseudo-random number generation method as described in claim 1.

Citation Information

Patent Citations

  • Cryptographically secure pseudo-random number generator

    CN101292464A