You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use rand_chacha to generate an SSH key but it does not accept it as ssh_key::rand_core::CryptoRngCore even though it implements rand_core::CryptoRng.
To me it seems like these are seen as different traits because of parameter mismatch due to ssh_key having its own rand_core re-export.
Code:
let chacha = ChaCha20Rng::from_os_rng();PrivateKey::random(&mut chacha, ssh_key::Algorithm::Ed25519);
Error:
error[E0277]: the trait bound `ChaCha20Rng: CryptoRngCore` is not satisfied
--> src/main.rs:41:24
|
41 | PrivateKey::random(&mut chacha, ssh_key::Algorithm::Ed25519);
| ------------------ ^^^^^^^^^^^ the trait `ssh_key::rand_core::CryptoRng` is not implemented for `ChaCha20Rng`, which is required by `ChaCha20Rng: CryptoRngCore`
| |
| required by a bound introduced by this call
|
= help: the following other types implement trait `ssh_key::rand_core::CryptoRng`:
&'a mut R
ssh_key::rand_core::block::BlockRng<R>
= note: required for `ChaCha20Rng` to implement `CryptoRngCore`
note: required by a bound in `PrivateKey::random`
--> /home/simao/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ssh-key-0.6.7/src/private.rs:488:34
|
488 | pub fn random(rng: &mut impl CryptoRngCore, algorithm: Algorithm) -> Result<Self> {
| ^^^^^^^^^^^^^ required by this bound in `PrivateKey::random`
The rand_core this is using appears to be rand_core 0.6.4.
Cargo.toml dependencies:
tokio = { version = "1.43.0", features = ["full"] }
clap = { version = "4.5.28", features = ["derive", "unicode"] }
hcloud = "0.21.0"structured-logger = "1.0.3"strum = "0.27"strum_macros = "0.27"log = "0.4.25"thiserror = "2.0.11"anyhow = "1.0.95"ssh-key = { version = "0.6.7", features = ["ed25519"] }
rand_chacha = { version = "0.9.0", features = ["os_rng", "std"] }
Adding rand_core = { version = "0.9.1", features = ["os_rng", "std"] } does not help.
Is there a way to convert between ssh_key::rand_core and rand_core variants?
The text was updated successfully, but these errors were encountered:
tarcieri
changed the title
Can't use CSPRNG from rand_chacha
rand_core v0.9 support
Feb 21, 2025
We are in the process of upgrading all of the crates in the @RustCrypto org to rand_core v0.9. You can track upstream progress here: RustCrypto/traits#1642
Oh that's great, thanks for letting me know. Is this going to be an ongoing issue where upgrades to rand_core could cause these issues? Or is it only when an API change happens?
I'm guessing when rand_core reaches v1 it would only break on v2.
Would you recommend using v0.6.4 in the meantime?
I'm trying to use
rand_chacha
to generate an SSH key but it does not accept it asssh_key::rand_core::CryptoRngCore
even though it implementsrand_core::CryptoRng
.To me it seems like these are seen as different traits because of parameter mismatch due to
ssh_key
having its own rand_core re-export.Code:
Error:
The rand_core this is using appears to be rand_core 0.6.4.
Cargo.toml dependencies:
Adding
rand_core = { version = "0.9.1", features = ["os_rng", "std"] }
does not help.Is there a way to convert between ssh_key::rand_core and rand_core variants?
The text was updated successfully, but these errors were encountered: