diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2019-12-13 15:31:43 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2019-12-13 16:37:02 +0100 |
commit | 5bef82801ced8f754552110959ad6fcfcf94c7ac (patch) | |
tree | ed170b037b6d6a5b6aabba53746ca2862750ae99 | |
parent | 87f175aacd370e3bf8e1d736a51e3710f7142506 (diff) |
openpgp: Call the computed hash a digest.
-rw-r--r-- | openpgp/src/packet/signature/mod.rs | 20 | ||||
-rw-r--r-- | openpgp/src/parse/parse.rs | 16 |
2 files changed, 18 insertions, 18 deletions
diff --git a/openpgp/src/packet/signature/mod.rs b/openpgp/src/packet/signature/mod.rs index 35f55c8f..546ab349 100644 --- a/openpgp/src/packet/signature/mod.rs +++ b/openpgp/src/packet/signature/mod.rs @@ -275,7 +275,7 @@ impl Builder { fields: self, hash_prefix: [digest[0], digest[1]], mpis: mpis, - computed_hash: Some(digest), + computed_digest: Some(digest), level: 0, }.into()) } @@ -334,7 +334,7 @@ pub struct Signature4 { /// When used in conjunction with a one-pass signature, this is the /// hash computed over the enclosed message. - computed_hash: Option<Vec<u8>>, + computed_digest: Option<Vec<u8>>, /// Signature level. /// @@ -366,8 +366,8 @@ impl fmt::Debug for Signature4 { .field("unhashed_area", self.unhashed_area()) .field("hash_prefix", &crate::fmt::to_hex(&self.hash_prefix, false)) - .field("computed_hash", - &if let Some(ref hash) = self.computed_hash { + .field("computed_digest", + &if let Some(ref hash) = self.computed_digest { Some(crate::fmt::to_hex(&hash[..], false)) } else { None @@ -435,7 +435,7 @@ impl Signature4 { }, hash_prefix: hash_prefix, mpis: mpis, - computed_hash: None, + computed_digest: None, level: 0, } } @@ -461,15 +461,15 @@ impl Signature4 { } /// Gets the computed hash value. - pub fn computed_hash(&self) -> Option<&[u8]> { - self.computed_hash.as_ref().map(|d| &d[..]) + pub fn computed_digest(&self) -> Option<&[u8]> { + self.computed_digest.as_ref().map(|d| &d[..]) } /// Sets the computed hash value. - pub(crate) fn set_computed_hash(&mut self, hash: Option<Vec<u8>>) + pub(crate) fn set_computed_digest(&mut self, hash: Option<Vec<u8>>) -> Option<Vec<u8>> { - ::std::mem::replace(&mut self.computed_hash, hash) + ::std::mem::replace(&mut self.computed_digest, hash) } /// Gets the signature level. @@ -702,7 +702,7 @@ impl Signature4 { return Err(Error::UnsupportedSignatureType(self.typ()).into()); } - if let Some(ref hash) = self.computed_hash { + if let Some(ref hash) = self.computed_digest { self.verify_digest(key, hash) } else { Err(Error::BadSignature("Hash not computed.".to_string()).into()) diff --git a/openpgp/src/parse/parse.rs b/openpgp/src/parse/parse.rs index db591304..202041ba 100644 --- a/openpgp/src/parse/parse.rs +++ b/openpgp/src/parse/parse.rs @@ -1026,7 +1026,7 @@ impl Signature4 { // Locate the corresponding HashedReader and extract the // computed hash. - let mut computed_hash = None; + let mut computed_digest = None; { let recursion_depth = pp.recursion_depth(); @@ -1057,8 +1057,8 @@ impl Signature4 { }) { t!("popped a {:?} HashedReader", hash_algo); - computed_hash = Some((cookie.signature_level(), - hash.clone())); + computed_digest = Some((cookie.signature_level(), + hash.clone())); } if cookie.sig_group_unused() { @@ -1072,14 +1072,14 @@ impl Signature4 { } } - if let Some((level, mut hash)) = computed_hash { + if let Some((level, mut hash)) = computed_digest { if let Packet::Signature(ref mut sig) = pp.packet { sig.hash(&mut hash); let mut digest = vec![0u8; hash.digest_size()]; hash.digest(&mut digest); - sig.set_computed_hash(Some(digest)); + sig.set_computed_digest(Some(digest)); sig.set_level(level); } else { unreachable!() @@ -1388,12 +1388,12 @@ fn one_pass_sig_test () { crate::fmt::to_hex(&test.hash_prefix[sigs][..], false), crate::fmt::to_hex(sig.hash_prefix(), false)); eprintln!(" computed hash: {}", - crate::fmt::to_hex(&sig.computed_hash().unwrap(), - false)); + crate::fmt::to_hex(&sig.computed_digest().unwrap(), + false)); assert_eq!(&test.hash_prefix[sigs], sig.hash_prefix()); assert_eq!(&test.hash_prefix[sigs][..], - &sig.computed_hash().unwrap()[..2]); + &sig.computed_digest().unwrap()[..2]); sigs += 1; } else if one_pass_sigs > 0 { |