PeSign

Struct PeSign 

Source
pub struct PeSign {
    pub signed_data: SignedData,
    pub authenticode_digest: String,
    pub authenticode_digest_algorithm: Algorithm,
    /* private fields */
}
Expand description

Obtaining a PE file’s signature

This includes all the information in the PE signature: certificate list, signer information, and Authenticode.

You can retrieve the signature data from a specified PE file path using PeSign::from_pe_path, or parse it from an exported signature byte array using PeSign::from_certificate_table_buf.

Example:

use pesign::PeSign;

let pesign = PeSign::from_pe_path("test.exe").unwrap().unwrap();
println!("{}", pesign.signed_data.signer_info);

Fields§

§signed_data: SignedData§authenticode_digest: String§authenticode_digest_algorithm: Algorithm

Implementations§

Source§

impl<'a> PeSign

Source

pub fn from_reader<R: Reader<'a>>(decoder: &mut R) -> Result<Self, PeSignError>

Source

pub fn from_certificate_table_buf(bin: &[u8]) -> Result<Self, PeSignError>

Extract signature information from the exported certificate.

Source

pub fn from_pe_path<P: AsRef<Path>>( filename: P, ) -> Result<Option<Self>, PeSignError>

Extract signature information from a disk file.

Source

pub fn from_pe_data(bin: &[u8]) -> Result<Option<Self>, PeSignError>

Extract signature information from a memory pe data.

Source

pub fn from_pe_image(image: &mut PE<'_>) -> Result<Option<Self>, PeSignError>

Extract signature information from PE.

Source

pub fn verify(&self, option: &VerifyOption) -> Result<PeSignStatus, PeSignError>

Verify the validity of the certificate.

Source

pub fn verify_pe_path<P: AsRef<Path>>( &self, filename: P, option: &VerifyOption, ) -> Result<PeSignStatus, PeSignError>

Verify the validity of the certificate.

Source

pub fn verify_pe_data( &self, bin: &[u8], option: &VerifyOption, ) -> Result<PeSignStatus, PeSignError>

Verify the validity of the certificate.

Source

pub fn verify_pe_image( &self, image: &mut PE<'_>, option: &VerifyOption, ) -> Result<PeSignStatus, PeSignError>

Verify the validity of the certificate.

Source

pub fn export_der(&self) -> Result<Vec<u8>, PeSignError>

Export as DER.

Source

pub fn export_pem(&self) -> Result<String, PeSignError>

Export as PEM.

Trait Implementations§

Source§

impl Clone for PeSign

Source§

fn clone(&self) -> PeSign

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 PeSign

Source§

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

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

impl<'a> Decode<'a> for PeSign

Source§

fn decode<R: Reader<'a>>(decoder: &mut R) -> Result<Self>

Attempt to decode this message using the provided decoder.
Source§

fn from_der(bytes: &'a [u8]) -> Result<Self, Error>

Parse Self from the provided DER-encoded byte slice.
Source§

impl Encode for PeSign

Source§

fn encoded_len(&self) -> Result<Length>

Compute the length of this value in bytes when encoded as ASN.1 DER.
Source§

fn encode(&self, encoder: &mut impl Writer) -> Result<()>

Encode this value as ASN.1 DER using the provided Writer.
Source§

fn encode_to_slice<'a>(&self, buf: &'a mut [u8]) -> Result<&'a [u8], Error>

Encode this value to the provided byte slice, returning a sub-slice containing the encoded message.
Source§

fn encode_to_vec(&self, buf: &mut Vec<u8>) -> Result<Length, Error>

Encode this message as ASN.1 DER, appending it to the provided byte vector.
Source§

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

Encode this type as DER, returning a byte vector.
Source§

impl PartialEq for PeSign

Source§

fn eq(&self, other: &PeSign) -> 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 PemLabel for PeSign

Source§

const PEM_LABEL: &'static str = "PKCS7"

Expected PEM type label for a given document, e.g. "PRIVATE KEY"
Source§

fn validate_pem_label(actual: &str) -> Result<(), Error>

Validate that a given label matches the expected label.
Source§

impl Eq for PeSign

Source§

impl StructuralPartialEq for PeSign

Auto Trait Implementations§

§

impl Freeze for PeSign

§

impl RefUnwindSafe for PeSign

§

impl Send for PeSign

§

impl Sync for PeSign

§

impl Unpin for PeSign

§

impl UnwindSafe for PeSign

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> DecodePem for T
where T: DecodeOwned + PemLabel,

Source§

fn from_pem(pem: impl AsRef<[u8]>) -> Result<T, Error>

Try to decode this type from PEM.
Source§

impl<T> EncodePem for T
where T: Encode + PemLabel,

Source§

fn to_pem(&self, line_ending: LineEnding) -> Result<String, Error>

Try to encode this type as PEM.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DecodeOwned for T
where T: for<'a> Decode<'a>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,