wintrust/lib.rs
1//! Portable catalog trust with idiomatic Rust functions and Windows-name aliases.
2//!
3//! With the `std` feature, `WinVerifyTrust` re-exports `win_verify_trust` with the same safe
4//! Rust signature. These names do not expose the Windows C ABI or inherit the
5//! machine catalog database. Policy and member format remain explicit.
6//!
7//! The default build uses `no_std` with `alloc`. Supply pinned artifact bytes
8//! through [`portable::Verifier::from_artifact_reader`] and an explicit clock.
9//! Filesystem APIs and automatic clock capture require `std`.
10//!
11//! ```
12//! # #[cfg(feature = "std")]
13//! # fn example() -> wintrust::error::Result<()> {
14//! use wintrust::{CryptCATAdminAcquireContext2, crypt_cat_admin_acquire_context2};
15//! use wintrust::portable::sip::{DigestAlgorithm, MemberHashPolicy, SipKind};
16//!
17//! let context = CryptCATAdminAcquireContext2(
18//! DigestAlgorithm::Sha256, SipKind::FlatXml, MemberHashPolicy::default(),
19//! )?;
20//! let other = crypt_cat_admin_acquire_context2(
21//! DigestAlgorithm::Sha256, SipKind::FlatXml, MemberHashPolicy::default(),
22//! )?;
23//! # let _ = (context, other);
24//! # Ok::<(), wintrust::error::Error>(())
25//! # }
26//! ```
27
28#![cfg_attr(not(feature = "std"), no_std)]
29
30extern crate alloc;
31#[cfg(test)]
32extern crate std;
33
34#[cfg(feature = "std")]
35mod api;
36pub mod catalog;
37pub mod catalog_trust;
38pub mod ctl;
39mod der;
40pub mod error;
41pub use error::{Error, Result};
42mod certificates;
43pub use ::der::asn1::ObjectIdentifier;
44pub use certificates::CertificateStore;
45mod oid_serde;
46mod stringprep;
47
48#[cfg(feature = "std")]
49pub use api::{
50 CatalogAdminContext, crypt_cat_admin_acquire_context2,
51 crypt_cat_admin_calc_hash_from_file_handle2, crypt_cat_admin_release_context, win_verify_trust,
52};
53pub use catalog_trust::portable;
54
55// Aliases are the same function items, not duplicate Windows-style wrappers.
56#[cfg(feature = "std")]
57pub use crypt_cat_admin_acquire_context2 as CryptCATAdminAcquireContext2;
58#[cfg(feature = "std")]
59pub use crypt_cat_admin_calc_hash_from_file_handle2 as CryptCATAdminCalcHashFromFileHandle2;
60#[cfg(feature = "std")]
61pub use crypt_cat_admin_release_context as CryptCATAdminReleaseContext;
62#[cfg(feature = "std")]
63pub use win_verify_trust as WinVerifyTrust;