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

Implement rand traits for Rng #942

Closed
Natureshadow opened this issue Nov 14, 2023 · 4 comments
Closed

Implement rand traits for Rng #942

Natureshadow opened this issue Nov 14, 2023 · 4 comments

Comments

@Natureshadow
Copy link

In order to use the hardware RNG with external code that accepts implementations of RngCore and CryptoRng, these traits should be implemented for the Rng struct.

@Natureshadow
Copy link
Author

Looking at Espressif's documentation about the ESP32 RNG, I learnt that the system has one random number generator, that produces randomness of different quality depending on conditions:

  • real random data when any of WiFi, Bluetooth or the special bootloader entropy source is enabled
  • pseudo random data if not

Hence, the CryptoRng trait must only be usable if one of the above conditions is true. I wonder what would be the best way to do this?

  • let the CryptoRng impl check the conditions, and return an Err if hardware-backed randomness cannot be guaranteed
  • let the CryptoRng simply turn on the bootloader entropy source

@bjoernQ
Copy link
Contributor

bjoernQ commented Nov 16, 2023

I guess the first option is better since the behavior for the second option might be somewhat surprising. (We could have it in the docs but often people only look into the docs if something isn't working as expected)

@jessebraham
Copy link
Member

We have implemented the necessary trait(s) in #1122, however (as is already documented) we have not met the necessary preconditions to produce true random numbers. Should we consider this issue closed regardless, or should we keep it open until this changes? I think it's fine to close, but just want to double-check with others.

CC @bjoernQ @MabezDev

@Natureshadow
Copy link
Author

Natureshadow commented Jan 29, 2024 via email

@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

3 participants