-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: attestation test on azure and default dcap
``` ❯ docker run -i --rm --privileged --device /dev/sgx_enclave --net host \ matterlabsrobot/teepot-self-attestation-test-sgx-azure:latest \ | base64 -d --ignore-garbage \ | docker run -i --rm --net host matterlabsrobot/verify-attestation-sgx-azure:latest ``` Signed-off-by: Harald Hoyer <harald@matterlabs.dev>
- Loading branch information
Showing
15 changed files
with
355 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/container-self-attestation-test-sgx-azure/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright (c) 2024 Matter Labs | ||
|
||
FROM teepot-self-attestation-test-sgx-azure:base | ||
|
||
WORKDIR /app | ||
|
||
COPY packages/container-vault-sgx-azure/test-enclave-key.pem /tmp/ | ||
|
||
RUN set -eux; \ | ||
gramine-manifest -Darch_libdir=/lib/x86_64-linux-gnu \ | ||
-Dentrypoint=$(readlink /bin/tee-self-attestation-test) \ | ||
-Dexecdir=/bin \ | ||
-Dlog_level=error \ | ||
tee-self-attestation-test.manifest.toml tee-self-attestation-test.manifest; \ | ||
gramine-sgx-sign --manifest tee-self-attestation-test.manifest --output tee-self-attestation-test.manifest.sgx --key /tmp/test-enclave-key.pem; \ | ||
rm /tmp/test-enclave-key.pem | ||
|
||
EXPOSE 8443 | ||
|
||
ENTRYPOINT ["/bin/sh", "-c"] | ||
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt | ||
CMD [ "restart-aesmd >&2; exec gramine-sgx tee-self-attestation-test" ] |
52 changes: 52 additions & 0 deletions
52
packages/container-self-attestation-test-sgx-azure/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright (c) 2024 Matter Labs | ||
{ pkgs | ||
, vat | ||
, nixsgx | ||
, curl | ||
, teepot | ||
, bash | ||
, coreutils | ||
, openssl | ||
, vault | ||
}: | ||
let manifest = ./tee-self-attestation-test.manifest.toml; | ||
in pkgs.dockerTools.buildLayeredImage { | ||
name = "teepot-self-attestation-test-sgx-azure"; | ||
tag = "base"; | ||
|
||
config.Entrypoint = [ "/bin/sh" "-c" ]; | ||
|
||
contents = pkgs.buildEnv { | ||
name = "image-root"; | ||
|
||
paths = with pkgs.dockerTools; with nixsgx;[ | ||
bash | ||
coreutils | ||
openssl.out | ||
azure-dcap-client | ||
curl.out | ||
teepot.teepot.tee_self_attestation_test | ||
gramine | ||
restart-aesmd | ||
sgx-dcap.quote_verify | ||
sgx-psw | ||
usrBinEnv | ||
binSh | ||
caCertificates | ||
fakeNss | ||
]; | ||
pathsToLink = [ "/bin" "/lib" "/etc" "/share" "/app" ]; | ||
postBuild = '' | ||
mkdir -p $out/{app,etc} | ||
cp ${manifest} $out/app/tee-self-attestation-test.manifest.toml | ||
mkdir -p $out/var/run | ||
mkdir -p $out/${nixsgx.sgx-psw.out}/aesm/ | ||
touch $out/etc/sgx_default_qcnl.conf | ||
mkdir -p $out/opt/vault/.cache $out/opt/vault/tls | ||
ln -s ${curl.out}/lib/libcurl.so $out/${nixsgx.sgx-psw.out}/aesm/ | ||
ln -s ${nixsgx.azure-dcap-client.out}/lib/libdcap_quoteprov.so $out/${nixsgx.sgx-psw.out}/aesm/libdcap_quoteprov.so.1 | ||
printf "precedence ::ffff:0:0/96 100\n" > $out/etc/gai.conf | ||
''; | ||
}; | ||
} |
56 changes: 56 additions & 0 deletions
56
packages/container-self-attestation-test-sgx-azure/tee-self-attestation-test.manifest.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
libos.entrypoint = "{{ entrypoint }}" | ||
|
||
[loader] | ||
argv = ["{{ entrypoint }}"] | ||
entrypoint = "file:{{ gramine.libos }}" | ||
log_level = "{{ log_level }}" | ||
|
||
[loader.env] | ||
### DEBUG ### | ||
RUST_BACKTRACE = "1" | ||
RUST_LOG = "warning" | ||
|
||
### Fixed values ### | ||
LD_LIBRARY_PATH = "{{ gramine.runtimedir() }}:/lib" | ||
SSL_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt" | ||
PATH = "/bin" | ||
HOME = "/app" | ||
|
||
MALLOC_ARENA_MAX = "1" | ||
AZDCAP_DEBUG_LOG_LEVEL = "ignore" | ||
AZDCAP_COLLATERAL_VERSION = "v4" | ||
|
||
[fs] | ||
root.uri = "file:/" | ||
start_dir = "/app" | ||
mounts = [ | ||
{ type = "tmpfs", path = "/var/tmp" }, | ||
{ type = "tmpfs", path = "/tmp" }, | ||
{ type = "tmpfs", path = "/app/.dcap-qcnl" }, | ||
{ type = "tmpfs", path = "/app/.az-dcap-client" }, | ||
] | ||
|
||
[sgx] | ||
trusted_files = [ | ||
"file:/app/", | ||
"file:/bin/", | ||
"file:/etc/gai.conf", | ||
"file:/etc/ssl/certs/ca-bundle.crt", | ||
"file:/lib/", | ||
"file:/nix/", | ||
"file:{{ gramine.libos }}", | ||
"file:{{ gramine.runtimedir() }}/", | ||
] | ||
remote_attestation = "dcap" | ||
max_threads = 64 | ||
edmm_enable = false | ||
## max enclave size | ||
enclave_size = "2G" | ||
|
||
[sys] | ||
enable_extra_runtime_domain_names_conf = true | ||
enable_sigterm_injection = true | ||
|
||
# possible tweak option, if problems with mio | ||
# currently mio is compiled with `mio_unsupported_force_waker_pipe` | ||
# insecure__allow_eventfd = true |
25 changes: 25 additions & 0 deletions
25
packages/container-self-attestation-test-sgx-dcap/Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright (c) 2024 Matter Labs | ||
|
||
FROM teepot-self-attestation-test-sgx-dcap:base | ||
|
||
WORKDIR /app | ||
|
||
COPY packages/container-vault-sgx-azure/test-enclave-key.pem /tmp/ | ||
COPY assets/sgx_default_qcnl.conf.json /etc/sgx_default_qcnl.conf | ||
|
||
RUN set -eux; \ | ||
touch -r /nix/store /etc/sgx_default_qcnl.conf; \ | ||
gramine-manifest -Darch_libdir=/lib/x86_64-linux-gnu \ | ||
-Dentrypoint=$(readlink /bin/tee-self-attestation-test) \ | ||
-Dexecdir=/bin \ | ||
-Dlog_level=error \ | ||
tee-self-attestation-test.manifest.toml tee-self-attestation-test.manifest; \ | ||
gramine-sgx-sign --manifest tee-self-attestation-test.manifest --output tee-self-attestation-test.manifest.sgx --key /tmp/test-enclave-key.pem; \ | ||
rm /tmp/test-enclave-key.pem | ||
|
||
EXPOSE 8443 | ||
|
||
ENTRYPOINT ["/bin/sh", "-c"] | ||
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt | ||
CMD [ "restart-aesmd >&2; exec gramine-sgx tee-self-attestation-test" ] |
49 changes: 49 additions & 0 deletions
49
packages/container-self-attestation-test-sgx-dcap/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright (c) 2024 Matter Labs | ||
{ pkgs | ||
, vat | ||
, nixsgx | ||
, curl | ||
, teepot | ||
, bash | ||
, coreutils | ||
, openssl | ||
}: | ||
let manifest = ./tee-self-attestation-test.manifest.toml; | ||
in pkgs.dockerTools.buildLayeredImage { | ||
name = "teepot-self-attestation-test-sgx-dcap"; | ||
tag = "base"; | ||
|
||
config.Entrypoint = [ "/bin/sh" "-c" ]; | ||
|
||
contents = pkgs.buildEnv { | ||
name = "image-root"; | ||
|
||
paths = with pkgs.dockerTools; with nixsgx;[ | ||
bash | ||
coreutils | ||
openssl.out | ||
curl.out | ||
teepot.teepot.tee_self_attestation_test | ||
gramine | ||
restart-aesmd | ||
sgx-dcap.quote_verify | ||
sgx-dcap.default_qpl | ||
sgx-psw | ||
usrBinEnv | ||
binSh | ||
caCertificates | ||
fakeNss | ||
]; | ||
pathsToLink = [ "/bin" "/lib" "/etc" "/share" "/app" ]; | ||
postBuild = '' | ||
mkdir -p $out/{app,etc} | ||
mkdir -p $out/app/{.dcap-qcnl,.az-dcap-client} | ||
mkdir -p $out/var/run | ||
mkdir -p $out/${nixsgx.sgx-psw.out}/aesm/ | ||
ln -s ${curl.out}/lib/libcurl.so $out/${nixsgx.sgx-psw.out}/aesm/ | ||
cp ${manifest} $out/app/tee-self-attestation-test.manifest.toml | ||
printf "precedence ::ffff:0:0/96 100\n" > $out/etc/gai.conf | ||
''; | ||
}; | ||
} |
57 changes: 57 additions & 0 deletions
57
packages/container-self-attestation-test-sgx-dcap/tee-self-attestation-test.manifest.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
libos.entrypoint = "{{ entrypoint }}" | ||
|
||
[loader] | ||
argv = ["{{ entrypoint }}"] | ||
entrypoint = "file:{{ gramine.libos }}" | ||
log_level = "{{ log_level }}" | ||
|
||
[loader.env] | ||
### DEBUG ### | ||
RUST_BACKTRACE = "1" | ||
RUST_LOG = "warning" | ||
|
||
### Fixed values ### | ||
LD_LIBRARY_PATH = "{{ gramine.runtimedir() }}:/lib" | ||
SSL_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt" | ||
PATH = "/bin" | ||
HOME = "/app" | ||
|
||
MALLOC_ARENA_MAX = "1" | ||
AZDCAP_DEBUG_LOG_LEVEL = "ignore" | ||
AZDCAP_COLLATERAL_VERSION = "v4" | ||
|
||
[fs] | ||
root.uri = "file:/" | ||
start_dir = "/app" | ||
mounts = [ | ||
{ type = "tmpfs", path = "/var/tmp" }, | ||
{ type = "tmpfs", path = "/tmp" }, | ||
{ type = "tmpfs", path = "/app/.dcap-qcnl" }, | ||
{ type = "tmpfs", path = "/app/.az-dcap-client" }, | ||
] | ||
|
||
[sgx] | ||
trusted_files = [ | ||
"file:/app/", | ||
"file:/bin/", | ||
"file:/etc/gai.conf", | ||
"file:/etc/sgx_default_qcnl.conf", | ||
"file:/etc/ssl/certs/ca-bundle.crt", | ||
"file:/lib/", | ||
"file:/nix/", | ||
"file:{{ gramine.libos }}", | ||
"file:{{ gramine.runtimedir() }}/", | ||
] | ||
remote_attestation = "dcap" | ||
max_threads = 64 | ||
edmm_enable = false | ||
## max enclave size | ||
enclave_size = "2G" | ||
|
||
[sys] | ||
enable_extra_runtime_domain_names_conf = true | ||
enable_sigterm_injection = true | ||
|
||
# possible tweak option, if problems with mio | ||
# currently mio is compiled with `mio_unsupported_force_waker_pipe` | ||
# insecure__allow_eventfd = true |
38 changes: 38 additions & 0 deletions
38
packages/container-verify-attestation-sgx-azure/default.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# Copyright (c) 2024 Matter Labs | ||
{ lib | ||
, dockerTools | ||
, buildEnv | ||
, teepot | ||
, openssl | ||
, curl | ||
, nixsgx | ||
, ... | ||
}: | ||
dockerTools.buildLayeredImage { | ||
name = "verify-attestation-sgx-azure"; | ||
tag = "latest"; | ||
|
||
config.Cmd = [ "${teepot.teepot.verify_attestation}/bin/verify-attestation" ]; | ||
config.Env = [ | ||
"LD_LIBRARY_PATH=/lib" | ||
"AZDCAP_DEBUG_LOG_LEVEL=ignore" | ||
"AZDCAP_COLLATERAL_VERSION=v4" | ||
]; | ||
contents = buildEnv { | ||
name = "image-root"; | ||
|
||
paths = with dockerTools; with nixsgx;[ | ||
openssl.out | ||
curl.out | ||
azure-dcap-client | ||
sgx-dcap.quote_verify | ||
teepot.teepot.verify_attestation | ||
usrBinEnv | ||
binSh | ||
caCertificates | ||
fakeNss | ||
]; | ||
pathsToLink = [ "/bin" "/lib" "/etc" "/share" ]; | ||
}; | ||
} |
Oops, something went wrong.