From f5f140d1725d535c6be42f1a0889b36af6f34648 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 20 Aug 2021 16:22:22 +0100 Subject: [PATCH] Fix various clippy lints --- src/format.rs | 2 +- src/p256.rs | 2 +- src/plugin.rs | 12 ++++++------ src/util.rs | 2 +- src/yubikey.rs | 5 ++--- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/format.rs b/src/format.rs index 491f81d..bf2b124 100644 --- a/src/format.rs +++ b/src/format.rs @@ -106,7 +106,7 @@ impl RecipientLine { let epk = esk.public_key(); let epk_bytes = EphemeralKeyBytes::from_public_key(&epk); - let shared_secret = esk.diffie_hellman(&pk.public_key()); + let shared_secret = esk.diffie_hellman(pk.public_key()); let mut salt = vec![]; salt.extend_from_slice(epk_bytes.as_bytes()); diff --git a/src/p256.rs b/src/p256.rs index d905cdd..c9bd31b 100644 --- a/src/p256.rs +++ b/src/p256.rs @@ -48,7 +48,7 @@ impl Recipient { /// This accepts both compressed (as used by the plugin) and uncompressed (as used in /// the YubiKey certificate) encodings. pub(crate) fn from_encoded(encoded: &p256::EncodedPoint) -> Option { - p256::PublicKey::from_encoded_point(&encoded).map(Recipient) + p256::PublicKey::from_encoded_point(encoded).map(Recipient) } /// Returns the compressed SEC-1 encoding of this recipient. diff --git a/src/plugin.rs b/src/plugin.rs index 9a917b9..6c18f23 100644 --- a/src/plugin.rs +++ b/src/plugin.rs @@ -23,7 +23,7 @@ impl RecipientPluginV1 for RecipientPlugin { bytes: &[u8], ) -> Result<(), recipient::Error> { if let Some(pk) = if plugin_name == PLUGIN_NAME { - Recipient::from_bytes(&bytes) + Recipient::from_bytes(bytes) } else { None } { @@ -44,7 +44,7 @@ impl RecipientPluginV1 for RecipientPlugin { bytes: &[u8], ) -> Result<(), recipient::Error> { if let Some(stub) = if plugin_name == PLUGIN_NAME { - yubikey::Stub::from_bytes(&bytes, index) + yubikey::Stub::from_bytes(bytes, index) } else { None } { @@ -88,7 +88,7 @@ impl RecipientPluginV1 for RecipientPlugin { self.recipients .iter() .chain(yk_recipients.iter()) - .map(|pk| format::RecipientLine::wrap_file_key(&file_key, &pk).into()) + .map(|pk| format::RecipientLine::wrap_file_key(&file_key, pk).into()) .collect() }) .collect()) @@ -111,7 +111,7 @@ impl IdentityPluginV1 for IdentityPlugin { bytes: &[u8], ) -> Result<(), identity::Error> { if let Some(stub) = if plugin_name == PLUGIN_NAME { - yubikey::Stub::from_bytes(&bytes, index) + yubikey::Stub::from_bytes(bytes, index) } else { None } { @@ -145,7 +145,7 @@ impl IdentityPluginV1 for IdentityPlugin { for (file, stanzas) in files.iter().enumerate() { for (stanza_index, stanza) in stanzas.iter().enumerate() { match ( - format::RecipientLine::from_stanza(&stanza).map(|res| { + format::RecipientLine::from_stanza(stanza).map(|res| { res.map_err(|_| identity::Error::Stanza { file_index: file, stanza_index, @@ -225,7 +225,7 @@ impl IdentityPluginV1 for IdentityPlugin { } for (stanza_index, line) in stanzas.iter().enumerate() { - match conn.unwrap_file_key(&line) { + match conn.unwrap_file_key(line) { Ok(file_key) => { // We've managed to decrypt this file! file_keys.entry(file_index).or_insert(Ok(file_key)); diff --git a/src/util.rs b/src/util.rs index bbf90e7..b8fb968 100644 --- a/src/util.rs +++ b/src/util.rs @@ -138,7 +138,7 @@ impl Metadata { extract_name(cert, all) .map(|(name, ours)| { if ours { - let (pin_policy, touch_policy) = policies(&cert); + let (pin_policy, touch_policy) = policies(cert); (name, pin_policy, touch_policy) } else { // We can extract the PIN and touch policies via an attestation. This diff --git a/src/yubikey.rs b/src/yubikey.rs index 5b5ab36..10e47ca 100644 --- a/src/yubikey.rs +++ b/src/yubikey.rs @@ -358,9 +358,8 @@ impl Connection { None => { return Ok(Err(identity::Error::Identity { index: self.identity_index, - message: format!( - "Certificate for YubiKey identity contains an invalid PIN policy" - ), + message: "Certificate for YubiKey identity contains an invalid PIN policy" + .to_string(), })) } }