summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ffi/src/error.rs2
-rw-r--r--ipc/src/keygrip.rs2
-rw-r--r--ipc/src/sexp.rs2
-rw-r--r--openpgp-ffi/src/error.rs2
-rw-r--r--openpgp/src/crypto/backend/cng/ecdh.rs2
-rw-r--r--openpgp/src/crypto/backend/nettle/ecdh.rs2
-rw-r--r--openpgp/src/crypto/backend/nettle/hash.rs3
-rw-r--r--openpgp/src/crypto/backend/nettle/symmetric.rs3
-rw-r--r--openpgp/src/crypto/hash.rs1
-rw-r--r--openpgp/src/crypto/mpi.rs31
-rw-r--r--openpgp/src/crypto/s2k.rs9
-rw-r--r--openpgp/src/fingerprint.rs7
-rw-r--r--openpgp/src/keyid.rs11
-rw-r--r--openpgp/src/lib.rs5
-rw-r--r--openpgp/src/message/lexer.rs5
-rw-r--r--openpgp/src/message/mod.rs6
-rw-r--r--openpgp/src/packet/mod.rs75
-rw-r--r--openpgp/src/packet/signature.rs2
-rw-r--r--openpgp/src/packet/signature/subpacket.rs23
-rw-r--r--openpgp/src/packet/skesk.rs1
-rw-r--r--openpgp/src/parse.rs4
-rw-r--r--openpgp/src/parse/mpis.rs8
-rw-r--r--openpgp/src/policy.rs7
-rw-r--r--openpgp/src/serialize.rs52
-rw-r--r--openpgp/src/types/mod.rs71
-rw-r--r--sq/src/commands/dump.rs31
26 files changed, 60 insertions, 307 deletions
diff --git a/ffi/src/error.rs b/ffi/src/error.rs
index 935d4515..7ca484d1 100644
--- a/ffi/src/error.rs
+++ b/ffi/src/error.rs
@@ -79,7 +79,7 @@ impl<'a> FromSequoiaError<'a> for Status {
Status::InvalidKey,
&openpgp::Error::PolicyViolation(_, _) =>
Status::PolicyViolation,
- openpgp::Error::__Nonexhaustive => unreachable!(),
+ &_ => unreachable!(), // openpgp::Error is non-exhaustive.
}
}
diff --git a/ipc/src/keygrip.rs b/ipc/src/keygrip.rs
index c6d01eeb..148c11d7 100644
--- a/ipc/src/keygrip.rs
+++ b/ipc/src/keygrip.rs
@@ -174,7 +174,7 @@ impl Keygrip {
"Keygrip not defined for this kind of public key".into())
.into()),
- __Nonexhaustive => unreachable!(),
+ &_ => unreachable!(), // Ciphertext is non-exhaustive.
}
let mut digest = [0; 20];
diff --git a/ipc/src/sexp.rs b/ipc/src/sexp.rs
index ee376f61..1ca36a04 100644
--- a/ipc/src/sexp.rs
+++ b/ipc/src/sexp.rs
@@ -294,7 +294,7 @@ impl TryFrom<&mpi::Ciphertext> for Sexp {
format!("Don't know how to convert {:?}", ciphertext))
.into()),
- __Nonexhaustive => unreachable!(),
+ &_ => unreachable!(), // Ciphertext is non-exhaustive.
}
}
}
diff --git a/openpgp-ffi/src/error.rs b/openpgp-ffi/src/error.rs
index d1e9e962..3bfa0f5c 100644
--- a/openpgp-ffi/src/error.rs
+++ b/openpgp-ffi/src/error.rs
@@ -267,7 +267,7 @@ impl<'a> From<&'a anyhow::Error> for Status {
Status::InvalidKey,
&openpgp::Error::PolicyViolation(_, _) =>
Status::PolicyViolation,
- openpgp::Error::__Nonexhaustive => unreachable!(),
+ &_ => unreachable!(), // openpgp::Error is non-exhaustive.
}
}
diff --git a/openpgp/src/crypto/backend/cng/ecdh.rs b/openpgp/src/crypto/backend/cng/ecdh.rs
index a9118a87..b8f38577 100644
--- a/openpgp/src/crypto/backend/cng/ecdh.rs
+++ b/openpgp/src/crypto/backend/cng/ecdh.rs
@@ -142,8 +142,6 @@ where
// N/A
Curve::Unknown(_) | Curve::Ed25519 =>
Err(Error::UnsupportedEllipticCurve(curve.clone()).into()),
-
- Curve::__Nonexhaustive => unreachable!(),
}
}
diff --git a/openpgp/src/crypto/backend/nettle/ecdh.rs b/openpgp/src/crypto/backend/nettle/ecdh.rs
index 29e3d448..93d22a07 100644
--- a/openpgp/src/crypto/backend/nettle/ecdh.rs
+++ b/openpgp/src/crypto/backend/nettle/ecdh.rs
@@ -109,8 +109,6 @@ pub fn encrypt<R>(recipient: &Key<key::PublicParts, R>,
// N/A
Curve::Unknown(_) | Curve::Ed25519 =>
Err(Error::UnsupportedEllipticCurve(curve.clone()).into()),
-
- Curve::__Nonexhaustive => unreachable!(),
}
} else {
Err(Error::InvalidArgument("Expected an ECDHPublicKey".into()).into())
diff --git a/openpgp/src/crypto/backend/nettle/hash.rs b/openpgp/src/crypto/backend/nettle/hash.rs
index b4600b14..bf1d9cb5 100644
--- a/openpgp/src/crypto/backend/nettle/hash.rs
+++ b/openpgp/src/crypto/backend/nettle/hash.rs
@@ -29,7 +29,6 @@ impl HashAlgorithm {
HashAlgorithm::MD5 => true,
HashAlgorithm::Private(_) => false,
HashAlgorithm::Unknown(_) => false,
- HashAlgorithm::__Nonexhaustive => unreachable!(),
}
}
@@ -60,7 +59,6 @@ impl HashAlgorithm {
HashAlgorithm::RipeMD => Ok(Box::new(Ripemd160::default())),
HashAlgorithm::Private(_) | HashAlgorithm::Unknown(_) =>
Err(Error::UnsupportedHashAlgorithm(self).into()),
- HashAlgorithm::__Nonexhaustive => unreachable!(),
}
}
@@ -78,7 +76,6 @@ impl HashAlgorithm {
HashAlgorithm::RipeMD => Ok(rsa::ASN1_OID_RIPEMD160),
HashAlgorithm::Private(_) | HashAlgorithm::Unknown(_) =>
Err(Error::UnsupportedHashAlgorithm(self).into()),
- HashAlgorithm::__Nonexhaustive => unreachable!(),
}
}
}
diff --git a/openpgp/src/crypto/backend/nettle/symmetric.rs b/openpgp/src/crypto/backend/nettle/symmetric.rs
index 4883a5a1..f25bcd7e 100644
--- a/openpgp/src/crypto/backend/nettle/symmetric.rs
+++ b/openpgp/src/crypto/backend/nettle/symmetric.rs
@@ -58,7 +58,6 @@ impl SymmetricAlgorithm {
=> true,
Unencrypted | IDEA | Private(_) | Unknown(_)
=> false,
- __Nonexhaustive => unreachable!(),
}
}
@@ -246,4 +245,4 @@ impl SymmetricAlgorithm {
_ => Err(Error::UnsupportedSymmetricAlgorithm(self).into()),
}
}
-} \ No newline at end of file
+}
diff --git a/openpgp/src/crypto/hash.rs b/openpgp/src/crypto/hash.rs
index 82add847..c7a8b248 100644
--- a/openpgp/src/crypto/hash.rs
+++ b/openpgp/src/crypto/hash.rs
@@ -305,7 +305,6 @@ impl Hash for Signature {
fn hash(&self, hash: &mut Context) {
match self {
Signature::V4(sig) => sig.hash(hash),
- Signature::__Nonexhaustive => unreachable!(),
}
}
}
diff --git a/openpgp/src/crypto/mpi.rs b/openpgp/src/crypto/mpi.rs
index 3918a4c2..8f9cfb2a 100644
--- a/openpgp/src/crypto/mpi.rs
+++ b/openpgp/src/crypto/mpi.rs
@@ -434,6 +434,7 @@ impl fmt::Debug for ProtectedMPI {
///
/// Note: This enum cannot be exhaustively matched to allow future
/// extensions.
+#[non_exhaustive]
#[derive(Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
pub enum PublicKey {
/// RSA public key.
@@ -501,10 +502,6 @@ pub enum PublicKey {
/// Any data that failed to parse.
rest: Box<[u8]>,
},
-
- /// This marks this enum as non-exhaustive. Do not use this
- /// variant.
- #[doc(hidden)] __Nonexhaustive,
}
impl PublicKey {
@@ -528,7 +525,6 @@ impl PublicKey {
&ECDSA { ref curve,.. } => curve.bits(),
&ECDH { ref curve,.. } => curve.bits(),
&Unknown { .. } => None,
- __Nonexhaustive => unreachable!(),
}
}
@@ -544,7 +540,6 @@ impl PublicKey {
ECDSA { .. } => Some(PublicKeyAlgorithm::ECDSA),
ECDH { .. } => Some(PublicKeyAlgorithm::ECDH),
Unknown { .. } => None,
- __Nonexhaustive => unreachable!(),
}
}
}
@@ -614,6 +609,7 @@ impl Arbitrary for PublicKey {
// Deriving Hash here is okay: PartialEq is manually implemented to
// ensure that secrets are compared in constant-time.
#[allow(clippy::derive_hash_xor_eq)]
+#[non_exhaustive]
#[derive(Clone, Hash)]
pub enum SecretKeyMaterial {
/// RSA secret key.
@@ -665,10 +661,6 @@ pub enum SecretKeyMaterial {
/// Any data that failed to parse.
rest: Protected,
},
-
- /// This marks this enum as non-exhaustive. Do not use this
- /// variant.
- #[doc(hidden)] __Nonexhaustive,
}
impl fmt::Debug for SecretKeyMaterial {
@@ -689,7 +681,6 @@ impl fmt::Debug for SecretKeyMaterial {
write!(f, "ECDH {{ scalar: {:?} }}", scalar),
&SecretKeyMaterial::Unknown{ ref mpis, ref rest } =>
write!(f, "Unknown {{ mips: {:?}, rest: {:?} }}", mpis, rest),
- SecretKeyMaterial::__Nonexhaustive => unreachable!(),
}
} else {
match self {
@@ -707,7 +698,6 @@ impl fmt::Debug for SecretKeyMaterial {
f.write_str("ECDH { <Redacted> }"),
&SecretKeyMaterial::Unknown{ .. } =>
f.write_str("Unknown { <Redacted> }"),
- SecretKeyMaterial::__Nonexhaustive => unreachable!(),
}
}
}
@@ -726,7 +716,6 @@ impl PartialOrd for SecretKeyMaterial {
&SecretKeyMaterial::ECDSA{ .. } => 4,
&SecretKeyMaterial::ECDH{ .. } => 5,
&SecretKeyMaterial::Unknown{ .. } => 6,
- SecretKeyMaterial::__Nonexhaustive => unreachable!(),
}
}
@@ -812,7 +801,6 @@ impl SecretKeyMaterial {
ECDSA { .. } => Some(PublicKeyAlgorithm::ECDSA),
ECDH { .. } => Some(PublicKeyAlgorithm::ECDH),
Unknown { .. } => None,
- __Nonexhaustive => unreachable!(),
}
}
}
@@ -889,6 +877,7 @@ impl Default for SecretKeyChecksum {
///
/// Note: This enum cannot be exhaustively matched to allow future
/// extensions.
+#[non_exhaustive]
#[derive(Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
pub enum Ciphertext {
/// RSA ciphertext.
@@ -920,10 +909,6 @@ pub enum Ciphertext {
/// Any data that failed to parse.
rest: Box<[u8]>,
},
-
- /// This marks this enum as non-exhaustive. Do not use this
- /// variant.
- #[doc(hidden)] __Nonexhaustive,
}
impl Ciphertext {
@@ -940,7 +925,6 @@ impl Ciphertext {
&ElGamal { .. } => Some(PublicKeyAlgorithm::ElGamalEncrypt),
&ECDH { .. } => Some(PublicKeyAlgorithm::ECDH),
&Unknown { .. } => None,
- __Nonexhaustive => unreachable!(),
}
}
}
@@ -986,6 +970,7 @@ impl Arbitrary for Ciphertext {
///
/// Note: This enum cannot be exhaustively matched to allow future
/// extensions.
+#[non_exhaustive]
#[derive(Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
pub enum Signature {
/// RSA signature.
@@ -1033,10 +1018,6 @@ pub enum Signature {
/// Any data that failed to parse.
rest: Box<[u8]>,
},
-
- /// This marks this enum as non-exhaustive. Do not use this
- /// variant.
- #[doc(hidden)] __Nonexhaustive,
}
impl Hash for Signature {
@@ -1111,7 +1092,6 @@ mod tests {
PublicKey::parse(ECDH, cur).unwrap(),
PublicKey::Unknown { .. } => unreachable!(),
- PublicKey::__Nonexhaustive => unreachable!(),
};
pk == pk_
@@ -1162,7 +1142,6 @@ mod tests {
SecretKeyMaterial::parse(ElGamalEncrypt, cur).unwrap(),
SecretKeyMaterial::Unknown { .. } => unreachable!(),
- SecretKeyMaterial::__Nonexhaustive => unreachable!(),
};
sk == sk_
@@ -1188,7 +1167,6 @@ mod tests {
Ciphertext::parse(ECDH, cur).unwrap(),
Ciphertext::Unknown { .. } => unreachable!(),
- Ciphertext::__Nonexhaustive => unreachable!(),
};
ct == ct_
@@ -1218,7 +1196,6 @@ mod tests {
Signature::parse(ECDSA, cur).unwrap(),
Signature::Unknown { .. } => unreachable!(),
- Signature::__Nonexhaustive => unreachable!(),
};
sig == sig_
diff --git a/openpgp/src/crypto/s2k.rs b/openpgp/src/crypto/s2k.rs
index 67198a0e..4eee84d8 100644
--- a/openpgp/src/crypto/s2k.rs
+++ b/openpgp/src/crypto/s2k.rs
@@ -33,6 +33,7 @@ use rand::Rng;
///
/// Note: This enum cannot be exhaustively matched to allow future
/// extensions.
+#[non_exhaustive]
#[derive(Clone, PartialEq, Eq, Hash, Debug)]
pub enum S2K {
/// Repeatently hashes the password with a public `salt` value.
@@ -111,10 +112,6 @@ pub enum S2K {
/// packet is serialized again, it is written out.
parameters: Option<Box<[u8]>>,
},
-
- /// This marks this enum as non-exhaustive. Do not use this
- /// variant.
- #[doc(hidden)] __Nonexhaustive,
}
impl Default for S2K {
@@ -229,7 +226,6 @@ impl S2K {
}
S2K::Unknown { .. } | &S2K::Private { .. } =>
unreachable!(),
- S2K::__Nonexhaustive => unreachable!(),
}
hash.digest(data);
@@ -241,7 +237,6 @@ impl S2K {
S2K::Unknown { tag, .. } | S2K::Private { tag, .. } =>
Err(Error::MalformedPacket(
format!("Unknown S2K type {:#x}", tag)).into()),
- S2K::__Nonexhaustive => unreachable!(),
}
}
@@ -251,7 +246,6 @@ impl S2K {
#[allow(deprecated)]
match self {
Simple { .. } | Salted { .. } | Iterated { .. } => true,
- __Nonexhaustive => unreachable!(),
_ => false,
}
}
@@ -367,7 +361,6 @@ impl fmt::Display for S2K {
} else {
write!(f, "Unknown S2K {}", tag)
},
- S2K::__Nonexhaustive => unreachable!(),
}
}
}
diff --git a/openpgp/src/fingerprint.rs b/openpgp/src/fingerprint.rs
index c2dfce1d..42a5c313 100644
--- a/openpgp/src/fingerprint.rs
+++ b/openpgp/src/fingerprint.rs
@@ -13,6 +13,7 @@ use quickcheck::{Arbitrary, Gen};
///
/// Note: This enum cannot be exhaustively matched to allow future
/// extensions.
+#[non_exhaustive]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Hash)]
pub enum Fingerprint {
/// 20 byte SHA-1 hash.
@@ -20,10 +21,6 @@ pub enum Fingerprint {
/// Used for holding fingerprints that we don't understand. For
/// instance, we don't grok v3 fingerprints.
Invalid(Box<[u8]>),
-
- /// This marks this enum as non-exhaustive. Do not use this
- /// variant.
- #[doc(hidden)] __Nonexhaustive,
}
impl fmt::Display for Fingerprint {
@@ -79,7 +76,6 @@ impl Fingerprint {
match self {
&Fingerprint::V4(ref fp) => fp,
&Fingerprint::Invalid(ref fp) => fp,
- Fingerprint::__Nonexhaustive => unreachable!(),
}
}
@@ -131,7 +127,6 @@ impl Fingerprint {
let raw = match self {
&Fingerprint::V4(ref fp) => &fp[..],
&Fingerprint::Invalid(ref fp) => &fp[..],
- Fingerprint::__Nonexhaustive => unreachable!(),
};
// We currently only handle V4 fingerprints, which look like:
diff --git a/openpgp/src/keyid.rs b/openpgp/src/keyid.rs
index 7b545165..a507527f 100644
--- a/openpgp/src/keyid.rs
+++ b/openpgp/src/keyid.rs
@@ -17,6 +17,7 @@ use crate::Result;
///
/// Note: This enum cannot be exhaustively matched to allow future
/// extensions.
+#[non_exhaustive]
#[derive(PartialEq, Eq, PartialOrd, Ord, Clone, Hash)]
pub enum KeyID {
/// Lower 8 byte SHA-1 hash.
@@ -25,10 +26,6 @@ pub enum KeyID {
/// instance, we don't grok v3 keyids. And, it is possible that
/// the Issuer subpacket contains the wrong number of bytes.
Invalid(Box<[u8]>),
-
- /// This marks this enum as non-exhaustive. Do not use this
- /// variant.
- #[doc(hidden)] __Nonexhaustive,
}
impl fmt::Display for KeyID {
@@ -82,7 +79,6 @@ impl From<KeyID> for Vec<u8> {
match id {
KeyID::V4(ref b) => r.extend_from_slice(b),
KeyID::Invalid(ref b) => r.extend_from_slice(b),
- KeyID::__Nonexhaustive => unreachable!(),
}
r
}
@@ -108,7 +104,6 @@ impl From<&Fingerprint> for KeyID {
Fingerprint::Invalid(fp) => {
KeyID::Invalid(fp.clone())
}
- Fingerprint::__Nonexhaustive => unreachable!(),
}
}
}
@@ -121,7 +116,6 @@ impl From<Fingerprint> for KeyID {
Fingerprint::Invalid(fp) => {
KeyID::Invalid(fp)
}
- Fingerprint::__Nonexhaustive => unreachable!(),
}
}
}
@@ -140,7 +134,6 @@ impl KeyID {
Ok(u64::from_be_bytes(*b)),
KeyID::Invalid(_) =>
Err(Error::InvalidArgument("Invalid KeyID".into()).into()),
- KeyID::__Nonexhaustive => unreachable!(),
}
}
@@ -160,7 +153,6 @@ impl KeyID {
match self {
&KeyID::V4(ref id) => id,
&KeyID::Invalid(ref id) => id,
- KeyID::__Nonexhaustive => unreachable!(),
}
}
@@ -218,7 +210,6 @@ impl KeyID {
let raw = match self {
&KeyID::V4(ref fp) => &fp[..],
&KeyID::Invalid(ref fp) => &fp[..],
- KeyID::__Nonexhaustive => unreachable!(),
};
// We currently only handle V4 key IDs, which look like:
diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs
index d71bb483..bb143d2f 100644
--- a/openpgp/src/lib.rs
+++ b/openpgp/src/lib.rs
@@ -177,6 +177,7 @@ pub type Result<T> = ::std::result::Result<T, anyhow::Error>;
///
/// Note: This enum cannot be exhaustively matched to allow future
/// extensions.
+#[non_exhaustive]
#[derive(thiserror::Error, Debug, Clone, PartialEq, Eq)]
pub enum Error {
/// Invalid argument.
@@ -296,8 +297,4 @@ pub enum Error {
.1.as_ref().map(|t| format!(" since {}", crate::fmt::time(t)))
.unwrap_or("".into()))]
PolicyViolation(String, Option<std::time::SystemTime>),
-
- /// This marks this enum as non-exhaustive. Do not use this
- /// variant.
- #[doc(hidden)] #[error("__Nonexhaustive")] __Nonexhaustive,
}
diff --git a/openpgp/src/message/lexer.rs b/openpgp/src/message/lexer.rs
index b0a0c16b..623dc05d 100644
--- a/openpgp/src/message/lexer.rs
+++ b/openpgp/src/message/lexer.rs
@@ -11,6 +11,7 @@ pub(crate) type LexerItem<Tok, Loc, Error>
///
/// Note: This enum cannot be exhaustively matched to allow future
/// extensions.
+#[non_exhaustive]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Token {
/// A Literal data packet.
@@ -40,10 +41,6 @@ pub enum Token {
/// A container's unparsed content.
OpaqueContent,
-
- /// This marks this enum as non-exhaustive. Do not use this
- /// variant.
- #[doc(hidden)] __Nonexhaustive,
}
impl fmt::Display for Token {
diff --git a/openpgp/src/message/mod.rs b/openpgp/src/message/mod.rs
index 82dd1695..5b35f161 100644
--- a/openpgp/src/message/mod.rs
+++ b/openpgp/src/message/mod.rs
@@ -48,16 +48,13 @@ use self::grammar::MessageParser;
///
/// Note: This enum cannot be exhaustively matched to allow future
/// extensions.
+#[non_exhaustive]
#[derive(Debug, Clone)]
pub enum MessageParserError {
/// A parser error.
Parser(ParseError<usize, Token, LexicalError>),
/// An OpenPGP error.
OpenPGP(Error),
-
- /// This marks this enum as non-exhaustive. Do not use this
- /// variant.
- #[doc(hidden)] __Nonexhaustive,
}
impl From<MessageParserError> for anyhow::Error {
@@ -65,7 +62,6 @@ impl From<MessageParserError> for anyhow::Error {
match err {
MessageParserError::Parser(p) => p.into(),
MessageParserError::OpenPGP(p) => p.into(),
- MessageParserError::__Nonexhaustive => unreachable!(),
}
}
}
diff --git a/openpgp/src/packet/mod.rs b/openpgp/src/packet/mod.rs
index 6b165916..e446f68f 100644
--- a/openpgp/src/packet/mod.rs
+++ b/openpgp/src/packet/mod.rs
@@ -243,6 +243,7 @@ use super::*;
/// [`CTB`]: header/enum.CTB.html
/// [length style]: https://tools.ietf.org/html/rfc4880#section-4.2
/// [partial body encoding]: https://tools.ietf.org/html/rfc4880#section-4.2.2.4
+#[non_exhaustive]
#[derive(Debug)]
#[derive(PartialEq, Eq, Hash, Clone)]
pub enum Packet {
@@ -282,10 +283,6 @@ pub enum Packet {