crypto101 / merlyn

Server backend for interactive online exercises.
ISC License
3 stars 2 forks source link

Verify that passing random.Random.seed a str is okay #7

Open lvh opened 10 years ago

lvh commented 10 years ago

Right now, when you ask exercises.Secret to give you a non-secure PRNG, it derives a key (str) and passes it to random.Random.seed. It has the wonderful API that lets you pass in anything hashable; but it's not clear just how much entropy survives. Since this is explicitly NOT for cryptographically secure PRNG purposes, we probably don't really care, but this might be interesting information for other people.

Right now, the str hashing algorithm in CPython is FNV-1; see detailed description in PEP 456.

So then I guess we have to care what Py_uhash_t is, and how big the seed is for the MT variant Python uses on 64 bit machines, and, perhaps most importantly, how much bias FNV-1 introduces.