Struct AuthenticodeInfo

Source
pub struct AuthenticodeInfo<'a> {
    pub certificates: Vec<AuthenticodeCertificate>,
    pub digest: DigestInfo,
    /* private fields */
}
Expand description

Contains information about the Authenticode signature of a PE file.

Fields§

§certificates: Vec<AuthenticodeCertificate>

List of certificates with additional information found in the PE file.

§digest: DigestInfo

Information about the digest of the Authenticode signature file.

Implementations§

Source§

impl AuthenticodeInfo<'_>

Source

pub fn verify(&self) -> Result<bool, AuthenticodeError>

Verifies the Authenticode signature by comparing the hash of the PE file with the hash found in the Authenticode signature.

Supports SHA1 and SHA256 algorithms, for all other algorithms, use the authenticode_hash function to compute the hash and compare it manually with the DigestInfo.hash.

Source

pub fn authenticode_sha1(&self) -> Result<Vec<u8>, AuthenticodeError>

Returns the SHA1 hash of the Authenticode signature computed from the PE file.

Source

pub fn authenticode_sha256(&self) -> Result<Vec<u8>, AuthenticodeError>

Returns the SHA256 hash of the Authenticode signature computed from the PE file.

Source

pub fn authenticode_hash<D: Digest>(&self) -> Result<Vec<u8>, AuthenticodeError>

Returns the hash of the Authenticode signature computed from the PE file.

This function is generic and can be used with any hashing algorithm that implements the Digest trait.

§Example
use sha2::Sha512;
use cross_authenticode::AuthenticodeInfo;
use std::fs::File;
use std::path::PathBuf;

let pe_path = PathBuf::from("test-pe/test-signed-64.bin");
let pe_file = std::fs::read(pe_path).unwrap();

let authenticode_info = AuthenticodeInfo::try_from(&pe_file).unwrap();
let hash = authenticode_info.authenticode_hash::<Sha512>().unwrap();

Trait Implementations§

Source§

impl<'a> TryFrom<&'a [u8]> for AuthenticodeInfo<'a>

Tries to create an AuthenticodeInfo struct from a slice of bytes.

Source§

type Error = AuthenticodeError

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

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

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Vec<u8>> for AuthenticodeInfo<'a>

Tries to create an AuthenticodeInfo struct from a vector of bytes.

Source§

type Error = AuthenticodeError

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

fn try_from(data: &'a Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a> Freeze for AuthenticodeInfo<'a>

§

impl<'a> !RefUnwindSafe for AuthenticodeInfo<'a>

§

impl<'a> !Send for AuthenticodeInfo<'a>

§

impl<'a> !Sync for AuthenticodeInfo<'a>

§

impl<'a> Unpin for AuthenticodeInfo<'a>

§

impl<'a> !UnwindSafe for AuthenticodeInfo<'a>

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> 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, 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.