|
|
@ -8,7 +8,7 @@ use std::path::Path; |
|
|
|
pub struct Key<C, P> {
|
|
|
|
file_path: P,
|
|
|
|
command_runner: C,
|
|
|
|
bytes: u32,
|
|
|
|
bits: u32,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<C, P> Key<C, P> {
|
|
|
@ -16,7 +16,7 @@ impl<C, P> Key<C, P> { |
|
|
|
Self {
|
|
|
|
file_path,
|
|
|
|
command_runner,
|
|
|
|
bytes: 4096,
|
|
|
|
bits: 4096,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -42,8 +42,10 @@ impl<C: CommandRunner, P: AsRef<Path>> Symbol for Key<C, P> { |
|
|
|
],
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
// FIXME check bytes
|
|
|
|
Ok(stdout.ends_with(b"RSA key ok\n"))
|
|
|
|
Ok(
|
|
|
|
stdout.ends_with(b"RSA key ok\n")
|
|
|
|
&& stdout.starts_with(format!("RSA Private-Key: ({} bit, 2 primes)\n", self.bits).as_ref()),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn execute(&self) -> Result<(), Box<dyn Error>> {
|
|
|
@ -55,7 +57,7 @@ impl<C: CommandRunner, P: AsRef<Path>> Symbol for Key<C, P> { |
|
|
|
"genrsa",
|
|
|
|
"-out",
|
|
|
|
self.file_path.as_ref(),
|
|
|
|
self.bytes.to_string(),
|
|
|
|
self.bits.to_string(),
|
|
|
|
],
|
|
|
|
)
|
|
|
|
.await
|
|
|
|