Skip to content

Commit

Permalink
Adds MRENCLAVE and digest information to SGX build scripts (#223)
Browse files Browse the repository at this point in the history
  • Loading branch information
italo-sampaio authored Nov 25, 2024
1 parent 2e8d75f commit 738fb0f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build-dist-sgx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ $ROOT_DIR/firmware/build/build-sgx $CHECKPOINT $DIFFICULTY $NETWORK > /dev/null
cp $ROOT_DIR/firmware/src/sgx/bin/hsmsgx $HSM_DIR/
cp $ROOT_DIR/firmware/src/sgx/bin/hsmsgx_enclave.signed $HSM_DIR/

HOST_HASH=$(sha256sum $ROOT_DIR/firmware/src/sgx/bin/hsmsgx | cut -d ' ' -f 1)
ENCLAVE_HASH=$($ROOT_DIR/firmware/build/extract-mrenclave $ROOT_DIR/firmware/src/sgx/bin/hsmsgx_enclave.signed)
echo "$HSM_DIR/hsmsgx:"
echo $HOST_HASH
echo
echo "$HSM_DIR/hsmsgx_enclave.signed"
echo "$ENCLAVE_HASH"

echo
echo -e "\e[32mBuild complete.\e[0m"

Expand Down
17 changes: 17 additions & 0 deletions firmware/build/build-sgx
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,20 @@ BUILD_CMD="\$SGX_ENVSETUP && make clean $BUILD_TARGET CHECKPOINT=$1 TARGET_DIFFI
DOCKER_USER="$(id -u):$(id -g)"

docker run -t --rm --user $DOCKER_USER -w /hsm2/firmware/src/sgx -v ${HSM_ROOT}:/hsm2 ${DOCKER_IMAGE} /bin/bash -c "$BUILD_CMD"

if [[ $? -ne 0 ]]; then
echo "Build failed"
exit 1
fi

HOST_BIN=$HSM_ROOT/firmware/src/sgx/bin/hsmsgx
ENCLAVE_BIN=$HSM_ROOT/firmware/src/sgx/bin/hsmsgx_enclave.signed

echo "*******************"
echo "Build successful."
echo "$(realpath $HOST_BIN --relative-to=$HSM_ROOT):"
sha256sum $HOST_BIN | cut -d ' ' -f 1
echo ""
echo "$(realpath $ENCLAVE_BIN --relative-to=$HSM_ROOT):"
$BUILD_ROOT/extract-mrenclave $ENCLAVE_BIN
echo "*******************"

0 comments on commit 738fb0f

Please sign in to comment.