From bf71871088886eb17ecd5c6ecc4c399dd7ef2f2e Mon Sep 17 00:00:00 2001 From: Firas Ghanmi Date: Thu, 5 Sep 2024 10:16:09 +0200 Subject: [PATCH] cargo build updates Signed-off-by: Firas Ghanmi --- tough/src/sign.rs | 8 +++----- tuftool/src/error.rs | 2 +- tuftool/src/root.rs | 5 +---- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/tough/src/sign.rs b/tough/src/sign.rs index 848fa725d..46acf7152 100644 --- a/tough/src/sign.rs +++ b/tough/src/sign.rs @@ -175,11 +175,9 @@ pub fn decrypt_key( let decrypted_private_key_document = encrypted_private_key_document.decrypt(password.as_bytes())?; let decrypted_key_bytes: Vec = decrypted_private_key_document.as_ref().to_vec(); - let decrypted_key_base64 = STANDARD.encode(&decrypted_key_bytes); - let pem_key = format!( - "-----BEGIN PRIVATE KEY-----\n{}\n-----END PRIVATE KEY-----", - decrypted_key_base64 - ); + let decrypted_key_base64 = STANDARD.encode(decrypted_key_bytes); + let pem_key = + format!("-----BEGIN PRIVATE KEY-----\n{decrypted_key_base64}\n-----END PRIVATE KEY-----"); let pem_key_bytes = pem_key.as_bytes().to_vec(); Ok(pem_key_bytes) } diff --git a/tuftool/src/error.rs b/tuftool/src/error.rs index 11e399f29..663c850cc 100644 --- a/tuftool/src/error.rs +++ b/tuftool/src/error.rs @@ -356,7 +356,7 @@ pub(crate) enum Error { source: tokio::task::JoinError, backtrace: Backtrace, }, - + #[snafu(display("More passwords provided than key sources"))] MorePasswords { backtrace: Backtrace }, diff --git a/tuftool/src/root.rs b/tuftool/src/root.rs index 8e88976d9..615ea9f75 100644 --- a/tuftool/src/root.rs +++ b/tuftool/src/root.rs @@ -178,10 +178,7 @@ impl Command { } => { let mut keys = Vec::new(); let default_password = String::new(); - let passwords = match passwords { - Some(pws) => pws, - None => vec![], - }; + let passwords = passwords.unwrap_or_default(); if passwords.len() > key_sources.len() { error::MorePasswordsSnafu.fail()?; }