-
Notifications
You must be signed in to change notification settings - Fork 121
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 getentropy for OpenBSD, FreeBSD, and MacOS #2099
base: randomness_generation
Are you sure you want to change the base?
Use getentropy for OpenBSD, FreeBSD, and MacOS #2099
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## randomness_generation #2099 +/- ##
=======================================================
Coverage 78.73% 78.74%
=======================================================
Files 608 608
Lines 102800 102582 -218
Branches 14585 14552 -33
=======================================================
- Hits 80944 80780 -164
+ Misses 21144 21101 -43
+ Partials 712 701 -11 ☔ View full report in Codecov by Sentry. |
f6de544
to
d6b5249
Compare
#endif | ||
|
||
#if defined(USE_NR_getrandom) || defined(FREEBSD_GETRANDOM) | ||
#if defined(USE_NR_getrandom) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: This #endif
below this (line 380) is not needed. It's immediately followed by another #if defined (USE_NR_getrandom)
(line 382).
|
||
#if defined(FREEBSD_GETRANDOM) | ||
*urandom_fd_bss_get() = kHaveGetrandom; | ||
#if defined(OPENSSL_IOS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NP: The ubiquitous use of #if defined(XXX)
throughout this file makes it a nightmare to parse/read (especially with an IDE like CLion that like to collapse all code that doesn't apply to the current build configuration). The platforms with the USE_NR_getrandom
seem to be needing/wanting a refactor into their own separate implementation. (?)
Any plan to improve the readability of the logic?
Description of changes:
Use
getentropy
for some operating systems. Namely, Apple MacOS, OpenBSD, and FreeBSD.getentropy
is closer to the noise sources.See also q/3t08AyoE0m4q.
Testing:
Even though we didn't use
getentropy
prior to this PR, we had a unit test. Just re-use that.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license and the ISC license.