1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
"""
Type stubs for dcap_qvl Python bindings.
This file provides type hints for the compiled Rust extension, enabling better
IDE support, type checking with mypy, and improved developer experience.
"""
:
:
"""
Represents quote collateral data required for DCAP quote verification.
This class contains all the necessary certificate chains, CRLs, and
attestation information needed to verify an SGX or TDX quote.
"""
"""
Create a new QuoteCollateralV3 instance.
Args:
pck_crl_issuer_chain: PCK CRL issuer certificate chain (PEM format)
root_ca_crl: Root CA certificate revocation list
pck_crl: PCK certificate revocation list
tcb_info_issuer_chain: TCB info issuer certificate chain (PEM format)
tcb_info: TCB (Trusted Computing Base) information (JSON string)
tcb_info_signature: Signature for the TCB info
qe_identity_issuer_chain: QE identity issuer certificate chain (PEM format)
qe_identity: Quoting Enclave identity information (JSON string)
qe_identity_signature: Signature for the QE identity
"""
...
"""PCK CRL issuer certificate chain in PEM format."""
...
"""Root CA certificate revocation list."""
...
"""PCK certificate revocation list."""
...
"""TCB info issuer certificate chain in PEM format."""
...
"""TCB (Trusted Computing Base) information as JSON string."""
...
"""Signature for the TCB info."""
...
"""QE identity issuer certificate chain in PEM format."""
...
"""Quoting Enclave identity information as JSON string."""
...
"""Signature for the QE identity."""
...
"""
Serialize the collateral to a JSON string.
Returns:
JSON string representation of the collateral data
Raises:
ValueError: If serialization fails
"""
...
"""
Create a QuoteCollateralV3 instance from a JSON string.
Args:
json_str: JSON string containing collateral data
Returns:
New QuoteCollateralV3 instance
Raises:
ValueError: If JSON parsing fails or data is invalid
"""
...
"""
Contains the results of DCAP quote verification.
This class holds the verification status and any security advisories
that were found during the quote verification process.
"""
"""
Verification status string.
Common values include:
- "OK": Verification successful, no issues
- "SW_HARDENING_NEEDED": Software hardening recommended
- "CONFIGURATION_NEEDED": Platform configuration required
- "OUT_OF_DATE": TCB is out of date
- "REVOKED": Certificate or key has been revoked
"""
...
"""
List of security advisory IDs that apply to this quote.
These are Intel security advisory identifiers (e.g., "INTEL-SA-00334")
that indicate known security issues affecting the attested platform.
"""
...
"""
Serialize the verification report to a JSON string.
Returns:
JSON string representation of the verification report
Raises:
ValueError: If serialization fails
"""
...
"""
Represents a parsed SGX or TDX quote.
This class provides access to quote metadata and identifiers
without requiring collateral data for verification.
"""
"""
Parse a raw quote from bytes.
Args:
raw_quote: Raw quote data as bytes (SGX or TDX format)
Returns:
Quote instance with parsed quote data
Raises:
ValueError: If quote parsing fails due to invalid format or corrupted data
Example:
>>> import dcap_qvl
>>>
>>> with open("quote.bin", "rb") as f:
... quote_data = f.read()
>>>
>>> quote = dcap_qvl.Quote.parse(quote_data)
>>> print(f"Quote type: {quote.quote_type()}")
>>> print(f"FMSPC: {quote.fmspc()}")
"""
...
"""
Extract the FMSPC (Family-Model-Stepping-Platform-CustomSKU) identifier.
The FMSPC is a 6-byte identifier that uniquely identifies the
platform's TCB level and is used for collateral retrieval.
Returns:
FMSPC as uppercase hexadecimal string (12 characters)
Raises:
ValueError: If FMSPC cannot be extracted from the quote
Example:
>>> quote = dcap_qvl.Quote.parse(quote_data)
>>> fmspc = quote.fmspc()
>>> print(f"FMSPC: {fmspc}") # e.g., "00606A000000"
"""
...
"""
Extract the CA (Certificate Authority) identifier.
The CA identifier indicates which certificate authority
should be used for quote verification.
Returns:
CA identifier as string
Raises:
ValueError: If CA identifier cannot be extracted from the quote
"""
...
"""
Check if this is a TDX (Trust Domain Extensions) quote.
Returns:
True if the quote is TDX format, False if SGX format
Example:
>>> quote = dcap_qvl.Quote.parse(quote_data)
>>> if quote.is_tdx():
... print("This is a TDX quote")
... else:
... print("This is an SGX quote")
"""
...
"""
Check if this is an SGX quote.
Returns:
True if the quote is SGX format, False if TDX format
Example:
>>> quote = dcap_qvl.Quote.parse(quote_data)
>>> if quote.is_sgx():
... print("This is an SGX quote")
... else:
... print("This is a TDX quote")
"""
...
"""
Get the quote type as a string.
Returns:
"TDX" for TDX quotes, "SGX" for SGX quotes
Example:
>>> quote = dcap_qvl.Quote.parse(quote_data)
>>> print(f"Quote type: {quote.quote_type()}")
"""
...
# Synchronous functions
"""
Verify an SGX or TDX quote with the provided collateral data.
This function performs cryptographic verification of the quote against
the provided collateral information, checking certificates, signatures,
and revocation status.
Args:
raw_quote: Raw quote data as bytes (SGX or TDX format)
collateral: Quote collateral containing certificates and attestation data
now_secs: Current timestamp in seconds since Unix epoch for time-based checks
Returns:
VerifiedReport containing verification status and advisory information
Raises:
ValueError: If verification fails due to invalid data, expired certificates,
revoked keys, or other verification errors
Example:
>>> import dcap_qvl
>>> import time
>>>
>>> # Load quote and collateral data
>>> with open("quote.bin", "rb") as f:
... quote_data = f.read()
>>>
>>> collateral = dcap_qvl.QuoteCollateralV3.from_json(collateral_json)
>>> result = dcap_qvl.verify(quote_data, collateral, int(time.time()))
>>> print(f"Status: {result.status}")
"""
...
"""
Parse a raw quote from bytes (convenience function).
This is a convenience function that calls Quote.parse() directly.
Args:
raw_quote: Raw quote data as bytes (SGX or TDX format)
Returns:
Quote instance with parsed quote data
Raises:
ValueError: If quote parsing fails due to invalid format or corrupted data
Example:
>>> import dcap_qvl
>>>
>>> with open("quote.bin", "rb") as f:
... quote_data = f.read()
>>>
>>> quote = dcap_qvl.parse_quote(quote_data)
>>> print(f"Quote type: {quote.quote_type()}")
>>> print(f"FMSPC: {quote.fmspc()}")
"""
...
"""Get collateral for a specific FMSPC from PCCS URL."""
...