Skip to main content

vta_tee/
types.rs

1use serde::{Deserialize, Serialize};
2
3/// Supported TEE platform types.
4#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
5#[serde(rename_all = "snake_case")]
6#[derive(utoipa::ToSchema)]
7pub enum TeeType {
8    SevSnp,
9    Nitro,
10    Simulated,
11}
12
13impl std::fmt::Display for TeeType {
14    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
15        match self {
16            TeeType::SevSnp => write!(f, "sev_snp"),
17            TeeType::Nitro => write!(f, "nitro"),
18            TeeType::Simulated => write!(f, "simulated"),
19        }
20    }
21}
22
23/// TEE detection result.
24#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
25pub struct TeeStatus {
26    pub tee_type: TeeType,
27    pub detected: bool,
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub platform_version: Option<String>,
30}
31
32/// Hardware-signed attestation report.
33#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
34pub struct AttestationReport {
35    pub tee_type: TeeType,
36    /// Base64-encoded platform-specific attestation evidence.
37    pub evidence: String,
38    /// Hex-encoded nonce that was bound into the report.
39    pub nonce: String,
40    /// Unix timestamp when the report was generated.
41    pub generated_at: u64,
42    /// VTA DID bound into the report as user_data.
43    #[serde(skip_serializing_if = "Option::is_none")]
44    pub vta_did: Option<String>,
45}
46
47/// Request body for `POST /attestation/report`.
48#[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)]
49pub struct AttestationRequest {
50    /// Client-provided nonce (hex, 32 bytes) to prevent replay.
51    pub nonce: String,
52}