Nix, crates and tools for TEE handling
Find a file
Harald Hoyer 695355d095
chore: Update GitHub actions to run on custom runner and push to Google Artifact Registry
This commit updates the GitHub workflows to push Docker images to Google Artifact Registry.
Additionally, it refines event conditions, separates build ID generation for normal pushes and tag pushes, and introduces tagging workflow for '*-sgx-*' tags.

Signed-off-by: Harald Hoyer <harald@matterlabs.dev>
2024-06-28 10:41:58 +02:00
.github chore: Update GitHub actions to run on custom runner and push to Google Artifact Registry 2024-06-28 10:41:58 +02:00
assets feat: attestation test on azure and default dcap 2024-03-07 16:05:27 +01:00
bin chore: remove obsolete Dockerfiles 2024-06-21 11:23:41 +02:00
crates chore(deps): update to rust version 1.78 2024-06-10 13:09:05 +02:00
examples docs(examples): fix the container names 2024-06-12 13:35:54 +02:00
packages fix(container-vault-unseal): remove azure config 2024-06-12 13:32:51 +02:00
shells/teepot chore: cleanup and nixify 2024-02-28 11:09:34 +01: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 chore(deps): update rust crate log to v0.4.22 2024-06-28 01:01:27 +00:00
Cargo.toml chore: cargo update + taplo fmt 2024-06-20 14:00:18 +02:00
deny.toml chore(deps): update deps and licenses 2024-06-12 15:00:10 +02:00
flake.lock feat: remove mio workaround with gramine 1.7 2024-06-18 10:38:23 +02:00
flake.nix feat: use nixsgx nix function to create containers 2024-06-10 16:32:02 +02: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 feat: use nixsgx nix function to create containers 2024-06-10 16:32:02 +02:00
rust-toolchain.toml chore(deps): update to rust version 1.78 2024-06-10 13:09:05 +02:00
taplo.toml chore(taplo): ignore some directories 2024-02-28 09:53:05 +01:00
teepot-crate.nix feat: remove mio workaround with gramine 1.7 2024-06-18 10:38:23 +02:00

teepot

Key Value store in a TEE with Remote Attestation for Authentication

Introduction

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.

Parts of this project

  • teepot: The main rust crate that abstracts TEEs and key-value stores.
  • 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.
  • 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.

Development

Prerequisites

Install nix.

In ~/.config/nix/nix.conf

experimental-features = nix-command flakes

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

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

Optionally install cachix (to save build time) and use the nixsgx cache:

$ nix-env -iA cachix -f https://cachix.org/api/v1/install
$ cachix use nixsgx

Develop

$ nix develop --impure

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-23.11#nixci

Build and test individual container

See the packages directory for the available packages and containers.

$ nix build -L .#container-vault-sgx-azure
[...]
#8 5.966 Measurement:
#8 5.966     45b9f90fc2562e66516f40c83adc30007c88427d8d9fa7a35718f4cbdeac3efd
[...]
$ docker load -i result
$ docker run -v $(pwd):/mnt -i --init --rm teepot-vault-sgx-azure:latest "cp teepot-vault-sgx-azure.sig /mnt"
$ nix shell github:matter-labs/nixsgx#gramine -c gramine-sgx-sigstruct-view teepot-vault-sgx-azure.sig
Attributes:
    mr_signer: c5591a72b8b86e0d8814d6e8750e3efe66aea2d102b8ba2405365559b858697d
    mr_enclave: 45b9f90fc2562e66516f40c83adc30007c88427d8d9fa7a35718f4cbdeac3efd
    isv_prod_id: 0
    isv_svn: 0
    debug_enclave: False