Generate pseudo-random numbers using hash function and Mac

Source: Internet
Author: User
Tags hmac

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.