pub type ValidErasedKeyAmalgamation<'a, P> = ValidKeyAmalgamation<'a, P, UnspecifiedRole, bool>;
Expand description

A valid key whose role is not known at compile time.

A specialized version of ValidKeyAmalgamation.

Aliased Type§

struct ValidErasedKeyAmalgamation<'a, P> { /* private fields */ }

Implementations§

source§

impl<'a, P> ValidErasedKeyAmalgamation<'a, P>
where P: KeyParts,

source

pub fn parts_into_public(self) -> ValidErasedKeyAmalgamation<'a, PublicParts>

Changes the key’s parts tag to PublicParts.

source

pub fn parts_as_public( &'a self, ) -> &'a ValidErasedKeyAmalgamation<'a, PublicParts>

Changes the key’s parts tag to PublicParts.

source

pub fn parts_as_public_mut( &'a mut self, ) -> &'a mut ValidErasedKeyAmalgamation<'a, PublicParts>

Changes the key’s parts tag to PublicParts.

source

pub fn parts_into_secret( self, ) -> Result<ValidErasedKeyAmalgamation<'a, SecretParts>>

Changes the key’s parts tag to SecretParts.

source

pub fn parts_as_secret( &'a self, ) -> Result<&'a ValidErasedKeyAmalgamation<'a, SecretParts>>

Changes the key’s parts tag to SecretParts.

source

pub fn parts_as_secret_mut( &'a mut self, ) -> Result<&'a mut ValidErasedKeyAmalgamation<'a, SecretParts>>

Changes the key’s parts tag to SecretParts.

source

pub fn parts_into_unspecified( self, ) -> ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

Changes the key’s parts tag to UnspecifiedParts.

source

pub fn parts_as_unspecified( &'a self, ) -> &ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

Changes the key’s parts tag to UnspecifiedParts.

source

pub fn parts_as_unspecified_mut( &'a mut self, ) -> &mut ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

Changes the key’s parts tag to UnspecifiedParts.

source§

impl<'a, P> ValidErasedKeyAmalgamation<'a, P>
where P: 'a + KeyParts,

source

pub fn set_expiration_time( &self, primary_signer: &mut dyn Signer, subkey_signer: Option<&mut dyn Signer>, expiration: Option<SystemTime>, ) -> Result<Vec<Signature>>

Creates signatures that cause the key to expire at the specified time.

This function creates new binding signatures that cause the key to expire at the specified time when integrated into the certificate. For subkeys, only a single Signature is returned. For the primary key, however, it is necessary to create a new self-signature for each non-revoked User ID, and to create a direct key signature. This is needed, because the primary User ID is first consulted when determining the primary key’s expiration time, and certificates can be distributed with a possibly empty subset of User IDs.

Setting a key’s expiry time means updating an existing binding signature—when looking up information, only one binding signature is normally considered, and we don’t want to drop the other information stored in the current binding signature. This function uses the binding signature determined by ValidKeyAmalgamation’s policy and reference time for this.

When updating the expiration time of signing-capable subkeys, we need to create a new primary key binding signature. Therefore, we need a signer for the subkey. If subkey_signer is None, and this is a signing-capable subkey, this function fails with Error::InvalidArgument. Likewise, this function fails if subkey_signer is not None when updating the expiration of the primary key, or an non signing-capable subkey.

§Examples
use std::time;
use openpgp::policy::StandardPolicy;

let p = &StandardPolicy::new();

let vc = cert.with_policy(p, None)?;

// Assert that the keys are not expired.
for ka in vc.keys() {
    assert!(ka.alive().is_ok());
}

// Make the keys expire in a week.
let t = time::SystemTime::now()
    + time::Duration::from_secs(7 * 24 * 60 * 60);

// We assume that the secret key material is available, and not
// password protected.
let mut primary_signer = vc.primary_key()
    .key().clone().parts_into_secret()?.into_keypair()?;
let mut signing_subkey_signer = vc.keys().for_signing().nth(0).unwrap()
    .key().clone().parts_into_secret()?.into_keypair()?;

let mut sigs = Vec::new();
for ka in vc.keys() {
    if ! ka.for_signing() {
        // Non-signing-capable subkeys are easy to update.
        sigs.append(&mut ka.set_expiration_time(&mut primary_signer,
                                                None, Some(t))?);
    } else {
        // Signing-capable subkeys need to create a primary
        // key binding signature with the subkey:
        assert!(ka.set_expiration_time(&mut primary_signer,
                                       None, Some(t)).is_err());

        // Here, we need the subkey's signer:
        sigs.append(&mut ka.set_expiration_time(&mut primary_signer,
                                                Some(&mut signing_subkey_signer),
                                                Some(t))?);
    }
}
let cert = cert.insert_packets(sigs)?;

// They aren't expired yet.
let vc = cert.with_policy(p, None)?;
for ka in vc.keys() {
    assert!(ka.alive().is_ok());
}

// But in two weeks, they will be...
let t = time::SystemTime::now()
    + time::Duration::from_secs(2 * 7 * 24 * 60 * 60);
let vc = cert.with_policy(p, t)?;
for ka in vc.keys() {
    assert!(ka.alive().is_err());
}

Trait Implementations§

source§

impl<'a, P: 'a + KeyParts> From<&ValidKeyAmalgamation<'a, P, PrimaryRole, ()>> for ValidErasedKeyAmalgamation<'a, P>

source§

fn from(vka: &ValidPrimaryKeyAmalgamation<'a, P>) -> Self

Converts to this type from the input type.
source§

impl<'a, P: 'a + KeyParts> From<&ValidKeyAmalgamation<'a, P, SubordinateRole, ()>> for ValidErasedKeyAmalgamation<'a, P>

source§

fn from(vka: &ValidSubordinateKeyAmalgamation<'a, P>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&ValidKeyAmalgamation<'a, PublicParts, PrimaryRole, ()>> for ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(vka: &ValidPrimaryKeyAmalgamation<'a, PublicParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&ValidKeyAmalgamation<'a, PublicParts, SubordinateRole, ()>> for ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(vka: &ValidSubordinateKeyAmalgamation<'a, PublicParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a ValidKeyAmalgamation<'a, PublicParts, UnspecifiedRole, bool>> for &'a ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(p: &'a ValidErasedKeyAmalgamation<'a, PublicParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&ValidKeyAmalgamation<'a, SecretParts, PrimaryRole, ()>> for ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(vka: &ValidPrimaryKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&ValidKeyAmalgamation<'a, SecretParts, PrimaryRole, ()>> for ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(vka: &ValidPrimaryKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&ValidKeyAmalgamation<'a, SecretParts, SubordinateRole, ()>> for ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(vka: &ValidSubordinateKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&ValidKeyAmalgamation<'a, SecretParts, SubordinateRole, ()>> for ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(vka: &ValidSubordinateKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a ValidKeyAmalgamation<'a, SecretParts, UnspecifiedRole, bool>> for &'a ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(p: &'a ValidErasedKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a ValidKeyAmalgamation<'a, SecretParts, UnspecifiedRole, bool>> for &'a ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(p: &'a ValidErasedKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&ValidKeyAmalgamation<'a, UnspecifiedParts, PrimaryRole, ()>> for ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(vka: &ValidPrimaryKeyAmalgamation<'a, UnspecifiedParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&ValidKeyAmalgamation<'a, UnspecifiedParts, SubordinateRole, ()>> for ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(vka: &ValidSubordinateKeyAmalgamation<'a, UnspecifiedParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a ValidKeyAmalgamation<'a, UnspecifiedParts, UnspecifiedRole, bool>> for &'a ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(p: &'a ValidErasedKeyAmalgamation<'a, UnspecifiedParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a mut ValidKeyAmalgamation<'a, PublicParts, UnspecifiedRole, bool>> for &'a mut ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(p: &'a mut ValidErasedKeyAmalgamation<'a, PublicParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a mut ValidKeyAmalgamation<'a, SecretParts, UnspecifiedRole, bool>> for &'a mut ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(p: &'a mut ValidErasedKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a mut ValidKeyAmalgamation<'a, SecretParts, UnspecifiedRole, bool>> for &'a mut ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(p: &'a mut ValidErasedKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<&'a mut ValidKeyAmalgamation<'a, UnspecifiedParts, UnspecifiedRole, bool>> for &'a mut ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(p: &'a mut ValidErasedKeyAmalgamation<'a, UnspecifiedParts>) -> Self

Converts to this type from the input type.
source§

impl<'a, P: 'a + KeyParts> From<ValidKeyAmalgamation<'a, P, PrimaryRole, ()>> for ValidErasedKeyAmalgamation<'a, P>

source§

fn from(vka: ValidPrimaryKeyAmalgamation<'a, P>) -> Self

Converts to this type from the input type.
source§

impl<'a, P: 'a + KeyParts> From<ValidKeyAmalgamation<'a, P, SubordinateRole, ()>> for ValidErasedKeyAmalgamation<'a, P>

source§

fn from(vka: ValidSubordinateKeyAmalgamation<'a, P>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<ValidKeyAmalgamation<'a, PublicParts, PrimaryRole, ()>> for ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(vka: ValidPrimaryKeyAmalgamation<'a, PublicParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<ValidKeyAmalgamation<'a, PublicParts, SubordinateRole, ()>> for ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(vka: ValidSubordinateKeyAmalgamation<'a, PublicParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<ValidKeyAmalgamation<'a, PublicParts, UnspecifiedRole, bool>> for ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(p: ValidErasedKeyAmalgamation<'a, PublicParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<ValidKeyAmalgamation<'a, SecretParts, PrimaryRole, ()>> for ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(vka: ValidPrimaryKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<ValidKeyAmalgamation<'a, SecretParts, PrimaryRole, ()>> for ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(vka: ValidPrimaryKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<ValidKeyAmalgamation<'a, SecretParts, SubordinateRole, ()>> for ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(vka: ValidSubordinateKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<ValidKeyAmalgamation<'a, SecretParts, SubordinateRole, ()>> for ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(vka: ValidSubordinateKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<ValidKeyAmalgamation<'a, SecretParts, UnspecifiedRole, bool>> for ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(p: ValidErasedKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<ValidKeyAmalgamation<'a, SecretParts, UnspecifiedRole, bool>> for ValidErasedKeyAmalgamation<'a, UnspecifiedParts>

source§

fn from(p: ValidErasedKeyAmalgamation<'a, SecretParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<ValidKeyAmalgamation<'a, UnspecifiedParts, PrimaryRole, ()>> for ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(vka: ValidPrimaryKeyAmalgamation<'a, UnspecifiedParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<ValidKeyAmalgamation<'a, UnspecifiedParts, SubordinateRole, ()>> for ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(vka: ValidSubordinateKeyAmalgamation<'a, UnspecifiedParts>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<ValidKeyAmalgamation<'a, UnspecifiedParts, UnspecifiedRole, bool>> for ValidErasedKeyAmalgamation<'a, PublicParts>

source§

fn from(p: ValidErasedKeyAmalgamation<'a, UnspecifiedParts>) -> Self

Converts to this type from the input type.
source§

impl<'a, P> PrimaryKey<'a, P, UnspecifiedRole> for ValidErasedKeyAmalgamation<'a, P>
where P: 'a + KeyParts,

source§

fn primary(&self) -> bool

Returns whether the key amalgamation is a primary key amalgamation. Read more
source§

impl<'a> TryFrom<&'a ValidKeyAmalgamation<'a, PublicParts, UnspecifiedRole, bool>> for &'a ValidErasedKeyAmalgamation<'a, SecretParts>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(p: &'a ValidErasedKeyAmalgamation<'a, PublicParts>) -> Result<Self>

Performs the conversion.
source§

impl<'a> TryFrom<&'a ValidKeyAmalgamation<'a, UnspecifiedParts, UnspecifiedRole, bool>> for &'a ValidErasedKeyAmalgamation<'a, SecretParts>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from( p: &'a ValidErasedKeyAmalgamation<'a, UnspecifiedParts>, ) -> Result<Self>

Performs the conversion.
source§

impl<'a> TryFrom<&'a mut ValidKeyAmalgamation<'a, PublicParts, UnspecifiedRole, bool>> for &'a mut ValidErasedKeyAmalgamation<'a, SecretParts>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from( p: &'a mut ValidErasedKeyAmalgamation<'a, PublicParts>, ) -> Result<Self>

Performs the conversion.
source§

impl<'a> TryFrom<&'a mut ValidKeyAmalgamation<'a, UnspecifiedParts, UnspecifiedRole, bool>> for &'a mut ValidErasedKeyAmalgamation<'a, SecretParts>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from( p: &'a mut ValidErasedKeyAmalgamation<'a, UnspecifiedParts>, ) -> Result<Self>

Performs the conversion.
source§

impl<'a> TryFrom<ValidKeyAmalgamation<'a, PublicParts, UnspecifiedRole, bool>> for ValidErasedKeyAmalgamation<'a, SecretParts>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(p: ValidErasedKeyAmalgamation<'a, PublicParts>) -> Result<Self>

Performs the conversion.
source§

impl<'a> TryFrom<ValidKeyAmalgamation<'a, UnspecifiedParts, UnspecifiedRole, bool>> for ValidErasedKeyAmalgamation<'a, SecretParts>

§

type Error = Error

The type returned in the event of a conversion error.
source§

fn try_from(p: ValidErasedKeyAmalgamation<'a, UnspecifiedParts>) -> Result<Self>

Performs the conversion.
source§

impl<'a, P> ValidateAmalgamation<'a, Key<P, UnspecifiedRole>> for ValidErasedKeyAmalgamation<'a, P>
where P: 'a + KeyParts,

§

type V = ValidKeyAmalgamation<'a, P, UnspecifiedRole, bool>

The type returned by with_policy. Read more
source§

fn with_policy<T>(self, policy: &'a dyn Policy, time: T) -> Result<Self::V>
where T: Into<Option<SystemTime>>, Self: Sized,

Uses the specified Policy and reference time with the amalgamation. Read more