summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <justus@sequoia-pgp.org>2023-08-22 10:06:24 +0200
committerJustus Winter <justus@sequoia-pgp.org>2023-08-22 10:31:11 +0200
commita4dc34fc6574fa333067bdafe772071240e688ed (patch)
treee23c86e8870da83d8f276605ae20e7f095296fc6
parent4a7ae04f150f5687f89ea182147f01765e39ac29 (diff)
openpgp: Rename the MDC feature to SEIPDv1.
-rw-r--r--openpgp/NEWS3
-rw-r--r--openpgp/src/cert.rs6
-rw-r--r--openpgp/src/cert/builder.rs4
-rw-r--r--openpgp/src/packet/signature/subpacket.rs6
-rw-r--r--openpgp/src/types/features.rs68
5 files changed, 55 insertions, 32 deletions
diff --git a/openpgp/NEWS b/openpgp/NEWS
index 60db1dd3..4b24313f 100644
--- a/openpgp/NEWS
+++ b/openpgp/NEWS
@@ -6,6 +6,9 @@
* Changes in 1.17.0
** New functionality
- types::AEADAlgorithm::GCM
+ - types::Features::{clear,set,supports}_seipdv1
+** Deprecated functionality
+ - types::Features::{clear,set,supports}_mdc
* Changes in 1.16.0
** New functionality
- Add KeyFlags::set_certification_to.
diff --git a/openpgp/src/cert.rs b/openpgp/src/cert.rs
index 819b9245..8f421913 100644
--- a/openpgp/src/cert.rs
+++ b/openpgp/src/cert.rs
@@ -6543,7 +6543,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g=
// Some(KeyServerPreferences::new(&[])));
assert_eq!(userid.features(),
- Some(Features::new(&[]).set_mdc()));
+ Some(Features::new(&[]).set_seipdv1()));
} else {
panic!("two user ids");
}
@@ -6572,7 +6572,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g=
Some(KeyServerPreferences::new(&[0x80])));
assert_eq!(userid.features(),
- Some(Features::new(&[]).set_mdc()));
+ Some(Features::new(&[]).set_seipdv1()));
// Using the certificate should choose the primary user
// id, which is this one (because it is lexicographically
@@ -6618,7 +6618,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g=
Some(KeyServerPreferences::new(&[0x80])));
assert_eq!(userid.features(),
- Some(Features::new(&[]).set_mdc()));
+ Some(Features::new(&[]).set_seipdv1()));
} else {
panic!("two user ids");
}
diff --git a/openpgp/src/cert/builder.rs b/openpgp/src/cert/builder.rs
index 3060627c..4704667b 100644
--- a/openpgp/src/cert/builder.rs
+++ b/openpgp/src/cert/builder.rs
@@ -1592,7 +1592,7 @@ mod tests {
let sig =
cert.primary_key().with_policy(p, None).unwrap().binding_signature();
assert_eq!(sig.typ(), crate::types::SignatureType::DirectKey);
- assert!(sig.features().unwrap().supports_mdc());
+ assert!(sig.features().unwrap().supports_seipdv1());
}
#[test]
@@ -1625,7 +1625,7 @@ mod tests {
PublicKeyAlgorithm::EdDSA);
assert!(cert1.subkeys().next().is_none());
assert!(cert1.with_policy(p, None).unwrap().primary_userid().unwrap()
- .binding_signature().features().unwrap().supports_mdc());
+ .binding_signature().features().unwrap().supports_seipdv1());
}
#[test]
diff --git a/openpgp/src/packet/signature/subpacket.rs b/openpgp/src/packet/signature/subpacket.rs
index 22a844dc..3d324fb0 100644
--- a/openpgp/src/packet/signature/subpacket.rs
+++ b/openpgp/src/packet/signature/subpacket.rs
@@ -7278,7 +7278,7 @@ fn accessors() {
assert_eq!(sig_.reason_for_revocation(),
Some((ReasonForRevocation::KeyRetired, &b"foobar"[..])));
- let feats = Features::empty().set_mdc();
+ let feats = Features::empty().set_seipdv1();
sig = sig.set_features(feats.clone()).unwrap();
let sig_ =
sig.clone().sign_hash(&mut keypair, hash.clone()).unwrap();
@@ -7568,13 +7568,13 @@ fn subpacket_test_2() {
authenticated: false,
}));
- assert_eq!(sig.features().unwrap(), Features::empty().set_mdc());
+ assert_eq!(sig.features().unwrap(), Features::empty().set_seipdv1());
assert_eq!(sig.subpacket(SubpacketTag::Features),
Some(&Subpacket {
length: 2.into(),
critical: false,
value: SubpacketValue::Features(
- Features::empty().set_mdc()),
+ Features::empty().set_seipdv1()),
authenticated: false,
}));
diff --git a/openpgp/src/types/features.rs b/openpgp/src/types/features.rs
index caac3cd2..ebda6821 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() {
match i {
- FEATURE_FLAG_MDC => (),
+ FEATURE_FLAG_SEIPDV1 => (),
FEATURE_FLAG_AEAD => (),
i => {
if need_comma { f.write_str(", ")?; }
@@ -114,7 +114,8 @@ impl Features {
pub fn sequoia() -> Self {
let v : [u8; 1] = [ 0 ];
- Self::new(&v[..]).set_mdc()
+ Self::new(&v[..])
+ .set_seipdv1()
}
/// Compares two feature sets for semantic equality.
@@ -168,7 +169,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(()) }
/// ```
@@ -194,7 +195,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(()) }
/// ```
@@ -220,7 +221,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(()) }
/// ```
@@ -228,7 +229,7 @@ impl Features {
Self(self.0.clear(bit))
}
- /// Returns whether the MDC feature flag is set.
+ /// Returns whether the SEIPDv1 feature flag is set.
///
/// # Examples
///
@@ -240,14 +241,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
///
@@ -257,17 +264,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
///
@@ -278,14 +291,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.
@@ -349,8 +368,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).
@@ -442,7 +462,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));
@@ -452,7 +472,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));