-
Notifications
You must be signed in to change notification settings - Fork 120
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
Entropy pool implementation #1090
Conversation
aefd0e1
to
6e59032
Compare
// entropy_pool_ensure_can_satisfy returns 1 if the entropy pool |entropy_pool| | ||
// contains enough entropy to satisfy a get request of size |get_size|. | ||
// Returns 0 otherwise. | ||
static int entropy_pool_ensure_can_satisfy(struct entropy_pool *entropy_pool, |
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.
Should this abort if entropy_pool == NULL
?. I know you gate some of the functions already, but not all of them.
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.
I changed it to only validate the pointer in "exported" functions, not the static ones.
Also changed such that the entropy pool doesn't abort. Callers can do that if they wish. But not at this layer.
return 1; | ||
} | ||
|
||
static void entropy_pool_cannot_satisfy_request(void) { |
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: to me entropy_pool_cannot_satisfy_request seems like it was getting ready to abort, it's not clear what it does.
static void entropy_pool_cannot_satisfy_request(void) { | |
static void request_external_entropy(void) { |
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.
if not entropy_pool_ensure_can_satisfy()
then entropy_pool_cannot_satisfy_request()
seems like the logically named next action.
Just tried to separate logic. Maybe it was too "smart". Just inlined the code instead.
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.
approved accidentally, taking it back for a moment :)
Given #1112, this implementation is no longer needed. Closing. |
Issues:
CryptoAlg-1952
Description of changes:
Implements the backend for passive entropy. The integration as the actual entropy backend for
RAND_bytes
(for fips build), will occur in the next PR.The entropy pool has one main action:
RAND_entropy_pool_get
. This function can be used to fetch entropy from the pool. If the pool is depleted, the "depleted workflow" is activated, that workflow requests a need for more entropy outside the module. New entropy is loaded into the module throughRAND_load_entropy
(the entropy sourcing part is not implemented yet).Call-outs:
As noted in the source code:
I could soft-lock the pool during the depleted workflow. This shouldn't really be necessary since the every operation is serialised in the thread.
Testing:
Added a bunch of tests. Can add more if needed.
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.