[][src]Struct sequoia_openpgp::tpk::TPKRevocationBuilder

pub struct TPKRevocationBuilder { /* fields omitted */ }

A TPK revocation builder.

Note: a TPK revocation has two degrees of freedom: the TPK, and the key used to generate the revocation.

Normally, the key used to generate the revocation is the TPK's primary key. However, this is not required.

If Alice has marked Robert's key (R) as a designated revoker for her key (A), then R can revoke A or parts of A. In this case, the TPK is A, and the key used to generate the revocation comes from R.

Example

use openpgp::RevocationStatus;
use openpgp::types::{ReasonForRevocation, SignatureType};
use openpgp::tpk::{CipherSuite, TPKBuilder, TPKRevocationBuilder};
use openpgp::crypto::KeyPair;
use openpgp::parse::Parse;

let (tpk, _) = TPKBuilder::new()
    .set_cipher_suite(CipherSuite::Cv25519)
    .generate()?;
assert_eq!(RevocationStatus::NotAsFarAsWeKnow,
           tpk.revoked(None));

let mut signer = tpk.primary().clone()
    .mark_parts_secret()?.into_keypair()?;
let sig = TPKRevocationBuilder::new()
    .set_reason_for_revocation(ReasonForRevocation::KeyCompromised,
                               b"It was the maid :/")?
    .build(&mut signer, &tpk, None)?;
assert_eq!(sig.typ(), SignatureType::KeyRevocation);

let tpk = tpk.merge_packets(vec![sig.clone().into()])?;
assert_eq!(RevocationStatus::Revoked(vec![&sig]),
           tpk.revoked(None));

Methods

impl TPKRevocationBuilder[src]

pub fn new() -> Self[src]

Returns a new TPKRevocationBuilder.

pub fn set_reason_for_revocation(
    self,
    code: ReasonForRevocation,
    reason: &[u8]
) -> Result<Self>
[src]

Sets the reason for revocation.

pub fn set_signature_creation_time(
    self,
    creation_time: SystemTime
) -> Result<Self>
[src]

Sets the revocation signature's creation time.

pub fn build<H, R>(
    self,
    signer: &mut dyn Signer<R>,
    tpk: &TPK,
    hash_algo: H
) -> Result<Signature> where
    H: Into<Option<HashAlgorithm>>,
    R: KeyRole
[src]

Returns a revocation certificate for the tpk TPK signed by signer.

Methods from Deref<Target = Builder>

pub fn version(&self) -> u8[src]

Gets the version.

pub fn typ(&self) -> SignatureType[src]

Gets the signature type.

pub fn pk_algo(&self) -> PublicKeyAlgorithm[src]

Gets the public key algorithm.

pub fn hash_algo(&self) -> HashAlgorithm[src]

Gets the hash algorithm.

Trait Implementations

impl Deref for TPKRevocationBuilder[src]

type Target = Builder

The resulting type after dereferencing.

Auto Trait Implementations

Blanket Implementations

impl<T> From for T[src]

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip for T where
    V: MultiLane<T>,