Open
Description
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?
Metadata
Assignees
Labels
No labels
Activity