summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet/mdc.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2019-12-13 15:35:57 +0100
committerJustus Winter <justus@sequoia-pgp.org>2019-12-13 16:37:02 +0100
commit2dde931854b779562777b8946aa619c86fc821db (patch)
tree6060307277a7e4e0dc58f87f6b97c1b19f3bea0e /openpgp/src/packet/mdc.rs
parent5bef82801ced8f754552110959ad6fcfcf94c7ac (diff)
openpgp: Likewise for MDC.
Diffstat (limited to 'openpgp/src/packet/mdc.rs')
-rw-r--r--openpgp/src/packet/mdc.rs31
1 files changed, 15 insertions, 16 deletions
diff --git a/openpgp/src/packet/mdc.rs b/openpgp/src/packet/mdc.rs
index d6628479..9b64190c 100644
--- a/openpgp/src/packet/mdc.rs
+++ b/openpgp/src/packet/mdc.rs
@@ -13,39 +13,39 @@ pub struct MDC {
/// CTB packet header fields.
pub(crate) common: packet::Common,
/// Our SHA-1 hash.
- computed_hash: [u8; 20],
+ computed_digest: [u8; 20],
/// A 20-octet SHA-1 hash of the preceding plaintext data.
- hash: [u8; 20],
+ digest: [u8; 20],
}
impl MDC {
/// Creates an MDC packet.
- pub fn new(hash: [u8; 20], computed_hash: [u8; 20]) -> Self {
+ pub fn new(digest: [u8; 20], computed_digest: [u8; 20]) -> Self {
MDC {
common: Default::default(),
- computed_hash: computed_hash,
- hash: hash,
+ computed_digest,
+ digest,
}
}
/// Gets the packet's hash value.
- pub fn hash(&self) -> &[u8] {
- &self.hash[..]
+ pub fn digest(&self) -> &[u8] {
+ &self.digest[..]
}
/// Gets the computed hash value.
- pub fn computed_hash(&self) -> &[u8] {
- &self.computed_hash[..]
+ pub fn computed_digest(&self) -> &[u8] {
+ &self.computed_digest[..]
}
/// Returns whether the data protected by the MDC is valid.
pub fn valid(&self) -> bool {
- if self.hash == [ 0; 20 ] {
- // If the computed_hash and hash are uninitialized, then
+ if self.digest == [ 0; 20 ] {
+ // If the computed_digest and digest are uninitialized, then
// return false.
false
} else {
- self.computed_hash == self.hash
+ self.computed_digest == self.digest
}
}
}
@@ -57,12 +57,12 @@ impl From<MDC> for Packet {
}
impl From<[u8; 20]> for MDC {
- fn from(hash: [u8; 20]) -> Self {
+ fn from(digest: [u8; 20]) -> Self {
MDC {
common: Default::default(),
// All 0s.
- computed_hash: Default::default(),
- hash: hash,
+ computed_digest: Default::default(),
+ digest,
}
}
}
@@ -74,4 +74,3 @@ impl From<crypto::hash::Context> for MDC {
value.into()
}
}
-