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 17:00:49 +0200
commitb6a685c722a7922b528753ca0b1ee1de305e59a9 (patch)
tree0072d8f4855e3d95fa6dd1812ed7592ca3dbfaa3
parentc9aa8f586ee339adbe3baa3f8da63491e3b1bd13 (diff)
openpgp: Rename the MDC feature to SEIPDv1.
-rw-r--r--openpgp/NEWS6
-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, 58 insertions, 32 deletions
diff --git a/openpgp/NEWS b/openpgp/NEWS
index e156a64f..5af5cdd1 100644
--- a/openpgp/NEWS
+++ b/openpgp/NEWS
@@ -36,6 +36,9 @@
- parse::PacketParserBuilder::automatic_hashing
- types::AEADAlgorithm::GCM
- types::Bitfield
+ - types::Features::clear_seipdv1
+ - types::Features::set_seipdv1
+ - types::Features::supports_seipdv1
- types::Features::as_bitfield
- types::KeyFlags::as_bitfield
- types::KeyServerPreferences::as_bitfield
@@ -46,6 +49,9 @@
- packet::signature::subpacket::SubpacketTag::PreferredAEADAlgorithms
- packet::signature::subpacket::SubpacketValue::PreferredAEADAlgorithms
- types::Curve::len, use types::Curve::bits instead
+ - types::Features::clear_mdc
+ - types::Features::set_mdc
+ - types::Features::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 f1f233da..fd5f5d0d 100644
--- a/openpgp/src/cert.rs
+++ b/openpgp/src/cert.rs
@@ -6547,7 +6547,7 @@ Pu1xwz57O4zo1VYf6TqHJzVC3OMvMUM2hhdecMUe5x6GorNaj6g=
// Some(KeyServerPreferences::new(&[])));
assert_eq!(userid.features(),
- Some(Features::new(&[]).set_mdc()));
+ Some(Features::new(&[]).set_seipdv1()));
} else {
panic!("two user ids");
}
@@ -6578,7 +6578,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
@@ -6628,7 +6628,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 43a27aab..c8477c95 100644
--- a/openpgp/src/cert/builder.rs
+++ b/openpgp/src/cert/builder.rs
@@ -1602,7 +1602,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]
@@ -1635,7 +1635,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 cbba8454..d88a6b72 100644
--- a/openpgp/src/packet/signature/subpacket.rs
+++ b/openpgp/src/packet/signature/subpacket.rs
@@ -7290,7 +7290,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();
@@ -7584,13 +7584,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 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));