dalek-cryptography / x25519-dalek

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

Broken with rand_core 0.6.1 #65

Closed Andrew-Shay closed 2 years ago

Andrew-Shay commented 3 years ago

It seems rand_core 0.6.1 breaks this lib

Here is my usage and then the error I get

use rand_core::OsRng;
let local_diffie_secret = EphemeralSecret::new(OsRng);
error[E0277]: the trait bound `OsRng: rand_core::RngCore` is not satisfied
   --> src\main.rs:406:49
    |
406 |     let local_diffie_secret = EphemeralSecret::new(OsRng);
    |                                                    ^^^^^ the trait `rand_core::RngCore` is not implemented for `OsRng`
    |
   ::: C:\Users\laptopuser\.cargo\registry\src\github.com-1ecc6299db9ec823\x25519-dalek-1.1.0\src\x25519.rs:76:19
    |
76  |     pub fn new<T: RngCore + CryptoRng>(mut csprng: T) -> Self {
    |                   ------- required by this bound in `EphemeralSecret::new`

error[E0277]: the trait bound `OsRng: rand_core::CryptoRng` is not satisfied
   --> src\main.rs:406:49
    |
406 |     let local_diffie_secret = EphemeralSecret::new(OsRng);
    |                                                    ^^^^^ the trait `rand_core::CryptoRng` is not implemented for `OsRng`
Windows 10 20H2 19042.746

rustup 1.23.1 (3df2264a9 2020-11-30)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.49.0 (e1884a8e3 2020-12-29)`

[dependencies.x25519-dalek]
version = "1.1.0"

[dependencies]
rand = "0.8.3"
rand_core = "0.6.1"
------# Full dependencies
[dependencies]
sciter-rs = "0.5.53"
libc = "0.2"
lazy_static = "1.4"

serde = { version = "1.0.117", features = ["derive", "rc"] }
serde_json = "1.0.59"
rand = "0.8.3"
rand_core = "0.6.1"
aes-gcm = { version = "0.8.0", features = ["heapless"]}
ring = "0.16.5"
base64 = "0.13.0"

[dependencies.x25519-dalek]
version = "1.1.0"
isislovecruft commented 3 years ago

Hi! Thanks for alerting us to this. We're not supporting rand 0.6 yet, but we plan to in an upcoming 2.x-alpha release. (cf. PR #64)