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

Randomizer: always use CSPRNG from OpenSSL #54

Open
wants to merge 1 commit into
base: community
Choose a base branch
from

Conversation

thillux
Copy link

@thillux thillux commented Sep 5, 2024

The Randomizer class provided an insecure mersenne twister PRNG as a convenience method to draw things like PINs and serial numbers from it.

I changed this to always use a secure OpenSSL-based CSPRNG.

Furthermore, the OpenSSL PRNG was insecurely seeded from the mersenne twister RNG. Fix this, by combining several input sources via a cryptographic hash function and seed OpenSSL from it.

Please note, that OpenSSL in typical configurations is automatically seeded and the seeding strategy here probably did no harm by accident in the past.

@CLAassistant
Copy link

CLAassistant commented Sep 5, 2024

CLA assistant check
All committers have signed the CLA.

@thillux
Copy link
Author

thillux commented Sep 5, 2024

I was too stupid to get make format running. Please format on your own discretion.

@thillux thillux force-pushed the csprng-fixes branch 3 times, most recently from 79f892c to e328d0a Compare September 6, 2024 11:50
The Randomizer class provided an insecure mersenne twister PRNG
as a convenience method to draw things like PINs and serial numbers
from it.

I changed this to always use a secure OpenSSL-based CSPRNG.

Furthermore, the OpenSSL PRNG was insecurely seeded from the mersenne
twister RNG. Fix this, by combining several input sources via a
cryptographic hash function and seed OpenSSL from it.
The code now tries to read 256 Bit from different sources and combines
them, with SHA-512. When OpenSSL aims for 256 Bit security strength,
seed it with at least 1.5x this security strength.

Please note, that OpenSSL in typical configurations is automatically
seeded and the seeding strategy here probably did no harm by accident in the
past.

Signed-off-by: Markus Theil <[email protected]>
@misery
Copy link
Contributor

misery commented Sep 6, 2024

Thanks for your pull request. We will look into this soon and cooperate with the BSI.

The OpenSSL randomizer is always seeded by OpenSSL itself. RAND_seed won't "reset" the entropy. It will add more entropy like RAND_add.

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