Enum sequoia_openpgp::types::ReasonForRevocation [−][src]
#[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
No reason specified (key revocations or cert revocations)
Key is superseded (key revocations)
Key material has been compromised (key revocations)
Key is retired and no longer used (key revocations)
User ID information is no longer valid (cert revocations)
Private(u8)
Private reason identifier.
Unknown(u8)
Unknown reason identifier.
Implementations
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);
Trait Implementations
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Auto Trait Implementations
impl RefUnwindSafe for ReasonForRevocation
impl Send for ReasonForRevocation
impl Sync for ReasonForRevocation
impl Unpin for ReasonForRevocation
impl UnwindSafe for ReasonForRevocation
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self