summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNora Widdecke <nora@sequoia-pgp.org>2022-02-11 11:00:26 +0100
committerNora Widdecke <nora@sequoia-pgp.org>2022-02-11 17:50:35 +0100
commit91791d4c28ece29eff6e927e78a41b337a5c772a (patch)
tree1c35ed63d45af5ad5584add55efb90a823e515fc
parentb8d0fd829c0eb749e8de044c9324ec8fdfdfce16 (diff)
openpgp: Deprecate {Fingerprint,KeyID}::Invalid.
-rw-r--r--openpgp/src/fingerprint.rs3
-rw-r--r--openpgp/src/keyhandle.rs9
-rw-r--r--openpgp/src/keyid.rs9
-rw-r--r--openpgp/src/serialize.rs6
4 files changed, 21 insertions, 6 deletions
diff --git a/openpgp/src/fingerprint.rs b/openpgp/src/fingerprint.rs
index d7484917..72d8fc65 100644
--- a/openpgp/src/fingerprint.rs
+++ b/openpgp/src/fingerprint.rs
@@ -51,6 +51,7 @@ pub enum Fingerprint {
V4([u8;20]),
/// Used for holding fingerprint data that is not a V4 fingerprint, e.g. a
/// V3 fingerprint (deprecated) or otherwise wrong-length data.
+ #[deprecated(note = "Use `Unknown`.")]
Invalid(Box<[u8]>),
/// Used for holding data that is not valid as a known fingerprint version,
/// optionally with associated version number.
@@ -145,6 +146,7 @@ impl Fingerprint {
pub fn as_bytes(&self) -> &[u8] {
match self {
Fingerprint::V4(ref fp) => fp,
+ #[allow(deprecated)]
Fingerprint::Invalid(ref fp) => fp,
Fingerprint::Unknown { fp, .. } => fp,
}
@@ -238,6 +240,7 @@ impl Fingerprint {
fn convert_to_string(&self, pretty: bool) -> String {
let raw = match self {
Fingerprint::V4(ref fp) => &fp[..],
+ #[allow(deprecated)]
Fingerprint::Invalid(ref fp) => &fp[..],
Fingerprint::Unknown{ fp, .. } => &fp[..],
};
diff --git a/openpgp/src/keyhandle.rs b/openpgp/src/keyhandle.rs
index 0e9113c2..ae536b7c 100644
--- a/openpgp/src/keyhandle.rs
+++ b/openpgp/src/keyhandle.rs
@@ -331,11 +331,14 @@ impl KeyHandle {
/// # Ok(()) }
/// ```
pub fn is_invalid(&self) -> bool {
- matches!(self,
+ #[allow(deprecated)]
+ let matches_invalid = matches!(self,
KeyHandle::Fingerprint(Fingerprint::Invalid(_))
- | KeyHandle::KeyID(KeyID::Invalid(_))
+ | KeyHandle::KeyID(KeyID::Invalid(_)));
+ let matches_unknown = matches!(self,
| KeyHandle::Fingerprint(Fingerprint::Unknown { .. })
- | KeyHandle::KeyID(KeyID::Unknown { .. }))
+ | KeyHandle::KeyID(KeyID::Unknown { .. }));
+ matches_invalid | matches_unknown
}
/// Converts this `KeyHandle` to its canonical hexadecimal
diff --git a/openpgp/src/keyid.rs b/openpgp/src/keyid.rs
index 22897672..9762f44f 100644
--- a/openpgp/src/keyid.rs
+++ b/openpgp/src/keyid.rs
@@ -63,8 +63,7 @@ pub enum KeyID {
V4([u8;8]),
/// Used for holding invalid keyids encountered during parsing
/// e.g. wrong number of bytes.
- // TODO
- // #[deprecated]
+ #[deprecated(note = "Use `Unknown`.")]
Invalid(Box<[u8]>),
/// Used for holding data that is not valid as a known keyid version,
/// optionally with associated version number.
@@ -119,6 +118,7 @@ impl From<KeyID> for Vec<u8> {
let mut r = Vec::with_capacity(8);
match id {
KeyID::V4(ref b) => r.extend_from_slice(b),
+ #[allow(deprecated)]
KeyID::Invalid(ref b) => r.extend_from_slice(b),
KeyID::Unknown{ id, .. } => r.extend_from_slice(&id),
}
@@ -143,6 +143,7 @@ impl From<&Fingerprint> for KeyID {
match fp {
Fingerprint::V4(fp) =>
KeyID::from_bytes(&fp[fp.len() - 8..]),
+ #[allow(deprecated)]
Fingerprint::Invalid(fp) => {
KeyID::Invalid(fp.clone())
},
@@ -159,6 +160,7 @@ impl From<Fingerprint> for KeyID {
match fp {
Fingerprint::V4(fp) =>
KeyID::from_bytes(&fp[fp.len() - 8..]),
+ #[allow(deprecated)]
Fingerprint::Invalid(fp) => {
KeyID::Invalid(fp)
},
@@ -203,6 +205,7 @@ impl KeyID {
match &self {
KeyID::V4(ref b) =>
Ok(u64::from_be_bytes(*b)),
+ #[allow(deprecated)]
KeyID::Invalid(_) =>
Err(Error::InvalidArgument("Invalid KeyID".into()).into()),
KeyID::Unknown{ .. } =>
@@ -256,6 +259,7 @@ impl KeyID {
pub fn as_bytes(&self) -> &[u8] {
match self {
KeyID::V4(ref id) => id,
+ #[allow(deprecated)]
KeyID::Invalid(ref id) => id,
KeyID::Unknown{ id , .. } => id,
}
@@ -370,6 +374,7 @@ impl KeyID {
fn convert_to_string(&self, pretty: bool) -> String {
let raw = match self {
KeyID::V4(ref fp) => &fp[..],
+ #[allow(deprecated)]
KeyID::Invalid(ref fp) => &fp[..],
KeyID::Unknown{ id, .. } => &id[..],
};
diff --git a/openpgp/src/serialize.rs b/openpgp/src/serialize.rs
index d13650af..3783a954 100644
--- a/openpgp/src/serialize.rs
+++ b/openpgp/src/serialize.rs
@@ -835,8 +835,8 @@ impl seal::Sealed for KeyID {}
impl Marshal for KeyID {
fn serialize(&self, o: &mut dyn std::io::Write) -> Result<()> {
let raw = match self {
-// TODO rename fp to id
KeyID::V4(ref fp) => &fp[..],
+ #[allow(deprecated)]
KeyID::Invalid(ref fp) => &fp[..],
KeyID::Unknown { id, .. } => &id[..],
};
@@ -850,6 +850,7 @@ impl MarshalInto for KeyID {
fn serialized_len(&self) -> usize {
match self {
KeyID::V4(_) => 8,
+ #[allow(deprecated)]
KeyID::Invalid(ref fp) => fp.len(),
KeyID::Unknown { id, .. } => id.len(),
}
@@ -874,6 +875,7 @@ impl MarshalInto for Fingerprint {
fn serialized_len(&self) -> usize {
match self {
Fingerprint::V4(_) => 20,
+ #[allow(deprecated)]
Fingerprint::Invalid(ref fp) => fp.len(),
Fingerprint::Unknown { fp, .. } => fp.len(),
}
@@ -1522,6 +1524,7 @@ impl MarshalInto for SubpacketValue {
Fingerprint::V4(_) =>
1 + (fp as &dyn MarshalInto).serialized_len(),
// Educated guess for unknown versions.
+ #[allow(deprecated)]
Fingerprint::Invalid(_) => 1 + fp.as_bytes().len(),
// Educated guess for unknown versions.
Fingerprint::Unknown{ .. } => 1 + fp.as_bytes().len(),
@@ -1531,6 +1534,7 @@ impl MarshalInto for SubpacketValue {
Fingerprint::V4(_) =>
1 + (fp as &dyn MarshalInto).serialized_len(),
// Educated guess for unknown versions.
+ #[allow(deprecated)]
Fingerprint::Invalid(_) => 1 + fp.as_bytes().len(),
// Educated guess for unknown versions.
Fingerprint::Unknown{ .. } => 1 + fp.as_bytes().len(),