summaryrefslogtreecommitdiffstats
path: root/openpgp/src
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/src
parent97ce753fefae770ee0b5b02a611d75e29a7cd01d (diff)
Remove unnecessary borrows.
- Fixed with the help of clippy::needless_borrow.
Diffstat (limited to 'openpgp/src')
-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
21 files changed, 62 insertions, 62 deletions
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(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