intel_dcap_api/types.rs
1// SPDX-License-Identifier: Apache-2.0
2// Copyright (c) 2025 Matter Labs
3
4use std::fmt;
5
6/// Represents the type of Certificate Authority (CA) for Intel Trusted Services.
7///
8/// This enum defines the different types of Certificate Authorities used in the Intel DCAP API,
9/// specifically distinguishing between processor and platform CAs.
10#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11pub enum CaType {
12 /// Represents a processor-specific Certificate Authority.
13 Processor,
14 /// Represents a platform-wide Certificate Authority.
15 Platform,
16}
17
18impl fmt::Display for CaType {
19 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
20 match self {
21 CaType::Processor => write!(f, "processor"),
22 CaType::Platform => write!(f, "platform"),
23 }
24 }
25}
26
27/// Represents the encoding format for Certificate Revocation Lists (CRLs).
28///
29/// This enum defines the supported encoding formats for CRLs in the Intel DCAP API,
30/// distinguishing between PEM (Privacy Enhanced Mail) and DER (Distinguished Encoding Rules) formats.
31#[derive(Debug, Clone, Copy, PartialEq, Eq)]
32pub enum CrlEncoding {
33 /// Represents the PEM (Privacy Enhanced Mail) encoding format.
34 Pem,
35 /// Represents the DER (Distinguished Encoding Rules) encoding format.
36 Der,
37}
38
39impl fmt::Display for CrlEncoding {
40 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
41 match self {
42 CrlEncoding::Pem => write!(f, "pem"),
43 CrlEncoding::Der => write!(f, "der"),
44 }
45 }
46}
47
48/// Represents the type of update for Intel Trusted Services.
49///
50/// This enum defines different update types, distinguishing between early and standard updates
51/// in the Intel DCAP (Data Center Attestation Primitives) API.
52#[derive(Debug, Clone, Copy, PartialEq, Eq)]
53pub enum UpdateType {
54 /// Represents early updates, typically used for preview or beta releases.
55 Early,
56 /// Represents standard updates, which are the regular release cycle.
57 Standard,
58}
59
60impl fmt::Display for UpdateType {
61 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
62 match self {
63 UpdateType::Early => write!(f, "early"),
64 UpdateType::Standard => write!(f, "standard"),
65 }
66 }
67}
68
69/// Represents the platform filter options for Intel DCAP (Data Center Attestation Primitives) API.
70///
71/// This enum allows filtering platforms based on different criteria,
72/// such as selecting all platforms, client-specific platforms, or specific Intel processor generations.
73#[derive(Debug, Clone, Copy, PartialEq, Eq)]
74pub enum PlatformFilter {
75 /// Represents a selection of all available platforms.
76 All,
77 /// Represents a selection of client-specific platforms.
78 Client,
79 /// Represents platforms with Intel E3 processors.
80 E3,
81 /// Represents platforms with Intel E5 processors.
82 E5,
83}
84
85impl fmt::Display for PlatformFilter {
86 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
87 match self {
88 PlatformFilter::All => write!(f, "all"),
89 PlatformFilter::Client => write!(f, "client"),
90 PlatformFilter::E3 => write!(f, "E3"),
91 PlatformFilter::E5 => write!(f, "E5"),
92 }
93 }
94}
95
96/// Represents the version of the Intel Trusted Services API to target.
97#[derive(Debug, Clone, Copy, PartialEq, Eq)]
98pub enum ApiVersion {
99 /// Represents version 3 of the Intel Trusted Services API.
100 V3,
101 /// Represents version 4 of the Intel Trusted Services API.
102 V4,
103}
104
105impl ApiVersion {
106 /// Returns the string representation of the version for URL paths.
107 pub fn path_segment(&self) -> &'static str {
108 match self {
109 ApiVersion::V3 => "v3",
110 ApiVersion::V4 => "v4",
111 }
112 }
113}
114
115impl fmt::Display for ApiVersion {
116 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
117 match self {
118 ApiVersion::V3 => write!(f, "v3"),
119 ApiVersion::V4 => write!(f, "v4"),
120 }
121 }
122}