Struct Signature

Source
pub struct Signature {
    pub config: SignatureConfig,
    pub signed_hash_value: [u8; 2],
    pub signature: SignatureBytes,
    /* private fields */
}
Expand description

Fields§

§config: SignatureConfig§signed_hash_value: [u8; 2]§signature: SignatureBytes

Implementations§

Source§

impl Signature

Source

pub fn from_slice(packet_version: Version, input: &[u8]) -> Result<Self>

Parses a Signature packet from the given slice.

Source§

impl Signature

Source

pub fn v2( packet_version: Version, typ: SignatureType, pub_alg: PublicKeyAlgorithm, hash_alg: HashAlgorithm, created: DateTime<Utc>, issuer: KeyId, signed_hash_value: [u8; 2], signature: SignatureBytes, ) -> Self

Constructor for an OpenPGP v2 signature packet. Note: This is a historical packet version!

Source

pub fn v3( packet_version: Version, typ: SignatureType, pub_alg: PublicKeyAlgorithm, hash_alg: HashAlgorithm, created: DateTime<Utc>, issuer: KeyId, signed_hash_value: [u8; 2], signature: SignatureBytes, ) -> Self

Constructor for an OpenPGP v3 signature packet. Note: This is a historical packet version!

Source

pub fn v4( packet_version: Version, typ: SignatureType, pub_alg: PublicKeyAlgorithm, hash_alg: HashAlgorithm, signed_hash_value: [u8; 2], signature: SignatureBytes, hashed_subpackets: Vec<Subpacket>, unhashed_subpackets: Vec<Subpacket>, ) -> Self

Constructor for an OpenPGP v4 signature packet.

OpenPGP v4 signatures are typically used with OpenPGP v4 keys, as specified in RFC 9580 (and formerly in 4880 and 2440).

Source

pub fn v6( packet_version: Version, typ: SignatureType, pub_alg: PublicKeyAlgorithm, hash_alg: HashAlgorithm, signed_hash_value: [u8; 2], signature: SignatureBytes, hashed_subpackets: Vec<Subpacket>, unhashed_subpackets: Vec<Subpacket>, salt: Vec<u8>, ) -> Self

Constructor for an OpenPGP v6 signature packet.

OpenPGP v6 signatures are specified in RFC 9580 and only used with OpenPGP v6 keys.

Source

pub fn from_config( config: SignatureConfig, signed_hash_value: [u8; 2], signature: SignatureBytes, ) -> Self

Source

pub fn typ(&self) -> SignatureType

Returns what kind of signature this is.

Source

pub fn hash_alg(&self) -> HashAlgorithm

The used HashAlgorithm.

Source

pub fn verify<R>(&self, key: &impl PublicKeyTrait, data: R) -> Result<()>
where R: Read,

Verify this signature.

Source

pub fn verify_certification( &self, key: &impl PublicKeyTrait, tag: Tag, id: &impl Serialize, ) -> Result<()>

Verifies a certification signature type (for self-signatures).

Source

pub fn verify_third_party_certification( &self, signee: &impl PublicKeyTrait, signer: &impl PublicKeyTrait, tag: Tag, id: &impl Serialize, ) -> Result<()>

Verifies a certification signature type (for third-party signatures).

Source

pub fn verify_key_binding( &self, signing_key: &impl PublicKeyTrait, key: &impl PublicKeyTrait, ) -> Result<()>

Verifies a key binding (which binds a subkey to the primary key).

“Subkey Binding Signature (type ID 0x18)”

Source

pub fn verify_backwards_key_binding( &self, signing_key: &impl PublicKeyTrait, key: &impl PublicKeyTrait, ) -> Result<()>

Verifies a primary key binding signature, or “back signature” (which links the primary to a signing subkey).

“Primary Key Binding Signature (type ID 0x19)”

Source

pub fn verify_key(&self, key: &impl PublicKeyTrait) -> Result<()>

Verifies a direct key signature or a revocation.

Source

pub fn is_certification(&self) -> bool

Returns if the signature is a certification or not.

Source

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

Source

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

Source

pub fn created(&self) -> Option<&DateTime<Utc>>

Source

pub fn issuer(&self) -> Vec<&KeyId>

Source

pub fn issuer_fingerprint(&self) -> Vec<&Fingerprint>

Source

pub fn preferred_symmetric_algs(&self) -> &[SymmetricKeyAlgorithm]

Source

pub fn preferred_aead_algs(&self) -> &[(SymmetricKeyAlgorithm, AeadAlgorithm)]

Source

pub fn preferred_hash_algs(&self) -> &[HashAlgorithm]

Source

pub fn preferred_compression_algs(&self) -> &[CompressionAlgorithm]

Source

pub fn key_server_prefs(&self) -> &[u8]

Source

pub fn key_flags(&self) -> KeyFlags

Source

pub fn features(&self) -> &[u8]

Source

pub fn revocation_reason_code(&self) -> Option<&RevocationCode>

Source

pub fn revocation_reason_string(&self) -> Option<&BStr>

Source

pub fn is_primary(&self) -> bool

Source

pub fn is_revocable(&self) -> bool

Source

pub fn embedded_signature(&self) -> Option<&Signature>

Source

pub fn preferred_key_server(&self) -> Option<&str>

Source

pub fn notations(&self) -> Vec<&Notation>

Source

pub fn revocation_key(&self) -> Option<&RevocationKey>

Source

pub fn signers_userid(&self) -> Option<&BStr>

Gets the user id of the signer

Note that the user id may not be valid utf-8, if it was created using a different encoding. But since the RFC describes every text as utf-8 it is up to the caller whether to error on non utf-8 data.

Source

pub fn policy_uri(&self) -> Option<&str>

Source

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

Source

pub fn regular_expression(&self) -> Option<&BStr>

Source

pub fn exportable_certification(&self) -> bool

Trait Implementations§

Source§

impl Clone for Signature

Source§

fn clone(&self) -> Signature

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Signature

Source§

fn fmt(&self, __derive_more_f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<Signature> for Packet

Source§

fn from(other: Signature) -> Packet

Converts to this type from the input type.
Source§

impl PacketTrait for Signature

Source§

impl PartialEq for Signature

Source§

fn eq(&self, other: &Signature) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Signature

Source§

fn to_writer<W: Write>(&self, writer: &mut W) -> Result<()>

Source§

fn to_bytes(&self) -> Result<Vec<u8>>

Source§

impl TryFrom<Packet> for Signature

Source§

type Error = Error

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

fn try_from(other: Packet) -> Result<Signature, Self::Error>

Performs the conversion.
Source§

impl Eq for Signature

Source§

impl StructuralPartialEq for Signature

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

fn vzip(self) -> V