Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include CPRNGs #24

Closed
tiran opened this issue Aug 8, 2013 · 1 comment
Closed

Include CPRNGs #24

tiran opened this issue Aug 8, 2013 · 1 comment

Comments

@tiran
Copy link
Contributor

tiran commented Aug 8, 2013

Every decent cryptographic library needs proper crypto pseudo random number generators.

Most (all?) Unix-like operation systems have /dev/random and /dev/urandom. /dev/urandom is non-blocking and sufficient for most crypto stuff except for long-living keys (e.g. ssh, TLS and PGP private keys). The API needs some flags to classify entropy of a CPRNG and its blocking state.

OpenSSL has RAND_pseudo_bytes() and RAND_bytes() as documented at http://www.openssl.org/docs/crypto/RAND_bytes.html . We should also consider http://www.openssl.org/docs/crypto/RAND_add.html and EGD, too.

OpenSSL's RAND generator has a twist: it must be reset on fork(). Otherwise parent and child generate the same random values. Postgres suffered from the issue and now calls RAND_cleanup() on fork(). It's an unsolved issue in Python, too. See http://bugs.python.org/issue16500 for my proposal of an atfork module.

@alex
Copy link
Member

alex commented Feb 6, 2014

We now replace OpenSSL's CSPRNG with /dev/urandom. I'm going to send a PR which reccomends users always generate random numbers with os.urandom(), then I think we're done.

@alex alex closed this as completed Feb 6, 2014
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants