10

Would hashing the result of a regular random number generator produce a cryptographically secure PRNG?

For example, would sha1(rand()) effectively be a secure PRNG?

Assuming it doesn't, how would you go about attacking it?

Edit: Lets assume that by attack I mean determine the next value it will generate after seeing a series of values it has produced.

Note: I should note that I'm not choosing to implement a PRNG in this way. I'm really interested in analysing the properties of this because I have seen similar constructs in code. It doesn't look like a good idea to me, but I'm struggling to think of the best way to attack it.

Colin Newell
  • 201
  • 2
  • 5
  • 1
    @TidalWave how are hash collisions useful in this context? – Colin Newell Jun 08 '13 at 21:15
  • 3
    with Rand() the seeding is the biggest problem. – CodesInChaos Jun 08 '13 at 22:05
  • So I want to say that I'm very unsatisfied with some of the answers above. Much better answers: http://crypto.stackexchange.com/questions/9076/using-a-hash-as-a-secure-prng – derekmc Mar 29 '14 at 22:14
  • 1
    @derekmc That's a completely different question. This question is about hashing the output of a bad PRNG which is usually but not always insecure mostly because those PRNGs will be badly seeded. The linked question is about constructing a stream cipher from a hash, which is easy since we simply assume that the key/seed has high enough entropy. – CodesInChaos Mar 30 '14 at 08:20