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 4 times, most recently from e328d0a to 3076429 Compare September 6, 2024 11:58
@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.

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]>
@thillux
Copy link
Author

thillux commented Sep 16, 2024

Do you have update(s) on this?

@thillux
Copy link
Author

thillux commented Sep 24, 2024

One further question: do you plan to secure the UD <-> Remote-IFD pairing mechanism, which is currently susceptible against MitM attacks in future versions? For example, by using DHE/ECHE-PSK and exchanging a longer PSK or certificate in the established connection and limiting the number of failed connection attempts to a small number? The best solution would be to use PACE or another PAKE here, for secure coupling of UD and Remote-IFD based on low-entropy passphrases.

Why aren't QR codes containing a sufficiently long PSK or certificate used here? Because of accesibility issues?

@thillux
Copy link
Author

thillux commented Oct 1, 2024

@misery Do you need additional input/help on this?

@thillux
Copy link
Author

thillux commented Oct 29, 2024

?

@misery
Copy link
Contributor

misery commented Oct 29, 2024

We are waiting for an answer from the BSI.

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.

3 participants