Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> If you're not using it for cryptographic purposes, then I don't see why it matters. :)

There was a program I was using that used libtommath, and used that library's mp_rand function. libtommath's mp_rand does various trickery but essentially adds two results of rand() together[0].

If you call rand() multiple times on OpenBSD you will get a sequence that alternates between odd and even, which is completely standards compliant. Because of this the result of adding two rand() results together will always be odd (odd + even = odd).

The program didn't need cryptographic levels of randomness, but only returning odd numbers turned out to be a bit of a problem.

[0] https://github.com/libtom/libtommath/blob/develop/bn_mp_rand...



That's really fascinating! :D




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: