Skip to content

rand_core v0.9 support #466

Closed
Closed

Description

@EricZHANG1688

So with v 0.9.0 for rand and rand_core, will get a error like 'error[E0277]: the trait bound ThreadRng: CryptoRngCore is not satisfied".

Activity

  1. c410-f3r commented on Feb 11, 2025

    @c410-f3r

    With the possible addition of rust-lang/rust#130703 it would be nice to avoid hard-coding rand in public interfaces.

    For example, some functions could provide a callback where the user is responsible for providing entropy.

    pub fn encrypt(msg: &[u8], cb: impl FnOnce(&mut [u8])) -> Result<Vec<u8>> {
      ...
    }
    
    let mut rng = thread_rng();
    encrypt(&[1, 2, 3, 4], |slice| {
      rng.fill_bytes(slice);
    })?;
  2. Its-Just-Nans commented on Feb 11, 2025

    @Its-Just-Nans
  3. tarcieri commented on Feb 11, 2025

    @tarcieri
    Member

    @c410-f3r the nice thing about CryptoRng is it provides a type-safe interface for ensuring the supplied RNG is actually safe to use for cryptography. A "just make some bytes" API like that can be easily misused with RNGs which are unsuitable for cryptographic use.

    In the next set of releases of the https://github.com/rustcrypto/traits crates, we're also providing (and pushing people towards) a non-parameterized random generation APIs which avoids compatibility problems between crate versions and explicit RNGs: RustCrypto/traits#1371

  4. changed the title [-]CryptoRngCore was removed from the latest version of rand_core[/-] [+]`rand_core` v0.9 support[/+] on Feb 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions