SignaturePacket

Struct SignaturePacket 

Source
pub struct SignaturePacket {
    pub sig_type: SignatureType,
    pub pubkey_algo: PublicKeyAlgorithm,
    pub hash_algo: HashAlgorithm,
    pub hashed_subpackets: Vec<Subpacket>,
    pub unhashed_subpackets: Vec<Subpacket>,
    /* private fields */
}
Expand description

The contents of a PGP signature packet.

Fields§

§sig_type: SignatureType§pubkey_algo: PublicKeyAlgorithm§hash_algo: HashAlgorithm§hashed_subpackets: Vec<Subpacket>§unhashed_subpackets: Vec<Subpacket>

Implementations§

Source§

impl SignaturePacket

Source

pub fn new( sig_type: SignatureType, pubkey_algo: PublicKeyAlgorithm, hash_algo: HashAlgorithm, ) -> Result<SignaturePacket, Error>

Create a new signature with the given parameters. The new signature’s creation time will be set to the current system time, and the contents will be empty.

Source

pub fn contents(&self) -> Result<Signature, Error>

Retrieve the contents of this signature. For RSA signatures, this is a single multiprecision integer representing m^d mod n; for DSA signatures this is two multiprecision integers representing r and s.

Source

pub fn set_contents(&mut self, sig: Signature) -> Result<(), Error>

Set the contents of this signature.

Source

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

Retrive the creation time of this signature.

Source

pub fn set_timestamp(&mut self, timestamp: Duration)

Set the creation time of this signature.

Source

pub fn signer(&self) -> Option<u64>

Retrieve the key ID of this signature’s issuer.

Source

pub fn set_signer(&mut self, signer: u64)

Set the key ID of this signature’s issuer.

Source

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

Retrieve the preferred hash algorithms of this signature.

Source

pub fn set_preferred_hash_algorithms<T: AsRef<[HashAlgorithm]>>( &mut self, algos: T, hashed: bool, )

Set the preferred hash algorithms of this signature. If hashed is true, this subpacket will be added as a hashed subpacket.

Source

pub fn signable_payload<T: AsRef<[u8]>>( &self, payload: T, ) -> Result<Vec<u8>, Error>

Build a payload suitable for signing.

Note that this payload must be placed in an ASN.1 DigestInfo structure prior to signing, which is outside the scope of this library.

Source

pub fn header(&self) -> Result<Vec<u8>, Error>

Retrieve the header for this signature, i.e. everything except the MPI contents of the signature.

Source

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

Serialize this signature to bytes.

Source

pub fn from_bytes(bytes: &[u8]) -> Result<SignaturePacket, Error>

Read in a signature from some bytes.

Trait Implementations§

Source§

impl Clone for SignaturePacket

Source§

fn clone(&self) -> SignaturePacket

Returns a duplicate 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 SignaturePacket

Source§

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

Formats the value using the given formatter. Read more

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.