Skip to content

rand_core::RngCore & CryptoRng support for CryptoProvider #1853

Closed as not planned
@pinkforest

Description

@pinkforest

Checklist

  • I've searched the issue tracker for similar requests

Is your feature request related to a problem? Please describe.
Low level cryptography primitives, e.g. x25519-dalek::EphemeralSecret constructors expect to be provided a CryptoRng impl

This was made so no_std environments can provide their own chosen randomness, e.g. wasm32-unknown-unknown with a runtime that has a virtual machine that provides source of secure randomness that can be presented via CryptoRng trait.

Lower level crypto primitives have started pulling the rand_core trait so different random implementations don't need to be supported at lower level primitive.

Meanwhile SecureRandom is neither accessible within the interface to lower level primitives within CryptoProvider:

but this is not included in the interface with rustls: it is assumed that the cryptography library provides for this itself.

Lower level primitives don't generally offer a lot of choice when it comes to source of randomness leading to limited platform support where the primitive can be used unless it is provided the appropriate source of randomness.

Describe the solution you'd like
Ideally it would be great of rustls relays rand_core::CryptoRng that implements several methods over tls::SecureRandom for crypto primitive use that can be used to pass the primitives within ecosystem which expects this trait implementation.

Describe alternatives you've considered
I thought about using slow getrandom = ["custom"] - primitives I'm dealing with use rand_core::OsRng when constructor is called with rand_core/getrandom feature
Also thought about storing a state within the wrapper provider struct but then it leads to complications of navigating Arc<Mutex<>> landscape (which typically also requires std) which should be left to runtimes which may not implement threading etc. permutations involved.

Additional context

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