-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Use arc4random_buf() as the best practice method for obtaining randomness on OpenBSD (examples) #1215
base: master
Are you sure you want to change the base?
Conversation
…ness on OpenBSD modified: examples/random.h
Hm, I don't think "regular code" means "user code". This is a syscall after all, if it is not supposed to be called by user code who else should call it?
Together with the above quote, I read this as "Use |
Hey Tim, thank you for the links and the quick response. OpenBSD actually has two functions named The linked discussion mentions that OpenSSL uses |
Sigh ok, all of this is a huge mess.
Oh, you're right. The kernel one is here: Internally, it performs the same ChaCha "stirring" as the libc one. So IIUC the entire stack is as follows. There's
I think this confirms my theory that randomness output by By the way: The way they get rid of error statues is as follows: If libc's call to Another interesting question one can ask: What does Bitcoin Core do? They have changed to Okay, what does all of this mean for us?
But currently all methods in I think a better approach would be to sync our code with Bitcoin Core. There could be a library/header file which is used by both, and then we don't need to maintain two versions of this mess. (Of course, requirements are bit different, e.g., getting randomness vs seeding RNGs vs just getting randomness, but in the end, none of this really matters.) |
The method above is suggested instead of the current
getentropy()
, which is not intended to be used by user code.See OpenBSD's man page: