#![deny(clippy::all)]
#![deny(clippy::pedantic)]
pub mod auth;
pub mod cli;
pub mod command;
pub mod crypto;
pub mod device;
pub mod handle;
pub mod io;
pub mod job;
pub mod key;
pub mod pcr;
pub mod policy;
pub mod print;
pub mod spinner;
pub mod template;
pub mod vtpm;
pub static TEARDOWN: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
pub fn write_object<T: tpm2_protocol::TpmBuild>(
obj: &T,
) -> Result<Vec<u8>, tpm2_protocol::TpmError> {
let mut buf = vec![0u8; tpm2_protocol::constant::TPM_MAX_COMMAND_SIZE];
let len = {
let mut writer = tpm2_protocol::TpmWriter::new(&mut buf);
obj.build(&mut writer)?;
writer.len()
};
buf.truncate(len);
Ok(buf)
}
pub fn parse_hex_u32(hex_str: &str) -> Result<u32, std::num::ParseIntError> {
let hex_str = hex_str.strip_prefix("0x").unwrap_or(hex_str);
u32::from_str_radix(hex_str, 16)
}