Enum sequoia_openpgp::types::ReasonForRevocation
source · [−]#[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
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
sourceimpl 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
sourceimpl Clone for ReasonForRevocation
impl Clone for ReasonForRevocation
sourcefn clone(&self) -> ReasonForRevocation
fn clone(&self) -> ReasonForRevocation
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ReasonForRevocation
impl Debug for ReasonForRevocation
sourceimpl Display for ReasonForRevocation
impl Display for ReasonForRevocation
sourceimpl From<ReasonForRevocation> for u8
impl From<ReasonForRevocation> for u8
sourcefn from(r: ReasonForRevocation) -> u8
fn from(r: ReasonForRevocation) -> u8
Converts to this type from the input type.
sourceimpl From<u8> for ReasonForRevocation
impl From<u8> for ReasonForRevocation
sourceimpl Hash for ReasonForRevocation
impl Hash for ReasonForRevocation
sourceimpl Ord for ReasonForRevocation
impl Ord for ReasonForRevocation
sourceimpl PartialEq<ReasonForRevocation> for ReasonForRevocation
impl PartialEq<ReasonForRevocation> for ReasonForRevocation
sourcefn 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 ==
. Read more
sourcefn ne(&self, other: &ReasonForRevocation) -> bool
fn ne(&self, other: &ReasonForRevocation) -> bool
This method tests for !=
.
sourceimpl PartialOrd<ReasonForRevocation> for ReasonForRevocation
impl PartialOrd<ReasonForRevocation> for ReasonForRevocation
sourcefn partial_cmp(&self, other: &ReasonForRevocation) -> Option<Ordering>
fn partial_cmp(&self, other: &ReasonForRevocation) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn 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 more
impl Copy for ReasonForRevocation
impl Eq for ReasonForRevocation
impl StructuralEq for ReasonForRevocation
impl StructuralPartialEq for ReasonForRevocation
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more