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

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

A Key and its associated data.

Methods

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

pub fn key(&self) -> &'a Key<P, UnspecifiedRole> where
    &'a Key<P, UnspecifiedRole>: From<&'a Key<PublicParts, PrimaryRole>>, 
[src]

Returns the key.

pub fn cert(&self) -> &'a Cert[src]

Returns the certificate that the key came from.

pub fn has_secret(&self) -> bool[src]

Returns whether the key contains secret key material.

pub fn has_unencrypted_secret(&self) -> bool[src]

Returns whether the key contains unencrypted secret key material.

pub fn bundle(&self) -> &'a KeyBundle<P, UnspecifiedRole> where
    &'a KeyBundle<P, UnspecifiedRole>: From<&'a KeyBundle<PublicParts, PrimaryRole>>, 
[src]

Returns this key's bundle.

pub fn with_policy<T>(
    self,
    policy: &'a dyn Policy,
    time: T
) -> Result<ValidKeyAmalgamation<'a, P>> where
    T: Into<Option<SystemTime>>, 
[src]

Sets the reference time for the amalgamation.

If time is None, the current time is used.

This transforms the KeyAmalgamation into a ValidKeyAmalgamation.

Methods from Deref<Target = Key<P, UnspecifiedRole>>

pub fn encrypt(&self, data: &SessionKey) -> Result<Ciphertext>[src]

Encrypts the given data with this key.

pub fn verify(&self, sig: &Signature, digest: &[u8]) -> Result<()>[src]

Verifies the given signature.

pub fn mark_parts_public_ref(&self) -> &Key<PublicParts, R>[src]

Changes the key's parts tag to PublicParts.

pub fn mark_parts_secret_ref(&self) -> Result<&Key<SecretParts, R>>[src]

Changes the key's parts tag to SecretParts.

pub fn mark_parts_unspecified_ref(&self) -> &Key<UnspecifiedParts, R>[src]

Changes the key's parts tag to UnspecifiedParts.

pub fn mark_role_primary_ref(&self) -> &Key<P, PrimaryRole>[src]

Changes the key's role tag to PrimaryRole.

pub fn mark_role_subordinate_ref(&self) -> &Key<P, SubordinateRole>[src]

Changes the key's role tag to SubordinateRole.

pub fn mark_role_unspecified_ref(&self) -> &Key<P, UnspecifiedRole>[src]

Changes the key's role tag to UnspecifiedRole.

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

Gets the version.

pub fn public_cmp<PB, RB>(&self, b: &Key<PB, RB>) -> Ordering where
    PB: KeyParts,
    RB: KeyRole
[src]

Compares the public bits of two keys.

This returns Ordering::Equal if the public MPIs, version, creation time and algorithm of the two Keys match. This does not consider the packet's encoding, packet's tag or the secret key material.

pub fn bind(
    &self,
    signer: &mut dyn Signer,
    cert: &Cert,
    signature: Builder
) -> Result<Signature>
[src]

Creates a binding signature.

The signature binds this userid to cert. signer will be used to create a signature using signature as builder. Thehash_algo defaults to SHA512, creation_time to the current time.

This function adds a creation time subpacket, a issuer fingerprint subpacket, and a issuer subpacket to the signature.

Example

This example demonstrates how to bind this key to a Cert. Note that in general, the CertBuilder is a better way to add subkeys to a Cert.

use sequoia_openpgp::policy::StandardPolicy;
let p = &StandardPolicy::new();

// Generate a Cert, and create a keypair from the primary key.
let (cert, _) = CertBuilder::new().generate()?;
let mut keypair = cert.primary_key().key().clone()
    .mark_parts_secret()?.into_keypair()?;

// Let's add an encryption subkey.
let flags = KeyFlags::default().set_storage_encryption(true);
assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false)
               .key_flags(&flags).count(),
           0);

// Generate a subkey and a binding signature.
let subkey: Key<_, key::SubordinateRole> =
    Key4::generate_ecc(false, Curve::Cv25519)?
    .into();
let builder = signature::Builder::new(SignatureType::SubkeyBinding)
    .set_key_flags(&flags)?;
let binding = subkey.bind(&mut keypair, &cert, builder)?;

// Now merge the key and binding signature into the Cert.
let cert = cert.merge_packets(vec![subkey.into(),
                                 binding.into()])?;

// Check that we have an encryption subkey.
assert_eq!(cert.keys().with_policy(p, None).alive().revoked(false)
               .key_flags(flags).count(),
           1);

Trait Implementations

impl<'a, P: Clone + KeyParts> Clone for KeyAmalgamation<'a, P>[src]

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

impl<'a, P: KeyParts> Deref for KeyAmalgamation<'a, P> where
    &'a Key<P, UnspecifiedRole>: From<&'a Key<PublicParts, PrimaryRole>>, 
[src]

type Target = Key<P, UnspecifiedRole>

The resulting type after dereferencing.

impl<'a> From<KeyAmalgamation<'a, PublicParts>> for KeyAmalgamation<'a, UnspecifiedParts>[src]

impl<'a> From<KeyAmalgamation<'a, SecretParts>> for KeyAmalgamation<'a, PublicParts>[src]

impl<'a, P> From<PrimaryKeyAmalgamation<'a, P>> for KeyAmalgamation<'a, P> where
    P: KeyParts
[src]

impl<'a, P: KeyParts> From<ValidKeyAmalgamation<'a, P>> for KeyAmalgamation<'a, P>[src]

impl<'a> TryFrom<KeyAmalgamation<'a, PublicParts>> for KeyAmalgamation<'a, SecretParts>[src]

type Error = Error

The type returned in the event of a conversion error.

Auto Trait Implementations

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

impl<'a, P> Send for KeyAmalgamation<'a, P> where
    P: Sync

impl<'a, P> Sync for KeyAmalgamation<'a, P> where
    P: Sync

impl<'a, P> Unpin for KeyAmalgamation<'a, P>

impl<'a, P> !UnwindSafe for KeyAmalgamation<'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<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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<V, T> VZip<V> for T where
    V: MultiLane<T>,