summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWiktor Kwapisiewicz <wiktor@metacode.biz>2023-05-30 10:56:01 +0200
committerWiktor Kwapisiewicz <wiktor@metacode.biz>2023-06-14 09:13:29 +0200
commita060be6cbf29a00d085dc83b6c9f2730d98489f5 (patch)
treead26b01a7f1a3d24b4036e40b2e0bc9128c523c6
parent98952a4024e036e005e33d317d2ae1327ffc34fd (diff)
openpgp: Deprecate `Packet::MDC` variant.
- Crypto refresh changes MDC to not be a standalone packet but an implementation detail of the SEIPDv1 packet. - Adjust use-sites to allow for deprecations. - See https://gitlab.com/sequoia-pgp/sequoia/-/issues/860
-rw-r--r--autocrypt/src/lib.rs1
-rw-r--r--openpgp/src/packet/any.rs3
-rw-r--r--openpgp/src/packet/mdc.rs1
-rw-r--r--openpgp/src/packet/mod.rs7
-rw-r--r--openpgp/src/packet/unknown.rs1
-rw-r--r--openpgp/src/parse.rs4
-rw-r--r--openpgp/src/parse/stream.rs2
-rw-r--r--openpgp/src/serialize.rs3
-rw-r--r--openpgp/src/serialize/stream.rs2
9 files changed, 23 insertions, 1 deletions
diff --git a/autocrypt/src/lib.rs b/autocrypt/src/lib.rs
index e5fae326..d75649da 100644
--- a/autocrypt/src/lib.rs
+++ b/autocrypt/src/lib.rs
@@ -786,6 +786,7 @@ impl<'a> AutocryptSetupMessageParser<'a> {
// Get the MDC packet.
if let PacketParserResult::Some(pp) = ppr {
match pp.packet {
+ #[allow(deprecated)]
Packet::MDC(_) => (),
ref p => return
Err(Error::MalformedMessage(
diff --git a/openpgp/src/packet/any.rs b/openpgp/src/packet/any.rs
index 8af73eaf..31994e05 100644
--- a/openpgp/src/packet/any.rs
+++ b/openpgp/src/packet/any.rs
@@ -75,6 +75,7 @@ pub trait Any<T>: crate::seal::Sealed {
macro_rules! impl_downcast_for {
($typ: tt) => {
+ #[allow(deprecated)]
impl Any<$typ> for Packet {
fn downcast(self) -> std::result::Result<$typ, Packet> {
match self {
@@ -108,7 +109,7 @@ macro_rules! impl_downcasts {
///
/// Not visible outside this module, isn't supposed to be
/// called, this is a compile-time check.
- #[allow(unused)]
+ #[allow(unused, deprecated)]
fn check_exhaustion(p: Packet) {
match p {
$(Packet::$typ(_) => (),)*
diff --git a/openpgp/src/packet/mdc.rs b/openpgp/src/packet/mdc.rs
index 5c3544ca..b834d95e 100644
--- a/openpgp/src/packet/mdc.rs
+++ b/openpgp/src/packet/mdc.rs
@@ -77,6 +77,7 @@ impl MDC {
impl From<MDC> for Packet {
fn from(s: MDC) -> Self {
+ #[allow(deprecated)]
Packet::MDC(s)
}
}
diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs
index 1a3da9ab..8e72170d 100644
--- a/openpgp/src/packet/mod.rs
+++ b/openpgp/src/packet/mod.rs
@@ -273,6 +273,7 @@ pub enum Packet {
/// Symmetric key encrypted, integrity protected data packet.
SEIP(SEIP),
/// Modification detection code packet.
+ #[deprecated]
MDC(MDC),
/// AEAD Encrypted Data Packet.
AED(AED),
@@ -349,6 +350,7 @@ impl Packet {
Packet::PKESK(_) => Tag::PKESK,
Packet::SKESK(_) => Tag::SKESK,
Packet::SEIP(_) => Tag::SEIP,
+ #[allow(deprecated)]
Packet::MDC(_) => Tag::MDC,
Packet::AED(_) => Tag::AED,
}
@@ -391,6 +393,7 @@ impl Packet {
Packet::PKESK(p) => Some(p.version()),
Packet::SKESK(p) => Some(p.version()),
Packet::SEIP(p) => Some(p.version()),
+ #[allow(deprecated)]
Packet::MDC(_) => None,
Packet::AED(p) => Some(p.version()),
}
@@ -431,6 +434,7 @@ impl Packet {
Packet::PKESK(x) => Hash::hash(&x, state),
Packet::SKESK(x) => Hash::hash(&x, state),
Packet::SEIP(x) => Hash::hash(&x, state),
+ #[allow(deprecated)]
Packet::MDC(x) => Hash::hash(&x, state),
Packet::AED(x) => Hash::hash(&x, state),
Packet::Unknown(x) => Hash::hash(&x, state),
@@ -461,6 +465,7 @@ impl Deref for Packet {
Packet::SKESK(SKESK::V4(ref packet)) => &packet.common,
Packet::SKESK(SKESK::V5(ref packet)) => &packet.skesk4.common,
Packet::SEIP(ref packet) => &packet.common,
+ #[allow(deprecated)]
Packet::MDC(ref packet) => &packet.common,
Packet::AED(ref packet) => &packet.common,
}
@@ -487,6 +492,7 @@ impl DerefMut for Packet {
Packet::SKESK(SKESK::V4(ref mut packet)) => &mut packet.common,
Packet::SKESK(SKESK::V5(ref mut packet)) => &mut packet.skesk4.common,
Packet::SEIP(ref mut packet) => &mut packet.common,
+ #[allow(deprecated)]
Packet::MDC(ref mut packet) => &mut packet.common,
Packet::AED(ref mut packet) => &mut packet.common,
}
@@ -514,6 +520,7 @@ impl fmt::Debug for Packet {
PKESK(v) => write!(f, "PKESK({:?})", v),
SKESK(v) => write!(f, "SKESK({:?})", v),
SEIP(v) => write!(f, "SEIP({:?})", v),
+ #[allow(deprecated)]
MDC(v) => write!(f, "MDC({:?})", v),
AED(v) => write!(f, "AED({:?})", v),
}
diff --git a/openpgp/src/packet/unknown.rs b/openpgp/src/packet/unknown.rs
index 1302f407..e7d82afa 100644
--- a/openpgp/src/packet/unknown.rs
+++ b/openpgp/src/packet/unknown.rs
@@ -223,6 +223,7 @@ impl std::convert::TryFrom<Packet> for Unknown {
Packet::UserAttribute(v) => convert(tag, common, v),
Packet::PKESK(v) => convert(tag, common, v),
Packet::SKESK(v) => convert(tag, common, v),
+ #[allow(deprecated)]
Packet::MDC(v) => convert(tag, common, v),
// Here we can avoid copying the body.
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs
index 7c34f62b..d273eb44 100644
--- a/openpgp/src/parse.rs
+++ b/openpgp/src/parse.rs
@@ -321,6 +321,7 @@ macro_rules! impl_parse_with_buffered_reader {
pp.buffer_unread_content()?;
match pp.next()? {
+ #[allow(deprecated)]
(Packet::$typ(o), PacketParserResult::EOF(_))
=> Ok(o),
(p, PacketParserResult::EOF(_)) =>
@@ -2894,6 +2895,7 @@ impl MDC {
let mut digest: [u8; 20] = Default::default();
digest.copy_from_slice(&php_try!(php.parse_bytes("digest", 20)));
+ #[allow(deprecated)]
php.ok(Packet::MDC(MDC::new(digest, computed_digest)))
}
}
@@ -4813,6 +4815,7 @@ impl <'a> PacketParser<'a> {
}
},
// Packets that don't recurse.
+ #[allow(deprecated)]
Packet::Unknown(_) | Packet::Signature(_) | Packet::OnePassSig(_)
| Packet::PublicKey(_) | Packet::PublicSubkey(_)
| Packet::SecretKey(_) | Packet::SecretSubkey(_)
@@ -5742,6 +5745,7 @@ mod test {
decrypt_test_common(true);
}
+ #[allow(deprecated)]
fn decrypt_test_common(stream: bool) {
for test in DECRYPT_TESTS.iter() {
if !test.algo.is_supported() {
diff --git a/openpgp/src/parse/stream.rs b/openpgp/src/parse/stream.rs
index 7a188bc4..23466f20 100644
--- a/openpgp/src/parse/stream.rs
+++ b/openpgp/src/parse/stream.rs
@@ -2478,6 +2478,7 @@ impl<'a, H: VerificationHelper + DecryptionHelper> Decryptor<'a, H> {
return Ok(v);
},
+ #[allow(deprecated)]
Packet::MDC(ref mdc) => if ! mdc.valid() {
return Err(Error::ManipulatedMessage.into());
},
@@ -2672,6 +2673,7 @@ impl<'a, H: VerificationHelper + DecryptionHelper> Decryptor<'a, H> {
&& self.structure.expect_mdc_at(recursion_depth)
{
match &p {
+ #[allow(deprecated)]
Packet::MDC(mdc) if mdc.valid() =>
(), // Good.
_ => // Bad.
diff --git a/openpgp/src/serialize.rs b/openpgp/src/serialize.rs
index 531b3d35..f01197ef 100644
--- a/openpgp/src/serialize.rs
+++ b/openpgp/src/serialize.rs
@@ -2738,6 +2738,7 @@ impl Marshal for Packet {
Packet::PKESK(ref p) => p.serialize(o),
Packet::SKESK(ref p) => p.serialize(o),
Packet::SEIP(ref p) => p.serialize(o),
+ #[allow(deprecated)]
Packet::MDC(ref p) => p.serialize(o),
Packet::AED(ref p) => p.serialize(o),
}
@@ -2779,6 +2780,7 @@ impl Marshal for Packet {
Packet::PKESK(ref p) => p.export(o),
Packet::SKESK(ref p) => p.export(o),
Packet::SEIP(ref p) => p.export(o),
+ #[allow(deprecated)]
Packet::MDC(ref p) => p.export(o),
Packet::AED(ref p) => p.export(o),
}
@@ -2804,6 +2806,7 @@ impl NetLength for Packet {
Packet::PKESK(ref p) => p.net_len(),
Packet::SKESK(ref p) => p.net_len(),
Packet::SEIP(ref p) => p.net_len(),
+ #[allow(deprecated)]
Packet::MDC(ref p) => p.net_len(),
Packet::AED(ref p) => p.net_len(),
}
diff --git a/openpgp/src/serialize/stream.rs b/openpgp/src/serialize/stream.rs
index 24e4b165..5990fd35 100644
--- a/openpgp/src/serialize/stream.rs
+++ b/openpgp/src/serialize/stream.rs
@@ -2960,6 +2960,7 @@ impl<'a> Encryptor<'a> {
BodyLength::Full(20).serialize(&mut header)?;
self.hash.update(&header);
+ #[allow(deprecated)]
Packet::MDC(MDC::from(self.hash.clone())).serialize(&mut w)?;
// Now recover the original writer. First, strip the
@@ -3341,6 +3342,7 @@ mod test {
},
// Look for the MDC packet.
+ #[allow(deprecated)]
State::MDC =>
if let Packet::MDC(ref mdc) = pp.packet {
assert_eq!(mdc.digest(), mdc.computed_digest());