Skip to content

Commit 81ddcf2

Browse files
authored
Merge pull request #78 from Freax13/feature/features
add cargo features for different TEEs
2 parents 5efb074 + 4efe3d1 commit 81ddcf2

File tree

11 files changed

+218
-46
lines changed

11 files changed

+218
-46
lines changed

.github/workflows/build.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,35 @@ jobs:
4646
env:
4747
PROFILE: ${{ matrix.profile }}
4848

49+
# Build the CLI with various feature configurations.
50+
build-cli:
51+
strategy:
52+
matrix:
53+
snp:
54+
- true
55+
- false
56+
tdx:
57+
- true
58+
- false
59+
insecure:
60+
- true
61+
- false
62+
name: "Build CLI"
63+
runs-on: ubuntu-latest
64+
steps:
65+
- uses: actions/checkout@v4
66+
- uses: Swatinem/rust-cache@v2
67+
with:
68+
key: build-cli-${{ matrix.snp }}-${{ matrix.tdx }}-${{ matrix.insecure }}
69+
workspaces: |
70+
host
71+
- name: "Build"
72+
run: make cli
73+
env:
74+
TEE_SNP: ${{ matrix.snp }}
75+
TEE_TDX: ${{ matrix.tdx }}
76+
TEE_INSECURE: ${{ matrix.insecure }}
77+
4978
clippy:
5079
name: "Clippy"
5180
runs-on: ubuntu-latest

config.mk

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,26 @@ endif
6666
OUTPUT ?= output.bin
6767
ATTESTATION_REPORT ?= report.bin
6868

69+
TEE_SNP ?= true
70+
TEE_TDX ?= true
71+
TEE_INSECURE ?= true
72+
73+
# Make sure that the TEE flags are either true or false.
74+
KNOWN_BOOL_true = 1
75+
KNOWN_BOOL_false = 1
76+
KNOWN_TEE_SNP = $(KNOWN_BOOL_$(TEE_SNP))
77+
KNOWN_TEE_TDX = $(KNOWN_BOOL_$(TEE_TDX))
78+
KNOWN_TEE_INSECURE = $(KNOWN_BOOL_$(TEE_INSECURE))
79+
ifneq ($(KNOWN_TEE_SNP),1)
80+
$(error unknown value for TEE_SNP $(TEE_SNP))
81+
endif
82+
ifneq ($(KNOWN_TEE_TDX),1)
83+
$(error unknown value for TEE_TDX $(TEE_TDX))
84+
endif
85+
ifneq ($(KNOWN_TEE_INSECURE),1)
86+
$(error unknown value for TEE_INSECURE $(TEE_INSECURE))
87+
endif
88+
6989
TEE ?= auto
7090

7191
# Make sure that the requested TEE value is supported.

host/Cargo.lock

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

host/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ members = ["mushroom", "mushroom-verify", "qgs-client", "vcek-kds"]
33
resolver = "2"
44

55
[workspace.dependencies]
6-
mushroom-verify = { path = "mushroom-verify" }
6+
mushroom-verify = { path = "mushroom-verify", default-features = false }
77
constants = { path = "../common/constants" }
88
io = { path = "../common/io" }
99
loader = { path = "../common/loader" }

host/mushroom-verify/Cargo.toml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7-
bytemuck = { version = "1.15.0", features = ["derive", "min_const_generics"] }
8-
loader = { workspace = true }
7+
bytemuck = { version = "1.15.0", features = ["derive", "min_const_generics"], optional = true }
8+
loader = { workspace = true, optional = true }
99
io = { workspace = true }
10-
p384 = "0.13.0"
10+
p384 = { version = "0.13.0", optional = true }
1111
sha2 = "0.10.8"
12-
snp-types = { workspace = true }
13-
vcek-kds = { workspace = true }
14-
tdx-types = { workspace = true, features = ["quote"] }
15-
x86_64 = "0.15.1"
12+
snp-types = { workspace = true, optional = true }
13+
vcek-kds = { workspace = true, optional = true }
14+
tdx-types = { workspace = true, features = ["quote"], optional = true }
15+
x86_64 = { version = "0.15.1", optional = true }
16+
17+
[features]
18+
default = ["snp", "tdx"]
19+
snp = ["dep:bytemuck", "dep:p384", "dep:loader", "dep:snp-types", "dep:vcek-kds"]
20+
tdx = ["dep:loader", "dep:tdx-types", "dep:x86_64"]

