Lightweight random number generation method and system for power internet of things based on hash function
By adopting a lightweight random number generation method based on hash function on power Internet of Things devices, the problems of excessive calculation time for random number generation and excessive resource consumption in the prior art are solved, and efficient random number generation and randomness guarantee on resource-constrained devices are realized.
Patent Information
- Application Number
- CN202510175054.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-06-06
AI Technical Summary
The prior art has too long calculation time and too much resource consumption in the process of random number generation in the power Internet of Things environment, so it cannot operate smoothly on resource-constrained devices.
A lightweight random number generation method based on hash function is adopted. By obtaining the data of IoT devices, the connection processing of the hash function input value and the length comparison of the hash function output value is performed. Random numbers are generated based on different comparison results, reducing the number of parameter functions and calculation complexity.
It realizes efficient generation of random numbers on power Internet of Things devices with extremely limited resources, reduces the burden of random number generation in the device, and ensures the randomness of random numbers.
Smart Images

Figure CN120104096A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of electric power Internet of Things, specifically to the technical field of security technology and cryptographic hash function technology, and more specifically to a lightweight random number generation method and system for electric power Internet of Things based on hash function. Background Art
[0002] Random number generation is one of the key components of system security. In existing technologies, the design of random number generation process often requires a trade-off between randomness and computational efficiency. Especially in the power Internet of Things environment, devices usually have limited computing power and storage resources, which requires the random number generator to be lightweight enough to adapt to the performance limitations of these devices.
[0003] Each time the prior art HASH_DRBG generates a random number, it needs to call the hash function calculation additionally in the initialization, random number calculation and internal state update processes, and needs to store multiple state variables, which will cause the calculation time to be too long and increase resource consumption, and it cannot run smoothly on resource-constrained devices.
[0004] Each time the prior art CTR_DRBG generates a random number, it needs to call an encryption function to perform an encryption operation on the counter. This has a large amount of computation in itself, and it also needs to maintain internal states including keys, counters, and seed materials. The maintenance process requires multiple calls to the encryption function. Multiple encryption operations result in long calculation time and high calculation complexity, involving additional computing and storage overhead, and cannot run smoothly on resource-constrained devices.
[0005] The prior art HMAC_DRBG needs to call the HMAC function multiple times each time it generates a random number. Each time an output block is generated, the HMAC function also includes and needs to be called when the status is updated. When random numbers from different sources are combined, the complex combination logic will also increase the calculation complexity. Calling the HMAC function multiple times will also lead to excessively long calculation time and increased resource consumption, and it cannot run smoothly on resource-constrained devices.
[0006] Prior art document 1 (CN113965315B) discloses a lightweight cryptographically secure pseudo-random number generator. The disadvantage is that the parameter function of the random number generator and the random number generation process in the document are very complicated, and it is difficult to run on resource-constrained devices in the power Internet of Things. Summary of the invention
[0007] In order to solve the deficiencies in the prior art, the present invention provides a lightweight random number generation method and system for an electric power Internet of Things based on a hash function. By inputting different random number generation lengths and hash function type parameters for different application scenarios, the corresponding random numbers are efficiently obtained. The method and system can be used on electric power Internet of Things devices with extremely limited resources, thereby reducing the burden of generating random numbers in the electric power Internet of Things devices.
[0008] The present invention adopts the following technical solution.
[0009] A first aspect of the present invention provides a lightweight random number generation method for an electric power Internet of Things based on a hash function, comprising:
[0010] Obtain IoT device data and set initial expected data;
[0011] Connect and process the acquired IoT device data to obtain the hash function input value;
[0012] Inputting the hash function input value into the hash function to obtain the hash function output value;
[0013] Compare the length of the hash function output value with the length of the expected generated random number in the initial expected data to obtain a comparison result;
[0014] According to different comparison results, random numbers are generated to realize lightweight random number generation for the power Internet of Things based on hash functions.
[0015] Preferably, the IoT device data includes: a unique identifier UK generating a random number, a value Cnt of a counter, and data D sampled from the IoT device.
[0016] Preferably, the initial expected data includes: the length L of the random number to be generated, the hash function H to be used type and the length L of the counter value Cnt Cnt .
[0017] Preferably, the hash function H that is expected to be used is verified type If the verification is illegal, an error message is returned and the random number generation ends. If the verification is legal, the obtained IoT device data is connected and processed.
[0018] Preferably, the acquired IoT device data is connected and processed, which is expressed by the following formula:
[0019] INPUT=(UK||Cnt||D) (1)
[0020] In the formula,
[0021] INPUT represents the hash function input value.
[0022] || indicates a connection operation.
[0023] UK represents a unique identifier that generates a random number.
[0024] Cnt represents the value of the counter, and the initial value is set to 0.
[0025] D represents the data sampled by IoT devices.
[0026] Preferably, generating a random number according to different comparison results specifically includes:
[0027] If the length of the hash function output value is L OUT The counter value Cnt is incremented by the same length L as the expected random number length, and the output value of the hash function is directly set to the generated random number;
[0028] If the length of the hash function output value is L OUT If the length of the random number generated is greater than L, the counter value Cnt is incremented, and the first L bits of the hash function output value are set as the generated random number.
[0029] If the length of the hash function output value is L OUT If the length of the random number generated is less than the expected length L of the random number to be generated, the output value of the hash function is stored in a temporary storage, the value Cnt of the counter is incremented, the expected length L of the random number to be generated is updated, the connection processing and hash function processing are performed again through the value of the counter Cnt after the increment, and the length of the new hash function output value is generated and compared with the updated expected length L′ of the random number to be generated, and a random number is generated based on different comparison results.
[0030] Preferably, after the value Cnt of the counter is incremented, it is determined whether the length of the value Cnt of the counter after the increment exceeds the length L of the set counter Cnt. Cnt If it exceeds, the counter value Cnt is set to 0, and the next time a random number is generated, Cnt=0 is used for connection processing. If it does not exceed, the next time a random number is generated, the counter value Cnt is incremented and used for connection processing.
[0031] Preferably, if the length L of the hash function output value is OUT If it is less than the expected length L of the random number generated, update the expected length L of the random number generated. The calculation is expressed as follows:
[0032] L′=LL OUT (2)
[0033] In the formula,
[0034] L OUT Indicates the length of the hash function output value,
[0035] L′ represents the updated expected length of generated random numbers.
[0036] Preferably, if the length L of the hash function output value is OUT If the length of the random number generated is less than the expected length L, a new hash function output value is generated and compared with the reset expected length of the random number generated. Based on the different comparison results, a random number is generated, specifically including:
[0037] If the length of the new hash function output value is equal to L′, extract the stored value from the temporary storage, concatenate the new hash function output value to the stored value, and obtain the generated random number;
[0038] If the length of the new hash function output value is greater than L′, extract the stored value from the temporary storage, and concatenate the first L′ bits of the new hash function output value to the stored value to obtain the generated random number;
[0039] If the length of the new hash function output value is less than L′, extract the stored value from the temporary storage, concatenate the new hash function output value to the stored value, replace the original stored value in the temporary storage with the concatenated value, increment the counter value Cnt again and update the expected length of the random number to be generated, and loop through the connection processing, hash function processing, and the comparison process of the length of the output value after the latest hash function processing and the length of the latest expected random number to be generated, until the length of the output value after the latest hash function processing is greater than the length of the latest expected random number to be generated or the two are equal, to obtain the generated random number.
[0040] The second aspect of the present invention provides a lightweight random number generation system for an electric power Internet of Things based on a hash function. According to the lightweight random number generation method for an electric power Internet of Things based on a hash function described in the first aspect of the present invention, the method comprises:
[0041] Data acquisition and setting module: used to obtain IoT device data and set initial expected data;
[0042] Data connection module: used to connect and process the acquired IoT device data to obtain the hash function input value;
[0043] Hash processing module: used to input the hash function input value into the hash function to obtain the hash function output value;
[0044] Data comparison module: used to compare the length of the hash function output value with the length of the expected generated random number in the initial expected data to obtain a comparison result;
[0045] Random number generation module: used to generate random numbers based on different comparison results, and realize lightweight random number generation for the power Internet of Things based on hash functions.
[0046] Compared with the prior art, the beneficial effects of the present invention include at least:
[0047] The present invention uses only one encryption component (hash function) to participate in the generation of random numbers, which greatly reduces the number of parameter functions and does not occupy too many device resources. Each time a random number is generated, the hash function is only calculated once. Each time a random number is calculated and generated, it is only necessary to save the random number generated last time, and the memory occupancy is small. At the same time, the generation of multiple random numbers only requires taking out the last generation result from the memory and splicing the multiple generated random numbers. The random number generation process is simplified by avoiding the use of complex combination algorithms. The present invention does not rely on the memory state and therefore avoids calling multiple hash functions. Splicing the generated multiple random numbers can also ensure the randomness of the generated random numbers, thereby ensuring the lightweight of the calculation process. The present invention efficiently obtains the corresponding random numbers by inputting different random number generation lengths and hash function type parameters for different application scenarios. It can be used on power Internet of Things devices with extremely limited resources, thereby reducing the burden of generating random numbers in power Internet of Things devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 It is a schematic diagram of a lightweight random number generation process of a power Internet of Things based on a hash function provided in accordance with an embodiment of the present invention. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical scheme and advantages of the present invention clearer, the technical scheme of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. The described embodiments are only embodiments of a part of the present invention, not all embodiments. Based on the spirit of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the protection scope of the present invention.
[0050] like Figure 1 As shown, embodiment 1 of the present invention provides a lightweight random number generation method for power Internet of Things based on a hash function, comprising the following steps:
[0051] Step 1: Obtain IoT device data and set initial expected data.
[0052] In a preferred but non-limiting embodiment of the present invention, the IoT device data includes a unique identifier UK for generating a random number, a value Cnt of a counter, and data D sampled from the IoT device. The expected IoT data includes the length L (in bits) of the expected random number, the hash function H type and the length L of the counter value Cnt Cnt(Unit: bit). UK represents the unique identifier for generating random numbers, which is used to locate the current random number generation method; Cnt represents the value of the counter, with an initial value of 0. The longer Cnt is, the higher the randomness of the random number is.
[0053] Verify the expected hash function H type If the verification is illegal, an error message is returned and the random number generation ends. If the verification is legal, go to step 2 to connect the obtained IoT device data.
[0054] Step 2: Connect the IoT device data obtained in step 1 to obtain a hash function input value.
[0055] In a preferred but non-limiting embodiment of the present invention, the acquired data is subjected to connection processing, which is expressed by the following formula:
[0056] INPUT=(UK||Cnt||D) (1)
[0057] In the formula,
[0058] INPUT represents the hash function input value;
[0059] || indicates a connection operation, that is, UK, Cnt, and D data are connected in sequence to obtain INPUT.
[0060] Step 3: Input the hash function input value into the hash function to obtain the hash function output value.
[0061] Step 4, comparing the length of the hash function output value with the expected length of the random number generated in the initial expected IoT data set in step 1 to obtain a comparison result;
[0062] Step 5: Generate random numbers based on different comparison results to realize lightweight random number generation for the power Internet of Things based on hash functions.
[0063] In a preferred but non-limiting embodiment of the present invention, if the length L of the hash function output value is OUT The counter value Cnt is incremented by itself, which is the same as the expected length L of the random number to be generated. The output value of the hash function is directly set to the generated random number, including:
[0064] If the length of the hash function output value is L OUT The counter value Cnt is incremented by itself, which is the same as the expected length L of the random number to be generated. If there is a storage value in the temporary storage, the output value of the hash function is spliced to the storage value to obtain the generated random number. If there is no storage value in the temporary storage, the output value of the hash function is directly set to the generated random number. After the random number is generated, the temporary storage is cleared.
[0065] When a random number is generated next time, there is no need to reset Cnt. Use the Cnt updated by Formula 2 as the Cnt in Formula 1 for data connection next time.
[0066] Further preferably, input UK=0x00000001, Cnt=0x00000000, D=0x3901, L Cnt =32, H type =SM3, L = 256. Find H type The corresponding SM3 hash function.
[0067] Calculate INPUT=(UK||Cnt||D)=0x00000001000000003901, and INPUT is input to the SM3 hash function.
[0068] The SM3 hash function outputs OUTPUT, the length of OUTPUT is 256 bits and equal to L, therefore, Cnt=Cnt+1=0x00000001, OUTPUT is output as a random number, and the program ends.
[0069] In a preferred but non-limiting embodiment of the present invention, if the length L of the hash function output value is OUT If the length of the random number generated is greater than L, the counter value Cnt is incremented, and the first L bits of the hash function output value are set as the generated random number, including:
[0070] If the length of the hash function output value is L OUT If the value Cnt of the counter is greater than the expected length L of the random number to be generated, it will increase automatically. If there is a storage value in the temporary storage, the first L bits of the output value of the hash function will be concatenated with the storage value to obtain the generated random number. If there is no storage value in the temporary storage, the first L bits of the output value of the hash function will be set as the generated random number. After the random number is generated, the temporary storage will be cleared.
[0071] Further preferably, input UK=0x00000001, Cnt=0x00000000, D=0x3901, L Cnt =32, H type =SM3, L = 128. Find H type The corresponding SM3 hash function.
[0072] Calculate INPUT=(UK||Cnt||D)=0x00000001000000003901, and INPUT is input to the SM3 hash function.
[0073] The SM3 hash function outputs OUTPUT. The length of OUTPUT is 256 bits, which is greater than L. Therefore, Cnt=Cnt+1=0x00000001. The first 128 bits of OUTPUT are output as a random number, and the program ends.
[0074] In a preferred but non-limiting embodiment of the present invention, if the length L of the hash function output value is OUT If the expected random number length L is less than the expected random number length, the hash function output value is stored in temporary storage, the counter value Cnt is incremented, and the expected random number length L is updated. The updated expected random number length L′ is calculated as follows:
[0075] L′=LL OUT (2)
[0076] In the formula,
[0077] L OUT Indicates the length of the hash function output value,
[0078] L′ represents the updated expected length of generated random numbers.
[0079] Further preferably, if the length of the new hash function output value is equal to L′, the stored value is extracted from the temporary storage, and the new hash function output value is concatenated after the stored value to obtain the generated random number;
[0080] If the length of the new hash function output value is greater than L′, extract the stored value from the temporary storage, and concatenate the first L′ bits of the new hash function output value to the stored value to obtain the generated random number;
[0081] If the length of the new hash function output value is less than L′, extract the stored value from the temporary storage, concatenate the new hash function output value to the stored value, replace the original stored value in the temporary storage with the concatenated value, increment the counter value Cnt again and update the expected length of the random number to be generated, and loop through the connection processing, hash function processing, and the comparison process of the length of the output value after the latest hash function processing and the length of the latest expected random number to be generated, until the length of the output value after the latest hash function processing is greater than the length of the latest expected random number to be generated or the two are equal, to obtain the generated random number.
[0082] After generating the random number, clear the temporary storage.
[0083] More preferably, input UK=0x00000001, Cnt=0x00000000, D=0x3901, L Cnt =32, H type =SM3, L = 510, find H type The corresponding SM3 hash function;
[0084] Calculate INPUT = (UK||Cnt||D) = 0x00000001000000003901, INPUT is input to the SM3 hash function; the SM3 hash function outputs OUTPUT, the length of OUTPUT is 256 bits, which is less than L = 510, therefore, Cnt = Cnt + 1 = 0x00000001, L = L-256 = 510-256 = 254, and output OUTPUT as 0-255 bits of the random number;
[0085] Calculate INPUT = (UK||Cnt||D) = 0x00000001000000013901, INPUT is input to the SM3 hash function; SM3 hash function outputs OUTPUT, the length of OUTPUT is 256 bits, which is greater than L=254, therefore, Cnt = Cnt+1 = 0x00000002, output the first 254 bits of OUTPUT as 256-509 bits of the random number, and the program ends.
[0086] More preferably, input UK=0x00000001, Cnt=0x00000000, D=0x3901, L Cnt =32, H type =SM3, L = 520, find H type The corresponding SM3 hash function;
[0087] Calculate INPUT = (UK||Cnt||D) = 0x00000001000000003901, INPUT is input to the SM3 hash function; the SM3 hash function outputs OUTPUT, the length of OUTPUT is 256 bits, which is less than L = 520, therefore, Cnt = Cnt + 1 = 0x00000001, L = L-256 = 520-256 = 264, and output OUTPUT as 0-255 bits of the random number;
[0088] Calculate INPUT = (UK||Cnt||D) = 0x00000001000000013901, INPUT is input to the SM3 hash function; the SM3 hash function outputs OUTPUT, the length of OUTPUT is 256 bits, which is greater than L = 264, therefore, Cnt = Cnt + 1 = 0x00000002, L = L-256 = 264-256 = 8, and output OUTPUT as 256-511 bits of the random number;
[0089] Calculate INPUT=(UK||Cnt||D)==0x00000001000000023901, INPUT is input to the SM3 hash function; SM3 hash function outputs OUTPUT, the length of OUTPUT is 256 bits, which is greater than L=8, therefore, Cnt=Cnt+1=0x00000003, output the first 8 bits of OUTPUT as 512-519 bits of the random number, and the program ends.
[0090] Compared with the prior art, the beneficial effects of the present invention include at least:
[0091] The present invention uses only one encryption component (hash function) to participate in the generation of random numbers, which greatly reduces the number of parameter functions and does not occupy too many device resources. Each time a random number is generated, the hash function is only calculated once. Each time a random number is calculated and generated, it is only necessary to save the random number generated last time, and the memory occupancy is small. At the same time, the generation of multiple random numbers only requires taking out the last generation result from the memory and splicing the multiple generated random numbers. The random number generation process is simplified by avoiding the use of complex combination algorithms. The present invention does not rely on the memory state and therefore avoids calling multiple hash functions. Splicing the generated multiple random numbers can also ensure the randomness of the generated random numbers, thereby ensuring the lightweight of the calculation process. The present invention efficiently obtains the corresponding random numbers by inputting different random number generation lengths and hash function type parameters for different application scenarios. It can be used on power Internet of Things devices with extremely limited resources, thereby reducing the burden of generating random numbers in power Internet of Things devices.
[0092] Embodiment 2 of the present invention provides a power Internet of Things lightweight random number generation system based on a hash function, and runs a power Internet of Things lightweight random number generation method based on a hash function described in Embodiment 1, including:
[0093] Data acquisition and setting module: used to obtain IoT device data and set initial expected data;
[0094] Data connection module: used to connect and process the acquired IoT device data to obtain the hash function input value;
[0095] Hash processing module: used to input the hash function input value into the hash function to obtain the hash function output value;
[0096] Data comparison module: used to compare the length of the hash function output value with the length of the expected generated random number in the initial expected data to obtain a comparison result;
[0097] Random number generation module: used to generate random numbers based on different comparison results, and realize lightweight random number generation for the power Internet of Things based on hash functions.
[0098] Example 3
[0099] Embodiment 3 of the present invention is simulated on a resource-constrained device of the power Internet of Things, and runs a lightweight random number generation method for the power Internet of Things based on a hash function provided by Embodiment 1 of the present invention, to test the execution time of generating random numbers, as well as the randomness test of the generated random numbers, so as to illustrate the advantages of the present invention.
[0100] The implementation scenario selected in Example 3 of the present invention is real-time key update of smart meters in the power Internet of Things.
[0101] 1. Scene background
[0102] Device type: Smart meter.
[0103] Core requirements: security, regular generation of random numbers for communication key updates;
[0104] Resource limitations: The device hardware is Orange Pi PC Plus (1.3GHz Cortex-A7, 1GB RAM, Ubuntu Linux 3.4.113);
[0105] Real-time: Key updates need to be completed within 100ms.
[0106] 2. Parameter settings
[0107] Hash function: SHA-256.
[0108] Random number length: 128 bits.
[0109] 3. Data Collection
[0110] Sampling data D: The ambient temperature is collected using the built-in temperature sensor of the meter (4 bytes).
[0111] Device unique identifier UK: pre-burned hardware key UK (4 bytes).
[0112] Counter: Cnt (4 bytes).
[0113] 4. Application process
[0114] The collected data is spliced as input to different schemes, and random numbers are generated according to different test schemes. The first 128 bits of the random number are intercepted as the final random number, which is used for session keys and device identity authentication.
[0115] Table 1 Comparison test results of the solution of the present invention and the prior art
[0116]
[0117]
[0118] Notes to table:
[0119] Platform: Orange Pi PC Plus (1.3GHz Cortex-A7, 1GB RAM, Ubuntu Linux 3.4.113) simulates a resource-constrained platform in the power Internet of Things.
[0120] Data: All schemes have the same input data parameters, and all results are the average of 100,000 independent experiments.
[0121] Randomness test standard: National Institute of Standards and Technology (NIST) SP 800-22 Randomness Test Suite.
[0122] It can be seen from the above table data that the present invention has significant advantages in execution time compared with existing technical solutions such as HASH_DRBG, CTR_DRBG, HMAC_DRBG, and the like, and is on par with the existing technical solutions in the NIST randomness test pass rate, both of which are 100%, indicating that the present invention can achieve the same effect as the existing technology while achieving lightweight.
[0123] The reason for achieving such an effect is that the present invention removes redundant calculation steps and unnecessary parameter functions, and deeply optimizes and simplifies the entire process. However, in the process of simplification, the present invention retains the key steps to maintain randomness, such as the hash function operation link, which can fully disrupt the original structure and rules of the input data and ensure that the output result has a high degree of randomness. Therefore, it is achieved while ensuring the randomness of random number generation while being lightweight.
[0124] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, ordinary technicians in the relevant field should understand that the specific implementation methods of the present invention can still be modified or replaced by equivalents, and any modifications or equivalent replacements that do not depart from the spirit and scope of the present invention should be covered within the scope of protection of the claims of the present invention.
Claims
1. A lightweight random number generation method for power Internet of Things based on hash function, characterized in that: include: Obtain IoT device data and set initial expected data; Connect and process the acquired IoT device data to obtain the hash function input value; Inputting the hash function input value into the hash function to obtain the hash function output value; Compare the length of the hash function output value with the length of the expected generated random number in the initial expected data to obtain a comparison result; According to different comparison results, random numbers are generated to realize lightweight random number generation for the power Internet of Things based on hash functions.
2. According to the method for generating lightweight random numbers for power Internet of Things based on hash functions according to claim 1, it is characterized in that: The IoT device data includes: a unique identifier UK that generates a random number, a value Cnt of a counter, and data D sampled from the IoT device.
3. According to the method for generating lightweight random numbers for power Internet of Things based on hash function according to claim 1, it is characterized in that: The initial expected data includes: the length L of the random number to be generated, the hash function H to be used type and the length L of the counter value Cnt Cnt .
4. According to the method for generating lightweight random numbers for power Internet of Things based on hash functions according to claim 3, it is characterized in that: Verify the expected hash function H type If the verification is illegal, an error message is returned and the random number generation ends. If the verification is legal, the obtained IoT device data is connected and processed.
5. According to the method for generating lightweight random numbers for power Internet of Things based on hash function according to claim 1, it is characterized in that: The acquired IoT device data is connected and processed, which can be expressed as the following formula: INPUT=(UK||Cnt||D) (1) In the formula, INPUT represents the hash function input value. || indicates a connection operation. UK represents a unique identifier that generates a random number. Cnt represents the value of the counter, and the initial value is set to 0. D represents the data sampled by IoT devices.
6. The method for generating lightweight random numbers for power Internet of Things based on hash functions according to claim 1 is characterized in that: Generate random numbers based on different comparison results, including: If the length of the hash function output value is L OUT The counter value Cnt is incremented by the same length L as the expected random number length, and the output value of the hash function is directly set to the generated random number; If the length of the hash function output value is L OUT If the length of the random number generated is greater than L, the counter value Cnt is incremented, and the first L bits of the hash function output value are set as the generated random number. If the length of the hash function output value is L OUT If the length of the random number generated is less than the expected length L of the random number to be generated, the output value of the hash function is stored in a temporary storage, the value Cnt of the counter is incremented, the expected length L of the random number to be generated is updated, the connection processing and hash function processing are performed again through the value of the counter Cnt after the increment, and the length of the new hash function output value is generated and compared with the updated expected length L′ of the random number to be generated, and a random number is generated based on different comparison results.
7. The method for generating lightweight random numbers for power Internet of Things based on hash functions according to claim 6 is characterized in that: After the counter value Cnt is incremented, determine whether the length of the counter value Cnt after the increment exceeds the length L of the set counter Cnt Cnt If it exceeds, the counter value Cnt is set to 0, and the next time a random number is generated, Cnt=0 is used for connection processing. If it does not exceed, the next time a random number is generated, the counter value Cnt is incremented and used for connection processing.
8. The method for generating lightweight random numbers for power Internet of Things based on hash functions according to claim 6 is characterized in that: If the length of the hash function output value is L OUT If it is less than the expected length L of the random number generated, update the expected length L of the random number generated. The calculation is expressed as follows: L′=LL OUT (2) In the formula, L OUT Indicates the length of the hash function output value, L′ represents the updated expected length of generated random numbers.
9. A method for generating lightweight random numbers for power Internet of Things based on hash functions according to claim 6 or 8, characterized in that: If the length of the hash function output value is L OUT If the length of the random number generated is less than the expected length L, a new hash function output value is generated and compared with the reset expected length of the random number generated. Based on the different comparison results, a random number is generated, specifically including: If the length of the new hash function output value is equal to L′, extract the stored value from the temporary storage, concatenate the new hash function output value to the stored value, and obtain the generated random number; If the length of the new hash function output value is greater than L′, extract the stored value from the temporary storage, and concatenate the first L′ bits of the new hash function output value to the stored value to obtain the generated random number; If the length of the new hash function output value is less than L′, extract the storage value from the temporary storage, concatenate the new hash function output value to the storage value, replace the original storage value in the temporary storage with the concatenated value, increment the counter value Cnt again and update the expected length of the random number to be generated, and loop through the connection processing, hash function processing, and the comparison process of the length of the output value after the latest hash function processing and the length of the latest expected random number to be generated, until the length of the output value after the latest hash function processing is greater than the length of the latest expected random number to be generated or the two are equal, to obtain the generated random number.
10. A hash function-based lightweight random number generation system for an electric power Internet of Things, running a hash function-based lightweight random number generation method for an electric power Internet of Things according to any one of claims 1 to 9, characterized in that: Data acquisition and setting module: used to obtain IoT device data and set initial expected data; Data connection module: used to connect and process the acquired IoT device data to obtain the hash function input value; Hash processing module: used to input the hash function input value into the hash function to obtain the hash function output value; Data comparison module: used to compare the length of the hash function output value with the length of the expected generated random number in the initial expected data to obtain a comparison result; Random number generation module: used to generate random numbers based on different comparison results, and realize lightweight random number generation for the power Internet of Things based on hash functions.
Citation Information
Patent Citations
A lightweight cryptographically secure pseudorandom number generator and a method for generating pseudorandom numbers
CN113965315B