Skip to main content

TEE attestation library for AMD SEV-SNP and Intel TDX platforms

Project description

FHEnom TEE Attestation Library

A Python library for generating and verifying TEE (Trusted Execution Environment) attestation reports across different hardware platforms.

Features

  • Multi-Platform Support: Intel TDX and AMD SEV-SNP
  • Unified API: Single interface for all TEE platforms
  • Cryptographic Verification: Full certificate chain validation
  • Production Ready: Used in FHEnom AI confidential computing platform

Supported Platforms

  • Intel TDX (Trust Domain Extensions)
  • AMD SEV-SNP (Secure Encrypted Virtualization - Secure Nested Paging)

Basic Installation (Python API only)

pip install dk-tee-attestation

Quick Start

Generate an Attestation Report (Inside TEE)

from dk_tee_attestation import AttestationEngineFactory, TeeNotDetectedError

# Auto-detect the TEE platform (recommended)
try:
    engine = AttestationEngineFactory.get()
except TeeNotDetectedError:
    raise RuntimeError("No supported TEE platform detected on this machine.")

# Generate report with nonce (must be 64 bytes)
nonce = b"your_nonce_here" + b"\x00" * (64 - len(b"your_nonce_here"))
report_bytes = engine.get_report(nonce)

# Save for verification
with open("attestation_report.bin", "wb") as f:
    f.write(report_bytes)

To explicitly select a platform instead of auto-detecting:

from dk_tee_attestation import AttestationEngineFactory, AttestationEngineType

engine = AttestationEngineFactory.get(AttestationEngineType.INTEL_TDX)
# or
engine = AttestationEngineFactory.get(AttestationEngineType.AMD_SEV_SNP)

Verify an Attestation Report (Verifier Side)

from dk_tee_attestation import AttestationEngineFactory, AttestationEngineType

# Create engine for the platform that generated the report
engine = AttestationEngineFactory.get(AttestationEngineType.INTEL_TDX)

# Load report
with open("attestation_report.bin", "rb") as f:
    report_bytes = f.read()

# Verify (raises exception on failure)
nonce = b"your_nonce_here" + b"\x00" * (64 - len(b"your_nonce_here"))
try:
    engine.verify_report(report_bytes, nonce)
    print("Attestation verified successfully!")
except Exception as e:
    print(f"Verification failed: {e}")

API Reference

AttestationEngine

Base interface for TEE attestation engines.


get_report(report_data: bytes) -> bytes

Generate a TEE attestation report.

Parameters

  • report_data (bytes): Nonce / challenge. Must be exactly 64 bytes.

Returns

  • bytes: Raw attestation report.

Raises

  • AttestationError: If report generation fails.
  • TeeNotDetectedError: If AttestationEngineFactory.get() is called with no argument and no supported TEE platform is found.

verify_report(report_bytes: bytes, expected_report_data: bytes) -> None

Verify a TEE attestation report.

Parameters

  • report_bytes (bytes): Raw attestation report to verify.
  • expected_report_data (bytes): Expected nonce. Must be exactly 64 bytes.

Returns

  • None: Verification succeeded.

Raises

  • AttestationError: If verification fails.

Verification Process

Intel TDX Verification Steps

  1. Parse Quote: Extract structured data from TDX Quote v4 bytes
  2. Validate Nonce: Ensure report_data matches expected value
  3. Verify PCK Chain: Validate the embedded PCK certificate chain up to Intel Root CA
  4. Fetch TCB Info: Retrieve and verify TCB Info from Intel PCS
  5. Check TCB Status: Ensure platform TCB is not revoked or out of date
  6. Fetch QE Identity: Retrieve and verify QE Identity from Intel PCS
  7. Verify QE Report: Validate PCK signature over the Quoting Enclave report
  8. Verify Quote Signature: Validate attestation key signature over the TD Report Body

AMD SEV-SNP Verification Steps

  1. Parse Report: Extract structured data from raw bytes
  2. Validate Nonce: Ensure nonce matches expected value
  3. Fetch Certificates: Retrieve ARK, ASK, and VCEK from AMD KDS
  4. Verify Chain: Validate certificate chain signatures
  5. Check Metadata: Ensure TCB and hardware ID match
  6. Verify Signature: Validate report signature with VCEK

Platform-Specific Notes

Intel TDX

  • Requires access to /dev/tdx_guest device and libtdx_attest.so for quote generation
  • Fetches TCB Info and QE Identity from Intel Provisioning Certification Service (PCS)
  • Verification is pure Python and works on any machine with network access

AMD SEV-SNP

  • Requires access to /dev/sev-guest device for report generation
  • Fetches certificates from AMD Key Distribution Service (KDS)
  • Supports Milan, Genoa, and Turin processor families

Integration with FHEnom AI

This library is integrated into the FHEnom AI SDK:

# Install FHEnom AI with attestation support
pip install fhenomai

# Use via FHEnom AI client
from fhenomai import FHEnomClient

client = FHEnomClient.from_config()
result = client.admin.verify_attestation(report_bytes, nonce_hex)

Requirements

  • Python >= 3.8
  • cryptography >= 46.0.0
  • requests >= 2.32.0

Use Cases

  • Remote Attestation: Prove code runs in genuine TEE
  • Zero-Trust Security: Establish trust before sensitive operations
  • Compliance: Demonstrate hardware-backed security
  • Confidential Computing: Verify encrypted model execution

License

TBD

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dk_tee_attestation-0.0.0.tar.gz (28.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

dk_tee_attestation-0.0.0-cp312-cp312-win_amd64.whl (138.5 kB view details)

Uploaded CPython 3.12Windows x86-64

dk_tee_attestation-0.0.0-cp312-cp312-manylinux_2_38_x86_64.whl (245.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.38+ x86-64

File details

Details for the file dk_tee_attestation-0.0.0.tar.gz.

File metadata

  • Download URL: dk_tee_attestation-0.0.0.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for dk_tee_attestation-0.0.0.tar.gz
Algorithm Hash digest
SHA256 3a42b05bc479301e63a74511d0c0f70b526162e45fccb936c3487c98c2d9b35f
MD5 04ac90819dd8a7c18e2ab9367855c884
BLAKE2b-256 72b67a6f526369433f4eac211cc16c63d42c31e109656a18ecad34195d31ef25

See more details on using hashes here.

File details

Details for the file dk_tee_attestation-0.0.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for dk_tee_attestation-0.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1c5e86f798b38355c8327b369a4c6c1104b108d7f79c699d33bbd80f2db6cf40
MD5 73777e09514e9e92369b2fb944f20b8d
BLAKE2b-256 0c0e2c92d364d66eff25da12807f189cc49d7e12e9caa194f473c153f9570a5d

See more details on using hashes here.

File details

Details for the file dk_tee_attestation-0.0.0-cp312-cp312-manylinux_2_38_x86_64.whl.

File metadata

File hashes

Hashes for dk_tee_attestation-0.0.0-cp312-cp312-manylinux_2_38_x86_64.whl
Algorithm Hash digest
SHA256 edf610e37f9668dc4dbbb558406155fd66ca4bc098bf324d1c1649e3baed6e0e
MD5 6e0328a74f2e82f0b954b7fbd71eab38
BLAKE2b-256 576a0a88e37cd7131438eaa84c047f976b42029fe7bc592047eccde57f493e82

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page