host/mushroom-verify/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
use io::input::Header;
44
use sha2::{Digest, Sha256};
55

6+
#[cfg(feature = "snp")]
67
pub mod snp;
8+
#[cfg(feature = "tdx")]
79
pub mod tdx;
810

911
#[derive(Debug)]

host/mushroom/Cargo.toml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,32 @@ name = "mushroom"
88
required-features = ["bin"]
99

1010
[features]
11-
bin = ["dep:clap", "dep:mushroom-verify"]
11+
default = ["insecure", "snp", "tdx"]
12+
insecure = ["dep:loader", "dep:snp-types", "dep:supervisor-services"]
13+
snp = ["dep:loader", "mushroom-verify?/snp", "dep:snp-types"]
14+
tdx = ["dep:loader", "mushroom-verify?/tdx", "dep:qgs-client", "dep:tdx-types"]
15+
bin = ["dep:clap", "dep:mushroom-verify", "dep:tokio", "dep:tracing-subscriber", "dep:vcek-kds"]
1216

1317
[dependencies]
1418
anyhow = "1.0.81"
1519
bit_field = "0.10.2"
16-
bitflags = "2.4.2"
20+
bitflags = { version = "2.4.2", features = ["bytemuck"] }
1721
bytemuck = { version = "1.15.0", features = ["derive", "min_const_generics", "extern_crate_std"] }
1822
clap = { version = "4.5.2", features = ["derive", "env"], optional = true }
1923
constants = { workspace = true }
20-
libc = "0.2.153"
21-
loader = { workspace = true }
24+
loader = { workspace = true, optional = true }
2225
log-types = { workspace = true, features = ["std"] }
2326
mushroom-verify = { workspace = true, optional = true }
2427
nix = { version = "0.28.0", features = ["fs", "ioctl", "mman", "pthread", "signal"] }
2528
profiler-types = { workspace = true }
26-
qgs-client = { workspace = true }
29+
qgs-client = { workspace = true, optional = true }
2730
rand = "0.8.5"
28-
snp-types = { workspace = true }
29-
supervisor-services = { workspace = true, features = ["supervisor"], default-features = false }
30-
tdx-types = { workspace = true }
31-
tokio = { version = "1.36.0", features = ["fs", "macros", "rt-multi-thread"] }
31+
snp-types = { workspace = true, optional = true }
32+
supervisor-services = { workspace = true, features = ["supervisor"], default-features = false , optional = true}
33+
tdx-types = { workspace = true, optional = true }
34+
tokio = { version = "1.36.0", features = ["fs", "macros", "rt-multi-thread"], optional = true }
3235
tracing = "0.1.40"
33-
tracing-subscriber = "0.3.18"
34-
vcek-kds = { workspace = true }
36+
tracing-subscriber = { version = "0.3.18", optional = true }
37+
vcek-kds = { workspace = true, optional = true }
3538
volatile = { version = "0.5.1", features = ["unstable"] }
3639
x86_64 = "0.15.1"

host/mushroom/Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,25 @@ else ifeq ($(PROFILE),profiling)
77
PROFILE = release
88
endif
99

10+
CARGO_FEATURE_SNP_FLAGS_true = --features snp
11+
CARGO_FEATURE_SNP_FLAGS = $(CARGO_FEATURE_SNP_FLAGS_$(TEE_SNP))
12+
13+
CARGO_FEATURE_TDX_FLAGS_true = --features tdx
14+
CARGO_FEATURE_TDX_FLAGS = $(CARGO_FEATURE_TDX_FLAGS_$(TEE_TDX))
15+
16+
CARGO_FEATURE_INSECURE_FLAGS_true = --features insecure
17+
CARGO_FEATURE_INSECURE_FLAGS = $(CARGO_FEATURE_INSECURE_FLAGS_$(TEE_INSECURE))
18+
1019
CARGO_EXTRA_FLAGS_release = --release
1120
CARGO_EXTRA_FLAGS = $(CARGO_EXTRA_FLAGS_$(PROFILE))
1221

1322
cli:
1423
cargo build \
24+
--no-default-features \
1525
--features bin \
26+
$(CARGO_FEATURE_SNP_FLAGS) \
27+
$(CARGO_FEATURE_TDX_FLAGS) \
28+
$(CARGO_FEATURE_INSECURE_FLAGS) \
1629
$(CARGO_EXTRA_FLAGS)
1730

1831
.PHONY: cli

0 commit comments

Comments
 (0)