summaryrefslogtreecommitdiffstats
path: root/openpgp
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2021-11-22 12:58:47 +0100
committerNora Widdecke <nora@sequoia-pgp.org>2021-11-29 11:53:55 +0100
commit049055e3ff5ffe86700b668e924fbff96e82be94 (patch)
tree30dfd63e4d1c3016210b698813e99b70787890e8 /openpgp
parent97ce753fefae770ee0b5b02a611d75e29a7cd01d (diff)
Remove unnecessary borrows.
- Fixed with the help of clippy::needless_borrow.
Diffstat (limited to 'openpgp')
-rw-r--r--openpgp/benches/decrypt_message.rs8
-rw-r--r--openpgp/benches/decrypt_verify_message.rs4
-rw-r--r--openpgp/benches/encrypt_message.rs4
-rw-r--r--openpgp/benches/encrypt_sign_message.rs2
-rw-r--r--openpgp/benches/sign_message.rs2
-rw-r--r--openpgp/benches/verify_message.rs4
-rw-r--r--openpgp/examples/statistics.rs10
-rw-r--r--openpgp/src/armor.rs4
-rw-r--r--openpgp/src/cert.rs20
-rw-r--r--openpgp/src/cert/amalgamation.rs8
-rw-r--r--openpgp/src/crypto/backend/nettle/ecdh.rs6
-rw-r--r--openpgp/src/crypto/ecdh.rs2
-rw-r--r--openpgp/src/crypto/mem.rs4
-rw-r--r--openpgp/src/crypto/s2k.rs2
-rw-r--r--openpgp/src/crypto/symmetric.rs8
-rw-r--r--openpgp/src/packet/container.rs2
-rw-r--r--openpgp/src/packet/mod.rs2
-rw-r--r--openpgp/src/packet/signature.rs2
-rw-r--r--openpgp/src/packet/skesk.rs10
-rw-r--r--openpgp/src/packet/unknown.rs2
-rw-r--r--openpgp/src/packet_pile.rs2
-rw-r--r--openpgp/src/parse.rs14
-rw-r--r--openpgp/src/parse/hashed_reader.rs4
-rw-r--r--openpgp/src/parse/stream.rs2
-rw-r--r--openpgp/src/serialize.rs16
-rw-r--r--openpgp/src/serialize/cert.rs2
-rw-r--r--openpgp/src/serialize/cert_armored.rs10
-rw-r--r--openpgp/src/serialize/stream.rs2
28 files changed, 79 insertions, 79 deletions
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::<Vec<_>>();
- 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::<Vec<_>>();
- 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::<Vec<_>>();
- 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::<Vec<_>>();
- 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<key::PublicParts>
{
- 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<C> {
- &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<R>(recipient: &Key<key::PublicParts, R>,
let (V, r, field_sz) = match curve {
Curve::NistP256 => {
let V =
- ecc::Point::new::<ecc::Secp256r1>(&Vx, &Vy)?;
+ ecc::Point::new::<ecc::Secp256r1>(Vx, Vy)?;
let r =
ecc::Scalar::new::<ecc::Secp256r1>(scalar.value())?;
@@ -170,7 +170,7 @@ pub fn decrypt<R>(recipient: &Key<key::PublicParts, R>,
}
Curve::NistP384 => {
let V =
- ecc::Point::new::<ecc::Secp384r1>(&Vx, &Vy)?;
+ ecc::Point::new::<ecc::Secp384r1>(Vx, Vy)?;
let r =
ecc::Scalar::new::<ecc::Secp384r1>(scalar.value())?;
@@ -178,7 +178,7 @@ pub fn decrypt<R>(recipient: &Key<key::PublicParts, R>,
}
Curve::NistP521 => {
let V =
- ecc::Point::new::<ecc::Secp521r1>(&Vx, &Vy)?;
+ ecc::Point::new::<ecc::Secp521r1>(Vx, Vy)?;
let r =
ecc::Scalar::new::<ecc::Secp521r1>(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<R>(recipient: &Key<key::PublicParts, R>,
// 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, &param)?;
+ let Z = kdf(S, sym.key_size()?, *hash, &param)?;
// 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(se