[][src]Struct sequoia_openpgp::cert::components::ValidKeyIter

pub struct ValidKeyIter<'a, P: KeyParts> { /* fields omitted */ }

An iterator over all valid Keys in a certificate.

A key is valid at time t if it was not created after t and it has a live self-signature at time t. Note: this does not mean that the key or the certificate is also live at time t; the key or certificate may be expired, but the self-signature is still valid.

ValidKeyIter follows the builder pattern. There is no need to explicitly finalize it, however: it already implements the Iterator trait.

Methods

impl<'a, P: 'a + KeyParts> ValidKeyIter<'a, P>[src]

pub fn key_flags<F>(self, flags: F) -> Self where
    F: Borrow<KeyFlags>, 
[src]

Returns keys that have the at least one of the flags specified in flags.

If you call this function (or one of for_certification or for_signing functions) multiple times, the union of the values is used. Thus, cert.flags().for_certification().for_signing() will return keys that are certification capable or signing capable.

If you need more complex filtering, e.g., you want a key that is both certification and signing capable, then use Iterator::filter.

pub fn for_certification(self) -> Self[src]

Returns keys that are certification capable.

See key_flags for caveats.

pub fn for_signing(self) -> Self[src]

Returns keys that are signing capable.

See key_flags for caveats.

pub fn for_authentication(self) -> Self[src]

Returns keys that are authentication capable.

See key_flags for caveats.

pub fn for_storage_encryption(self) -> Self[src]

Returns keys that are capable of encrypting data at rest.

See key_flags for caveats.

pub fn for_transport_encryption(self) -> Self[src]

Returns keys that are capable of encrypting data for transport.

See key_flags for caveats.

pub fn alive(self) -> Self[src]

Only returns keys that are alive.

Note: this only checks if the key is alive; it does not check whether the certificate is alive.

pub fn revoked<T>(self, revoked: T) -> Self where
    T: Into<Option<bool>>, 
[src]

Filters by whether a key is definitely revoked.

A value of None disables this filter.

Note: If you call this function multiple times on the same iterator, only the last value is used.

Note: This only checks if the key is not revoked; it does not check whether the certificate not revoked.

This filter checks whether a key's revocation status is RevocationStatus::Revoked or not. The latter (i.e., revoked(false)) is equivalent to:

extern crate sequoia_openpgp as openpgp;
use openpgp::RevocationStatus;
use openpgp::cert::components::Amalgamation;
use sequoia_openpgp::policy::StandardPolicy;

let p = &StandardPolicy::new();

let non_revoked_keys = cert
    .keys()
    .with_policy(p, timestamp)
    .filter(|ka| {
        match ka.revoked() {
            RevocationStatus::Revoked(_) =>
                // It's definitely revoked, skip it.
                false,
            RevocationStatus::CouldBe(_) =>
                // There is a designated revoker that we
                // should check, but don't (or can't).  To
                // avoid a denial of service arising from fake
                // revocations, we assume that the key has not
                // been revoked and return it.
                true,
            RevocationStatus::NotAsFarAsWeKnow =>
                // We have no evidence to suggest that the key
                // is revoked.
                true,
        }
    })
    .map(|ka| ka.key())
    .collect::<Vec<_>>();

As the example shows, this filter is significantly less flexible than using KeyAmalgamation::revoked. However, this filter implements a typical policy, and does not preclude using filter to realize alternative policies.

pub fn secret(self) -> ValidKeyIter<'a, SecretParts>[src]

Changes the filter to only return keys with secret key material.

pub fn unencrypted_secret(self) -> ValidKeyIter<'a, SecretParts>[src]

Changes the filter to only return keys with unencrypted secret key material.

pub fn key_handle<H>(self, h: H) -> Self where
    H: Into<KeyHandle>, 
[src]

Only returns a key if it matches the specified handle.

Note: this function is cumulative. If you call this function (or key_handles) multiple times, then the iterator returns a key if it matches any of the specified handles.

pub fn key_handles<'b>(self, h: impl Iterator<Item = &'b KeyHandle>) -> Self where
    'a: 'b, 
[src]

Only returns a key if it matches any of the specified handles.

Note: this function is cumulative. If you call this function (or key_handle) multiple times, then the iterator returns a key if it matches any of the specified handles.

Trait Implementations

impl<'a, P: KeyParts> Debug for ValidKeyIter<'a, P>[src]

impl<'a> Iterator for ValidKeyIter<'a, PublicParts>[src]

type Item = ValidKeyAmalgamation<'a, PublicParts>

The type of the elements being iterated over.

impl<'a> Iterator for ValidKeyIter<'a, UnspecifiedParts>[src]

type Item = ValidKeyAmalgamation<'a, UnspecifiedParts>

The type of the elements being iterated over.

impl<'a> Iterator for ValidKeyIter<'a, SecretParts>[src]

type Item = ValidKeyAmalgamation<'a, SecretParts>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a, P> !RefUnwindSafe for ValidKeyIter<'a, P>

impl<'a, P> !Send for ValidKeyIter<'a, P>

impl<'a, P> !Sync for ValidKeyIter<'a, P>

impl<'a, P> Unpin for ValidKeyIter<'a, P> where
    P: Unpin

impl<'a, P> !UnwindSafe for ValidKeyIter<'a, P>

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

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

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<I> IteratorRandom for I where
    I: Iterator
[src]

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

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> 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<I> UnicodeNormalization<I> for I where
    I: Iterator<Item = char>, 
[src]

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