forked from veracruz-project/veracruz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
305 lines (264 loc) · 13.5 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# This makefile is used within the docker image generated by docker/Dockerfile
#
# AUTHORS
#
# The Veracruz Development Team.
#
# COPYRIGHT
#
# See the `LICENSE_MIT.markdown` file in the Veracruz root directory for licensing
# and copyright information.
.PHONY: all sdk sgx-veracruz-client-test trustzone-veracruz-client-test nitro-veracruz-client-test sgx trustzone sgx-veracruz-server-test sgx-veracruz-server-performance sgx-veracruz-test sgx-psa-attestation tz-psa-attestationtrustzone-veracruz-server-test-setting trustzone-veracruz-test-setting trustzone-env sgx-env trustzone-test-env clean clean-cargo-lock fmt
WARNING_COLOR := "\e[1;33m"
INFO_COLOR := "\e[1;32m"
RESET_COLOR := "\e[0m"
OPTEE_DIR_SDK ?= /work/rust-optee-trustzone-sdk/
AARCH64_GCC ?= $(OPTEE_DIR)/toolchains/aarch64/bin/aarch64-linux-gnu-gcc
SGX_RUST_FLAG ?= "-L/work/sgxsdk/lib64 -L/work/sgxsdk/sdk_libs"
OPENSSL_INCLUDE_DIR ?= /usr/include/aarch64-linux-gnu
OPENSSL_LIB_DIR ?= /usr/lib/aarch64-linux-gnu
TRUSTZONE_C_INCLUDE_PATH ?= /usr/include/aarch64-linux-gnu:/usr/include
NITRO_RUST_FLAG ?= ""
BIN_DIR ?= /usr/local/cargo/bin
all:
@echo $(WARNING_COLOR)"Please explicitly choose a target."$(RESET_COLOR)
# Build all of the SDK and examples
sdk:
$(MAKE) -C sdk
# Generate all test policy
sgx-test-collateral:
TEE=sgx $(MAKE) -C test-collateral
trustzone-test-collateral:
TEE=tz $(MAKE) -C test-collateral
# Test veracruz-client for sgx, due to the use of a mocked server with a fixed port, these tests must run in a single thread
sgx-veracruz-client-test: sgx sgx-test-collateral
cd veracruz-client && RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --lib --features "mock sgx" -- --test-threads=1
# Test veracruz-client for sgx, due to the use of a mocked server with a fixed port, these tests must run in a single thread
trustzone-veracruz-client-test: trustzone trustzone-test-collateral
cd veracruz-client && cargo test --lib --features "mock tz" -- --test-threads=1
nitro-veracruz-client-test: nitro nitro-test-collateral
cd veracruz-client && cargo test --lib --features "mock" -- --test-threads=1
nitro-test-collateral:
TEE=nitro $(MAKE) -C test-collateral
# Compile for sgx
# offset the CC OPENSSL_DIR, which might be used in compiling trustzone
sgx: sdk sgx-env
cd runtime-manager-bind && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build
cd sgx-root-enclave-bind && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build
cd veracruz-client && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build --lib --features sgx
sgx-cli: sgx-env
# enclave binaries needed for veracruz-server
cd runtime-manager-bind && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build
cd sgx-root-enclave-bind && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build
# build CLIs in top-level crates
cd proxy-attestation-server && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build --features sgx --features cli
cd veracruz-server && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build --features sgx --features cli
cd veracruz-client && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build --features sgx --features cli
# build CLIs in the SDK/test-collateral
$(MAKE) -C sdk/freestanding-execution-engine
$(MAKE) -C sdk/wasm-checker
$(MAKE) -C test-collateral/generate-policy
nitro: sdk
rustup target add x86_64-unknown-linux-musl
RUSTFLAGS=$(NITRO_RUST_FLAG) $(MAKE) -C runtime-manager nitro
nitro-cli:
# enclave binaries needed for veracruz-server
pwd
RUSTFLAGS=$(NITRO_RUST_FLAG) $(MAKE) -C runtime-manager nitro
RUSTFLAGS=$(NITRO_RUST_FLAG) $(MAKE) -C nitro-root-enclave
RUSTFLAGS=$(NITRO_RUST_FLAG) $(MAKE) -C nitro-root-enclave-server
# build CLIs in top-level crates
cd proxy-attestation-server && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build --features nitro --features cli
cd veracruz-server && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build --features nitro --features cli
cd veracruz-client && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build --features nitro --features cli
# build CLIs in the SDK/test-collateral
$(MAKE) -C sdk/freestanding-execution-engine
$(MAKE) -C sdk/wasm-checker
$(MAKE) -C test-collateral/generate-policy
# Compile for trustzone, note: source the rust-optee-trustzone-sdk/environment first, however assume `unset CC`.
trustzone: sdk trustzone-env
$(MAKE) -C runtime-manager trustzone CC=$(AARCH64_GCC) OPTEE_DIR=$(OPTEE_DIR) OPTEE_OS_DIR=$(OPTEE_OS_DIR)
$(MAKE) -C trustzone-root-enclave trustzone OPTEE_DIR=$(OPTEE_DIR) OPTEE_OS_DIR=$(OPTEE_OS_DIR)
cd veracruz-client && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build --lib --features tz
trustzone-cli: trustzone-env
# enclave binaries needed for veracruz-server
$(MAKE) -C runtime-manager trustzone CC=$(AARCH64_GCC) OPTEE_DIR=$(OPTEE_DIR) OPTEE_OS_DIR=$(OPTEE_OS_DIR)
$(MAKE) -C trustzone-root-enclave trustzone OPTEE_DIR=$(OPTEE_DIR) OPTEE_OS_DIR=$(OPTEE_OS_DIR)
# build CLIs in top-level crates
cd proxy-attestation-server && \
CC_aarch64_unknown_linux_gnu=$(AARCH64_GCC) \
OPENSSL_INCLUDE_DIR=$(OPENSSL_INCLUDE_DIR) \
OPENSSL_LIB_DIR=$(OPENSSL_LIB_DIR) \
C_INCLUDE_PATH=$(TRUSTZONE_C_INCLUDE_PATH) \
cargo build --target aarch64-unknown-linux-gnu --features psa --features cli
cd veracruz-server && \
CC_aarch64_unknown_linux_gnu=$(AARCH64_GCC) \
OPENSSL_INCLUDE_DIR=$(OPENSSL_INCLUDE_DIR) \
OPENSSL_LIB_DIR=$(OPENSSL_LIB_DIR) \
C_INCLUDE_PATH=$(TRUSTZONE_C_INCLUDE_PATH) \
cargo build --target aarch64-unknown-linux-gnu --features tz --features cli
cd veracruz-client && RUSTFLAGS=$(SGX_RUST_FLAG) cargo build --features tz --features cli
# build CLIs in the SDK/test-collateral
$(MAKE) -C sdk/freestanding-execution-engine
$(MAKE) -C sdk/wasm-checker
$(MAKE) -C test-collateral/generate-policy
%-cli-install: %-cli
# install to Cargo's bin directory
cp -f proxy-attestation-server/target/debug/proxy-attestation-server $(BIN_DIR)/proxy-attestation-server
cp -f veracruz-server/target/debug/veracruz-server $(BIN_DIR)/veracruz-server
cp -f veracruz-client/target/debug/veracruz-client $(BIN_DIR)/veracruz-client
# install CLIs in SDK/test-collateral
cp -f sdk/freestanding-execution-engine/target/release/freestanding-execution-engine $(BIN_DIR)/freestanding-execution-engine
cp -f sdk/wasm-checker/bin/wasm-checker $(BIN_DIR)/wasm-checker
cp -f test-collateral/generate-policy/target/release/generate-policy $(BIN_DIR)/generate-policy
# symlink concise names
ln -sf $(BIN_DIR)/proxy-attestation-server $(BIN_DIR)/vc-pas
ln -sf $(BIN_DIR)/veracruz-server $(BIN_DIR)/vc-server
ln -sf $(BIN_DIR)/veracruz-client $(BIN_DIR)/vc-client
ln -sf $(BIN_DIR)/freestanding-execution-engine $(BIN_DIR)/vc-fee
ln -sf $(BIN_DIR)/wasm-checker $(BIN_DIR)/vc-wc
ln -sf $(BIN_DIR)/generate-policy $(BIN_DIR)/vc-pgen
# symlink backwards compatible names
ln -sf $(BIN_DIR)/generate-policy $(BIN_DIR)/pgen
# Using wildcard in the dependencies because if they are there, and newer, it
# should be rebuilt, but if they aren't there, they don't need to be built
# (they are optional)
veracruz-test/proxy-attestation-server.db: $(wildcard sgx-root-enclave/css.bin)
cd veracruz-test && \
bash ../test-collateral/populate-test-database.sh
# Using wildcard in the dependencies because if they are there, and newer, it
# should be rebuilt, but if they aren't there, they don't need to be built
# (they are optional)
veracruz-server-test/proxy-attestation-server.db: $(wildcard sgx-root-enclave/css.bin)
cd veracruz-server-test && \
bash ../test-collateral/populate-test-database.sh
sgx-veracruz-server-test: sgx sgx-test-collateral veracruz-server-test/proxy-attestation-server.db
cd veracruz-server-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --features sgx \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test test_debug --features sgx -- --ignored --test-threads=1
sgx-veracruz-server-test-dry-run: sgx-test-collateral
cd veracruz-server-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --features sgx --no-run
sgx-veracruz-server-performance: sgx-test-collateral sgx veracruz-server-test/proxy-attestation-server.db
cd veracruz-server-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test test_performance_ --features sgx -- --ignored
sgx-veracruz-test-dry-run: sgx-test-collateral
cd veracruz-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --features sgx --no-run
sgx-veracruz-test: sgx-test-collateral sgx veracruz-test/proxy-attestation-server.db
cd veracruz-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --features sgx
sgx-psa-attestation: sgx-env
cd psa-attestation && cargo build --features sgx
tz-psa-attestation: trustzone-env
cd psa-attestation && cargo build --target aarch64-unknown-linux-gnu --features tz
trustzone-veracruz-server-test: trustzone-test-collateral trustzone trustzone-test-env veracruz-server-test/proxy-attestation-server.db
cd veracruz-server-test \
&& CC_aarch64_unknown_linux_gnu=$(AARCH64_GCC) OPENSSL_INCLUDE_DIR=$(OPENSSL_INCLUDE_DIR) \
OPENSSL_LIB_DIR=$(OPENSSL_LIB_DIR) C_INCLUDE_PATH=$(TRUSTZONE_C_INCLUDE_PATH) \
cargo test --target aarch64-unknown-linux-gnu --no-run --features tz -- --test-threads=1 \
&& ./cp-veracruz-server-test-tz.sh
chmod u+x run_veracruz_server_test_tz.sh
./run_veracruz_server_test_tz.sh
trustzone-veracruz-test: trustzone-test-collateral trustzone trustzone-test-env veracruz-test/proxy-attestation-server.db
cd veracruz-test \
&& CC_aarch64_unknown_linux_gnu=$(AARCH64_GCC) OPENSSL_INCLUDE_DIR=$(OPENSSL_INCLUDE_DIR) \
OPENSSL_LIB_DIR=$(OPENSSL_LIB_DIR) C_INCLUDE_PATH=$(TRUSTZONE_C_INCLUDE_PATH) \
cargo test --target aarch64-unknown-linux-gnu --no-run --features tz -- --test-threads=1
cd veracruz-test && ./cp-veracruz-tz.sh
chmod u+x run_veracruz_test_tz.sh
./run_veracruz_test_tz.sh
trustzone-test-env: tz_test.sh run_tz_test.sh
chmod u+x $^
nitro-veracruz-server-test: nitro nitro-test-collateral veracruz-server-test/proxy-attestation-server.db
cd veracruz-server-test \
&& RUSTFLAGS=$(NITRO_RUST_FLAG) cargo test --features nitro,debug -- --test-threads=1\
&& RUSTFLAGS=$(NITRO_RUST_FLAG) cargo test test_debug --features nitro,debug -- --ignored --test-threads=1
cd veracruz-server-test \
&& ./nitro-terminate.sh
nitro-veracruz-server-test-dry-run: nitro nitro-test-collateral
cd veracruz-server-test \
&& RUSTFLAGS=$(NITRO_RUST_FLAG) cargo test --features sgx --no-run
nitro-veracruz-server-performance: nitro nitro-test-collateral veracruz-server-test/proxy-attestation-server.db
cd veracruz-server-test \
&& RUSTFLAGS=$(NITRO_RUST_FLAG) cargo test test_performance_ --features nitro -- --ignored
cd veracruz-server-test \
&& ./nitro-terminate.sh
cd ./veracruz-server-test \
&& ./nitro-ec2-terminate-root.sh
nitro-veracruz-test-dry-run: nitro nitro-test-collateral
cd veracruz-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --features nitro --no-run
nitro-veracruz-test: nitro nitro-test-collateral veracruz-test/proxy-attestation-server.db
cd veracruz-test \
&& RUSTFLAGS=$(SGX_RUST_FLAG) cargo test --features nitro -- --test-threads=1
cd veracruz-server-test \
&& ./nitro-terminate.sh
cd ./veracruz-server-test \
&& ./nitro-ec2-terminate_root.sh
nitro-psa-attestation:
cd psa-attestation && cargo build --features nitro
trustzone-env:
unset CC
rustup target add aarch64-unknown-linux-gnu arm-unknown-linux-gnueabihf
rustup component add rust-src
chmod u+x tz_test.sh
sgx-env:
unset CC
clean:
# remove databases since these can easily fall out of date
rm -f proxy-attestation-server/proxy-attestation-server.db
rm -f veracruz-server-test/proxy-attestation-server.db
rm -f veracruz-test/proxy-attestation-server.db
# clean code
cd runtime-manager-bind && cargo clean
cd sgx-root-enclave-bind && cargo clean
cd psa-attestation && cargo clean
cd proxy-attestation-server && cargo clean
cd session-manager && cargo clean
cd veracruz-utils && cargo clean
cd veracruz-server-test && cargo clean
cd veracruz-test && cargo clean && rm -f proxy-attestation-server.db
$(MAKE) clean -C runtime-manager
$(MAKE) clean -C sgx-root-enclave
$(MAKE) clean -C veracruz-server
$(MAKE) clean -C test-collateral
$(MAKE) clean -C trustzone-root-enclave
$(MAKE) clean -C sdk
rm -rf bin
# NOTE: this target deletes ALL cargo.lock.
clean-cargo-lock:
$(MAKE) -C sdk clean
$(MAKE) -C test-collateral clean
rm -f $(addsuffix /Cargo.lock,execution-engine nitro-root-enclave nitro-root-enclave-server platform-services proxy-attestation-server psa-attestation runtime-manager runtime-manager-bind session-manager sgx-root-enclave sgx-root-enclave-bind transport-protocol trustzone-root-enclave veracruz-client veracruz-server veracruz-server-test veracruz-test veracruz-utils)
# update dependencies, note does NOT change Cargo.toml, useful if
# patched/github dependencies have changed without version bump
update:
cd session-manager && cargo update
cd execution-engine && cargo update
cd transport-protocol && cargo update
cd veracruz-client && cargo update
cd sgx-root-enclave && cargo update
cd runtime-manager && cargo update
cd psa-attestation && cargo update
cd veracruz-server-test && cargo update
cd veracruz-server && cargo update
cd veracruz-test && cargo update
cd veracruz-utils && cargo update
cd trustzone-root-enclave && cargo update
cd proxy-attestation-server && cargo update
fmt:
cd session-manager && cargo fmt
cd execution-engine && cargo fmt
cd transport-protocol && cargo fmt
cd veracruz-client && cargo fmt
cd sgx-root-enclave && cargo fmt
cd runtime-manager && cargo fmt
cd psa-attestation && cargo fmt
cd veracruz-server-test && cargo fmt
cd veracruz-server && cargo fmt
cd veracruz-test && cargo fmt
cd veracruz-utils && cargo fmt
cd trustzone-root-enclave && cargo fmt
cd proxy-attestation-server && cargo fmt
$(MAKE) -C sdk fmt