From 39f3a91bddc617d66927f1cd3301efae7d41b0c1 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Fri, 13 Dec 2019 16:23:42 +0100 Subject: openpgp: Rename hashing functions. - Verb hash: use hash_xxx instead of xxx_hash. --- openpgp/src/cert/mod.rs | 32 ++++++++++++++++---------------- openpgp/src/crypto/hash.rs | 20 ++++++++++---------- openpgp/src/packet/signature/mod.rs | 36 ++++++++++++++++++------------------ 3 files changed, 44 insertions(+), 44 deletions(-) (limited to 'openpgp') diff --git a/openpgp/src/cert/mod.rs b/openpgp/src/cert/mod.rs index d4c458ab..e9497c8a 100644 --- a/openpgp/src/cert/mod.rs +++ b/openpgp/src/cert/mod.rs @@ -1407,10 +1407,10 @@ impl Cert { self.primary, self_revocations, verify_primary_key_revocation); check_3rd_party!("primary key", self.primary, certifications, lookup_fn, - verify_primary_key_binding, primary_key_binding_hash); + verify_primary_key_binding, hash_primary_key_binding); check_3rd_party!("primary key", self.primary, other_revocations, lookup_fn, - verify_primary_key_revocation, primary_key_binding_hash); + verify_primary_key_revocation, hash_primary_key_binding); for binding in self.userids.iter_mut() { check!(format!("userid \"{}\"", @@ -1425,13 +1425,13 @@ impl Cert { format!("userid \"{}\"", String::from_utf8_lossy(binding.userid().value())), binding, certifications, lookup_fn, - verify_userid_binding, userid_binding_hash, + verify_userid_binding, hash_userid_binding, binding.userid()); check_3rd_party!( format!("userid \"{}\"", String::from_utf8_lossy(binding.userid().value())), binding, other_revocations, lookup_fn, - verify_userid_revocation, userid_binding_hash, + verify_userid_revocation, hash_userid_binding, binding.userid()); } @@ -1445,12 +1445,12 @@ impl Cert { check_3rd_party!( "user attribute", binding, certifications, lookup_fn, - verify_user_attribute_binding, user_attribute_binding_hash, + verify_user_attribute_binding, hash_user_attribute_binding, binding.user_attribute()); check_3rd_party!( "user attribute", binding, other_revocations, lookup_fn, - verify_user_attribute_revocation, user_attribute_binding_hash, + verify_user_attribute_revocation, hash_user_attribute_binding, binding.user_attribute()); } @@ -1464,12 +1464,12 @@ impl Cert { check_3rd_party!( format!("subkey {}", binding.key().keyid()), binding, certifications, lookup_fn, - verify_subkey_binding, subkey_binding_hash, + verify_subkey_binding, hash_subkey_binding, binding.key()); check_3rd_party!( format!("subkey {}", binding.key().keyid()), binding, other_revocations, lookup_fn, - verify_subkey_revocation, subkey_binding_hash, + verify_subkey_revocation, hash_subkey_binding, binding.key()); } @@ -1564,10 +1564,10 @@ impl Cert { verify_primary_key_revocation); check_one_3rd_party!( "primary key", self.primary.certifications, sig, lookup_fn, - verify_primary_key_binding, primary_key_binding_hash); + verify_primary_key_binding, hash_primary_key_binding); check_one_3rd_party!( "primary key", self.primary.other_revocations, sig, lookup_fn, - verify_primary_key_revocation, primary_key_binding_hash); + verify_primary_key_revocation, hash_primary_key_binding); for binding in self.userids.iter_mut() { check_one!(format!("userid \"{}\"", @@ -1584,13 +1584,13 @@ impl Cert { format!("userid \"{}\"", String::from_utf8_lossy(binding.userid().value())), binding.certifications, sig, lookup_fn, - verify_userid_binding, userid_binding_hash, + verify_userid_binding, hash_userid_binding, binding.userid()); check_one_3rd_party!( format!("userid \"{}\"", String::from_utf8_lossy(binding.userid().value())), binding.other_revocations, sig, lookup_fn, - verify_userid_revocation, userid_binding_hash, + verify_userid_revocation, hash_userid_binding, binding.userid()); } @@ -1606,13 +1606,13 @@ impl Cert { check_one_3rd_party!( "user attribute", binding.certifications, sig, lookup_fn, - verify_user_attribute_binding, user_attribute_binding_hash, + verify_user_attribute_binding, hash_user_attribute_binding, binding.user_attribute()); check_one_3rd_party!( "user attribute", binding.other_revocations, sig, lookup_fn, verify_user_attribute_revocation, - user_attribute_binding_hash, + hash_user_attribute_binding, binding.user_attribute()); } @@ -1626,12 +1626,12 @@ impl Cert { check_one_3rd_party!( format!("subkey {}", binding.key().keyid()), binding.certifications, sig, lookup_fn, - verify_subkey_binding, subkey_binding_hash, + verify_subkey_binding, hash_subkey_binding, binding.key()); check_one_3rd_party!( format!("subkey {}", binding.key().keyid()), binding.other_revocations, sig, lookup_fn, - verify_subkey_revocation, subkey_binding_hash, + verify_subkey_revocation, hash_subkey_binding, binding.key()); } diff --git a/openpgp/src/crypto/hash.rs b/openpgp/src/crypto/hash.rs index d1a12236..f97d05ce 100644 --- a/openpgp/src/crypto/hash.rs +++ b/openpgp/src/crypto/hash.rs @@ -353,7 +353,7 @@ impl Hash for signature::Builder { /// Hashing-related functionality. impl Signature { /// Computes the message digest of standalone signatures. - pub fn standalone_hash<'a, S>(sig: S) -> Result> + pub fn hash_standalone<'a, S>(sig: S) -> Result> where S: Into<&'a signature::Builder> { let sig = sig.into(); @@ -367,15 +367,15 @@ impl Signature { } /// Computes the message digest of timestamp signatures. - pub fn timestamp_hash<'a, S>(sig: S) -> Result> + pub fn hash_timestamp<'a, S>(sig: S) -> Result> where S: Into<&'a signature::Builder> { - Self::standalone_hash(sig) + Self::hash_standalone(sig) } /// Returns the message digest of the primary key binding over the /// specified primary key. - pub fn primary_key_binding_hash<'a, S>(sig: S, key: &key::PublicKey) + pub fn hash_primary_key_binding<'a, S>(sig: S, key: &key::PublicKey) -> Result> where S: Into<&'a signature::Builder> { @@ -393,7 +393,7 @@ impl Signature { /// Returns the message digest of the subkey binding over the /// specified primary key and subkey. - pub fn subkey_binding_hash<'a, P, S>(sig: S, + pub fn hash_subkey_binding<'a, P, S>(sig: S, key: &key::PublicKey, subkey: &Key) -> Result> @@ -415,7 +415,7 @@ impl Signature { /// Returns the message digest of the user ID binding over the /// specified primary key, user ID, and signature. - pub fn userid_binding_hash<'a, S>(sig: S, + pub fn hash_userid_binding<'a, S>(sig: S, key: &key::PublicKey, userid: &UserID) -> Result> @@ -435,7 +435,7 @@ impl Signature { /// Returns the message digest of the user attribute binding over /// the specified primary key, user attribute, and signature. - pub fn user_attribute_binding_hash<'a, S>(sig: S, + pub fn hash_user_attribute_binding<'a, S>(sig: S, key: &key::PublicKey, ua: &UserAttribute) -> Result> @@ -467,7 +467,7 @@ mod test { let mut userid_sigs = 0; for (i, binding) in cert.userids().enumerate() { for selfsig in binding.self_signatures() { - let h = Signature::userid_binding_hash( + let h = Signature::hash_userid_binding( selfsig, cert.primary(), binding.userid()).unwrap(); @@ -483,7 +483,7 @@ mod test { let mut ua_sigs = 0; for (i, binding) in cert.user_attributes().enumerate() { for selfsig in binding.self_signatures() { - let h = Signature::user_attribute_binding_hash( + let h = Signature::hash_user_attribute_binding( selfsig, cert.primary(), binding.user_attribute()).unwrap(); @@ -499,7 +499,7 @@ mod test { let mut subkey_sigs = 0; for (i, binding) in cert.subkeys().enumerate() { for selfsig in binding.self_signatures() { - let h = Signature::subkey_binding_hash( + let h = Signature::hash_subkey_binding( selfsig, cert.primary(), binding.key()).unwrap(); diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs index 20336f17..2bd4d171 100644 --- a/openpgp/src/packet/signature/mod.rs +++ b/openpgp/src/packet/signature/mod.rs @@ -142,7 +142,7 @@ impl Builder { -> Result { self.pk_algo = signer.public().pk_algo(); - let digest = Signature::standalone_hash(&self)?; + let digest = Signature::hash_standalone(&self)?; self.sign(signer, digest) } @@ -154,7 +154,7 @@ impl Builder { -> Result { self.pk_algo = signer.public().pk_algo(); - let digest = Signature::timestamp_hash(&self)?; + let digest = Signature::hash_timestamp(&self)?; self.sign(signer, digest) } @@ -167,7 +167,7 @@ impl Builder { { self.pk_algo = signer.public().pk_algo(); let digest = - Signature::primary_key_binding_hash(&self, + Signature::hash_primary_key_binding(&self, signer.public() .mark_role_primary_ref())?; @@ -184,7 +184,7 @@ impl Builder { -> Result { self.pk_algo = signer.public().pk_algo(); - let digest = Signature::userid_binding_hash(&self, key, userid)?; + let digest = Signature::hash_userid_binding(&self, key, userid)?; self.sign(signer, digest) } @@ -200,7 +200,7 @@ impl Builder { where P: key:: KeyParts { self.pk_algo = signer.public().pk_algo(); - let digest = Signature::subkey_binding_hash(&self, primary, subkey)?; + let digest = Signature::hash_subkey_binding(&self, primary, subkey)?; self.sign(signer, digest) } @@ -216,7 +216,7 @@ impl Builder { { self.pk_algo = signer.public().pk_algo(); let digest = - Signature::user_attribute_binding_hash(&self, key, ua)?; + Signature::hash_user_attribute_binding(&self, key, ua)?; self.sign(signer, digest) } @@ -733,7 +733,7 @@ impl Signature4 { // Standalone signatures are like binary-signatures over the // zero-sized string. - let digest = Signature::standalone_hash(self)?; + let digest = Signature::hash_standalone(self)?; self.verify_digest(key, &digest[..]) } @@ -758,7 +758,7 @@ impl Signature4 { // Timestamp signatures are like binary-signatures over the // zero-sized string. - let digest = Signature::timestamp_hash(self)?; + let digest = Signature::hash_timestamp(self)?; self.verify_digest(key, &digest[..]) } @@ -789,7 +789,7 @@ impl Signature4 { return Err(Error::UnsupportedSignatureType(self.typ()).into()); } - let hash = Signature::primary_key_binding_hash(self, pk)?; + let hash = Signature::hash_primary_key_binding(self, pk)?; self.verify_digest(signer, &hash[..]) } @@ -820,7 +820,7 @@ impl Signature4 { return Err(Error::UnsupportedSignatureType(self.typ()).into()); } - let hash = Signature::primary_key_binding_hash(self, pk)?; + let hash = Signature::hash_primary_key_binding(self, pk)?; self.verify_digest(signer, &hash[..]) } @@ -857,7 +857,7 @@ impl Signature4 { return Err(Error::UnsupportedSignatureType(self.typ()).into()); } - let hash = Signature::subkey_binding_hash(self, pk, subkey)?; + let hash = Signature::hash_subkey_binding(self, pk, subkey)?; if self.verify_digest(signer, &hash[..])? { // The signature is good, but we may still need to verify // the back sig. @@ -878,7 +878,7 @@ impl Signature4 { return Err(Error::UnsupportedSignatureType(self.typ()).into()); } else { // We can't use backsig.verify_subkey_binding. - let hash = Signature::subkey_binding_hash(&backsig, pk, subkey)?; + let hash = Signature::hash_subkey_binding(&backsig, pk, subkey)?; match backsig.verify_digest(subkey.mark_role_unspecified_ref(), &hash[..]) { @@ -937,7 +937,7 @@ impl Signature4 { return Err(Error::UnsupportedSignatureType(self.typ()).into()); } - let hash = Signature::subkey_binding_hash(self, pk, subkey)?; + let hash = Signature::hash_subkey_binding(self, pk, subkey)?; self.verify_digest(signer, &hash[..]) } @@ -972,7 +972,7 @@ impl Signature4 { return Err(Error::UnsupportedSignatureType(self.typ()).into()); } - let hash = Signature::userid_binding_hash(self, pk, userid)?; + let hash = Signature::hash_userid_binding(self, pk, userid)?; self.verify_digest(signer, &hash[..]) } @@ -1004,7 +1004,7 @@ impl Signature4 { return Err(Error::UnsupportedSignatureType(self.typ()).into()); } - let hash = Signature::userid_binding_hash(self, pk, userid)?; + let hash = Signature::hash_userid_binding(self, pk, userid)?; self.verify_digest(signer, &hash[..]) } @@ -1039,7 +1039,7 @@ impl Signature4 { return Err(Error::UnsupportedSignatureType(self.typ()).into()); } - let hash = Signature::user_attribute_binding_hash(self, pk, ua)?; + let hash = Signature::hash_user_attribute_binding(self, pk, ua)?; self.verify_digest(signer, &hash[..]) } @@ -1071,7 +1071,7 @@ impl Signature4 { return Err(Error::UnsupportedSignatureType(self.typ()).into()); } - let hash = Signature::user_attribute_binding_hash(self, pk, ua)?; + let hash = Signature::hash_user_attribute_binding(self, pk, ua)?; self.verify_digest(signer, &hash[..]) } @@ -1491,7 +1491,7 @@ mod test { let p = Packet::from_bytes(crate::tests::file( "contrib/gnupg/timestamp-signature-by-alice.asc")).unwrap(); if let Packet::Signature(sig) = p { - let digest = Signature::standalone_hash(&sig).unwrap(); + let digest = Signature::hash_standalone(&sig).unwrap(); eprintln!("{}", crate::fmt::hex::encode(&digest)); assert!(sig.verify_timestamp(alpha.primary()).unwrap()); } else { -- cgit v1.2.3