summaryrefslogtreecommitdiffstats
path: root/openpgp/src/packet/aed.rs
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2020-01-03 17:41:02 +0100
committerJustus Winter <justus@sequoia-pgp.org>2020-01-08 12:03:40 +0100
commit3218b24f3537f872f79081d01c0ad5e2f6871195 (patch)
treee0cac4ec3fb254de88fc2564555f261321397842 /openpgp/src/packet/aed.rs
parent245fa8ddb2d3ac2fa03cd67434c0f61349c64ce2 (diff)
openpgp: Explicitly implement PartialEq, Hash for packets.
- We explicitly exclude the common fields. - See #92.
Diffstat (limited to 'openpgp/src/packet/aed.rs')
-rw-r--r--openpgp/src/packet/aed.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/openpgp/src/packet/aed.rs b/openpgp/src/packet/aed.rs
index dffd654c..a8d1bfa0 100644
--- a/openpgp/src/packet/aed.rs
+++ b/openpgp/src/packet/aed.rs
@@ -15,7 +15,7 @@ use crate::Result;
/// of RFC 4880bis] for details.
///
/// [Section 5.16 of RFC 4880bis]: https://tools.ietf.org/html/draft-ietf-openpgp-rfc4880bis-05#section-5.16
-#[derive(PartialEq, Eq, Hash, Clone, Debug)]
+#[derive(Clone, Debug)]
pub struct AED1 {
/// CTB packet header fields.
pub(crate) common: packet::Common,
@@ -32,6 +32,28 @@ pub struct AED1 {
container: packet::Container,
}
+impl PartialEq for AED1 {
+ fn eq(&self, other: &AED1) -> bool {
+ self.sym_algo == other.sym_algo
+ && self.aead == other.aead
+ && self.chunk_size == other.chunk_size
+ && self.iv == other.iv
+ && self.container == other.container
+ }
+}
+
+impl Eq for AED1 {}
+
+impl std::hash::Hash for AED1 {
+ fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
+ std::hash::Hash::hash(&self.sym_algo, state);
+ std::hash::Hash::hash(&self.aead, state);
+ std::hash::Hash::hash(&self.chunk_size, state);
+ std::hash::Hash::hash(&self.iv, state);
+ std::hash::Hash::hash(&self.container, state);
+ }
+}
+
impl AED1 {
/// Creates a new AED1 object.
pub fn new(sym_algo: SymmetricAlgorithm,