[−][src]Struct sequoia_openpgp::cert::components::KeyAmalgamation
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]
&'a Key<P, UnspecifiedRole>: From<&'a Key<PublicParts, PrimaryRole>>,
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]
&'a KeyBundle<P, UnspecifiedRole>: From<&'a KeyBundle<PublicParts, PrimaryRole>>,
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]
self,
policy: &'a dyn Policy,
time: T
) -> Result<ValidKeyAmalgamation<'a, P>> where
T: Into<Option<SystemTime>>,
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]
PB: KeyParts,
RB: KeyRole,
Compares the public bits of two keys.
This returns Ordering::Equal if the public MPIs, version,
creation time and algorithm of the two Key
s 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]
&self,
signer: &mut dyn Signer,
cert: &Cert,
signature: Builder
) -> Result<Signature>
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]
fn clone(&self) -> KeyAmalgamation<'a, P>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[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]
&'a Key<P, UnspecifiedRole>: From<&'a Key<PublicParts, PrimaryRole>>,
type Target = Key<P, UnspecifiedRole>
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
impl<'a> From<KeyAmalgamation<'a, PublicParts>> for KeyAmalgamation<'a, UnspecifiedParts>
[src]
fn from(ka: KeyAmalgamation<'a, PublicParts>) -> Self
[src]
impl<'a> From<KeyAmalgamation<'a, SecretParts>> for KeyAmalgamation<'a, PublicParts>
[src]
fn from(ka: KeyAmalgamation<'a, SecretParts>) -> Self
[src]
impl<'a, P> From<PrimaryKeyAmalgamation<'a, P>> for KeyAmalgamation<'a, P> where
P: KeyParts,
[src]
P: KeyParts,
fn from(a: PrimaryKeyAmalgamation<'a, P>) -> Self
[src]
impl<'a, P: KeyParts> From<ValidKeyAmalgamation<'a, P>> for KeyAmalgamation<'a, P>
[src]
fn from(vka: ValidKeyAmalgamation<'a, P>) -> Self
[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.
fn try_from(ka: KeyAmalgamation<'a, PublicParts>) -> Result<Self>
[src]
Auto Trait Implementations
impl<'a, P> !RefUnwindSafe for KeyAmalgamation<'a, P>
impl<'a, P> Send for KeyAmalgamation<'a, P> where
P: Sync,
P: Sync,
impl<'a, P> Sync for KeyAmalgamation<'a, P> where
P: Sync,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,