1
$\begingroup$

I'm using SHA256 to hash the output of an entropy generator to generate random numbers. Is it generally better to treat the output of the entropy generator as single messages and hash each of those separately (internal state is reset), or as a message of unknown length (internal state is preserved)?

$\endgroup$

1 Answer 1

1
$\begingroup$

Generally seeds for PRNG's should be mixed in with the internal state using a hash function, and the output should be at least a hash away from the internal state. You could take some hints from the implementation of SHA1PRNG in the Sun JCE or from other hash based PRNG's on how to do this.

You do not want to forget the internal state, because in that case the output is fully dependent on the seed. If there is any problem with a seed, you would have predictable output.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.