From 049055e3ff5ffe86700b668e924fbff96e82be94 Mon Sep 17 00:00:00 2001 From: Nora Widdecke Date: Mon, 22 Nov 2021 12:58:47 +0100 Subject: Remove unnecessary borrows. - Fixed with the help of clippy::needless_borrow. --- openpgp/benches/decrypt_message.rs | 8 ++++---- openpgp/benches/decrypt_verify_message.rs | 4 ++-- openpgp/benches/encrypt_message.rs | 4 ++-- openpgp/benches/encrypt_sign_message.rs | 2 +- openpgp/benches/sign_message.rs | 2 +- openpgp/benches/verify_message.rs | 4 ++-- openpgp/examples/statistics.rs | 10 +++++----- openpgp/src/armor.rs | 4 ++-- openpgp/src/cert.rs | 20 ++++++++++---------- openpgp/src/cert/amalgamation.rs | 8 ++++---- openpgp/src/crypto/backend/nettle/ecdh.rs | 6 +++--- openpgp/src/crypto/ecdh.rs | 2 +- openpgp/src/crypto/mem.rs | 4 ++-- openpgp/src/crypto/s2k.rs | 2 +- openpgp/src/crypto/symmetric.rs | 8 ++++---- openpgp/src/packet/container.rs | 2 +- openpgp/src/packet/mod.rs | 2 +- openpgp/src/packet/signature.rs | 2 +- openpgp/src/packet/skesk.rs | 10 +++++----- openpgp/src/packet/unknown.rs | 2 +- openpgp/src/packet_pile.rs | 2 +- openpgp/src/parse.rs | 14 +++++++------- openpgp/src/parse/hashed_reader.rs | 4 ++-- openpgp/src/parse/stream.rs | 2 +- openpgp/src/serialize.rs | 16 ++++++++-------- openpgp/src/serialize/cert.rs | 2 +- openpgp/src/serialize/cert_armored.rs | 10 +++++----- openpgp/src/serialize/stream.rs | 2 +- 28 files changed, 79 insertions(+), 79 deletions(-) (limited to 'openpgp') diff --git a/openpgp/benches/decrypt_message.rs b/openpgp/benches/decrypt_message.rs index e2ed4e5e..9d3876e9 100644 --- a/openpgp/benches/decrypt_message.rs +++ b/openpgp/benches/decrypt_message.rs @@ -20,12 +20,12 @@ lazy_static::lazy_static! { fn decrypt_cert(bytes: &[u8], cert: &Cert) { let mut sink = Vec::new(); - decrypt::decrypt_with_cert(&mut sink, &bytes, cert).unwrap(); + decrypt::decrypt_with_cert(&mut sink, bytes, cert).unwrap(); } fn decrypt_password(bytes: &[u8]) { let mut sink = Vec::new(); - decrypt::decrypt_with_password(&mut sink, &bytes, PASSWORD).unwrap(); + decrypt::decrypt_with_password(&mut sink, bytes, PASSWORD).unwrap(); } fn bench_decrypt(c: &mut Criterion) { @@ -42,7 +42,7 @@ fn bench_decrypt(c: &mut Criterion) { group.bench_with_input( BenchmarkId::new("password", m.len()), &encrypted, - |b, e| b.iter(|| decrypt_password(&e)), + |b, e| b.iter(|| decrypt_password(e)), ); }); @@ -53,7 +53,7 @@ fn bench_decrypt(c: &mut Criterion) { group.bench_with_input( BenchmarkId::new("cert", m.len()), &encrypted, - |b, e| b.iter(|| decrypt_cert(&e, &TESTY)), + |b, e| b.iter(|| decrypt_cert(e, &TESTY)), ); }); diff --git a/openpgp/benches/decrypt_verify_message.rs b/openpgp/benches/decrypt_verify_message.rs index aa84e819..12a48642 100644 --- a/openpgp/benches/decrypt_verify_message.rs +++ b/openpgp/benches/decrypt_verify_message.rs @@ -21,7 +21,7 @@ lazy_static::lazy_static! { fn decrypt_and_verify(bytes: &[u8], sender: &Cert, recipient: &Cert) { let mut sink = Vec::new(); - decrypt::decrypt_and_verify(&mut sink, &bytes, sender, recipient).unwrap(); + decrypt::decrypt_and_verify(&mut sink, bytes, sender, recipient).unwrap(); } fn bench_decrypt_verify(c: &mut Criterion) { @@ -38,7 +38,7 @@ fn bench_decrypt_verify(c: &mut Criterion) { group.bench_with_input( BenchmarkId::new("decrypt and verify", m.len()), &encrypted, - |b, e| b.iter(|| decrypt_and_verify(&e, &SENDER, &RECIPIENT)), + |b, e| b.iter(|| decrypt_and_verify(e, &SENDER, &RECIPIENT)), ); }); diff --git a/openpgp/benches/encrypt_message.rs b/openpgp/benches/encrypt_message.rs index 5b0a0020..93f5925d 100644 --- a/openpgp/benches/encrypt_message.rs +++ b/openpgp/benches/encrypt_message.rs @@ -34,12 +34,12 @@ fn bench_encrypt(c: &mut Criterion) { group.bench_with_input( BenchmarkId::new("password", message.len()), &message, - |b, m| b.iter(|| encrypt_with_password(&m)), + |b, m| b.iter(|| encrypt_with_password(m)), ); group.bench_with_input( BenchmarkId::new("cert", message.len()), &message, - |b, m| b.iter(|| encrypt_to_testy(&m)), + |b, m| b.iter(|| encrypt_to_testy(m)), ); } group.finish(); diff --git a/openpgp/benches/encrypt_sign_message.rs b/openpgp/benches/encrypt_sign_message.rs index 5923ff88..62863eb5 100644 --- a/openpgp/benches/encrypt_sign_message.rs +++ b/openpgp/benches/encrypt_sign_message.rs @@ -34,7 +34,7 @@ fn bench_encrypt_sign(c: &mut Criterion) { group.bench_with_input( BenchmarkId::new("encrypt and sign", message.len()), &message, - |b, m| b.iter(|| encrypt_to_donald_sign_by_ivanka(&m)), + |b, m| b.iter(|| encrypt_to_donald_sign_by_ivanka(m)), ); } group.finish(); diff --git a/openpgp/benches/sign_message.rs b/openpgp/benches/sign_message.rs index 419be8bb..267ea91d 100644 --- a/openpgp/benches/sign_message.rs +++ b/openpgp/benches/sign_message.rs @@ -32,7 +32,7 @@ fn bench_sign(c: &mut Criterion) { group.bench_with_input( BenchmarkId::new("cert", message.len()), &message, - |b, m| b.iter(|| sign_by_testy(&m)), + |b, m| b.iter(|| sign_by_testy(m)), ); } group.finish(); diff --git a/openpgp/benches/verify_message.rs b/openpgp/benches/verify_message.rs index 8dfd3740..200cfb93 100644 --- a/openpgp/benches/verify_message.rs +++ b/openpgp/benches/verify_message.rs @@ -16,7 +16,7 @@ lazy_static::lazy_static! { fn verify(bytes: &[u8], sender: &Cert) { let mut sink = Vec::new(); - decrypt::verify(&mut sink, &bytes, sender).unwrap(); + decrypt::verify(&mut sink, bytes, sender).unwrap(); } fn bench_verify(c: &mut Criterion) { @@ -34,7 +34,7 @@ fn bench_verify(c: &mut Criterion) { group.bench_with_input( BenchmarkId::new("verify", m.len()), &signed, - |b, s| b.iter(|| verify(&s, &SENDER)), + |b, s| b.iter(|| verify(s, &SENDER)), ); }); diff --git a/openpgp/examples/statistics.rs b/openpgp/examples/statistics.rs index fc262ee8..d0c5023d 100644 --- a/openpgp/examples/statistics.rs +++ b/openpgp/examples/statistics.rs @@ -176,7 +176,7 @@ fn main() -> openpgp::Result<()> { SubpacketValue::Unknown { .. } => unreachable!(), SubpacketValue::KeyFlags(k) => - if let Some(count) = key_flags.get_mut(&k) { + if let Some(count) = key_flags.get_mut(k) { *count += 1; } else { key_flags.insert(k.clone(), 1); @@ -437,7 +437,7 @@ fn main() -> openpgp::Result<()> { // Sort by the number of occurrences. let mut kf = key_flags.iter().map(|(f, n)| (format!("{:?}", f), n)) .collect::>(); - kf.sort_unstable_by(|a, b| b.1.cmp(&a.1)); + kf.sort_unstable_by(|a, b| b.1.cmp(a.1)); for (f, n) in kf.iter() { println!("{:>22} {:>9}", f, n); } @@ -456,7 +456,7 @@ fn main() -> openpgp::Result<()> { let a = format!("{:?}", a); (a[1..a.len()-1].to_string(), n) }).collect::>(); - preferences.sort_unstable_by(|a, b| b.1.cmp(&a.1)); + preferences.sort_unstable_by(|a, b| b.1.cmp(a.1)); for (a, n) in preferences { println!("{:>70} {:>9}", a, n); } @@ -475,7 +475,7 @@ fn main() -> openpgp::Result<()> { let a = format!("{:?}", a); (a[1..a.len()-1].to_string(), n) }).collect::>(); - preferences.sort_unstable_by(|a, b| b.1.cmp(&a.1)); + preferences.sort_unstable_by(|a, b| b.1.cmp(a.1)); for (a, n) in preferences { let a = format!("{:?}", a); println!("{:>70} {:>9}", &a[1..a.len()-1], n); @@ -495,7 +495,7 @@ fn main() -> openpgp::Result<()> { let a = format!("{:?}", a); (a[1..a.len()-1].to_string(), n) }).collect::>(); - preferences.sort_unstable_by(|a, b| b.1.cmp(&a.1)); + preferences.sort_unstable_by(|a, b| b.1.cmp(a.1)); for (a, n) in preferences { let a = format!("{:?}", a); println!("{:>70} {:>9}", &a[1..a.len()-1], n); diff --git a/openpgp/src/armor.rs b/openpgp/src/armor.rs index 968fe025..a1eb3c7c 100644 --- a/openpgp/src/armor.rs +++ b/openpgp/src/armor.rs @@ -934,7 +934,7 @@ impl<'a> Reader<'a> { } // Possible ASCII-armor header. - if let Some((label, len)) = Label::detect_header(&input) { + if let Some((label, len)) = Label::detect_header(input) { if label == Label::CleartextSignature && ! self.enable_csft { // We found a message using the Cleartext @@ -1422,7 +1422,7 @@ impl<'a> Reader<'a> { armored data")); } - let (dashes, rest) = dash_prefix(&line); + let (dashes, rest) = dash_prefix(line); if dashes.len() > 2 // XXX: heuristic... && rest.starts_with(b"BEGIN PGP SIGNATURE") { diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs index 0d2d3dcf..3ab5ce65 100644 --- a/openpgp/src/cert.rs +++ b/openpgp/src/cert.rs @@ -814,7 +814,7 @@ impl Cert { /// ``` pub fn primary_key(&self) -> PrimaryKeyAmalgamation { - PrimaryKeyAmalgamation::new(&self) + PrimaryKeyAmalgamation::new(self) } /// Returns the certificate's revocation status. @@ -961,7 +961,7 @@ impl Cert { { CertRevocationBuilder::new() .set_reason_for_revocation(code, reason)? - .build(primary_signer, &self, None) + .build(primary_signer, self, None) } /// Sets the key to expire in delta seconds. @@ -2477,29 +2477,29 @@ impl Cert { // they match, then we keep whatever is in the // new key. (Packet::PublicKey(a), Packet::PublicKey(b)) => - (a.public_cmp(&b) == Ordering::Equal, + (a.public_cmp(b) == Ordering::Equal, a == b), (Packet::SecretKey(a), Packet::SecretKey(b)) => - (a.public_cmp(&b) == Ordering::Equal, + (a.public_cmp(b) == Ordering::Equal, a == b), (Packet::PublicKey(a), Packet::SecretKey(b)) => - (a.public_cmp(&b) == Ordering::Equal, + (a.public_cmp(b) == Ordering::Equal, false), (Packet::SecretKey(a), Packet::PublicKey(b)) => - (a.public_cmp(&b) == Ordering::Equal, + (a.public_cmp(b) == Ordering::Equal, false), (Packet::PublicSubkey(a), Packet::PublicSubkey(b)) => - (a.public_cmp(&b) == Ordering::Equal, + (a.public_cmp(b) == Ordering::Equal, a == b), (Packet::SecretSubkey(a), Packet::SecretSubkey(b)) => - (a.public_cmp(&b) == Ordering::Equal, + (a.public_cmp(b) == Ordering::Equal, a == b), (Packet::PublicSubkey(a), Packet::SecretSubkey(b)) => - (a.public_cmp(&b) == Ordering::Equal, + (a.public_cmp(b) == Ordering::Equal, false), (Packet::SecretSubkey(a), Packet::PublicSubkey(b)) => - (a.public_cmp(&b) == Ordering::Equal, + (a.public_cmp(b) == Ordering::Equal, false), // For signatures, don't compare the unhashed diff --git a/openpgp/src/cert/amalgamation.rs b/openpgp/src/cert/amalgamation.rs index 3ee80cf5..39031a4f 100644 --- a/openpgp/src/cert/amalgamation.rs +++ b/openpgp/src/cert/amalgamation.rs @@ -764,7 +764,7 @@ impl<'a, C> ComponentAmalgamation<'a, C> { /// # Ok(()) } /// ``` pub fn cert(&self) -> &'a Cert { - &self.cert + self.cert } /// Selects a binding signature. @@ -820,7 +820,7 @@ impl<'a, C> ComponentAmalgamation<'a, C> { /// # Ok(()) } /// ``` pub fn bundle(&self) -> &'a ComponentBundle { - &self.bundle + self.bundle } /// Returns this amalgamation's component. @@ -1665,7 +1665,7 @@ impl<'a, C> ValidComponentAmalgamation<'a, C> (false, true) => return Ordering::Less, _ => (), } - match a_signature_creation_time.cmp(&b_signature_creation_time) + match a_signature_creation_time.cmp(b_signature_creation_time) { Ordering::Less => return Ordering::Less, Ordering::Greater => return Ordering::Greater, @@ -1674,7 +1674,7 @@ impl<'a, C> ValidComponentAmalgamation<'a, C> // Fallback to a lexographical comparison. Prefer // the "smaller" one. - match a.0.component().cmp(&b.0.component()) { + match a.0.component().cmp(b.0.component()) { Ordering::Less => Ordering::Greater, Ordering::Greater => Ordering::Less, Ordering::Equal => diff --git a/openpgp/src/crypto/backend/nettle/ecdh.rs b/openpgp/src/crypto/backend/nettle/ecdh.rs index fbad33a5..75e86133 100644 --- a/openpgp/src/crypto/backend/nettle/ecdh.rs +++ b/openpgp/src/crypto/backend/nettle/ecdh.rs @@ -162,7 +162,7 @@ pub fn decrypt(recipient: &Key, let (V, r, field_sz) = match curve { Curve::NistP256 => { let V = - ecc::Point::new::(&Vx, &Vy)?; + ecc::Point::new::(Vx, Vy)?; let r = ecc::Scalar::new::(scalar.value())?; @@ -170,7 +170,7 @@ pub fn decrypt(recipient: &Key, } Curve::NistP384 => { let V = - ecc::Point::new::(&Vx, &Vy)?; + ecc::Point::new::(Vx, Vy)?; let r = ecc::Scalar::new::(scalar.value())?; @@ -178,7 +178,7 @@ pub fn decrypt(recipient: &Key, } Curve::NistP521 => { let V = - ecc::Point::new::(&Vx, &Vy)?; + ecc::Point::new::(Vx, Vy)?; let r = ecc::Scalar::new::(scalar.value())?; diff --git a/openpgp/src/crypto/ecdh.rs b/openpgp/src/crypto/ecdh.rs index 3407e8a3..1c3e600b 100644 --- a/openpgp/src/crypto/ecdh.rs +++ b/openpgp/src/crypto/ecdh.rs @@ -97,7 +97,7 @@ pub fn decrypt_unwrap(recipient: &Key, // Z_len = the key size for the KEK_alg_ID used with AESKeyWrap // Compute Z = KDF( S, Z_len, Param ); #[allow(non_snake_case)] - let Z = kdf(&S, sym.key_size()?, *hash, ¶m)?; + let Z = kdf(S, sym.key_size()?, *hash, ¶m)?; // Compute m = AESKeyUnwrap( Z, C ) as per [RFC3394] let m = aes_key_unwrap(*sym, &Z, key)?; diff --git a/openpgp/src/crypto/mem.rs b/openpgp/src/crypto/mem.rs index 1fa6266b..8342aa8e 100644 --- a/openpgp/src/crypto/mem.rs +++ b/openpgp/src/crypto/mem.rs @@ -65,14 +65,14 @@ impl Clone for Protected { // Make a vector with the correct size to avoid potential // reallocations when turning it into a `Protected`. let mut p = Vec::with_capacity(self.len()); - p.extend_from_slice(&self); + p.extend_from_slice(self); p.into_boxed_slice().into() } } impl PartialEq for Protected { fn eq(&self, other: &Self) -> bool { - secure_cmp(&self, &other) == Ordering::Equal + secure_cmp(self, other) == Ordering::Equal } } diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs index d64fde60..98895b5f 100644 --- a/openpgp/src/crypto/s2k.rs +++ b/openpgp/src/crypto/s2k.rs @@ -198,7 +198,7 @@ impl S2K { // Independent of what the hash count is, we // always hash the whole salt and password once. hash.update(&salt[..]); - hash.update(&string); + hash.update(string); }, &S2K::Iterated { ref salt, hash_bytes, .. } => { // Unroll the processing loop N times. diff --git a/openpgp/src/crypto/symmetric.rs b/openpgp/src/crypto/symmetric.rs index d2bec940..fcfd1d23 100644 --- a/openpgp/src/crypto/symmetric.rs +++ b/openpgp/src/crypto/symmetric.rs @@ -425,7 +425,7 @@ mod tests { // Ensure we use CFB128 by default let iv = hex::decode("000102030405060708090A0B0C0D0E0F").unwrap(); - let mut cfb = algo.make_encrypt_cfb(&key, iv).unwrap(); + let mut cfb = algo.make_encrypt_cfb(key, iv).unwrap(); let msg = hex::decode("6bc1bee22e409f96e93d7e117393172a").unwrap(); let mut dst = vec![0; msg.len()]; cfb.encrypt(&mut dst, &*msg).unwrap(); @@ -433,7 +433,7 @@ mod tests { // 32-byte long message let iv = hex::decode("000102030405060708090A0B0C0D0E0F").unwrap(); - let mut cfb = algo.make_encrypt_cfb(&key, iv).unwrap(); + let mut cfb = algo.make_encrypt_cfb(key, iv).unwrap(); let msg = b"This is a very important message"; let mut dst = vec![0; msg.len()]; cfb.encrypt(&mut dst, &*msg).unwrap(); @@ -443,7 +443,7 @@ mod tests { // 33-byte (uneven) long message let iv = hex::decode("000102030405060708090A0B0C0D0E0F").unwrap(); - let mut cfb = algo.make_encrypt_cfb(&key, iv).unwrap(); + let mut cfb = algo.make_encrypt_cfb(key, iv).unwrap(); let msg = b"This is a very important message!"; let mut dst = vec![0; msg.len()]; cfb.encrypt(&mut dst, &*msg).unwrap(); @@ -453,7 +453,7 @@ mod tests { // 33-byte (uneven) long message, chunked let iv = hex::decode("000102030405060708090A0B0C0D0E0F").unwrap(); - let mut cfb = algo.make_encrypt_cfb(&key, iv).unwrap(); + let mut cfb = algo.make_encrypt_cfb(key, iv).unwrap(); let mut dst = vec![0; msg.len()]; for (mut dst, msg) in dst.chunks_mut(16).zip(msg.chunks(16)) { cfb.encrypt(&mut dst, msg).unwrap(); diff --git a/openpgp/src/packet/container.rs b/openpgp/src/packet/container.rs index 41e9ca31..dfbb624b 100644 --- a/openpgp/src/packet/container.rs +++ b/openpgp/src/packet/container.rs @@ -340,7 +340,7 @@ impl Container { for (i, p) in self.children_ref().iter().enumerate() { eprintln!("{}{}: {:?}", Self::indent(indent), i + 1, p); - if let Some(ref children) = self.children_ref() + if let Some(children) = self.children_ref() .and_then(|c| c.get(i)).and_then(|p| p.container_ref()) { children.pretty_print(indent + 1); diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs index 7cb2da76..b39af8e8 100644 --- a/openpgp/src/packet/mod.rs +++ b/openpgp/src/packet/mod.rs @@ -825,7 +825,7 @@ fn packet_path_iter() { v.push(i); lpaths.push(v); - if let Some(ref container) = packet.container_ref() { + if let Some(container) = packet.container_ref() { if let Some(c) = container.children() { for mut path in paths(c).into_iter() { diff --git a/openpgp/src/packet/signature.rs b/openpgp/src/packet/signature.rs index e8d81904..464e30cd 100644 --- a/openpgp/src/packet/signature.rs +++ b/openpgp/src/packet/signature.rs @@ -3749,7 +3749,7 @@ mod test { assert_eq!(sig.subpackets(SubpacketTag::Issuer).count(), 0); // But normalization after verification adds the missing // information. - sig.verify_subkey_binding(&primary_key, &primary_key, &subkey)?; + sig.verify_subkey_binding(primary_key, primary_key, subkey)?; let normalized_sig = sig.normalize(); assert_eq!(normalized_sig.subpackets(SubpacketTag::Issuer).count(), 1); Ok(()) diff --git a/openpgp/src/packet/skesk.rs b/openpgp/src/packet/skesk.rs index cd30e564..6628dd3d 100644 --- a/openpgp/src/packet/skesk.rs +++ b/openpgp/src/packet/skesk.rs @@ -177,7 +177,7 @@ impl SKESK4 { // We need to prefix the cipher specifier to the session key. let mut psk: SessionKey = vec![0; 1 + session_key.len()].into(); psk[0] = payload_algo.into(); - psk[1..].copy_from_slice(&session_key); + psk[1..].copy_from_slice(session_key); let mut esk = vec![0u8; psk.len()]; for (pt, ct) in psk[..].chunks(block_size) @@ -252,7 +252,7 @@ impl SKESK4 { { let key = self.s2k.derive_key(password, self.sym_algo.key_size()?)?; - if let Some(ref esk) = self.esk()? { + if let Some(esk) = self.esk()? { // Use the derived key to decrypt the ESK. Unlike SEP & // SEIP we have to use plain CFB here. let blk_sz = self.sym_algo.block_size()?; @@ -474,7 +474,7 @@ impl SKESK5 { // We need to prefix the cipher specifier to the session key. let mut esk = vec![0u8; session_key.len()]; - ctx.encrypt(&mut esk, &session_key); + ctx.encrypt(&mut esk, session_key); // Digest. let mut digest = vec![0u8; esk_aead.digest_size()?]; @@ -500,10 +500,10 @@ impl SKESK5 { let key = self.s2k().derive_key(password, self.symmetric_algo().key_size()?)?; - if let Some(ref esk) = self.esk()? { + if let Some(esk) = self.esk()? { // Use the derived key to decrypt the ESK. let mut cipher = self.aead_algo.context( - self.symmetric_algo(), &key, &self.aead_iv()?, CipherOp::Decrypt)?; + self.symmetric_algo(), &key, self.aead_iv()?, CipherOp::Decrypt)?; let ad = [0xc3, 5 /* Version. */, self.symmetric_algo().into(), self.aead_algo.into()]; diff --git a/openpgp/src/packet/unknown.rs b/openpgp/src/packet/unknown.rs index 885bfddc..50000a61 100644 --- a/openpgp/src/packet/unknown.rs +++ b/openpgp/src/packet/unknown.rs @@ -135,7 +135,7 @@ impl Unknown { /// case. pub(crate) // For cert/mod.rs fn best_effort_cmp(&self, other: &Unknown) -> Ordering { - self.tag.cmp(&other.tag).then_with(|| self.body().cmp(&other.body())) + self.tag.cmp(&other.tag).then_with(|| self.body().cmp(other.body())) } } diff --git a/openpgp/src/packet_pile.rs b/openpgp/src/packet_pile.rs index 686f7715..98f70c66 100644 --- a/openpgp/src/packet_pile.rs +++ b/openpgp/src/packet_pile.rs @@ -267,7 +267,7 @@ impl PacketPile { let mut cont = Some(&self.top_level); for i in pathspec { - if let Some(ref c) = cont.take() { + if let Some(c) = cont.take() { if let Some(children) = c.children_ref() { if *i < children.len() { let p = &children[*i]; diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs index 326793fb..fe2f3db5 100644 --- a/openpgp/src/parse.rs +++ b/openpgp/src/parse.rs @@ -2106,7 +2106,7 @@ fn one_pass_sig_test () { crate::fmt::to_hex(&test.digest_prefix[sigs][..], false), crate::fmt::to_hex(sig.digest_prefix(), false)); eprintln!(" computed hash: {}", - crate::fmt::to_hex(&sig.computed_digest().unwrap(), + crate::fmt::to_hex(sig.computed_digest().unwrap(), false)); assert_eq!(&test.digest_prefix[sigs], sig.digest_prefix()); @@ -4149,13 +4149,13 @@ impl <'a> PacketParser<'a> { | Tag::Unknown(_) | Tag::Private(_) => Err(Error::MalformedPacket("Looks like garbage".into()).into()), - Tag::Marker => Marker::plausible(bio, &header), - Tag::Signature => Signature::plausible(bio, &header), + Tag::Marker => Marker::plausible(bio, header), + Tag::Signature => Signature::plausible(bio, header), - Tag::SecretKey => Key::plausible(bio, &header), - Tag::PublicKey => Key::plausible(bio, &header), - Tag::SecretSubkey => Key::plausible(bio, &header), - Tag::PublicSubkey => Key::plausible(bio, &header), + Tag::SecretKey => Key::plausible(bio, header), + Tag::PublicKey => Key::plausible(bio, header), + Tag::SecretSubkey => Key::plausible(bio, header), + Tag::PublicSubkey => Key::plausible(bio, header), Tag::UserID => bad, Tag::UserAttribute => bad, diff --git a/openpgp/src/parse/hashed_reader.rs b/openpgp/src/parse/hashed_reader.rs index f4ee5964..0568829d 100644 --- a/openpgp/src/parse/hashed_reader.rs +++ b/openpgp/src/parse/hashed_reader.rs @@ -146,8 +146,8 @@ impl Cookie { t!("{:?}: group {} {:?} hashing {} bytes.", hashes_for, i, mode.map(|ctx| ctx.algo()), data.len()); match mode { - HashingMode::Binary(h) => h.update(&data), - HashingMode::Text(h) => hash_update_text(h, &data), + HashingMode::Binary(h) => h.update(data), + HashingMode::Text(h) => hash_update_text(h, data), } } } diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs index a9a556ca..89535ac3 100644 --- a/openpgp/src/parse/stream.rs +++ b/openpgp/src/parse/stream.rs @@ -2780,7 +2780,7 @@ impl<'a, H: VerificationHelper + DecryptionHelper> Decryptor<'a, H> { Ok(()) => { if let Err(error) = self.policy.signature( - &sig, Default::default()) + sig, Default::default()) { t!("{:02X}{:02X}: signature rejected by policy: {}", sigid[0], sigid[1], error); diff --git a/openpgp/src/serialize.rs b/openpgp/src/serialize.rs index ae83c33f..04f36403 100644 --- a/openpgp/src/serialize.rs +++ b/openpgp/src/serialize.rs @@ -1449,7 +1449,7 @@ impl Marshal for SubpacketValue { o.write_all(reason)?; }, Features(ref f) => - o.write_all(&f.as_slice())?, + o.write_all(f.as_slice())?, SignatureTarget { pk_algo, hash_algo, ref digest } => { o.write_all(&[(*pk_algo).into(), (*hash_algo).into()])?; o.write_all(digest)?; @@ -2066,7 +2066,7 @@ impl Literal { pub(crate) fn serialize_headers(&self, o: &mut dyn std::io::Write, write_tag: bool) -> Result<()> { - let filename = if let Some(ref filename) = self.filename() { + let filename = if let Some(filename) = self.filename() { let len = cmp::min(filename.len(), 255) as u8; &filename[..len as usize] } else { @@ -2736,7 +2736,7 @@ impl<'a> PacketRef<'a> { /// [Section 4.3 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-4.3 fn tag(&self) -> packet::Tag { match self { - PacketRef::Unknown(ref packet) => packet.tag(), + PacketRef::Unknown(packet) => packet.tag(), PacketRef::Signature(_) => Tag::Signature, PacketRef::OnePassSig(_) => Tag::OnePassSig, PacketRef::PublicKey(_) => Tag::PublicKey, @@ -2771,7 +2771,7 @@ impl<'a> Marshal for PacketRef<'a> { // Special-case the compressed data packet, because we need // the accurate length, and CompressedData::net_len() // overestimates the size. - if let PacketRef::CompressedData(ref p) = self { + if let PacketRef::CompressedData(p) = self { let mut body = Vec::new(); p.serialize(&mut body)?; BodyLength::Full(body.len() as u32).serialize(o)?; @@ -2812,7 +2812,7 @@ impl<'a> Marshal for PacketRef<'a> { // Special-case the compressed data packet, because we need // the accurate length, and CompressedData::net_len() // overestimates the size. - if let PacketRef::CompressedData(ref p) = self { + if let PacketRef::CompressedData(p) = self { let mut body = Vec::new(); p.export(&mut body)?; BodyLength::Full(body.len() as u32).export(o)?; @@ -2984,9 +2984,9 @@ mod test { eprintln!("Packet contents don't match (for {}):", filename); eprintln!("Expected ({} bytes):\n{}", - expected_body.len(), binary_pp(&expected_body)); + expected_body.len(), binary_pp(expected_body)); eprintln!("Got ({} bytes):\n{}", - got_body.len(), binary_pp(&got_body)); + got_body.len(), binary_pp(got_body)); eprintln!("Packet: {:#?}", packet); fail = true; } @@ -3050,7 +3050,7 @@ mod test { Packet::Literal(_) | Packet::Signature(_) | Packet::PublicKey(_) | Packet::PublicSubkey(_) | Packet::UserID(_) | Packet::SKESK(_) => (), - ref p => { + p => { panic!("Didn't expect a {:?} packet.", p.tag()); }, } diff --git a/openpgp/src/serialize/cert.rs b/openpgp/src/serialize/cert.rs index b6967f02..fe25c19a 100644 --- a/openpgp/src/serialize/cert.rs +++ b/openpgp/src/serialize/cert.rs @@ -532,7 +532,7 @@ impl<'a> TSK<'a> { continue; } - PacketRef::Unknown(&u.unknown()).serialize(o)?; + PacketRef::Unknown(u.unknown()).serialize(o)?; for s in u.signatures() { serialize_sig(o, s)?; diff --git a/openpgp/src/serialize/cert_armored.rs b/openpgp/src/serialize/cert_armored.rs index 83b68479..68f7d332 100644 --- a/openpgp/src/serialize/cert_armored.rs +++ b/openpgp/src/serialize/cert_armored.rs @@ -140,7 +140,7 @@ impl<'a> Encoder<'a> { fn serialize_common(&self, o: &mut dyn io::Write, export: bool) -> Result<()> { let (prelude, headers) = match self { - Encoder::Cert(ref cert) => + Encoder::Cert(cert) => (armor::Kind::PublicKey, cert.armor_headers()), Encoder::TSK(ref tsk) => (armor::Kind::SecretKey, tsk.cert.armor_headers()), @@ -157,12 +157,12 @@ impl<'a> Encoder<'a> { armor::Writer::with_headers(o, prelude, headers)?; if export { match self { - Encoder::Cert(ref cert) => cert.export(&mut w)?, + Encoder::Cert(cert) => cert.export(&mut w)?, Encoder::TSK(ref tsk) => tsk.export(&mut w)?, } } else { match self { - Encoder::Cert(ref cert) => cert.serialize(&mut w)?, + Encoder::Cert(cert) => cert.serialize(&mut w)?, Encoder::TSK(ref tsk) => tsk.serialize(&mut w)?, } } @@ -188,14 +188,14 @@ impl<'a> crate::serialize::SerializeInto for Encoder<'a> {} impl<'a> MarshalInto for Encoder<'a> { fn serialized_len(&self) -> usize { let h = match self { - Encoder::Cert(ref cert) => cert.armor_headers(), + Encoder::Cert(cert) => cert.armor_headers(), Encoder::TSK(ref tsk) => tsk.cert.armor_headers(), }; let headers_len = ("Comment: ".len() + 1 /* NL */) * h.len() + h.iter().map(|c| c.len()).sum::(); let body_len = (match self { - Self::Cert(ref cert) => cert.serialized_len(), + Self::Cert(cert) => cert.serialized_len(), Self::TSK(ref tsk) => tsk.serialized_len(), } + 2) / 3 * 4; // base64 diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs index 1b3c13fd..dfc49d0d 100644 --- a/openpgp/src/serialize/stream.rs +++ b/openpgp/src/serialize/stream.rs @@ -3249,7 +3249,7 @@ mod test { let mut good = 0; while let PacketParserResult::Some(mut pp) = ppr { if let Packet::Signature(sig) = &mut pp.packet { - let key = keys.get(&sig.issuer_fingerprints().next().unwrap()) + let key = keys.get(sig.issuer_fingerprints().next().unwrap()) .unwrap(); sig.verify(key).unwrap(); good += 1; -- cgit v1.2.3