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<'_>
impl AuthenticodeInfo<'_>
Sourcepub fn verify(&self) -> Result<bool, AuthenticodeError>
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
.
Sourcepub fn authenticode_sha1(&self) -> Result<Vec<u8>, AuthenticodeError>
pub fn authenticode_sha1(&self) -> Result<Vec<u8>, AuthenticodeError>
Returns the SHA1 hash of the Authenticode signature computed from the PE file.
Sourcepub fn authenticode_sha256(&self) -> Result<Vec<u8>, AuthenticodeError>
pub fn authenticode_sha256(&self) -> Result<Vec<u8>, AuthenticodeError>
Returns the SHA256 hash of the Authenticode signature computed from the PE file.
Sourcepub fn authenticode_hash<D: Digest>(&self) -> Result<Vec<u8>, AuthenticodeError>
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.
impl<'a> TryFrom<&'a [u8]> for AuthenticodeInfo<'a>
Tries to create an AuthenticodeInfo
struct from a slice of bytes.