#[non_exhaustive]pub enum ReasonForRevocation {
Unspecified,
KeySuperseded,
KeyCompromised,
KeyRetired,
UIDRetired,
Private(u8),
Unknown(u8),
}
Expand description
Describes the reason for a revocation.
See the description of revocation subpackets Section 5.2.3.23 of RFC 4880.
Note: This enum cannot be exhaustively matched to allow future extensions.
§Examples
use sequoia_openpgp as openpgp;
use openpgp::cert::prelude::*;
use openpgp::policy::StandardPolicy;
use openpgp::types::{RevocationStatus, ReasonForRevocation, SignatureType};
let p = &StandardPolicy::new();
// A certificate with a User ID.
let (cert, _) = CertBuilder::new()
.add_userid("Alice <alice@example.org>")
.generate()?;
let mut keypair = cert.primary_key().key().clone()
.parts_into_secret()?.into_keypair()?;
let ca = cert.userids().nth(0).unwrap();
// Generate the revocation for the first and only UserID.
let revocation =
UserIDRevocationBuilder::new()
.set_reason_for_revocation(
ReasonForRevocation::UIDRetired,
b"Left example.org.")?
.build(&mut keypair, &cert, ca.userid(), None)?;
assert_eq!(revocation.typ(), SignatureType::CertificationRevocation);
// Now merge the revocation signature into the Cert.
let cert = cert.insert_packets(revocation.clone())?;
// Check that it is revoked.
let ca = cert.userids().nth(0).unwrap();
let status = ca.with_policy(p, None)?.revocation_status();
if let RevocationStatus::Revoked(revs) = status {
assert_eq!(revs.len(), 1);
let rev = revs[0];
assert_eq!(rev.typ(), SignatureType::CertificationRevocation);
assert_eq!(rev.reason_for_revocation(),
Some((ReasonForRevocation::UIDRetired,
"Left example.org.".as_bytes())));
// User ID has been revoked.
}
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
Unspecified
No reason specified (key revocations or cert revocations)
KeySuperseded
Key is superseded (key revocations)
KeyCompromised
Key material has been compromised (key revocations)
KeyRetired
Key is retired and no longer used (key revocations)
UIDRetired
User ID information is no longer valid (cert revocations)
Private(u8)
Private reason identifier.
Unknown(u8)
Unknown reason identifier.
Implementations§
source§impl ReasonForRevocation
impl ReasonForRevocation
sourcepub fn revocation_type(&self) -> RevocationType
pub fn revocation_type(&self) -> RevocationType
Returns the revocation’s RevocationType
.
§Examples
use sequoia_openpgp as openpgp;
use openpgp::types::{ReasonForRevocation, RevocationType};
assert_eq!(ReasonForRevocation::KeyCompromised.revocation_type(), RevocationType::Hard);
assert_eq!(ReasonForRevocation::Private(101).revocation_type(), RevocationType::Hard);
assert_eq!(ReasonForRevocation::KeyRetired.revocation_type(), RevocationType::Soft);
sourcepub fn variants() -> impl Iterator<Item = Self>
pub fn variants() -> impl Iterator<Item = Self>
Returns an iterator over all valid variants.
Returns an iterator over all known variants. This does not
include the ReasonForRevocation::Private
or
ReasonForRevocation::Unknown
variants.
Trait Implementations§
source§impl Clone for ReasonForRevocation
impl Clone for ReasonForRevocation
source§fn clone(&self) -> ReasonForRevocation
fn clone(&self) -> ReasonForRevocation
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for ReasonForRevocation
impl Debug for ReasonForRevocation
source§impl Display for ReasonForRevocation
impl Display for ReasonForRevocation
source§impl From<ReasonForRevocation> for u8
impl From<ReasonForRevocation> for u8
source§fn from(r: ReasonForRevocation) -> u8
fn from(r: ReasonForRevocation) -> u8
Converts to this type from the input type.
source§impl From<u8> for ReasonForRevocation
impl From<u8> for ReasonForRevocation
source§impl Hash for ReasonForRevocation
impl Hash for ReasonForRevocation
source§impl Ord for ReasonForRevocation
impl Ord for ReasonForRevocation
source§fn cmp(&self, other: &ReasonForRevocation) -> Ordering
fn cmp(&self, other: &ReasonForRevocation) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq for ReasonForRevocation
impl PartialEq for ReasonForRevocation
source§fn eq(&self, other: &ReasonForRevocation) -> bool
fn eq(&self, other: &ReasonForRevocation) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for ReasonForRevocation
impl PartialOrd for ReasonForRevocation
source§fn partial_cmp(&self, other: &ReasonForRevocation) -> Option<Ordering>
fn partial_cmp(&self, other: &ReasonForRevocation) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moreimpl Copy for ReasonForRevocation
impl Eq for ReasonForRevocation
impl StructuralPartialEq for ReasonForRevocation
Auto Trait Implementations§
impl Freeze for ReasonForRevocation
impl RefUnwindSafe for ReasonForRevocation
impl Send for ReasonForRevocation
impl Sync for ReasonForRevocation
impl Unpin for ReasonForRevocation
impl UnwindSafe for ReasonForRevocation
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)