-
Notifications
You must be signed in to change notification settings - Fork 711
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
Improve random number generation on Mac OS X and iOS #149
Comments
http://stackoverflow.com/questions/21734909/is-os-xs-secrandomcopybytes-fork-safe http://opensource.apple.com/source/Security/Security-55179.11/sec/Security/SecFramework.c So, basically, it's just reading from /dev/random like we already do on Mac OS X. So, really nothing useful there. But, on iOS it seems to be required to use the provided API since (direct) access to /dev/random is blocked by the sandbox. |
I thought about this some more, and I think it would be good to do this on both Mac OS X and iOS. The main advantage for doing it on Mac OS X is that it would share the same file handle with the toolkit-provided function and hopefully then have less overhead in cases where Rust and non-Rust code are mixed, e.g. when a Rust lib is being included in an ObjC or C project. |
BTW, this can be implemented very easily by extending the definition of sysrand in ring/src/rand.rs. Can be done with 100% Rust code, I think. |
A pull request was opened for this: #398. |
Avoid using
dev/urandom
on Mac OS X and instead do whatever is most like using thegetrandom
syscall on Linux (See #148).References:
Note, in particular, that
SecRandomCopyBytes
was added in OS X 10.7 (Lion). According to this Rust issue, 10.7 is the lowest version supported by Rust anyway, although we should verify that hasn't changed since then.The text was updated successfully, but these errors were encountered: