3 ms·
We moved to: time(NULL) * getpid() * clock() Thanks!
by justintocci 11y ago
We moved to:
time(NULL) * getpid() * clock()
Thanks!
- joelthelion 11y agoThat's still not a good idea. Use your OS' random source.
- justintocci 11y agoWe wanted to avoid anything controversial. Do we need to make this configurable to make everyone happy? https://www.schneier.com/blog/archives/2013/10/insecurities_in.html https://www.schneier.com/blog/archives/2013/10/insecurities_...
- MrRadar 11y agoEven if it isn't perfect /dev/random is a hell of a lot more random than just taking the current time stamp and PID. Edit: For reference, this is exactly how the Netscape's original SSL implementation was broken: https://web.archive.org/web/20141214141822/http://www.cs.berkeley.edu/~daw/papers/ddj-netscape.html https://web.archive.org/web/20141214141822/http://www.cs.ber...
- justintocci 11y agoUnderstood. Working on it now.
- justintocci 11y agoFixed!
- Canada 11y agoStill weak. Read the seed value from /dev/urandom or get it from CryptGenRandom if you're on Windows. I think it's also best to use #ifdef to prevent those hardcoded debugging keys from being included in production builds. That is, if you still need to keep them at all. edit: joelthelion: You are mistaken. It's not the 1990s anymore. Use the non-blocking /dev/urandom, not /dev/random. (I can't seem to reply directly to you)
- joelthelion 11y ago/dev/random, not /dev/urandom, if I'm not mistaken.
- MrRadar 11y agoThat's somewhat debatable: http://www.2uo.de/myths-about-urandom/ http://www.2uo.de/myths-about-urandom/ But really either will be way better than anything you could homebrew.
- DanBC 11y ago(EDIT: I reread this and it sounds like I'm ranting at you. Sorry, I'm not, even though it does read like that.) This is why cryptography is doomed to fail. This /dev/random vs /dev/urandom (blocking vs non-blocking and whether it matters) is discussed frequently on HN, usually with very long threads, and yet it still comes up. If I want to remember whether there's an apostrophe in possessive its there's a cartoon to tell me. We need a good, accurate, fact-checked cartoon for urandom vs random. (It's one of the things I'd do if I had FU money.)
- sgk284 11y agoThat is truly a horrible seed. Use /dev/random
- justintocci 11y agoI just made it so that it uses the first 4 bytes it gets from /dev/random, if it can't open /dev/random, it falls back to what we had before. --nunzio
- alcari 11y agoDon't fall back. If you don't have a reasonable enough environment to get a PRNG, you should halt and complain very loudly. As for actually generating random numbers, here's a good explanation from 'tptacek: http://sockpuppet.org/blog/2014/02/25/safely-generate-random-numbers/ http://sockpuppet.org/blog/2014/02/25/safely-generate-random...
- deleted 11y ago[deleted]
- justintocci 11y agoI have finished the error message and pushed to Github. Thank you for your input. I will look at the link you have referenced soon. --nunzio
- pmontra 11y agoUse /dev/urandom instead of /dev/random See http://www.2uo.de/myths-about-urandom/ http://www.2uo.de/myths-about-urandom/ for the reasons