From 94ae51458c310aca43e79325e324a3b98a02ab26 Mon Sep 17 00:00:00 2001 From: Paolo Asperti Date: Wed, 31 Jan 2024 04:21:00 +0100 Subject: fix Pk size check (#361) * more descriptive error * fix key size check --- src/common.rs | 3 +++ src/rendezvous_server.rs | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/common.rs b/src/common.rs index 977f8ed..c2c63ba 100644 --- a/src/common.rs +++ b/src/common.rs @@ -120,6 +120,9 @@ pub fn gen_sk(wait: u64) -> (String, Option) { let pk = base64::encode(&tmp[sign::SECRETKEYBYTES / 2..]); log::info!("Private key comes from {}", sk_file); return (pk, Some(sign::SecretKey(tmp))); + } else { + log::error!("Malformed private key. You probably have a trailing newline in the secret key file."); + std::process::exit(1); } } } else { diff --git a/src/rendezvous_server.rs b/src/rendezvous_server.rs index ede0ede..0c0d107 100644 --- a/src/rendezvous_server.rs +++ b/src/rendezvous_server.rs @@ -1174,9 +1174,6 @@ impl RendezvousServer { let mut tmp = [0u8; sign::SECRETKEYBYTES]; tmp[..].copy_from_slice(&sk); out_sk = Some(sign::SecretKey(tmp)); - } else { - log::error!("Malformed private key"); - std::process::exit(1); } } -- cgit v1.2.3