fix Pk size check (#361)

* more descriptive error

* fix key size check
This commit is contained in:
Paolo Asperti 2024-01-31 04:21:00 +01:00 committed by GitHub
parent 778c89efb1
commit 94ae51458c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -120,6 +120,9 @@ pub fn gen_sk(wait: u64) -> (String, Option<sign::SecretKey>) {
let pk = base64::encode(&tmp[sign::SECRETKEYBYTES / 2..]); let pk = base64::encode(&tmp[sign::SECRETKEYBYTES / 2..]);
log::info!("Private key comes from {}", sk_file); log::info!("Private key comes from {}", sk_file);
return (pk, Some(sign::SecretKey(tmp))); 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 { } else {

View File

@ -1174,9 +1174,6 @@ impl RendezvousServer {
let mut tmp = [0u8; sign::SECRETKEYBYTES]; let mut tmp = [0u8; sign::SECRETKEYBYTES];
tmp[..].copy_from_slice(&sk); tmp[..].copy_from_slice(&sk);
out_sk = Some(sign::SecretKey(tmp)); out_sk = Some(sign::SecretKey(tmp));
} else {
log::error!("Malformed private key");
std::process::exit(1);
} }
} }