diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2023-08-22 10:06:24 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2023-08-22 17:00:49 +0200 |
commit | b6a685c722a7922b528753ca0b1ee1de305e59a9 (patch) | |
tree | 0072d8f4855e3d95fa6dd1812ed7592ca3dbfaa3 /openpgp/src/types | |
parent | c9aa8f586ee339adbe3baa3f8da63491e3b1bd13 (diff) |
openpgp: Rename the MDC feature to SEIPDv1.
Diffstat (limited to 'openpgp/src/types')
-rw-r--r-- | openpgp/src/types/features.rs | 68 |
1 files changed, 44 insertions, 24 deletions
diff --git a/openpgp/src/types/features.rs b/openpgp/src/types/features.rs index 28fcfba8..4d165197 100644 --- a/openpgp/src/types/features.rs +++ b/openpgp/src/types/features.rs @@ -43,7 +43,7 @@ use crate::types::Bitfield; /// match cert.with_policy(p, None)?.primary_userid()?.features() { /// Some(features) => { /// println!("Certificate holder's supported features:"); -/// assert!(features.supports_mdc()); +/// assert!(features.supports_seipdv1()); /// assert!(!features.supports_aead()); /// } /// None => { @@ -61,8 +61,8 @@ impl fmt::Debug for Features { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // Print known features first. let mut need_comma = false; - if self.supports_mdc() { - f.write_str("MDC")?; + if self.supports_seipdv1() { + f.write_str("SEIPDv1")?; need_comma = true; } if self.supports_aead() { @@ -74,7 +74,7 @@ impl fmt::Debug for Features { // Now print any unknown features. for i in self.0.iter_set() { match i { - FEATURE_FLAG_MDC => (), + FEATURE_FLAG_SEIPDV1 => (), FEATURE_FLAG_AEAD => (), i => { if need_comma { f.write_str(", ")?; } @@ -113,7 +113,8 @@ impl Features { pub fn sequoia() -> Self { let v : [u8; 1] = [ 0 ]; - Self::new(&v[..]).set_mdc() + Self::new(&v[..]) + .set_seipdv1() } /// Returns a reference to the underlying [`Bitfield`]. @@ -172,7 +173,7 @@ impl Features { /// assert!(! f.get(3)); /// assert!(! f.get(8)); /// assert!(! f.get(80)); - /// # assert!(f.supports_mdc()); + /// # assert!(f.supports_seipdv1()); /// # assert!(! f.supports_aead()); /// # Ok(()) } /// ``` @@ -198,7 +199,7 @@ impl Features { /// assert!(! f.get(1)); /// assert!(f.get(2)); /// assert!(! f.get(3)); - /// # assert!(f.supports_mdc()); + /// # assert!(f.supports_seipdv1()); /// # assert!(! f.supports_aead()); /// # Ok(()) } /// ``` @@ -226,7 +227,7 @@ impl Features { /// assert!(! f.get(1)); /// assert!(! f.get(2)); /// assert!(! f.get(3)); - /// # assert!(f.supports_mdc()); + /// # assert!(f.supports_seipdv1()); /// # assert!(! f.supports_aead()); /// # Ok(()) } /// ``` @@ -236,7 +237,7 @@ impl Features { self } - /// Returns whether the MDC feature flag is set. + /// Returns whether the SEIPDv1 feature flag is set. /// /// # Examples /// @@ -248,14 +249,20 @@ impl Features { /// # fn main() -> Result<()> { /// let f = Features::empty(); /// - /// assert!(! f.supports_mdc()); + /// assert!(! f.supports_seipdv1()); /// # Ok(()) } /// ``` + pub fn supports_seipdv1(&self) -> bool { + self.get(FEATURE_FLAG_SEIPDV1) + } + + /// Returns whether the MDC feature flag is set. + #[deprecated(note = "Use supports_seipdv1.")] pub fn supports_mdc(&self) -> bool { - self.get(FEATURE_FLAG_MDC) + self.supports_seipdv1() } - /// Sets the MDC feature flag. + /// Sets the SEIPDv1 feature flag. /// /// # Examples /// @@ -265,17 +272,23 @@ impl Features { /// use openpgp::types::Features; /// /// # fn main() -> Result<()> { - /// let f = Features::empty().set_mdc(); + /// let f = Features::empty().set_seipdv1(); /// - /// assert!(f.supports_mdc()); + /// assert!(f.supports_seipdv1()); /// # assert!(f.get(0)); /// # Ok(()) } /// ``` + pub fn set_seipdv1(self) -> Self { + self.set(FEATURE_FLAG_SEIPDV1) + } + + /// Sets the MDC feature flag. + #[deprecated(note = "Use set_seipdv1.")] pub fn set_mdc(self) -> Self { - self.set(FEATURE_FLAG_MDC) + self.set_seipdv1() } - /// Clears the MDC feature flag. + /// Clears the SEIPDv1 feature flag. /// /// # Examples /// @@ -286,14 +299,20 @@ impl Features { /// /// # fn main() -> Result<()> { /// let f = Features::new(&[0x1]); - /// assert!(f.supports_mdc()); + /// assert!(f.supports_seipdv1()); /// - /// let f = f.clear_mdc(); - /// assert!(! f.supports_mdc()); + /// let f = f.clear_seipdv1(); + /// assert!(! f.supports_seipdv1()); /// # Ok(()) } /// ``` + pub fn clear_seipdv1(self) -> Self { + self.clear(FEATURE_FLAG_SEIPDV1) + } + + /// Clears the MDC feature flag. + #[deprecated(note = "Use clear_seipdv1.")] pub fn clear_mdc(self) -> Self { - self.clear(FEATURE_FLAG_MDC) + self.clear_seipdv1() } /// Returns whether the AEAD feature flag is set. @@ -357,8 +376,9 @@ impl Features { } } -/// Modification Detection (packets 18 and 19). -const FEATURE_FLAG_MDC: usize = 0; +/// Symmetrically Encrypted and Integrity Protected Data packet +/// version 1. +const FEATURE_FLAG_SEIPDV1: usize = 0; /// AEAD Encrypted Data Packet (packet 20) and version 5 Symmetric-Key /// Encrypted Session Key Packets (packet 3). @@ -453,7 +473,7 @@ mod tests { #[test] fn known() { - let a = Features::empty().set_mdc(); + let a = Features::empty().set_seipdv1(); let b = Features::new(&[ 0x1 ]); assert_eq!(a, b); assert!(a.normalized_eq(&b)); @@ -463,7 +483,7 @@ mod tests { assert_eq!(a, b); assert!(a.normalized_eq(&b)); - let a = Features::empty().set_mdc().set_aead(); + let a = Features::empty().set_seipdv1().set_aead(); let b = Features::new(&[ 0x1 | 0x2 ]); assert_eq!(a, b); assert!(a.normalized_eq(&b)); |