diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-09-06 11:57:19 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-09-17 09:23:25 +0200 |
commit | 43578c7951757f8f4a4eb5fab6eec7d65379311f (patch) | |
tree | 25386ad150fd649a276e0c1a044fe83ca0d84225 /openpgp | |
parent | 5e1505784f7b5636d91247c88443acb9715a7f66 (diff) |
openpgp: Add new type RevocationType.
- Add a new type to encode whether a ReasonForRevocation should be
considered hard or soft.
Diffstat (limited to 'openpgp')
-rw-r--r-- | openpgp/src/constants/mod.rs | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/openpgp/src/constants/mod.rs b/openpgp/src/constants/mod.rs index 227b18b4..df91f295 100644 --- a/openpgp/src/constants/mod.rs +++ b/openpgp/src/constants/mod.rs @@ -987,6 +987,51 @@ impl Arbitrary for ReasonForRevocation { } } +/// Describes whether a `ReasonForRevocation` should be consider hard +/// or soft. +/// +/// A hard revocation is a revocation that indicates that the key was +/// somehow compromised, and the provence of *all* artifacts should be +/// called into question. +/// +/// A soft revocation is a revocation that indicates that the key +/// should be considered invalid *after* the revocation signature's +/// creation time. `KeySuperseded`, `KeyRetired`, and `UIDRetired` +/// are considered soft revocations. +#[derive(Clone, Copy, PartialEq, Eq)] +pub enum RevocationType { + /// A hard revocation. + /// + /// Artifacts stemming from the revoked object should not be + /// trusted. + Hard, + /// A soft revocation. + /// + /// Artifacts stemming from the revoked object *after* the + /// revocation time should not be trusted. Earlier objects should + /// be considered okay. + /// + /// Only `KeySuperseded`, `KeyRetired`, and `UIDRetired` are + /// considered soft revocations. All other reasons for + /// revocations including unknown reasons are considered hard + /// revocations. + Soft, +} + +impl ReasonForRevocation { + /// Returns the revocation's `RevocationType`. + pub fn revocation_type(&self) -> RevocationType { + match self { + ReasonForRevocation::Unspecified => RevocationType::Hard, + ReasonForRevocation::KeySuperseded => RevocationType::Soft, + ReasonForRevocation::KeyCompromised => RevocationType::Hard, + ReasonForRevocation::KeyRetired => RevocationType::Soft, + ReasonForRevocation::UIDRetired => RevocationType::Soft, + ReasonForRevocation::Private(_) => RevocationType::Hard, + ReasonForRevocation::Unknown(_) => RevocationType::Hard, + } + } +} /// Describes the format of the body of a literal data packet. /// |