Skip to content

Commit ba17e5a

Browse files
committed
ci: update to build libdogecoin seperate for host and enclave
optee, openenclave: updated to confirm password
1 parent 412c8f7 commit ba17e5a

File tree

5 files changed

+54
-22
lines changed

5 files changed

+54
-22
lines changed

Diff for: .github/workflows/ci.yml

+22-10
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ jobs:
383383
curl https://storage.googleapis.com/git-repo-downloads/repo > /bin/repo && chmod a+x /bin/repo && \
384384
mkdir -p optee && \
385385
cd optee && \
386-
repo init -u https://github.com/OP-TEE/manifest.git -m nanopc-t6.xml -b master && \
386+
repo init -u https://github.com/OP-TEE/manifest.git -m qemu_v8.xml -b 4.2.0 && \
387387
export FORCE_UNSAFE_CONFIGURE=1 && \
388388
repo sync -j\"$(getconf _NPROCESSORS_ONLN)\" && \
389389
if [[ "${{ github.ref }}" == refs/tags/* ]]; then \
@@ -433,7 +433,7 @@ jobs:
433433
--subkey-version 1 && \
434434
435435
# Build and test the OP-TEE OS and client
436-
make -j\"$(getconf _NPROCESSORS_ONLN)\" && \
436+
make -j\"$(getconf _NPROCESSORS_ONLN)\" check && \
437437
cd /src && \
438438
git clone https://github.com/OP-TEE/optee_client.git && \
439439
cd optee_client && \
@@ -448,22 +448,28 @@ jobs:
448448
export PATH=/src/optee/toolchains/aarch64/bin:$PATH && \
449449
export CC=aarch64-linux-gnu-gcc && \
450450
451-
# Run the libdogecoin TA
452-
cd /src/src/optee/host && \
453-
make -j"$(getconf _NPROCESSORS_ONLN)" \
454-
CROSS_COMPILE=aarch64-linux-gnu- \
455-
LDFLAGS=\"-L/src/optee/toolchains/aarch64/lib -L/src/depends/aarch64-linux-gnu/lib -ldogecoin -lunistring\" \
456-
CFLAGS=\"-I/src/optee/toolchains/aarch64/include -I/src/src/optee/ta/include -I/src/depends/aarch64-linux-gnu/include -I/src/depends/aarch64-linux-gnu/include/ykpers-1 -I/src/depends/aarch64-linux-gnu/include/dogecoin\" && \
457-
458451
# Build the Trusted Application
459-
cd ../ta && \
452+
cd /src/src/optee/ta && \
460453
make -j"$(getconf _NPROCESSORS_ONLN)" \
461454
CROSS_COMPILE=aarch64-linux-gnu- \
462455
LDFLAGS=\"-L/src/depends/aarch64-linux-gnu/lib -ldogecoin -lunistring\" \
463456
CFLAGS=\"-I/src/depends/aarch64-linux-gnu/include -I/src/depends/aarch64-linux-gnu/include/dogecoin\" \
464457
PLATFORM=vexpress-qemu_armv8a \
465458
TA_DEV_KIT_DIR=/src/optee/optee_os/out/arm/export-ta_arm64 && \
466459
460+
# Build libdogecoin for Host
461+
cd /src/ && \
462+
./configure --prefix=/src/depends/aarch64-linux-gnu LIBS=-levent_pthreads --enable-static --disable-shared --enable-test-passwd HOST=aarch64-linux-gnu && \
463+
make -j 4 && \
464+
make install && \
465+
466+
# Run the libdogecoin TA
467+
cd /src/src/optee/host && \
468+
make -j"$(getconf _NPROCESSORS_ONLN)" \
469+
CROSS_COMPILE=aarch64-linux-gnu- \
470+
LDFLAGS=\"-L/src/optee/toolchains/aarch64/lib -L/src/depends/aarch64-linux-gnu/lib -ldogecoin -lunistring\" \
471+
CFLAGS=\"-I/src/optee/toolchains/aarch64/include -I/src/src/optee/ta/include -I/src/depends/aarch64-linux-gnu/include -I/src/depends/aarch64-linux-gnu/include/ykpers-1 -I/src/depends/aarch64-linux-gnu/include/dogecoin\" && \
472+
467473
# Create symbolic links and prepare image
468474
mkdir -p /src/optee/out/bin && \
469475
cd /src/optee/out/bin && \
@@ -498,6 +504,12 @@ jobs:
498504
openssl rsa -pubout -in src/openenclave/build/private.pem -out src/openenclave/build/public.pem; \
499505
fi && \
500506
docker run -v $PWD:/src -w /src ubuntu:20.04 bash -c "\
507+
# Build libdogecoin for Host
508+
make -j 4 -C depends HOST=x86_64-pc-linux-gnu/host && \
509+
./configure --prefix=/src/depends/x86_64-pc-linux-gnu/host --enable-test-passwd && \
510+
make && \
511+
make install && \
512+
501513
# Install dependencies
502514
export DEBIAN_FRONTEND=noninteractive && \
503515
apt-get update && \

Diff for: doc/enclaves.md

+22-10
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ cd libdogecoin
190190

191191
The SDK has several components and requires over 10GB of disk space to build. The build process can take over 30 minutes on a modern machine. Docker is used to build the SDK and client in a clean environment.
192192

193-
### Building OP-TEE SDK and Client (NanoPC-T6)
193+
### Step 1 (NanoPC): Building OP-TEE SDK and Client
194194

195195
This command builds the latest SDK and client for NanoPC-T6 (nanopc-t6.xml). When complete, the image will be located in `/doge/libdogecoin/optee/out/nanopc-t6.img`. Burn this image to an SD card to boot the NanoPC-T6. Connect an Ethernet cable, USB keyboard and HDMI to the NanoPC-T6 and power it on. The default IP address is configured using DHCP. Login as root via ssh (e.g. `ssh [email protected]`) or using the HDMI console.
196196

@@ -270,9 +270,9 @@ docker run -v "$(pwd):/src" -w /src jforissier/optee_os_ci:qemu_check /bin/bash
270270
make install"
271271
```
272272

273-
### Building OP-TEE SDK and Client (QEMU ARMv8)
273+
### Step 1 (QEMU): Building OP-TEE SDK and Client
274274

275-
This command builds the SDK (version 3.22.0) and client for ARMv8 QEMU emulation (qemu_v8.xml). For other platforms, change the manifest file in the `repo init` command accordingly. Replace `3.22.0` with the desired version and `qemu_v8.xml` with the desired platform. Refer to the [OP-TEE documentation](https://optee.readthedocs.io/en/latest/building/index.html) for more information.
275+
This command builds the SDK (version 4.2.0) and client for ARMv8 QEMU emulation (qemu_v8.xml). For other platforms, change the manifest file in the `repo init` command accordingly. Replace `4.2.0` with the desired version and `qemu_v8.xml` with the desired platform. Refer to the [OP-TEE documentation](https://optee.readthedocs.io/en/latest/building/index.html) for more information.
276276

277277
An RSA private key is generated and overwrites the default Trusted Application (TA) key. This key is used to sign the enclave binaries during development. In the Continuous Integration (CI) environment, an Actions secret is used. Subkeys are generated for testing purposes but are not used to sign the enclave binaries.
278278

@@ -287,7 +287,7 @@ docker run -v "$(pwd):/src" -w /src jforissier/optee_os_ci:qemu_check /bin/bash
287287
curl https://storage.googleapis.com/git-repo-downloads/repo > /bin/repo && chmod a+x /bin/repo && \
288288
mkdir -p optee && \
289289
cd optee && \
290-
repo init -u https://github.com/OP-TEE/manifest.git -m qemu_v8.xml -b master
290+
repo init -u https://github.com/OP-TEE/manifest.git -m qemu_v8.xml -b 4.2.0
291291
export FORCE_UNSAFE_CONFIGURE=1 && \
292292
repo sync -j 4 --force-sync && \
293293
patch -N -F 4 /src/optee/build/common.mk < /src/src/optee/common.mk.patch && \
@@ -340,7 +340,7 @@ docker run -v "$(pwd):/src" -w /src jforissier/optee_os_ci:qemu_check /bin/bash
340340
# Build and test the OP-TEE OS and client
341341
make -j 4 check
342342
cd /src && \
343-
git clone https://github.com/OP-TEE/optee_client.git && \
343+
[ ! -d optee_client ] && git clone https://github.com/OP-TEE/optee_client.git && \
344344
cd optee_client && \
345345
mkdir -p build && \
346346
cd build && \
@@ -351,7 +351,7 @@ docker run -v "$(pwd):/src" -w /src jforissier/optee_os_ci:qemu_check /bin/bash
351351
make install"
352352
```
353353

354-
### Building OP-TEE Libdogecoin Key Manager Enclave (QEMU ARMv8 or NanoPC-T6)
354+
### Step 2 (QEMU or NanoPC): Building OP-TEE Libdogecoin Key Manager Enclave
355355

356356
This command builds the OP-TEE Libdogecoin Key Manager Enclave for QEMU ARMv8 or NanoPC-T6. The enclave is built using the OP-TEE SDK and client. The enclave binary is located in `/doge/libdogecoin/optee/out/bin/libdogecoin.img`.
357357

@@ -361,9 +361,10 @@ docker run --privileged -v "$(pwd):/src" -w /src jforissier/optee_os_ci:qemu_che
361361
apt-get update && \
362362
apt-get install -y autoconf automake libtool-bin build-essential curl python3 valgrind g++-aarch64-linux-gnu qemu-user-static qemu-user && \
363363
364+
# Build libdogecoin for Host
364365
make -j 4 -C depends HOST=aarch64-linux-gnu && \
365366
./autogen.sh && \
366-
./configure --prefix=/src/depends/aarch64-linux-gnu LIBS=-levent_pthreads --enable-static --disable-shared --enable-test-passwd --enable-optee CFLAGS=-U_FORTIFY_SOURCE HOST=aarch64-linux-gnu && \
367+
./configure --prefix=/src/depends/aarch64-linux-gnu LIBS=-levent_pthreads --enable-static --disable-shared --enable-test-passwd HOST=aarch64-linux-gnu && \
367368
make -j 4 && \
368369
make install && \
369370
@@ -377,8 +378,14 @@ docker run --privileged -v "$(pwd):/src" -w /src jforissier/optee_os_ci:qemu_che
377378
LDFLAGS=\"-L/src/optee/toolchains/aarch64/lib -L/src/depends/aarch64-linux-gnu/lib -ldogecoin -lunistring\" \
378379
CFLAGS=\"-I/src/optee/toolchains/aarch64/include -I/src/src/optee/ta/include -I/src/depends/aarch64-linux-gnu/include -I/src/depends/aarch64-linux-gnu/include/ykpers-1 -I/src/depends/aarch64-linux-gnu/include/dogecoin\" && \
379380
381+
# Build libdogecoin for OP-TEE
382+
cd /src/ && \
383+
./configure --prefix=/src/depends/aarch64-linux-gnu LIBS=-levent_pthreads --enable-static --disable-shared --enable-test-passwd --enable-optee CFLAGS=-U_FORTIFY_SOURCE HOST=aarch64-linux-gnu && \
384+
make -j 4 && \
385+
make install && \
386+
380387
# Build the Enclave
381-
cd ../ta && \
388+
cd /src/src/optee/ta && \
382389
make -j 4 \
383390
CROSS_COMPILE=aarch64-linux-gnu- \
384391
LDFLAGS=\"-L/src/depends/aarch64-linux-gnu/lib -ldogecoin -lunistring\" \
@@ -414,7 +421,7 @@ docker run --privileged -v "$(pwd):/src" -w /src jforissier/optee_os_ci:qemu_che
414421
exit"
415422
```
416423

417-
### Running OP-TEE Libdogecoin Key Manager Enclave (on NanoPC-T6)
424+
### Step 3 (NanoPC): Running OP-TEE Libdogecoin Key Manager Enclave
418425

419426
Use scp to copy the /doge/libdogecoin/optee/out/bin/libdogecoin.img to the NanoPC-T6 (e.g. `scp /doge/libdogecoin/optee/out/bin/libdogecoin.img [email protected]:/root/`). Then, SSH into the NanoPC-T6 and run the following commands:
420427

@@ -426,7 +433,7 @@ cp /media/libdogecoin/62d95dc0-7fc2-4cb3-a7f3-c13ae4e633c4.ta /lib/optee_armtz/
426433
./optee_libdogecoin -c generate_mnemonic
427434
```
428435

429-
### Running OP-TEE Libdogecoin Key Manager Enclave (in QEMU ARMv8)
436+
### Step 3 (QEMU): Running OP-TEE Libdogecoin Key Manager Enclave
430437

431438
```sh
432439
docker run --privileged -v /dev/bus/usb:/dev/bus/usb -it -v "$(pwd):/src" -w /src jforissier/optee_os_ci:qemu_check /bin/bash -c "\
@@ -513,11 +520,16 @@ docker run --device /dev/sgx_enclave:/dev/sgx_enclave --device /dev/sgx_provisio
513520
apt-get install -y autoconf automake libtool-bin build-essential curl python3 valgrind python3-dev python3-dbg pkg-config && \
514521
cd /src && \
515522
make -j 4 -C depends HOST=x86_64-pc-linux-gnu && \
523+
make -j 4 -C depends HOST=x86_64-pc-linux-gnu/host && \
516524
./autogen.sh && \
517525
./configure --prefix=/src/depends/x86_64-pc-linux-gnu --enable-openenclave --enable-test-passwd CFLAGS=-U_FORTIFY_SOURCE && \
518526
make && \
519527
make install && \
520528
529+
./configure --prefix=/src/depends/x86_64-pc-linux-gnu/host --enable-test-passwd && \
530+
make && \
531+
make install && \
532+
521533
# Set up the OpenEnclave environment and build the enclave
522534
apt-get install -y wget gnupg2 cmake && \
523535
echo 'deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu focal main' | tee /etc/apt/sources.list.d/intel-sgx.list && \

Diff for: src/openenclave/host/CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ endif ()
1818

1919
target_include_directories(
2020
host PRIVATE # Needed for the generated file libdogecoin_u.h
21-
${CMAKE_CURRENT_BINARY_DIR} /usr/local/include /usr/local/include/dogecoin /usr/include/ykpers-1 ${CMAKE_SOURCE_DIR}/../../depends/x86_64-pc-linux-gnu/include/ ${CMAKE_SOURCE_DIR}/../../depends/x86_64-pc-linux-gnu/include/dogecoin/ ${CMAKE_SOURCE_DIR}/../../depends/x86_64-pc-linux-gnu/include/ykpers-1 ${CMAKE_SOURCE_DIR}/../../src/libevent/build/include)
21+
${CMAKE_CURRENT_BINARY_DIR} /usr/local/include /usr/local/include/dogecoin /usr/include/ykpers-1 ${CMAKE_SOURCE_DIR}/../../depends/x86_64-pc-linux-gnu/host/include/ ${CMAKE_SOURCE_DIR}/../../depends/x86_64-pc-linux-gnu/host/include/dogecoin/ ${CMAKE_SOURCE_DIR}/../../depends/x86_64-pc-linux-gnu/host/include/ykpers-1 ${CMAKE_SOURCE_DIR}/../../src/libevent/build/include)
2222

2323
# Add search paths to find the enclave libraries.
24-
target_link_directories(host PRIVATE ${CMAKE_SOURCE_DIR}../../ ${CMAKE_SOURCE_DIR}/../../src/libevent/build/lib ${CMAKE_SOURCE_DIR}/../../depends/x86_64-pc-linux-gnu/lib)
24+
target_link_directories(host PRIVATE ${CMAKE_SOURCE_DIR}../../ ${CMAKE_SOURCE_DIR}/../../src/libevent/build/lib ${CMAKE_SOURCE_DIR}/../../depends/x86_64-pc-linux-gnu/host/lib)
2525

2626
target_link_libraries(host openenclave::oehost "libdogecoin.a" "libevent.a" "libunistring.a" "libykpers-1.so" "libyubikey.so" "libusb-1.0.so")

Diff for: src/openenclave/host/host.c

+4
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,10 @@ int main(int argc, char* argv[])
458458
fprintf(stderr, "Password cannot be empty\n");
459459
goto exit;
460460
}
461+
if (strcmp (password, getpass("Confirm password: ")) != 0) {
462+
fprintf(stderr, "Password mismatch\n");
463+
goto exit;
464+
}
461465
}
462466

463467
MNEMONIC mnemonic = {0};

Diff for: src/optee/host/main.c

+4
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,10 @@ int main(int argc, const char* argv[])
821821
fprintf(stderr, "Password cannot be empty\n");
822822
goto exit;
823823
}
824+
if (strcmp (password, getpass("Confirm password: ")) != 0) {
825+
fprintf(stderr, "Password mismatch\n");
826+
goto exit;
827+
}
824828
}
825829

826830
TEEC_Result res = generate_mnemonic(&ctx, shared_secret, password, flags, mnemonic, entropy_size);

0 commit comments

Comments
 (0)