PRNG based on the hash function
The process is very similar to the CTR working mode of symmetric ciphers
The pseudo code of the algorithm is as follows
M =⌈n/outlen⌉
data = V
W = the null String
For i = 1 to M
WI = H (data)
w = W | | Wi
Data = (data + 1) MoD 2seedlen
return leftmost n bits of W
Description
V is the seed, Seedlen is the length of V, n is the desired output bit number, H is the hash function
For strong cryptographic hashing algorithms such as SHA-2, there is no known or suspected flaw in PRNG based on hash schemes. The SP800-90 standard provides a periodic update to V.
Mac-based PRNG
Mac-based prng are almost all HMAC constructs. Compared to hash-based schemes, the disadvantage is that the execution time increases by one times, because HMAC performs two hash function operations on each output block. However, the advantage of the HMAC scheme is that it provides higher security.
For Mac-based scenarios, two inputs are required: key K and Seed V, the keys are the same for each output group, and the input data for each packet equals the Mac value of the previous group. For added security, the SP800-90 standard provides periodic updates of K and V.
Generate pseudo-random numbers using hash function and Mac