sequoia_openpgp/packet/seip.rs
1//! Symmetrically Encrypted Integrity Protected data packets.
2//!
3//! An encrypted data packet is a container. See [Section 5.13 of RFC
4//! 9580] for details.
5//!
6//! [Section 5.13 of RFC 9580]: https://www.rfc-editor.org/rfc/rfc9580.html#section-5.13
7
8use crate::packet;
9use crate::Packet;
10
11mod v2;
12pub use v2::*;
13
14/// Holds an encrypted data packet.
15///
16/// An encrypted data packet is a container. See [Section 5.13 of RFC
17/// 9580] for details.
18///
19/// [Section 5.13 of RFC 9580]: https://www.rfc-editor.org/rfc/rfc9580.html#section-5.13
20///
21/// # A note on equality
22///
23/// An unprocessed (encrypted) `SEIP` packet is never considered equal
24/// to a processed (decrypted) one. Likewise, a processed (decrypted)
25/// packet is never considered equal to a structured (parsed) one.
26// IMPORTANT: If you add fields to this struct, you need to explicitly
27// IMPORTANT: implement PartialEq, Eq, and Hash.
28#[derive(Clone, Debug, PartialEq, Eq, Hash)]
29pub struct SEIP1 {
30 /// CTB packet header fields.
31 pub(crate) common: packet::Common,
32
33 /// This is a container packet.
34 container: packet::Container,
35}
36
37assert_send_and_sync!(SEIP1);
38
39impl SEIP1 {
40 /// Creates a new SEIP1 packet.
41 pub fn new() -> Self {
42 Self {
43 common: Default::default(),
44 container: Default::default(),
45 }
46 }
47}
48
49impl_processed_body_forwards!(SEIP1);
50
51impl From<SEIP1> for super::SEIP {
52 fn from(p: SEIP1) -> Self {
53 super::SEIP::V1(p)
54 }
55}
56
57impl From<SEIP1> for Packet {
58 fn from(s: SEIP1) -> Self {
59 Packet::SEIP(s.into())
60 }
61}