1 //! [TCG] (Trusted Computing Group) protocols. 2 //! 3 //! These protocols provide access to the [TPM][tpm] (Trusted Platform Module). 4 //! 5 //! There are two versions of the protocol. The original protocol is in 6 //! the [`v1`] module. It is used with TPM 1.1 and 1.2 devices. The 7 //! newer protocol in the [`v2`] module is generally provided for TPM 8 //! 2.0 devices, although the spec indicates it can be used for older 9 //! TPM versions as well. 10 //! 11 //! [TCG]: https://trustedcomputinggroup.org/ 12 //! [TPM]: https://en.wikipedia.org/wiki/Trusted_Platform_Module 13 14 pub mod v1; 15 pub mod v2; 16 17 mod enums; 18 pub use enums::*; 19 20 use bitflags::bitflags; 21 22 /// Platform Configuration Register (PCR) index. 23 #[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] 24 #[repr(transparent)] 25 pub struct PcrIndex(pub u32); 26 27 bitflags! { 28 /// Hash algorithms the protocol can provide. 29 /// 30 /// The [`v1`] protocol only supports SHA1. 31 #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord)] 32 #[repr(transparent)] 33 pub struct HashAlgorithm: u32 { 34 /// SHA-1 hash. 35 const SHA1 = 0x0000_0001; 36 37 /// SHA-256 hash. 38 const SHA256 = 0x0000_0002; 39 40 /// SHA-384 hash. 41 const SHA384 = 0x0000_0004; 42 43 /// SHA-512 hash. 44 const SHA512 = 0x0000_0008; 45 46 /// SM3-256 hash. 47 const SM3_256 = 0x0000_0010; 48 } 49 } 50