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
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.

Tuple Fields of Private

0: u8
Unknown(u8)

Unknown reason identifier.

Tuple Fields of Unknown

0: u8

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.