cross_authenticode/
lib.rs

1//! Cross platform library for verifying Authenticode signed files.
2//!
3//! This library can be used to verify the Authenticode signature of a PE file on both Windows and
4//! Linux.
5//!
6//! # Example
7//! ```rust
8//! use cross_authenticode::{AuthenticodeInfo, ToHex, Algorithm};
9//! use std::fs::File;
10//! use std::path::PathBuf;
11//!
12//! let pe_path = PathBuf::from("test-pe/test-signed-64.bin");
13//! let pe_file = std::fs::read(pe_path).unwrap();
14//!
15//! let ai = AuthenticodeInfo::try_from(&pe_file).unwrap();
16//!
17//! // Check thumbprints of the first two certificates
18//! assert_eq!(ai.certificates[0].sha1.to_hex(), "f55115d2439ce0a7529ffaaea654be2c71dce955");
19//! assert_eq!(ai.certificates[1].sha1.to_hex(), "580a6f4cc4e4b669b9ebdc1b2b3e087b80d0678d");
20//!
21//! // Check the Authenticode algorithm
22//! assert_eq!(ai.digest.algorithm, Algorithm::Sha256);
23//!
24//! // Verify the the Authenticode signature
25//! assert!(ai.verify().unwrap());
26//!
27//! // Verify the Authenticode signature manually
28//! assert_eq!(ai.authenticode_sha256().unwrap(), ai.digest.hash);
29//! ```
30
31mod algorithm;
32mod authenticode_certificate;
33mod authenticode_info;
34mod error;
35mod hex_ex;
36mod pe_file;
37mod spc_indirect_data;
38mod win_certificate;
39
40pub use algorithm::Algorithm;
41pub use authenticode_info::{AuthenticodeInfo, DigestInfo};
42pub use hex_ex::ToHex;