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

Use getentropy for OpenBSD, FreeBSD, and MacOS #2099

Open
wants to merge 3 commits into
base: randomness_generation
Choose a base branch
from

Conversation

torben-hansen
Copy link
Contributor

@torben-hansen torben-hansen commented Jan 7, 2025

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.

@codecov-commenter
Copy link

codecov-commenter commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.74%. Comparing base (19e9b93) to head (d6b5249).

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.
📢 Have feedback on the report? Share it here.

crypto/fipsmodule/rand/urandom.c Outdated Show resolved Hide resolved
crypto/fipsmodule/rand/urandom.c Outdated Show resolved Hide resolved
include/openssl/target.h Outdated Show resolved Hide resolved
@torben-hansen torben-hansen changed the title Try getentropy in CI Use getentropy for OpenBSD, FreeBSD, and MacOS Jan 28, 2025
@torben-hansen torben-hansen marked this pull request as ready for review January 28, 2025 14:48
@torben-hansen torben-hansen requested a review from a team as a code owner January 28, 2025 14:48
#endif

#if defined(USE_NR_getrandom) || defined(FREEBSD_GETRANDOM)
#if defined(USE_NR_getrandom)
Copy link
Contributor

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)
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants