[][src]Struct sequoia_openpgp::packet::signature::Signature

pub struct Signature { /* fields omitted */ }

Holds a signature packet.

Signature packets are used both for certification purposes as well as for document signing purposes.

See Section 5.2 of RFC 4880 for details.

Methods

impl Signature[src]

pub fn hash<H: Hash>(&self, hash: &mut H)[src]

Adds the Signature to the provided hash context.

impl Signature[src]

Hashing-related functionality.

pub fn primary_key_binding_hash<'a, S>(sig: S, key: &Key) -> Vec<u8> where
    S: Into<&'a Builder>, 
[src]

Returns the message digest of the primary key binding over the specified primary key.

pub fn subkey_binding_hash<'a, S>(sig: S, key: &Key, subkey: &Key) -> Vec<u8> where
    S: Into<&'a Builder>, 
[src]

Returns the message digest of the subkey binding over the specified primary key and subkey.

pub fn userid_binding_hash<'a, S>(sig: S, key: &Key, userid: &UserID) -> Vec<u8> where
    S: Into<&'a Builder>, 
[src]

Returns the message digest of the user ID binding over the specified primary key, user ID, and signature.

pub fn user_attribute_binding_hash<'a, S>(
    sig: S,
    key: &Key,
    ua: &UserAttribute
) -> Vec<u8> where
    S: Into<&'a Builder>, 
[src]

Returns the message digest of the user attribute binding over the specified primary key, user attribute, and signature.

impl Signature[src]

pub fn signature_creation_time(&self) -> Option<Tm>[src]

Returns the value of the Creation Time subpacket, which contains the time when the signature was created as a unix timestamp.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn signature_expiration_time(&self) -> Option<Duration>[src]

Returns the value of the Signature Expiration Time subpacket, which contains when the signature expires as the number of seconds after its creation.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

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

Returns whether or not the signature is expired.

Note that Section 5.2.3.4 of RFC 4880 states that "[[A Signature Creation Time subpacket]] MUST be present in the hashed area." Consequently, if such a packet does not exist, but a "Signature Expiration Time" subpacket exists, we conservatively treat the signature as expired, because there is no way to evaluate the expiration time.

pub fn signature_expired_at(&self, tm: Tm) -> bool[src]

Returns whether or not the signature is expired at the given time.

Note that Section 5.2.3.4 of RFC 4880 states that "[[A Signature Creation Time subpacket]] MUST be present in the hashed area." Consequently, if such a packet does not exist, but a "Signature Expiration Time" subpacket exists, we conservatively treat the signature as expired, because there is no way to evaluate the expiration time.

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

Returns whether or not the signature is alive, i.e. the creation time has passed, but the expiration time has not.

Note that Section 5.2.3.4 of RFC 4880 states that "[[A Signature Creation Time subpacket]] MUST be present in the hashed area." Consequently, if such a packet does not exist, but a "Signature Expiration Time" subpacket exists, we conservatively treat the signature as expired, because there is no way to evaluate the expiration time.

pub fn signature_alive_at(&self, tm: Tm) -> bool[src]

Returns whether or not the signature is alive at the given time, i.e. the creation time has passed, but the expiration time has not.

Note that Section 5.2.3.4 of RFC 4880 states that "[[A Signature Creation Time subpacket]] MUST be present in the hashed area." Consequently, if such a packet does not exist, but a "Signature Expiration Time" subpacket exists, we conservatively treat the signature as expired, because there is no way to evaluate the expiration time.

pub fn exportable_certification(&self) -> Option<bool>[src]

Returns the value of the Exportable Certification subpacket, which contains whether the certification should be exported (i.e., whether the packet is not a local signature).

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn trust_signature(&self) -> Option<(u8, u8)>[src]

Returns the value of the Trust Signature subpacket.

The return value is a tuple consisting of the level or depth and the trust amount.

Recall from Section 5.2.3.13 of RFC 4880:

Level 0 has the same meaning as an ordinary
validity signature.  Level 1 means that the signed key is asserted to
be a valid trusted introducer, with the 2nd octet of the body
specifying the degree of trust.  Level 2 means that the signed key is
asserted to be trusted to issue level 1 trust signatures, i.e., that
it is a "meta introducer".

And, the trust amount is:

interpreted such that values less than 120 indicate partial
trust and values of 120 or greater indicate complete trust.
Implementations SHOULD emit values of 60 for partial trust and
120 for complete trust.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn regular_expression(&self) -> Option<&[u8]>[src]

Returns the value of the Regular Expression subpacket.

This automatically strips any trailing NUL byte from the string.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn revocable(&self) -> Option<bool>[src]

Returns the value of the Revocable subpacket, which indicates whether the signature is revocable, i.e., whether revocation certificates for this signature should be ignored.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn key_expiration_time(&self) -> Option<Duration>[src]

Returns the value of the Key Expiration Time subpacket, which contains when the referenced key expires as the number of seconds after the key's creation.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn key_expired(&self, key: &Key) -> bool[src]

Returns whether or not the key is expired.

See Section 5.2.3.6 of RFC 4880.

pub fn key_expired_at(&self, key: &Key, tm: Tm) -> bool[src]

Returns whether or not the key is expired at the given time.

See Section 5.2.3.6 of RFC 4880.

pub fn key_alive(&self, key: &Key) -> bool[src]

Returns whether or not the given key is alive, i.e. the creation time has passed, but the expiration time has not.

See Section 5.2.3.6 of RFC 4880.

pub fn key_alive_at(&self, key: &Key, tm: Tm) -> bool[src]

Returns whether or not the given key is alive at the given time, i.e. the creation time has passed, but the expiration time has not.

See Section 5.2.3.6 of RFC 4880.

pub fn preferred_symmetric_algorithms(&self) -> Option<Vec<SymmetricAlgorithm>>[src]

Returns the value of the Preferred Symmetric Algorithms subpacket, which contains the list of symmetric algorithms that the key holder prefers, ordered according by the key holder's preference.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn revocation_key(&self) -> Option<(u8, PublicKeyAlgorithm, Fingerprint)>[src]

Returns the value of the Revocation Key subpacket, which contains a designated revoker.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn issuer(&self) -> Option<KeyID>[src]

Returns the value of the Issuer subpacket, which contains the KeyID of the key that allegedly created this signature.

Note: for historical reasons this packet is usually stored in the unhashed area of the signature and, consequently, it is not protected by the signature. Thus, it is trivial to modify it in transit. For this reason, the Issuer Fingerprint subpacket should be preferred, when it is present.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn notation_data(&self) -> Vec<NotationData>[src]

Returns the value of all Notation Data packets.

If the subpacket is not present or malformed, this returns None.

Note: unlike other subpacket accessor functions, this function returns all the Notation Data subpackets, not just the last one.

pub fn preferred_hash_algorithms(&self) -> Option<Vec<HashAlgorithm>>[src]

Returns the value of the Preferred Hash Algorithms subpacket, which contains the list of hash algorithms that the key holders prefers, ordered according by the key holder's preference.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn preferred_compression_algorithms(
    &self
) -> Option<Vec<CompressionAlgorithm>>
[src]

Returns the value of the Preferred Compression Algorithms subpacket, which contains the list of compression algorithms that the key holder prefers, ordered according by the key holder's preference.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn key_server_preferences(&self) -> KeyServerPreferences[src]

Returns the value of the Key Server Preferences subpacket, which contains the key holder's key server preferences.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn preferred_key_server(&self) -> Option<&[u8]>[src]

Returns the value of the Preferred Key Server subpacket, which contains the user's preferred key server for updates.

Note: this packet should be ignored, because it acts as key tracker.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn primary_userid(&self) -> Option<bool>[src]

Returns the value of the Primary UserID subpacket, which indicates whether the referenced UserID should be considered the user's primary User ID.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn policy_uri(&self) -> Option<&[u8]>[src]

Returns the value of the Policy URI subpacket.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn key_flags(&self) -> KeyFlags[src]

Returns the value of the Key Flags subpacket, which contains information about the referenced key, in particular, how it is used (certification, signing, encryption, authentication), and how it is stored (split, held by multiple people).

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn signers_user_id(&self) -> Option<&[u8]>[src]

Returns the value of the Signer's UserID subpacket, which contains the User ID that the key holder considers responsible for the signature.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn reason_for_revocation(&self) -> Option<(ReasonForRevocation, &[u8])>[src]

Returns the value of the Reason for Revocation subpacket.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn features(&self) -> Features[src]

Returns the value of the Features subpacket, which contains a list of features that the user's OpenPGP implementation supports.

If the subpacket is not present or malformed, this returns the default value.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn signature_target(
    &self
) -> Option<(PublicKeyAlgorithm, HashAlgorithm, &[u8])>
[src]

Returns the value of the Signature Target subpacket, which contains the hash of the referenced signature packet.

This is used, for instance, by a signature revocation certification to designate the signature that is being revoked.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn embedded_signature(&self) -> Option<Packet>[src]

Returns the value of the Embedded Signature subpacket, which contains a signature.

This is used, for instance, to store a subkey's primary key binding signature (0x19).

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn issuer_fingerprint(&self) -> Option<Fingerprint>[src]

Returns the value of the Issuer Fingerprint subpacket, which contains the fingerprint of the key that allegedly created this signature.

This subpacket should be preferred to the Issuer subpacket, because Fingerprints are not subject to collisions, and the Issuer subpacket is, for historic reasons, traditionally stored in the unhashed area, i.e., it is not cryptographically secured.

This is used, for instance, to store a subkey's primary key binding signature (0x19).

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn preferred_aead_algorithms(&self) -> Option<Vec<AEADAlgorithm>>[src]

Returns the value of the Preferred AEAD Algorithms subpacket, which contains the list of AEAD algorithms that the key holder prefers, ordered according by the key holder's preference.

If the subpacket is not present or malformed, this returns None.

Note: if the signature contains multiple instances of this subpacket, only the last one is considered.

pub fn intended_recipients(&self) -> Vec<Fingerprint>[src]

Returns the intended recipients.

impl Signature[src]

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

Gets the version.

