1 //! Symmetrically Encrypted Integrity Protected data packets. 2 //! 3 //! An encrypted data packet is a container. See [Section 5.13 of RFC 4 //! 4880] for details. 5 //! 6 //! [Section 5.13 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.13 7 8 use crate::packet; 9 use crate::Packet; 10 11 /// Holds an encrypted data packet. 12 /// 13 /// An encrypted data packet is a container. See [Section 5.13 of RFC 14 /// 4880] for details. 15 /// 16 /// [Section 5.13 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-5.13 17 /// 18 /// # A note on equality 19 /// 20 /// An unprocessed (encrypted) `SEIP` packet is never considered equal 21 /// to a processed (decrypted) one. Likewise, a processed (decrypted) 22 /// packet is never considered equal to a structured (parsed) one. 23 // IMPORTANT: If you add fields to this struct, you need to explicitly 24 // IMPORTANT: implement PartialEq, Eq, and Hash. 25 #[derive(Clone, Debug, PartialEq, Eq, Hash)] 26 pub struct SEIP1 { 27 /// CTB packet header fields. 28 pub(crate) common: packet::Common, 29 30 /// This is a container packet. 31 container: packet::Container, 32 } 33 34 impl std::ops::Deref for SEIP1 { 35 type Target = packet::Container; deref(&self) -> &Self::Target36 fn deref(&self) -> &Self::Target { 37 &self.container 38 } 39 } 40 41 impl std::ops::DerefMut for SEIP1 { deref_mut(&mut self) -> &mut Self::Target42 fn deref_mut(&mut self) -> &mut Self::Target { 43 &mut self.container 44 } 45 } 46 47 impl SEIP1 { 48 /// Creates a new SEIP1 packet. new() -> Self49 pub fn new() -> Self { 50 Self { 51 common: Default::default(), 52 container: Default::default(), 53 } 54 } 55 } 56 57 impl From<SEIP1> for super::SEIP { from(p: SEIP1) -> Self58 fn from(p: SEIP1) -> Self { 59 super::SEIP::V1(p) 60 } 61 } 62 63 impl From<SEIP1> for Packet { from(s: SEIP1) -> Self64 fn from(s: SEIP1) -> Self { 65 Packet::SEIP(s.into()) 66 } 67 } 68