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)?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
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.