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

Update rand and rand_core #794

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft

Update rand and rand_core #794

wants to merge 7 commits into from

Conversation

wysiwys
Copy link
Contributor

@wysiwys wysiwys commented Feb 6, 2025

This pull request updates the dependencies rand from 0.8 -> 0.9 and rand_core from 0.6 -> 0.9. It is based on dependabot's PRs (see #787 and #786).

  • Use new trait TryRngCore where necessary
  • Use OsRng::try_fill_bytes() instead of OsRng::fill_bytes(), which was removed. Also, to handle the case where try_fill_bytes() returns an error, add an Error::InsufficientOSRandomness variant

@wysiwys wysiwys self-assigned this Feb 6, 2025
@wysiwys wysiwys requested a review from a team as a code owner February 6, 2025 10:22
@wysiwys wysiwys marked this pull request as draft February 6, 2025 10:26
@jschneider-bensch
Copy link
Collaborator

jschneider-bensch commented Feb 10, 2025

It looks like many of the examples and tests expect OsRng to implement RngCore instead of TryRngCore. I think in many we can just .unwrap() on try_fill_bytes().
In some, we run into the issue that OsRng no longer implements CryptoRng, but TryCryptoRng. E.g. the top level ECDH API requires CryptoRng for key generation, but internally key generation already uses try_fill_bytes, so I think TryCryptoRng would be sufficient (at least in this case that I checked). But maybe that can be a separate PR, since it changes the public API. We can use unwrap_err in these cases for now to get a CryptoRng from a TryCryptoRng.

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.

2 participants