pub fn sigtype(&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.

pub fn hashed_area(&self) -> &SubpacketArea[src]

Gets a reference to the hashed area.

pub fn unhashed_area(&self) -> &SubpacketArea[src]

Gets a reference to the unhashed area.

pub fn unhashed_area_mut(&mut self) -> &mut SubpacketArea[src]

Gets a mutable reference to the unhashed area.

pub fn hash_prefix(&self) -> &[u8; 2][src]

Gets the hash prefix.

pub fn set_hash_prefix(&mut self, prefix: [u8; 2])[src]

Sets the hash prefix.

pub fn mpis(&self) -> &Signature[src]

Gets the signature packet's MPIs.

pub fn set_mpis(&mut self, mpis: Signature)[src]

Sets the signature packet's MPIs.

pub fn computed_hash(&self) -> Option<&(HashAlgorithm, Vec<u8>)>[src]

Gets the computed hash value.

pub fn set_computed_hash(&mut self, hash: Option<(HashAlgorithm, Vec<u8>)>)[src]

Sets the computed hash value.

pub fn level(&self) -> usize[src]

Gets the signature level.

A level of 0 indicates that the signature is directly over the data, a level of 1 means that the signature is a notarization over all level 0 signatures and the data, and so on.

pub fn set_level(&mut self, level: usize)[src]

Sets the signature level.

A level of 0 indicates that the signature is directly over the data, a level of 1 means that the signature is a notarization over all level 0 signatures and the data, and so on.

pub fn get_issuer(&self) -> Option<KeyID>[src]

Gets the issuer.

Prefers the issuer fingerprint to the issuer keyid, which may be stored in the unhashed area.

pub fn verify_hash(
    &self,
    key: &Key,
    hash_algo: HashAlgorithm,
    hash: &[u8]
) -> Result<bool>
[src]

Verifies the signature against hash.

pub fn verify(&self, key: &Key) -> Result<bool>[src]

Returns whether key made the signature.

This function does not check whether key can made valid signatures; it is up to the caller to make sure the key is not revoked, not expired, has a valid self-signature, has a subkey binding signature (if appropriate), has the signing capability, etc.

pub fn verify_primary_key_binding(&self, signer: &Key, pk: &Key) -> Result<bool>[src]

Verifies the primary key binding.

self is the primary key binding signature, signer is the key that allegedly made the signature, and pk is the primary key.

For a self-signature, signer and pk will be the same.

pub fn verify_primary_key_revocation(
    &self,
    signer: &Key,
    pk: &Key
) -> Result<bool>
[src]

Verifies the primary key revocation certificate.

self is the primary key revocation certificate, signer is the key that allegedly made the signature, and pk is the primary key,

For a self-signature, signer and pk will be the same.

pub fn verify_subkey_binding(
    &self,
    signer: &Key,
    pk: &Key,
    subkey: &Key
) -> Result<bool>
[src]

Verifies the subkey binding.

self is the subkey key binding signature, signer is the key that allegedly made the signature, pk is the primary key, and subkey is the subkey.

For a self-signature, signer and pk will be the same.

If the signature indicates that this is a Signing capable subkey, then the back signature is also verified. If it is missing or can't be verified, then this function returns false.

pub fn verify_subkey_revocation(
    &self,
    signer: &Key,
    pk: &Key,
    subkey: &Key
) -> Result<bool>
[src]

Verifies the subkey revocation.

self is the subkey key revocation certificate, signer is the key that allegedly made the signature, pk is the primary key, and subkey is the subkey.

For a self-revocation, signer and pk will be the same.

pub fn verify_userid_binding(
    &self,
    signer: &Key,
    pk: &Key,
    userid: &UserID
) -> Result<bool>
[src]

Verifies the user id binding.

self is the user id binding signature, signer is the key that allegedly made the signature, pk is the primary key, and userid is the user id.

For a self-signature, signer and pk will be the same.

pub fn verify_userid_revocation(
    &self,
    signer: &Key,
    pk: &Key,
    userid: &UserID
) -> Result<bool>
[src]

Verifies the user id revocation certificate.

self is the revocation certificate, signer is the key that allegedly made the signature, pk is the primary key, and userid is the user id.

For a self-signature, signer and pk will be the same.

pub fn verify_user_attribute_binding(
    &self,
    signer: &Key,
    pk: &Key,
    ua: &UserAttribute
) -> Result<bool>
[src]

Verifies the user attribute binding.

self is the user attribute binding signature, signer is the key that allegedly made the signature, pk is the primary key, and ua is the user attribute.

For a self-signature, signer and pk will be the same.

pub fn verify_user_attribute_revocation(
    &self,
    signer: &Key,
    pk: &Key,
    ua: &UserAttribute
) -> Result<bool>
[src]

Verifies the user attribute revocation certificate.

self is the user attribute binding signature, signer is the key that allegedly made the signature, pk is the primary key, and ua is the user attribute.

For a self-signature, signer and pk will be the same.

pub fn to_packet(self) -> Packet[src]

Convert the Signature struct to a Packet.

Trait Implementations

impl Serialize for Signature[src]

fn serialize<W: Write>(&self, o: &mut W) -> Result<()>[src]

Writes a serialized version of the specified Signature packet to o.

Note: this function does not compute the signature (which would require access to the private key); it assumes that sig.mpis is up to date.

Errors

Returns Error::InvalidArgument if invoked on a non-version 4 signature, or if either the hashed-area or the unhashed-area exceeds the size limit of 2^16.

fn to_vec(&self) -> Result<Vec<u8>>[src]

Serializes the packet to a vector.

impl From<Signature> for Builder[src]

impl<'a> From<&'a Signature> for &'a Builder[src]

impl From<Signature> for Packet[src]

impl Eq for Signature[src]

impl PartialEq<Signature> for Signature[src]

#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0
[src]

This method tests for !=.

impl Clone for Signature[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl Hash for Signature[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for Signature[src]

Auto Trait Implementations

impl Send for Signature

impl !Sync for Signature

Blanket Implementations

impl<T> From for T[src]

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

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.