tss_esapi/structures/attestation/
certify_info.rs

1// Copyright 2021 Contributors to the Parsec project.
2// SPDX-License-Identifier: Apache-2.0
3
4use crate::{structures::Name, tss2_esys::TPMS_CERTIFY_INFO, Error, Result};
5use std::convert::{TryFrom, TryInto};
6/// This a struct holding the attested data for the command TPM2_Certify
7///
8/// # Details
9/// This corresponds to the TPMS_CERTIFY_INFO.
10#[derive(Debug, Clone)]
11pub struct CertifyInfo {
12    name: Name,
13    qualified_name: Name,
14}
15
16impl CertifyInfo {
17    /// Returns a reference to the name
18    pub const fn name(&self) -> &Name {
19        &self.name
20    }
21
22    /// Returns a reference to the qualified name
23    pub const fn qualified_name(&self) -> &Name {
24        &self.qualified_name
25    }
26}
27
28impl From<CertifyInfo> for TPMS_CERTIFY_INFO {
29    fn from(certify_info: CertifyInfo) -> Self {
30        TPMS_CERTIFY_INFO {
31            name: certify_info.name.into(),
32            qualifiedName: certify_info.qualified_name.into(),
33        }
34    }
35}
36
37impl TryFrom<TPMS_CERTIFY_INFO> for CertifyInfo {
38    type Error = Error;
39
40    fn try_from(tpms_certify_info: TPMS_CERTIFY_INFO) -> Result<Self> {
41        Ok(CertifyInfo {
42            name: tpms_certify_info.name.try_into()?,
43            qualified_name: tpms_certify_info.qualifiedName.try_into()?,
44        })
45    }
46}