From e4af85726ff112e0eb25c10d25c23fb9c57c8157 Mon Sep 17 00:00:00 2001 From: Adrian Heine Date: Sun, 26 Dec 2021 01:45:16 +0100 Subject: [PATCH] Check TLS Key bits --- src/symbols/tls/key.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/symbols/tls/key.rs b/src/symbols/tls/key.rs index 720d7ab..be2ea9f 100644 --- a/src/symbols/tls/key.rs +++ b/src/symbols/tls/key.rs @@ -8,7 +8,7 @@ use std::path::Path; pub struct Key { file_path: P, command_runner: C, - bytes: u32, + bits: u32, } impl Key { @@ -16,7 +16,7 @@ impl Key { Self { file_path, command_runner, - bytes: 4096, + bits: 4096, } } } @@ -42,8 +42,10 @@ impl> Symbol for Key { ], ) .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> { @@ -55,7 +57,7 @@ impl> Symbol for Key { "genrsa", "-out", self.file_path.as_ref(), - self.bytes.to_string(), + self.bits.to_string(), ], ) .await