drbg_get_entropy: force a reseed before calling ssleay_rand_bytes() [first attempt]#7247
Closed
mspncp wants to merge 2 commits intoopenssl:OpenSSL_1_0_2-stablefrom
Closed
drbg_get_entropy: force a reseed before calling ssleay_rand_bytes() [first attempt]#7247mspncp wants to merge 2 commits intoopenssl:OpenSSL_1_0_2-stablefrom
mspncp wants to merge 2 commits intoopenssl:OpenSSL_1_0_2-stablefrom
Conversation
paulidale
approved these changes
Sep 17, 2018
Contributor
Author
|
Thanks Pauli. I'll wait for Kurts opinion nevertheless before merging. |
Fixes openssl#7240 In FIPS mode, the default FIPS DRBG uses the drbg_get_entropy() callback to reseed itself, which is provided by the wrapping libcrypto library. This callback in turn uses ssleay_rand_bytes() to generate random bytes. Now ssleay_rand_bytes() calls RAND_poll() once on first call to seed itself, but RAND_poll() is never called again (unless the application calls RAND_poll() explicitely). This implies that whenever the DRBG reseeds itself (which happens every 2^14 generate requests) this happens without obtaining fresh random data from the operating system's entropy sources. This patch forces a reseed from system entropy sources on every call to drbg_get_entropy(). In contrary to the automatic reseeding of the DRBG in master, this reseeding does not break applications running in a chroot() environment (see c7504ae), because the SSLEAY PRNG does not maintain an error state. (It does not even check the return value of RAND_poll() on its instantiation.) In the worst case, if no random device is available for reseeding, no fresh entropy will be added to the SSLEAY PRNG but it will happily continue to generate random bytes as 'entropy' input for the DRBG's reseeding, which is just as good (or bad) as before this patch.
237a376 to
86e2ab4
Compare
Contributor
Author
|
Just added |
Contributor
Author
|
@paulidale in view of #7240 (comment) I decided to remove the note about the locking from the comment. Please reconfirm. |
paulidale
approved these changes
Sep 18, 2018
Contributor
Author
|
@kroeckx are you interested in reviewing this pr? |
kaduk
approved these changes
Sep 18, 2018
Contributor
kaduk
left a comment
There was a problem hiding this comment.
Kind of an awkward workaround, but I don't think we have scope to do broader changes on this branch.
Member
|
I didn't have time to look at this yet, just merge it.
|
2 tasks
Contributor
Author
Contributor
Author
|
Closing this pull request in favour of #7259. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7240
In FIPS mode, the default FIPS DRBG uses the drbg_get_entropy()
callback to reseed itself, which is provided by the wrapping
libcrypto library. This callback in turn uses ssleay_rand_bytes()
to generate random bytes.
Now ssleay_rand_bytes() calls RAND_poll() once on first call to
seed itself, but RAND_poll() is never called again (unless the
application calls RAND_poll() explicitely). This implies that
whenever the DRBG reseeds itself (which happens every 2^14
generate requests) this happens without obtaining fresh random
data from the operating system's entropy sources.
This patch forces a reseed from system entropy sources on every
call to drbg_get_entropy(). In contrary to the automatic reseeding
of the DRBG in master, this reseeding does not break applications
running in a chroot() environment (see c7504ae), because the
SSLEAY PRNG does not maintain an error state. (It does not even
check the return value of RAND_poll() on its instantiation.)
In the worst case, if no random device is available for reseeding,
no fresh entropy will be added to the SSLEAY PRNG but it will happily
continue to generate random bytes as 'entropy' input for the DRBG's
reseeding, which is just as good (or bad) as before this patch.
Checklist