Nix, crates and tools for TEE handling
Find a file
Harald Hoyer 205113ecfa
feat(intel-dcap-api): add comprehensive testing infrastructure and examples
- Add mock tests using real Intel API response data (25 tests)
- Create fetch_test_data tool to retrieve real API responses for testing
- Add integration_test example covering 17 API endpoints
- Add common_usage example demonstrating attestation verification patterns
- Add issuer chain validation checks to ensure signature verification is possible
- Add comprehensive documentation in CLAUDE.md

The test suite now covers all major Intel DCAP API functionality including
TCB info, enclave identities, PCK CRLs, FMSPCs, and evaluation data numbers
for both SGX and TDX platforms across API v3 and v4.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Harald Hoyer <harald@matterlabs.dev>
2025-05-28 11:52:31 +02:00
.github chore(deps): update trufflesecurity/trufflehog action to v3.88.30 2025-05-16 21:21:53 +00:00
assets feat(ci): switch to GitHub Container Registry for images 2025-04-02 17:10:20 +02:00
bin refactor: remove redundant continue 2025-04-17 16:53:01 +01:00
checks feat: add Google Metadata support and TDX container test 2025-01-27 16:18:58 +01:00
crates feat(intel-dcap-api): add comprehensive testing infrastructure and examples 2025-05-28 11:52:31 +02:00
examples feat(ci): switch to GitHub Container Registry for images 2025-04-02 17:10:20 +02:00
lib feat(tdx): add nix build for TDX google VMs 2025-01-14 14:50:43 +01:00
packages feat(intel-dcap-api): add comprehensive testing infrastructure and examples 2025-05-28 11:52:31 +02:00
shells/teepot refactor(shells): simplify environment variable declarations 2025-04-14 17:07:35 +02:00
systems/x86_64-linux/tdxtest feat(ci): switch to GitHub Container Registry for images 2025-04-02 17:10:20 +02:00
.dockerignore feat: initial commit 2024-02-09 10:10:53 +01:00
.gitignore feat: initial commit 2024-02-09 10:10:53 +01:00
Cargo.lock feat(intel-dcap-api): add comprehensive testing infrastructure and examples 2025-05-28 11:52:31 +02:00
Cargo.toml feat(quote): add FMSPC and CPUSVN extraction support 2025-05-06 11:43:51 +02:00
deny.toml feat: compat code for non x86_64-linux 2025-04-10 11:57:46 +02:00
flake.lock feat: bump rust version to 1.86 2025-04-10 11:57:47 +02:00
flake.nix feat: add Google Metadata support and TDX container test 2025-01-27 16:18:58 +01:00
LICENSE-APACHE feat: initial commit 2024-02-09 10:10:53 +01:00
LICENSE-MIT feat: initial commit 2024-02-09 10:10:53 +01:00
README.md chore: split-out vault code from teepot in teepot-vault 2025-03-06 09:47:51 +01:00
rust-toolchain.toml feat: bump rust version to 1.86 2025-04-10 11:57:47 +02:00
taplo.toml chore: prepare release tags 2024-09-16 16:14:26 +02:00

teepot

Parts of this project

teepot - lib

  • teepot: The main rust crate that abstracts TEEs.
    • verify-attestation: A client utility that verifies the attestation of an enclave.
    • tee-key-preexec: A pre-exec utility that generates a p256 secret key and passes it as an environment variable to the enclave along with the attestation quote containing the hash of the public key.
    • tdx_google: A base VM running on Google Cloud TDX. It receives a container URL via the instance metadata, measures the sha384 of the URL to RTMR3 and launches the container.
    • tdx-extend: A utility to extend an RTMR register with a hash value.
    • rtmr-calc: A utility to calculate RTMR1 and RTMR2 from a GPT disk, the linux kernel, the linux initrd and a UKI (unified kernel image).
    • sha384-extend: A utility to calculate RTMR registers after extending them with a digest.

Vault

Part of this project is a key-value store that runs in a Trusted Execution Environment (TEE) and uses Remote Attestation for Authentication. The key-value store is implemented using Hashicorp Vault running in an Intel SGX enclave via the Gramine runtime.

  • teepot-vault: A crate lib with for the TEE key-value store components:
    • tee-vault-unseal: An enclave that uses the Vault API to unseal a vault as a proxy.
    • vault-unseal: A client utility, that talks to tee-vault-unseal to unseal a vault.
    • tee-vault-admin: An enclave that uses the Vault API to administer a vault as a proxy.
    • vault-admin: A client utility, that talks to tee-vault-admin to administer a vault.
    • teepot-read : A pre-exec utility that reads from the key-value store and passes the key-value pairs as environment variables to the enclave.
    • teepot-write : A pre-exec utility that reads key-values from the environment variables and writes them to the key-value store.

Development

Prerequisites

Install nix.

In ~/.config/nix/nix.conf

experimental-features = nix-command flakes
sandbox = true

or on nixos in /etc/nixos/configuration.nix add the following lines:

{
  nix = {
    extraOptions = ''
      experimental-features = nix-command flakes
      sandbox = true
    '';
  };
}

Develop

$ nix develop

optionally create .envrc for direnv to automatically load the environment when entering the directory:

$ cat <<EOF > .envrc
use flake .#teepot
EOF
$ direnv allow

Format for commit

$ nix run .#fmt

Build as the CI would

$ nix run github:nixos/nixpkgs/nixos-24.11#nixci -- build

Build and test individual container

See the packages directory for the available packages and containers.

$ nix build -L .#container-self-attestation-test-sgx-azure
[...]
teepot-self-attestation-test-sgx-azure-manifest-app-customisation-layer> Measurement:
teepot-self-attestation-test-sgx-azure-manifest-app-customisation-layer>     eaaabf210797606bcfde818a52e4a434fbf4f2e620d7edcc7025e3e1bbaa95c4
[...]
$ export IMAGE_TAG=$(docker load < result | grep -Po 'Loaded image.*: \K.*')
$ docker run -v $(pwd):/mnt -i --init --rm $IMAGE_TAG "cp app.sig /mnt"
$ nix shell github:matter-labs/nixsgx#gramine -c gramine-sgx-sigstruct-view app.sig
Attributes:
    mr_signer: c5591a72b8b86e0d8814d6e8750e3efe66aea2d102b8ba2405365559b858697d
    mr_enclave: eaaabf210797606bcfde818a52e4a434fbf4f2e620d7edcc7025e3e1bbaa95c4
    isv_prod_id: 0
    isv_svn: 0
    debug_enclave: False

TDX VM testing

nixos-rebuild  -L --flake .#tdxtest build-vm && ./result/bin/run-tdxtest-vm