A Python library and CLI tool for Intel TDX (Trust Domain Extensions) attestation quote verification. This project provides functionality for parsing, validating, and verifying TDX attestation quotes, including cryptographic signature verification, certificate chain validation, and TCB (Trusted Computing Base) status evaluation.
Intel TDX (Trust Domain Extensions) is a confidential computing technology that provides hardware-assisted isolation for virtual machines. TDX attestation quotes are cryptographic evidence that prove the integrity and authenticity of a TDX-enabled system.
- Complete Quote Parsing: Parse TDX attestation quotes
- Cryptographic Verification: ECDSA signature verification for both P-256 and P-384 curves
- Certificate Chain Validation: Full X.509 certificate chain verification with CRL checking
- TCB Status Evaluation: Trusted Computing Base level matching and status assessment
- Intel PCS Integration: Automatic fetching of certificates and collateral from Intel's Provisioning Certification Service
- QE Identity Verification: Quoting Enclave identity validation
- Comprehensive Logging: Detailed verification steps with configurable logging levels
- CLI Tools: Ready-to-use command-line utilities for quote inspection and verification
The library is organized as follows:
-
quote.py: TDX quote structure parsing and representationTdQuoteHeader: Quote header parsing (48 bytes)TdQuoteBody: TD Report body parsing (584 bytes for v4)Quote: Complete quote structure with signature data
-
verify.py: Complete attestation verification pipeline- Quote signature verification using attestation key
- QE report signature verification using PCK certificate
- Attestation key binding validation
- Certificate chain verification
- TCB status evaluation
ecdsa.py: ECDSA cryptographic structures and utilitiesqe_report.py: Quoting Enclave report parsingtdx_logging.py: Centralized logging configurationcerts.py: X.509 certificate handling and SGX extension parsingtcb.py: TCB Info processing and status evaluationfetch.py: Intel PCS API integrationtdx_logging.py: Logging capabilities for command line and libraryprint_quote.py: Quote display
- Python 3.7+
- Dependencies (automatically installed):
cryptography >= 39.0.0requests >= 2.25.0pyasn1 >= 0.4.8urllib3 >= 1.26.0
git clone https://github.com/TEE-Attestation/tdx_pytools.git
cd tdx_pytools
pip install .pip install -e .pip uninstall tdx_pytoolsDisplay the contents of a TDX attestation quote in human-readable format:
# Using the installed command
tdx-print -f quote.dat
# With debug output
tdx-print -f quote.dat -d
# Using Python module directly
python -m tdx_pytools.print_quote -f quote.datOptions:
-f, --file: Path to the TDX quote file (default:quote.dat)-d, --debug: Enable debug mode for detailed parsing information
Perform complete cryptographic verification of a TDX attestation quote:
# Basic verification
tdx-verify -f quote.dat
# Verbose verification with detailed steps
tdx-verify -f quote.dat -v
# Debug mode with maximum detail
tdx-verify -f quote.dat -d
# Show report data after successful verification
tdx-verify -f quote.dat -r
# Use local certificates instead of fetching from Intel
tdx-verify -f quote.dat -c ./certs/
# Use early update policy for fetching collateral
tdx-verify -f quote.dat -eOptions:
-f, --file: Path to the TDX quote file (default:quote.dat)-d, --debug: Enable debug mode for quote parsing (implies verbose)-v, --verbose: Enable verbose verification output-r, --reportdata: Display report data after successful verification-c, --certs: Path to local certificate directory (default:./certs)-e, --early: Use early update policy for fetching collateral
from tdx_pytools import Quote
# Load and parse a quote
with open('quote.dat', 'rb') as f:
quote_data = f.read()
quote = Quote.unpack(quote_data)
# Access quote components
print(f"Quote version: {quote.header.version}")
print(f"TEE type: 0x{quote.header.tee_type:08x}")
print(f"Attestation key type: {quote.header.att_key_type}")
# Display quote details
quote.print_details()from tdx_pytools import verify_quote, verify_quote_bytes, Quote
# Parse quote
with open('quote.dat', 'rb') as f:
quote_bytes = f.read()
# Verify quote
quote = Quote.unpack(quote_bytes)
report_data, collateral, tcb_dict, combined_status = verify_quote(quote)The library implements a comprehensive 12-step verification process as documented in VERIFICATION_PROCESS.md:
- Quote Structure Verification: Validate quote format and basic properties
- Certificate Loading: Load or fetch required Intel certificates and CRLs
- Certificate Chain Verification: Verify PCK certificate chain to Intel Root CA
- Certificate Revocation Checks: Ensure no certificates are revoked
- Cryptographic Signature Verification: Verify quote and QE report signatures
- Attestation Key Binding: Validate attestation key binding to QE report
- SGX Extension Extraction: Parse Intel SGX-specific certificate extensions
- QE Identity Verification: Verify Quoting Enclave identity and status
- TCB Info Verification: Validate TCB Info document and signatures
- TCB Status Evaluation: Determine platform TCB status
- TD Debug Mode Check: Verify Trust Domain is not in debug mode
- Terminal TCB Status Check: Ensure platform is not in terminal state
For detailed information about each step, see VERIFICATION_PROCESS.md.
The toolkit supports validating attestation reports against security policies defined in JSON format. This allows you to enforce specific security requirements and check measurements are known good values.
Policies are defined in JSON format with the following structure:
{
"metadata": {
"name": "Intel TDX Security Policy",
"version": "1.0",
"description": "Example security policy for validating Intel TDX quotes"
},
"validation_rules": {
"tcb": {
"update": "standard",
"platform_tcb": "UpToDate",
"tdx_module_tcb": "UpToDate",
"qe_tcb": "UpToDate"
},
"body": {
"rtmr0": {
"exact_match": "abcd1234"
},
"rtmr1": {
"exact_match": "efab5678"
},
"rtmr2": {
"exact_match": "cdef9123"
},
"mr_td": {
"exact_match": "1234abcd"
}
},
"signature_data": {
"qe_cert_data": {
"qe_report": {
"cpu_svn": {
"exact_match": "1a2b3c4d1a2b3c4d0000000000000000"
}
}
}
}
}
}The tcb item within validation_rules is a special case. It is used to require specific TCB levels or better for various components, along with an update field to require a minimum TCB-R freshness. See the example policy or the excerpt above for an example.
All other items within validation_rules are evaluated according to the specified rule type. The following validation rule types are supported:
- exact_match: Field must exactly match the specified value
- min_value: Field must be greater than or equal to the specified minimum
- max_value: Field must be less than or equal to the specified maximum
- allow_list: Field value must be in the list of allowed values
- deny_list: Field value must not be in the list of denied values
- boolean: Field must match the specified boolean value (true/false). This can be specified using the boolean value as the attribute value directly.
By default, the library automatically fetches certificates and collateral from Intel's Provisioning Certification Service (PCS):
- Intel SGX Root CA Certificate
- Intel SGX Root CA CRL
- Intel SGX PCK Platform CRL
- QE Identity document
- TCB Info document
For offline verification or to avoid network requests, certificates and collateral are stored locally:
certs/
├── intel_sgx_root_ca.pem
├── intel_sgx_root_ca_crl.pem
├── intel_sgx_pck_platform_crl.pem
├── {update}_qe_identity.json
├── {update}_qe_identity_issuer_chain.pem
├── {fmspc}_{update}_tcb_info.json
└── {fmspc}_{update}_tcb_info_issuer_chain.pem
The library provides comprehensive logging with multiple levels:
import tdx_pytools.tdx_logging as logging
# Setup CLI-style logging with colors
logger = logging.setup_cli_logging(verbose=True, quiet=False)
# Setup library-style logging
logger = logging.setup_logging(
level='DEBUG',
cli_mode=False,
log_file='verification.log'
)- Version 3 TDX quotes
- Version 4 TDX quotes
- Version 5 TDX quotes
- Type 2: ECDSA-256 with P-256 curve
- Type 3: ECDSA-384 with P-384 curve
Contributions are welcome! Please follow the contribution guidelines in the TAS repository.
MIT License - Copyright 2025 Hewlett Packard Enterprise Development LP.
See LICENSE file for details.