diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-01-03 17:41:02 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-01-08 12:03:40 +0100 |
commit | 3218b24f3537f872f79081d01c0ad5e2f6871195 (patch) | |
tree | e0cac4ec3fb254de88fc2564555f261321397842 /openpgp/src/packet/pkesk.rs | |
parent | 245fa8ddb2d3ac2fa03cd67434c0f61349c64ce2 (diff) |
openpgp: Explicitly implement PartialEq, Hash for packets.
- We explicitly exclude the common fields.
- See #92.
Diffstat (limited to 'openpgp/src/packet/pkesk.rs')
-rw-r--r-- | openpgp/src/packet/pkesk.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/openpgp/src/packet/pkesk.rs b/openpgp/src/packet/pkesk.rs index db88c215..5b2a9ae9 100644 --- a/openpgp/src/packet/pkesk.rs +++ b/openpgp/src/packet/pkesk.rs @@ -28,7 +28,7 @@ use crate::packet; /// [Section 5.1 of RFC 4880] for details. /// /// [Section 5.1 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.1 -#[derive(PartialEq, Eq, Hash, Clone, Debug)] +#[derive(Clone, Debug)] pub struct PKESK3 { /// CTB header fields. pub(crate) common: packet::Common, @@ -40,6 +40,24 @@ pub struct PKESK3 { esk: Ciphertext, } +impl PartialEq for PKESK3 { + fn eq(&self, other: &PKESK3) -> bool { + self.recipient == other.recipient + && self.pk_algo == other.pk_algo + && self.esk == other.esk + } +} + +impl Eq for PKESK3 {} + +impl std::hash::Hash for PKESK3 { + fn hash<H: std::hash::Hasher>(&self, state: &mut H) { + std::hash::Hash::hash(&self.recipient, state); + std::hash::Hash::hash(&self.pk_algo, state); + std::hash::Hash::hash(&self.esk, state); + } +} + impl PKESK3 { /// Creates a new PKESK3 packet. pub fn new(recipient: KeyID, pk_algo: PublicKeyAlgorithm, |