tss_esapi/structures/attestation/
attest_info.rs

1// Copyright 2021 Contributors to the Parsec project.
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::{
5    structures::{
6        CertifyInfo, CommandAuditInfo, CreationInfo, NvCertifyInfo, QuoteInfo, SessionAuditInfo,
7        TimeAttestInfo,
8    },
9    tss2_esys::TPMU_ATTEST,
10};
11
12/// Enum that holds the different types of
13/// attest info.
14///
15/// # Details
16/// This type does to some degree corresponds to the
17/// TPMU_ATTEST but with the TPM_ST_ATTEST selectore
18/// included.
19#[derive(Debug, Clone)]
20pub enum AttestInfo {
21    Certify { info: CertifyInfo },
22    Quote { info: QuoteInfo },
23    SessionAudit { info: SessionAuditInfo },
24    CommandAudit { info: CommandAuditInfo },
25    Time { info: TimeAttestInfo },
26    Creation { info: CreationInfo },
27    Nv { info: NvCertifyInfo },
28    // NvDigest, the TPMS_NV_DIGEST_CERTIFY_INFO,
29    // was first added in the 3.1.0 version of the tpm2-tss
30}
31
32impl From<AttestInfo> for TPMU_ATTEST {
33    fn from(attest_info: AttestInfo) -> Self {
34        match attest_info {
35            AttestInfo::Certify { info } => TPMU_ATTEST {
36                certify: info.into(),
37            },
38            AttestInfo::Quote { info } => TPMU_ATTEST { quote: info.into() },
39            AttestInfo::SessionAudit { info } => TPMU_ATTEST {
40                sessionAudit: info.into(),
41            },
42            AttestInfo::CommandAudit { info } => TPMU_ATTEST {
43                commandAudit: info.into(),
44            },
45            AttestInfo::Time { info } => TPMU_ATTEST { time: info.into() },
46            AttestInfo::Creation { info } => TPMU_ATTEST {
47                creation: info.into(),
48            },
49            AttestInfo::Nv { info } => TPMU_ATTEST { nv: info.into() },
50        }
51    }
52}