dalek-cryptography / x25519-dalek

X25519 elliptic curve Diffie-Hellman key exchange in pure-Rust, using curve25519-dalek.
BSD 3-Clause "New" or "Revised" License
326 stars 132 forks source link

no_std Support #111

Closed pinkforest closed 1 year ago

pinkforest commented 1 year ago

Related

rand_core?/getrandom

It seems getrandom is brought by rand_core which isn't optional - that stops thumb building

    --> /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.8/src/lib.rs:268:9
    |
268 | /         compile_error!("target is not supported, for more information see: \
269 | |                         https://docs.rs/getrandom/#unsupported-targets");

https://github.com/pinkforest/x25519-dalek/actions/runs/4395315721/jobs/7697018808

Maybe we can make the get_random weak and gate via getrandom feature ?

This ofc requires some work around API re: providing randomness

tarcieri commented 1 year ago

This is unrelated to std: it's just a target that getrandom doesn't have support for.

That's why it's a feature and why things that require randomness use the RngCore trait: so the feature can be disabled.

The solution is to not enable the feature on these platforms. They need to provide their own RNG which impls CryptoRng + RngCore.

pinkforest commented 1 year ago

Yeah I mean it's part of no_std support as --no-default-features was the one that failed and that came up

EDIT: I worded my original issue wrong oops - I've re-worded so we need to make getrandom in rand_core optional

tarcieri commented 1 year ago

Aah, yeah this is the problem:

rand_core = { version = "0.6", default-features = false, features = ["getrandom"] }

Instead there should be a getrandom feature which activates rand_core/getrandom

tarcieri commented 1 year ago

Looks like features = ["getrandom"] was added in #95, although I'm not sure why as that PR does not reference OsRng, which is the main API provided by enabling getrandom

pinkforest commented 1 year ago

Yeah - I'll send a PR to fix it - getrandom is needed for the doctests only

pinkforest commented 1 year ago

PR's up: