Fix various clippy lints

This commit is contained in:
Jack Grigg
2021-08-20 16:22:22 +01:00
parent 2c90195f99
commit f5f140d172
5 changed files with 11 additions and 12 deletions
+1 -1
View File
@@ -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());
+1 -1
View File
@@ -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<Self> {
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.
+6 -6
View File
@@ -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));
+1 -1
View File
@@ -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
+2 -3
View File
@@ -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(),
}))
}
}