From c98e2b22fdbfec2e929dabb4241ac5abe2d73934 Mon Sep 17 00:00:00 2001 From: Yuan Zhuang Date: Fri, 5 Jul 2024 07:52:19 +0000 Subject: [PATCH] add std support --- .github/workflows/ci.yml | 80 ++++++++----- .licenserc.yaml | 1 + aarch64-unknown-optee.json | 21 ++++ arm-unknown-optee.json | 21 ++++ build_optee_libraries.sh | 24 ++-- environment | 65 +++++++--- examples/acipher-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/acipher-rs/host/Makefile | 8 +- examples/acipher-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/acipher-rs/ta/Cargo.toml | 4 +- examples/acipher-rs/ta/Makefile | 16 ++- examples/acipher-rs/ta/Xargo.toml | 24 ++++ examples/acipher-rs/ta/build.rs | 2 +- examples/aes-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/aes-rs/host/Makefile | 12 +- examples/aes-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/aes-rs/ta/Cargo.toml | 4 +- examples/aes-rs/ta/Makefile | 15 ++- examples/aes-rs/ta/Xargo.toml | 24 ++++ examples/aes-rs/ta/build.rs | 2 +- examples/authentication-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/authentication-rs/host/Makefile | 12 +- examples/authentication-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/authentication-rs/ta/Cargo.toml | 4 +- examples/authentication-rs/ta/Makefile | 15 ++- examples/authentication-rs/ta/Xargo.toml | 24 ++++ examples/authentication-rs/ta/build.rs | 2 +- examples/big_int-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/big_int-rs/host/Makefile | 12 +- examples/big_int-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/big_int-rs/ta/Cargo.toml | 4 +- examples/big_int-rs/ta/Makefile | 15 ++- examples/big_int-rs/ta/Xargo.toml | 24 ++++ examples/big_int-rs/ta/build.rs | 2 +- examples/diffie_hellman-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/diffie_hellman-rs/host/Makefile | 12 +- examples/diffie_hellman-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/diffie_hellman-rs/ta/Cargo.toml | 4 +- examples/diffie_hellman-rs/ta/Makefile | 16 ++- examples/diffie_hellman-rs/ta/Xargo.toml | 24 ++++ examples/diffie_hellman-rs/ta/build.rs | 2 +- examples/digest-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/digest-rs/host/Makefile | 12 +- examples/digest-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/digest-rs/ta/Cargo.toml | 4 +- examples/digest-rs/ta/Makefile | 16 ++- examples/digest-rs/ta/Xargo.toml | 24 ++++ examples/digest-rs/ta/build.rs | 2 +- examples/error_handling-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/error_handling-rs/host/Makefile | 12 +- examples/error_handling-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/error_handling-rs/ta/Cargo.toml | 4 +- examples/error_handling-rs/ta/Makefile | 15 ++- examples/error_handling-rs/ta/Xargo.toml | 24 ++++ examples/error_handling-rs/ta/build.rs | 2 +- examples/hello_world-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/hello_world-rs/host/Makefile | 12 +- examples/hello_world-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/hello_world-rs/ta/Cargo.toml | 4 +- examples/hello_world-rs/ta/Makefile | 16 ++- examples/hello_world-rs/ta/Xargo.toml | 24 ++++ examples/hello_world-rs/ta/build.rs | 2 +- examples/hotp-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/hotp-rs/host/Makefile | 12 +- examples/hotp-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/hotp-rs/ta/Cargo.toml | 4 +- examples/hotp-rs/ta/Makefile | 16 ++- examples/hotp-rs/ta/Xargo.toml | 24 ++++ examples/hotp-rs/ta/build.rs | 2 +- examples/hotp-rs/ta/src/main.rs | 6 +- examples/random-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/random-rs/host/Makefile | 12 +- examples/random-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/random-rs/ta/Cargo.toml | 4 +- examples/random-rs/ta/Makefile | 16 ++- examples/random-rs/ta/Xargo.toml | 24 ++++ examples/random-rs/ta/build.rs | 2 +- examples/secure_storage-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/secure_storage-rs/host/Makefile | 12 +- examples/secure_storage-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/secure_storage-rs/ta/Cargo.toml | 4 +- examples/secure_storage-rs/ta/Makefile | 16 ++- examples/secure_storage-rs/ta/Xargo.toml | 24 ++++ examples/secure_storage-rs/ta/build.rs | 2 +- .../signature_verification-rs/host/Cargo.lock | 104 ++++++++++++++++ .../signature_verification-rs/host/Makefile | 12 +- .../signature_verification-rs/ta/Cargo.lock | 109 +++++++++++++++++ .../signature_verification-rs/ta/Cargo.toml | 4 +- .../signature_verification-rs/ta/Makefile | 15 ++- .../signature_verification-rs/ta/Xargo.toml | 24 ++++ .../signature_verification-rs/ta/build.rs | 2 +- examples/supp_plugin-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/supp_plugin-rs/host/Makefile | 12 +- examples/supp_plugin-rs/plugin/Cargo.lock | 112 ++++++++++++++++++ examples/supp_plugin-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/supp_plugin-rs/ta/Cargo.toml | 4 +- examples/supp_plugin-rs/ta/Makefile | 16 ++- examples/supp_plugin-rs/ta/Xargo.toml | 24 ++++ examples/supp_plugin-rs/ta/build.rs | 2 +- examples/time-rs/host/Cargo.lock | 104 ++++++++++++++++ examples/time-rs/host/Makefile | 12 +- examples/time-rs/ta/Cargo.lock | 109 +++++++++++++++++ examples/time-rs/ta/Cargo.toml | 4 +- examples/time-rs/ta/Makefile | 16 ++- examples/time-rs/ta/Xargo.toml | 24 ++++ examples/time-rs/ta/build.rs | 2 +- optee-teec/optee-teec-sys/build.rs | 2 +- optee-utee/Cargo.toml | 11 +- optee-utee/Xargo.toml | 24 ++++ optee-utee/macros/src/lib.rs | 2 +- optee-utee/optee-utee-sys/Cargo.toml | 6 +- optee-utee/optee-utee-sys/src/lib.rs | 2 +- optee-utee/optee-utee-sys/src/tee_api.rs | 6 +- .../optee-utee-sys/src/tee_api_types.rs | 6 +- .../src/tee_internal_api_extensions.rs | 6 +- optee-utee/optee-utee-sys/src/tee_isocket.rs | 6 +- .../optee-utee-sys/src/tee_tcpsocket.rs | 6 +- .../optee-utee-sys/src/tee_udpsocket.rs | 6 +- optee-utee/optee-utee-sys/src/trace.rs | 6 +- .../optee-utee-sys/src/user_ta_header.rs | 6 +- .../optee-utee-sys/src/utee_syscalls.rs | 6 +- optee-utee/src/arithmetical.rs | 2 +- optee-utee/src/crypto_op.rs | 4 +- optee-utee/src/error.rs | 4 +- optee-utee/src/extension.rs | 4 +- optee-utee/src/lib.rs | 14 ++- optee-utee/src/object.rs | 4 +- rust-toolchain.toml | 5 +- setup_std_dependencies.sh | 52 ++++++++ tests/test_acipher.sh | 4 +- tests/test_aes.sh | 4 +- tests/test_authentication.sh | 4 +- tests/test_big_int.sh | 4 +- tests/test_diffie_hellman.sh | 4 +- tests/test_digest.sh | 4 +- tests/test_error_handling.sh | 4 +- tests/test_hello_world.sh | 4 +- tests/test_hotp.sh | 4 +- tests/test_random.sh | 4 +- tests/test_secure_storage.sh | 4 +- tests/test_signature_verification.sh | 4 +- tests/test_supp_plugin.sh | 6 +- tests/test_time.sh | 4 +- 143 files changed, 4012 insertions(+), 351 deletions(-) create mode 100644 aarch64-unknown-optee.json create mode 100644 arm-unknown-optee.json create mode 100644 examples/acipher-rs/host/Cargo.lock create mode 100644 examples/acipher-rs/ta/Cargo.lock create mode 100644 examples/acipher-rs/ta/Xargo.toml create mode 100644 examples/aes-rs/host/Cargo.lock create mode 100644 examples/aes-rs/ta/Cargo.lock create mode 100644 examples/aes-rs/ta/Xargo.toml create mode 100644 examples/authentication-rs/host/Cargo.lock create mode 100644 examples/authentication-rs/ta/Cargo.lock create mode 100644 examples/authentication-rs/ta/Xargo.toml create mode 100644 examples/big_int-rs/host/Cargo.lock create mode 100644 examples/big_int-rs/ta/Cargo.lock create mode 100644 examples/big_int-rs/ta/Xargo.toml create mode 100644 examples/diffie_hellman-rs/host/Cargo.lock create mode 100644 examples/diffie_hellman-rs/ta/Cargo.lock create mode 100644 examples/diffie_hellman-rs/ta/Xargo.toml create mode 100644 examples/digest-rs/host/Cargo.lock create mode 100644 examples/digest-rs/ta/Cargo.lock create mode 100644 examples/digest-rs/ta/Xargo.toml create mode 100644 examples/error_handling-rs/host/Cargo.lock create mode 100644 examples/error_handling-rs/ta/Cargo.lock create mode 100644 examples/error_handling-rs/ta/Xargo.toml create mode 100644 examples/hello_world-rs/host/Cargo.lock create mode 100644 examples/hello_world-rs/ta/Cargo.lock create mode 100644 examples/hello_world-rs/ta/Xargo.toml create mode 100644 examples/hotp-rs/host/Cargo.lock create mode 100644 examples/hotp-rs/ta/Cargo.lock create mode 100644 examples/hotp-rs/ta/Xargo.toml create mode 100644 examples/random-rs/host/Cargo.lock create mode 100644 examples/random-rs/ta/Cargo.lock create mode 100644 examples/random-rs/ta/Xargo.toml create mode 100644 examples/secure_storage-rs/host/Cargo.lock create mode 100644 examples/secure_storage-rs/ta/Cargo.lock create mode 100644 examples/secure_storage-rs/ta/Xargo.toml create mode 100644 examples/signature_verification-rs/host/Cargo.lock create mode 100644 examples/signature_verification-rs/ta/Cargo.lock create mode 100644 examples/signature_verification-rs/ta/Xargo.toml create mode 100644 examples/supp_plugin-rs/host/Cargo.lock create mode 100644 examples/supp_plugin-rs/plugin/Cargo.lock create mode 100644 examples/supp_plugin-rs/ta/Cargo.lock create mode 100644 examples/supp_plugin-rs/ta/Xargo.toml create mode 100644 examples/time-rs/host/Cargo.lock create mode 100644 examples/time-rs/ta/Cargo.lock create mode 100644 examples/time-rs/ta/Xargo.toml create mode 100644 optee-utee/Xargo.toml create mode 100755 setup_std_dependencies.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 58805184..539a9b9c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,14 +42,14 @@ jobs: ./build_optee_libraries.sh $HOME # Setup environment - export OPTEE_DIR=$HOME + export OPTEE_ROOT_PATH=$HOME source environment # Build Rust optee-utee and optee-teec - (cd optee-utee && cargo build --target aarch64-unknown-linux-gnu --no-default-features -vv) + (cd optee-utee && cargo build --target aarch64-unknown-linux-gnu -vv) (cd optee-teec && cargo build --target aarch64-unknown-linux-gnu -vv) - build-examples: + build-and-test-examples: runs-on: ubuntu-latest container: teaclave/teaclave-trustzone-sdk-build:0.3.0 steps: @@ -68,38 +68,58 @@ jobs: # Build optee_os and optee_client for qemu_v8 ./build_optee_libraries.sh $HOME - # Setup environment - export OPTEE_DIR=$HOME + # Build OP-TEE Rust examples for Arm 32-bit both host and TA + export ARCH_HOST=arm + export ARCH_TA=arm source environment - - # Build OP-TEE Rust examples for Arm 64-bit both host and TA make -j`nproc` - # Build OP-TEE Rust examples for Arm 64-bit host and 32-bit TA - export TA_DEV_KIT_DIR=~/optee_os/out/arm-plat-vexpress/export-ta_arm32/ - export CROSS_COMPILE_HOST=$CROSS_COMPILE64 - export CROSS_COMPILE_TA=$CROSS_COMPILE32 - export TARGET_HOST="aarch64-unknown-linux-gnu" - export TARGET_TA="arm-unknown-linux-gnueabihf" + # Build OP-TEE Rust examples for Arm 64-bit both host and TA + unset ARCH_TA + unset ARCH_HOST + export OPTEE_ROOT_PATH=$HOME + source environment make clean && make -j`nproc` + - name: Run tests for Arm 64-bit both host and TA + run: | + apt update && apt install libslirp-dev -y + source environment + (cd ci && ./ci.sh) + build-and-test-examples-for-std-TAs: + runs-on: ubuntu-latest + container: teaclave/teaclave-trustzone-sdk-build:0.3.0 + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Setting up $HOME + run: | + cp /root/.bashrc $HOME/.bashrc && + ln -sf /root/.rustup ~/.rustup && + ln -sf /root/.cargo ~/.cargo + - name: Building Arm 64-bit both host and TA (with STD enabled) + run: | + # Setup Rust and toolchains + ./setup.sh - # Build OP-TEE Rust examples for Arm 32-bit both host and TA - export TA_DEV_KIT_DIR=~/optee_os/out/arm-plat-vexpress/export-ta_arm32/ - export CROSS_COMPILE_HOST=$CROSS_COMPILE32 - export CROSS_COMPILE_TA=$CROSS_COMPILE32 - export TARGET_HOST="arm-unknown-linux-gnueabihf" - export TARGET_TA="arm-unknown-linux-gnueabihf" - (cd ~/optee_client && make clean && make CROSS_COMPILE=$CROSS_COMPILE32 WITH_TEEACL=0) - make clean && make -j`nproc` + # Setup std dependencies + ./setup_std_dependencies.sh - # Build OP-TEE Rust examples for Arm 32-bit host and 64-bit TA - export TA_DEV_KIT_DIR=~/optee_os/out/arm-plat-vexpress/export-ta_arm64/ - export CROSS_COMPILE_HOST=$CROSS_COMPILE32 - export CROSS_COMPILE_TA=$CROSS_COMPILE64 - export TARGET_HOST="arm-unknown-linux-gnueabihf" - export TARGET_TA="aarch64-unknown-linux-gnu" - make clean && make -j`nproc` + # Build optee_os and optee_client for qemu_v8 + ./build_optee_libraries.sh $HOME + # Setup environment + export OPTEE_ROOT_PATH=$HOME + export STD=y + source environment + + # Build OP-TEE Rust examples for Arm 64-bit both host and TA + make -j`nproc` + - name: Run tests for Arm 64-bit both host and TA + run: | + apt update && apt install libslirp-dev -y + export STD=y + source environment + (cd ci && ./ci.sh) OPTEE-repo-build-and-run-examples-64bit-TAs: runs-on: ubuntu-latest container: teaclave/teaclave-trustzone-sdk-build:0.3.0 @@ -123,6 +143,8 @@ jobs: run: | apt update && apt install libslirp-dev -y cd ~/optee-qemuv8 + # fixed the error: configure: error: you should not run configure as root: + export FORCE_UNSAFE_CONFIGURE=1 rm -rf optee_rust/ && mv $GITHUB_WORKSPACE/incubator-teaclave-trustzone-sdk optee_rust/ cd build && @@ -152,6 +174,8 @@ jobs: run: | apt update && apt install libslirp-dev -y cd ~/optee-qemuv8 + # fixed the error: configure: error: you should not run configure as root: + export FORCE_UNSAFE_CONFIGURE=1 rm -rf optee_rust/ && mv $GITHUB_WORKSPACE/incubator-teaclave-trustzone-sdk optee_rust/ cd build && diff --git a/.licenserc.yaml b/.licenserc.yaml index 0f46f771..0391c38c 100644 --- a/.licenserc.yaml +++ b/.licenserc.yaml @@ -29,3 +29,4 @@ header: - '**/Cargo.lock' - 'KEYS' - 'DISCLAIMER-WIP' + - '*.json' diff --git a/aarch64-unknown-optee.json b/aarch64-unknown-optee.json new file mode 100644 index 00000000..34c36960 --- /dev/null +++ b/aarch64-unknown-optee.json @@ -0,0 +1,21 @@ +{ + "arch": "aarch64", + "data-layout": "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128", + "features": "+strict-align", + "dynamic-linking": false, + "executables": true, + "has-rpath": true, + "linker-flavor": "ld", + "linker-is-gnu": true, + "llvm-target": "aarch64-unknown-linux-gnu", + "max-atomic-width": 128, + "os": "optee", + "position-independent-executables": true, + "relro-level": "full", + "target-c-int-width": "32", + "target-endian": "little", + "target-pointer-width": "64", + "vendor": "unknown", + "panic-strategy": "abort" + } + \ No newline at end of file diff --git a/arm-unknown-optee.json b/arm-unknown-optee.json new file mode 100644 index 00000000..79cf1257 --- /dev/null +++ b/arm-unknown-optee.json @@ -0,0 +1,21 @@ +{ + "arch": "arm", + "data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64", + "dynamic-linking": false, + "executables": true, + "features": "+strict-align,+v6,+vfp2", + "has-rpath": true, + "linker-flavor": "ld", + "linker-is-gnu": true, + "llvm-target": "arm-unknown-linux-gnueabihf", + "max-atomic-width": 64, + "os": "optee", + "position-independent-executables": true, + "relro-level": "full", + "target-c-int-width": "32", + "target-endian": "little", + "target-pointer-width": "32", + "vendor": "unknown", + "panic-strategy": "abort", + "singlethread": true +} diff --git a/build_optee_libraries.sh b/build_optee_libraries.sh index f88a8466..9d17c4aa 100755 --- a/build_optee_libraries.sh +++ b/build_optee_libraries.sh @@ -20,23 +20,29 @@ set -e OPTEE_VERSION=4.2.0 - -TARGET_PATH=$1 +OPTEE_ROOT_PATH=$1 # check arguments -if [ -z "$TARGET_PATH" ]; then - echo "Usage: $0 " +if [ -z "$OPTEE_ROOT_PATH" ]; then + echo "Usage: $0 " exit 1 +else + export OPTEE_ROOT_PATH=$OPTEE_ROOT_PATH + echo "OPTEE_ROOT_PATH=$OPTEE_ROOT_PATH" +fi + +if [ ! -d $OPTEE_ROOT_PATH ]; then + mkdir -p $OPTEE_ROOT_PATH fi # set toolchain -export CROSS_COMPILE="aarch64-linux-gnu-" export CROSS_COMPILE32="arm-linux-gnueabihf-" export CROSS_COMPILE64="aarch64-linux-gnu-" # build optee_os and optee_client for qemu_v8 -git clone https://github.com/OP-TEE/optee_os.git -b $OPTEE_VERSION $TARGET_PATH/optee_os -(cd $TARGET_PATH/optee_os && make PLATFORM=vexpress-qemu_armv8a) +git clone https://github.com/OP-TEE/optee_os.git -b $OPTEE_VERSION $OPTEE_ROOT_PATH/optee_os +(cd $OPTEE_ROOT_PATH/optee_os && make PLATFORM=vexpress-qemu_armv8a) -git clone https://github.com/OP-TEE/optee_client.git -b $OPTEE_VERSION $TARGET_PATH/optee_client -(cd $TARGET_PATH/optee_client && make WITH_TEEACL=0) +git clone https://github.com/OP-TEE/optee_client.git -b $OPTEE_VERSION $OPTEE_ROOT_PATH/optee_client +(cd $OPTEE_ROOT_PATH/optee_client && make WITH_TEEACL=0 DESTDIR=$PWD/export_arm32 CROSS_COMPILE=$CROSS_COMPILE32) +(cd $OPTEE_ROOT_PATH/optee_client && make clean && make WITH_TEEACL=0 DESTDIR=$PWD/export_arm64 CROSS_COMPILE=$CROSS_COMPILE64) diff --git a/environment b/environment index 4835c51f..04689a22 100644 --- a/environment +++ b/environment @@ -16,32 +16,48 @@ # under the License. export PATH=$PATH:$HOME/.cargo/bin +# for std: specify the target json file +export RUST_TARGET_PATH="$(pwd)" -if [ -z "$OPTEE_DIR" ] +if [ -z "$OPTEE_ROOT_PATH" ] then - echo -e "OPTEE_DIR has not set, use $PWD/optee/ as default\n" - export OPTEE_DIR=$PWD/optee + echo -e "OPTEE_ROOT_PATH has not set, use $PWD/optee/ as default\n" + export OPTEE_ROOT_PATH=$PWD/optee fi -export OPTEE_OS_DIR="$OPTEE_DIR/optee_os" -export OPTEE_CLIENT_DIR="$OPTEE_DIR/optee_client" +export OPTEE_OS_DIR="$OPTEE_ROOT_PATH/optee_os" +export OPTEE_CLIENT_DIR="$OPTEE_ROOT_PATH/optee_client" -export CROSS_COMPILE="aarch64-linux-gnu-" export CROSS_COMPILE32="arm-linux-gnueabihf-" export CROSS_COMPILE64="aarch64-linux-gnu-" -if [ "$ARCH" = "arm" ] +if [ "$ARCH_TA" = "arm" ] then - # build host and TA as 32-bit + # build TA as 32-bit export TA_DEV_KIT_DIR="$OPTEE_OS_DIR/out/arm-plat-vexpress/export-ta_arm32" - export OPTEE_CLIENT_EXPORT="$OPTEE_CLIENT_DIR/out/export" - export TARGET="arm-unknown-linux-gnueabihf" + if [ "$STD" ] + then + export TARGET_TA="arm-unknown-optee" + echo "set TARGET_TA=$TARGET_TA (std)" + else + export TARGET_TA="arm-unknown-linux-gnueabihf" + echo "set TARGET_TA=$TARGET_TA (no-std)" + fi + export CROSS_COMPILE_TA="$CROSS_COMPILE32" + echo "set CROSS_COMPILE_TA=$CROSS_COMPILE_TA" else - # build host and TA as 64-bit by default - unset ARCH + # build TA as 64-bit by default export TA_DEV_KIT_DIR="$OPTEE_OS_DIR/out/arm-plat-vexpress/export-ta_arm64" - export OPTEE_CLIENT_EXPORT="$OPTEE_CLIENT_DIR/out/export" - export TARGET="aarch64-unknown-linux-gnu" + if [ "$STD" ] + then + export TARGET_TA="aarch64-unknown-optee" + echo "set TARGET_TA=$TARGET_TA (std)" + else + export TARGET_TA="aarch64-unknown-linux-gnu" + echo "set TARGET_TA=$TARGET_TA (no-std)" + fi + export CROSS_COMPILE_TA="$CROSS_COMPILE64" + echo "set CROSS_COMPILE_TA=$CROSS_COMPILE_TA" fi # check if libraries exist @@ -50,7 +66,24 @@ then echo "set TA_DEV_KIT_DIR=$TA_DEV_KIT_DIR" else echo -e "Error: TA_DEV_KIT_DIR=$TA_DEV_KIT_DIR does not exist, please set the correct TA_DEV_KIT_DIR or run \"$ ./build_optee_libraries.sh optee/\" then try again\n" - unset OPTEE_DIR + unset OPTEE_ROOT_PATH +fi + +if [ "$ARCH_HOST" = "arm" ] +then + # build host as 32-bit + export OPTEE_CLIENT_EXPORT="$OPTEE_CLIENT_DIR/export_arm32" + export TARGET_HOST="arm-unknown-linux-gnueabihf" + echo "set TARGET_HOST=$TARGET_HOST" + export CROSS_COMPILE_HOST="$CROSS_COMPILE32" + echo "set CROSS_COMPILE_HOST=$CROSS_COMPILE_HOST" +else + # build host as 64-bit by default + export OPTEE_CLIENT_EXPORT="$OPTEE_CLIENT_DIR/export_arm64" + export TARGET_HOST="aarch64-unknown-linux-gnu" + echo "set TARGET_HOST=$TARGET_HOST" + export CROSS_COMPILE_HOST="$CROSS_COMPILE64" + echo "set CROSS_COMPILE_HOST=$CROSS_COMPILE_HOST" fi if [ -d "$OPTEE_CLIENT_EXPORT" ] @@ -58,5 +91,5 @@ then echo "set OPTEE_CLIENT_EXPORT=$OPTEE_CLIENT_EXPORT" else echo -e "Error: OPTEE_CLIENT_EXPORT=$OPTEE_CLIENT_EXPORT does not exist, please set the correct OPTEE_CLIENT_EXPORT or run \"$ ./build_optee_libraries.sh optee/\" then try again\n" - unset OPTEE_DIR + unset OPTEE_ROOT_PATH fi diff --git a/examples/acipher-rs/host/Cargo.lock b/examples/acipher-rs/host/Cargo.lock new file mode 100644 index 00000000..b2b2076d --- /dev/null +++ b/examples/acipher-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "acipher-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/acipher-rs/host/Makefile b/examples/acipher-rs/host/Makefile index 62166921..05bde6a7 100644 --- a/examples/acipher-rs/host/Makefile +++ b/examples/acipher-rs/host/Makefile @@ -18,11 +18,11 @@ NAME := acipher-rs TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip diff --git a/examples/acipher-rs/ta/Cargo.lock b/examples/acipher-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/acipher-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/acipher-rs/ta/Cargo.toml b/examples/acipher-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/acipher-rs/ta/Cargo.toml +++ b/examples/acipher-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/acipher-rs/ta/Makefile b/examples/acipher-rs/ta/Makefile index a6de23e6..e86893f7 100644 --- a/examples/acipher-rs/ta/Makefile +++ b/examples/acipher-rs/ta/Makefile @@ -17,19 +17,23 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +TARGET_TA ?= $(TARGET) +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/acipher-rs/ta/Xargo.toml b/examples/acipher-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/acipher-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/acipher-rs/ta/build.rs b/examples/acipher-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/acipher-rs/ta/build.rs +++ b/examples/acipher-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/aes-rs/host/Cargo.lock b/examples/aes-rs/host/Cargo.lock new file mode 100644 index 00000000..8a1648da --- /dev/null +++ b/examples/aes-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aes-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/aes-rs/host/Makefile b/examples/aes-rs/host/Makefile index ba3b26d7..510b25fc 100644 --- a/examples/aes-rs/host/Makefile +++ b/examples/aes-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := aes-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/aes-rs/ta/Cargo.lock b/examples/aes-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/aes-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/aes-rs/ta/Cargo.toml b/examples/aes-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/aes-rs/ta/Cargo.toml +++ b/examples/aes-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/aes-rs/ta/Makefile b/examples/aes-rs/ta/Makefile index a6de23e6..dff366ce 100644 --- a/examples/aes-rs/ta/Makefile +++ b/examples/aes-rs/ta/Makefile @@ -17,19 +17,22 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/aes-rs/ta/Xargo.toml b/examples/aes-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/aes-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/aes-rs/ta/build.rs b/examples/aes-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/aes-rs/ta/build.rs +++ b/examples/aes-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/authentication-rs/host/Cargo.lock b/examples/authentication-rs/host/Cargo.lock new file mode 100644 index 00000000..c9ff13ea --- /dev/null +++ b/examples/authentication-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "authentication-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/authentication-rs/host/Makefile b/examples/authentication-rs/host/Makefile index c3b03e86..387f1b0d 100644 --- a/examples/authentication-rs/host/Makefile +++ b/examples/authentication-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := authentication-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/authentication-rs/ta/Cargo.lock b/examples/authentication-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/authentication-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/authentication-rs/ta/Cargo.toml b/examples/authentication-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/authentication-rs/ta/Cargo.toml +++ b/examples/authentication-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/authentication-rs/ta/Makefile b/examples/authentication-rs/ta/Makefile index a6de23e6..dff366ce 100644 --- a/examples/authentication-rs/ta/Makefile +++ b/examples/authentication-rs/ta/Makefile @@ -17,19 +17,22 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/authentication-rs/ta/Xargo.toml b/examples/authentication-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/authentication-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/authentication-rs/ta/build.rs b/examples/authentication-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/authentication-rs/ta/build.rs +++ b/examples/authentication-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/big_int-rs/host/Cargo.lock b/examples/big_int-rs/host/Cargo.lock new file mode 100644 index 00000000..a5509beb --- /dev/null +++ b/examples/big_int-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "big_int-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/big_int-rs/host/Makefile b/examples/big_int-rs/host/Makefile index 9d8cb2c4..09ea0e82 100644 --- a/examples/big_int-rs/host/Makefile +++ b/examples/big_int-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := big_int-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/big_int-rs/ta/Cargo.lock b/examples/big_int-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/big_int-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/big_int-rs/ta/Cargo.toml b/examples/big_int-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/big_int-rs/ta/Cargo.toml +++ b/examples/big_int-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/big_int-rs/ta/Makefile b/examples/big_int-rs/ta/Makefile index a6de23e6..dff366ce 100644 --- a/examples/big_int-rs/ta/Makefile +++ b/examples/big_int-rs/ta/Makefile @@ -17,19 +17,22 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/big_int-rs/ta/Xargo.toml b/examples/big_int-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/big_int-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/big_int-rs/ta/build.rs b/examples/big_int-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/big_int-rs/ta/build.rs +++ b/examples/big_int-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/diffie_hellman-rs/host/Cargo.lock b/examples/diffie_hellman-rs/host/Cargo.lock new file mode 100644 index 00000000..b6edf01a --- /dev/null +++ b/examples/diffie_hellman-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "diffie_hellman-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/diffie_hellman-rs/host/Makefile b/examples/diffie_hellman-rs/host/Makefile index 1a6d7961..4ef55cb8 100644 --- a/examples/diffie_hellman-rs/host/Makefile +++ b/examples/diffie_hellman-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := diffie_hellman-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/diffie_hellman-rs/ta/Cargo.lock b/examples/diffie_hellman-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/diffie_hellman-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/diffie_hellman-rs/ta/Cargo.toml b/examples/diffie_hellman-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/diffie_hellman-rs/ta/Cargo.toml +++ b/examples/diffie_hellman-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/diffie_hellman-rs/ta/Makefile b/examples/diffie_hellman-rs/ta/Makefile index a6de23e6..e86893f7 100644 --- a/examples/diffie_hellman-rs/ta/Makefile +++ b/examples/diffie_hellman-rs/ta/Makefile @@ -17,19 +17,23 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +TARGET_TA ?= $(TARGET) +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/diffie_hellman-rs/ta/Xargo.toml b/examples/diffie_hellman-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/diffie_hellman-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/diffie_hellman-rs/ta/build.rs b/examples/diffie_hellman-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/diffie_hellman-rs/ta/build.rs +++ b/examples/diffie_hellman-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/digest-rs/host/Cargo.lock b/examples/digest-rs/host/Cargo.lock new file mode 100644 index 00000000..d2f2d17f --- /dev/null +++ b/examples/digest-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "digest-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/digest-rs/host/Makefile b/examples/digest-rs/host/Makefile index 8e37b313..2255b2ba 100644 --- a/examples/digest-rs/host/Makefile +++ b/examples/digest-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := digest-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/digest-rs/ta/Cargo.lock b/examples/digest-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/digest-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/digest-rs/ta/Cargo.toml b/examples/digest-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/digest-rs/ta/Cargo.toml +++ b/examples/digest-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/digest-rs/ta/Makefile b/examples/digest-rs/ta/Makefile index a6de23e6..e86893f7 100644 --- a/examples/digest-rs/ta/Makefile +++ b/examples/digest-rs/ta/Makefile @@ -17,19 +17,23 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +TARGET_TA ?= $(TARGET) +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/digest-rs/ta/Xargo.toml b/examples/digest-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/digest-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/digest-rs/ta/build.rs b/examples/digest-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/digest-rs/ta/build.rs +++ b/examples/digest-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/error_handling-rs/host/Cargo.lock b/examples/error_handling-rs/host/Cargo.lock new file mode 100644 index 00000000..60ee609d --- /dev/null +++ b/examples/error_handling-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "error_handling-rs" +version = "0.1.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/error_handling-rs/host/Makefile b/examples/error_handling-rs/host/Makefile index d92fe4a4..d8e92856 100644 --- a/examples/error_handling-rs/host/Makefile +++ b/examples/error_handling-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := error_handling-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/error_handling-rs/ta/Cargo.lock b/examples/error_handling-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/error_handling-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/error_handling-rs/ta/Cargo.toml b/examples/error_handling-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/error_handling-rs/ta/Cargo.toml +++ b/examples/error_handling-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/error_handling-rs/ta/Makefile b/examples/error_handling-rs/ta/Makefile index a6de23e6..dff366ce 100644 --- a/examples/error_handling-rs/ta/Makefile +++ b/examples/error_handling-rs/ta/Makefile @@ -17,19 +17,22 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/error_handling-rs/ta/Xargo.toml b/examples/error_handling-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/error_handling-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/error_handling-rs/ta/build.rs b/examples/error_handling-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/error_handling-rs/ta/build.rs +++ b/examples/error_handling-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/hello_world-rs/host/Cargo.lock b/examples/hello_world-rs/host/Cargo.lock new file mode 100644 index 00000000..3f03c2da --- /dev/null +++ b/examples/hello_world-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "hello_world-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/hello_world-rs/host/Makefile b/examples/hello_world-rs/host/Makefile index deae313d..ba1f5736 100644 --- a/examples/hello_world-rs/host/Makefile +++ b/examples/hello_world-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := hello_world-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/hello_world-rs/ta/Cargo.lock b/examples/hello_world-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/hello_world-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/hello_world-rs/ta/Cargo.toml b/examples/hello_world-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/hello_world-rs/ta/Cargo.toml +++ b/examples/hello_world-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/hello_world-rs/ta/Makefile b/examples/hello_world-rs/ta/Makefile index a6de23e6..e86893f7 100644 --- a/examples/hello_world-rs/ta/Makefile +++ b/examples/hello_world-rs/ta/Makefile @@ -17,19 +17,23 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +TARGET_TA ?= $(TARGET) +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/hello_world-rs/ta/Xargo.toml b/examples/hello_world-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/hello_world-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/hello_world-rs/ta/build.rs b/examples/hello_world-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/hello_world-rs/ta/build.rs +++ b/examples/hello_world-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/hotp-rs/host/Cargo.lock b/examples/hotp-rs/host/Cargo.lock new file mode 100644 index 00000000..c456fdd8 --- /dev/null +++ b/examples/hotp-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "hotp-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/hotp-rs/host/Makefile b/examples/hotp-rs/host/Makefile index 13c99824..b4646f15 100644 --- a/examples/hotp-rs/host/Makefile +++ b/examples/hotp-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := hotp-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/hotp-rs/ta/Cargo.lock b/examples/hotp-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/hotp-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/hotp-rs/ta/Cargo.toml b/examples/hotp-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/hotp-rs/ta/Cargo.toml +++ b/examples/hotp-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/hotp-rs/ta/Makefile b/examples/hotp-rs/ta/Makefile index a6de23e6..e86893f7 100644 --- a/examples/hotp-rs/ta/Makefile +++ b/examples/hotp-rs/ta/Makefile @@ -17,19 +17,23 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +TARGET_TA ?= $(TARGET) +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/hotp-rs/ta/Xargo.toml b/examples/hotp-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/hotp-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/hotp-rs/ta/build.rs b/examples/hotp-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/hotp-rs/ta/build.rs +++ b/examples/hotp-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/hotp-rs/ta/src/main.rs b/examples/hotp-rs/ta/src/main.rs index b7e7c1fd..8bc1720d 100644 --- a/examples/hotp-rs/ta/src/main.rs +++ b/examples/hotp-rs/ta/src/main.rs @@ -133,9 +133,11 @@ pub fn hmac_sha1(hotp: &mut HmacOtp, out: &mut [u8]) -> Result { mac.set_key(&key_object)?; } } - mac.init(&[0u8; 0]); + let iv = [0u8; 0]; + mac.init(&iv); mac.update(&hotp.counter); - let out_len = mac.compute_final(&[0u8; 0], out).unwrap(); + let message = [0u8; 0]; + let out_len = mac.compute_final(&message, out)?; Ok(out_len) } } diff --git a/examples/random-rs/host/Cargo.lock b/examples/random-rs/host/Cargo.lock new file mode 100644 index 00000000..4a32d9cb --- /dev/null +++ b/examples/random-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "random-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/random-rs/host/Makefile b/examples/random-rs/host/Makefile index 14e21f48..132dc8ea 100644 --- a/examples/random-rs/host/Makefile +++ b/examples/random-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := random-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/random-rs/ta/Cargo.lock b/examples/random-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/random-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/random-rs/ta/Cargo.toml b/examples/random-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/random-rs/ta/Cargo.toml +++ b/examples/random-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/random-rs/ta/Makefile b/examples/random-rs/ta/Makefile index a6de23e6..e86893f7 100644 --- a/examples/random-rs/ta/Makefile +++ b/examples/random-rs/ta/Makefile @@ -17,19 +17,23 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +TARGET_TA ?= $(TARGET) +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/random-rs/ta/Xargo.toml b/examples/random-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/random-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/random-rs/ta/build.rs b/examples/random-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/random-rs/ta/build.rs +++ b/examples/random-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/secure_storage-rs/host/Cargo.lock b/examples/secure_storage-rs/host/Cargo.lock new file mode 100644 index 00000000..459e55f6 --- /dev/null +++ b/examples/secure_storage-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "secure_storage-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/secure_storage-rs/host/Makefile b/examples/secure_storage-rs/host/Makefile index bc45b7f1..e20763f2 100644 --- a/examples/secure_storage-rs/host/Makefile +++ b/examples/secure_storage-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := secure_storage-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/secure_storage-rs/ta/Cargo.lock b/examples/secure_storage-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/secure_storage-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/secure_storage-rs/ta/Cargo.toml b/examples/secure_storage-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/secure_storage-rs/ta/Cargo.toml +++ b/examples/secure_storage-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/secure_storage-rs/ta/Makefile b/examples/secure_storage-rs/ta/Makefile index a6de23e6..e86893f7 100644 --- a/examples/secure_storage-rs/ta/Makefile +++ b/examples/secure_storage-rs/ta/Makefile @@ -17,19 +17,23 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +TARGET_TA ?= $(TARGET) +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/secure_storage-rs/ta/Xargo.toml b/examples/secure_storage-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/secure_storage-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/secure_storage-rs/ta/build.rs b/examples/secure_storage-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/secure_storage-rs/ta/build.rs +++ b/examples/secure_storage-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/signature_verification-rs/host/Cargo.lock b/examples/signature_verification-rs/host/Cargo.lock new file mode 100644 index 00000000..eb2cbcbf --- /dev/null +++ b/examples/signature_verification-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "signature_verification-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/signature_verification-rs/host/Makefile b/examples/signature_verification-rs/host/Makefile index 2ddf5e0f..d49e8a2c 100644 --- a/examples/signature_verification-rs/host/Makefile +++ b/examples/signature_verification-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := signature_verification-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/signature_verification-rs/ta/Cargo.lock b/examples/signature_verification-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/signature_verification-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/signature_verification-rs/ta/Cargo.toml b/examples/signature_verification-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/signature_verification-rs/ta/Cargo.toml +++ b/examples/signature_verification-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/signature_verification-rs/ta/Makefile b/examples/signature_verification-rs/ta/Makefile index a6de23e6..dff366ce 100644 --- a/examples/signature_verification-rs/ta/Makefile +++ b/examples/signature_verification-rs/ta/Makefile @@ -17,19 +17,22 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/signature_verification-rs/ta/Xargo.toml b/examples/signature_verification-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/signature_verification-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/signature_verification-rs/ta/build.rs b/examples/signature_verification-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/signature_verification-rs/ta/build.rs +++ b/examples/signature_verification-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/supp_plugin-rs/host/Cargo.lock b/examples/supp_plugin-rs/host/Cargo.lock new file mode 100644 index 00000000..d8239006 --- /dev/null +++ b/examples/supp_plugin-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "supp_plugin-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/supp_plugin-rs/host/Makefile b/examples/supp_plugin-rs/host/Makefile index 5437b966..a587762d 100644 --- a/examples/supp_plugin-rs/host/Makefile +++ b/examples/supp_plugin-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := supp_plugin-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/supp_plugin-rs/plugin/Cargo.lock b/examples/supp_plugin-rs/plugin/Cargo.lock new file mode 100644 index 00000000..d156b9ed --- /dev/null +++ b/examples/supp_plugin-rs/plugin/Cargo.lock @@ -0,0 +1,112 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "syslog_plugin" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "optee-teec-sys", + "proto", + "uuid 0.8.2", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/supp_plugin-rs/ta/Cargo.lock b/examples/supp_plugin-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/supp_plugin-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/supp_plugin-rs/ta/Cargo.toml b/examples/supp_plugin-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/supp_plugin-rs/ta/Cargo.toml +++ b/examples/supp_plugin-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/supp_plugin-rs/ta/Makefile b/examples/supp_plugin-rs/ta/Makefile index 2bf3e6f2..57edb956 100644 --- a/examples/supp_plugin-rs/ta/Makefile +++ b/examples/supp_plugin-rs/ta/Makefile @@ -17,19 +17,23 @@ UUID ?= $(shell cat "../ta_uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +TARGET_TA ?= $(TARGET) +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/supp_plugin-rs/ta/Xargo.toml b/examples/supp_plugin-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/supp_plugin-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/supp_plugin-rs/ta/build.rs b/examples/supp_plugin-rs/ta/build.rs index be2c8723..9890b999 100644 --- a/examples/supp_plugin-rs/ta/build.rs +++ b/examples/supp_plugin-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/examples/time-rs/host/Cargo.lock b/examples/time-rs/host/Cargo.lock new file mode 100644 index 00000000..89ea81f3 --- /dev/null +++ b/examples/time-rs/host/Cargo.lock @@ -0,0 +1,104 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346" + +[[package]] +name = "optee-teec" +version = "0.2.0" +dependencies = [ + "hex", + "libc", + "optee-teec-macros", + "optee-teec-sys", + "uuid 0.7.4", +] + +[[package]] +name = "optee-teec-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-teec-sys" +version = "0.2.0" +dependencies = [ + "libc", +] + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "time-rs" +version = "0.2.0" +dependencies = [ + "libc", + "optee-teec", + "proto", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90dbc611eb48397705a6b0f6e917da23ae517e4d127123d2cf7674206627d32a" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/time-rs/host/Makefile b/examples/time-rs/host/Makefile index 7ad571df..9d98a2e5 100644 --- a/examples/time-rs/host/Makefile +++ b/examples/time-rs/host/Makefile @@ -17,18 +17,18 @@ NAME := time-rs -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)gcc\" +TARGET_HOST ?= aarch64-unknown-linux-gnu +CROSS_COMPILE_HOST ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_HOST)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_HOST)gcc\" -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_HOST)/release all: host strip host: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @cargo build --target $(TARGET_HOST) --release --config $(LINKER_CFG) strip: host @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/$(NAME) $(OUT_DIR)/$(NAME) diff --git a/examples/time-rs/ta/Cargo.lock b/examples/time-rs/ta/Cargo.lock new file mode 100644 index 00000000..f9dabfab --- /dev/null +++ b/examples/time-rs/ta/Cargo.lock @@ -0,0 +1,109 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "bitflags" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12" + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "libc_alloc" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "004feaae88f49fe8cfeffb4565dae94ac608313e454ebab4a4d0d0202b553fb3" + +[[package]] +name = "optee-utee" +version = "0.2.0" +dependencies = [ + "bitflags", + "hex", + "libc_alloc", + "optee-utee-macros", + "optee-utee-sys", + "uuid 0.8.2", +] + +[[package]] +name = "optee-utee-macros" +version = "0.2.0" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "optee-utee-sys" +version = "0.2.0" + +[[package]] +name = "proc-macro2" +version = "0.4.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf3d2011ab5c909338f7887f4fc896d35932e29146c12c8d01da6b22a80ba759" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "proto" +version = "0.2.0" +dependencies = [ + "uuid 1.8.0", +] + +[[package]] +name = "quote" +version = "0.6.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce23b6b870e8f94f81fb0a363d65d86675884b34a09043c81e5562f11c1f8e1" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "syn" +version = "0.15.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ca4b3b69a77cbe1ffc9e198781b7acb0c7365a883670e8f1c1bc66fba79a5c5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "ta" +version = "0.2.0" +dependencies = [ + "optee-utee", + "optee-utee-sys", + "proto", + "uuid 1.8.0", +] + +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" + +[[package]] +name = "uuid" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a183cf7feeba97b4dd1c0d46788634f6221d87fa961b305bed08c851829efcc0" diff --git a/examples/time-rs/ta/Cargo.toml b/examples/time-rs/ta/Cargo.toml index 7e7cae7e..badab895 100644 --- a/examples/time-rs/ta/Cargo.toml +++ b/examples/time-rs/ta/Cargo.toml @@ -26,8 +26,8 @@ edition = "2018" [dependencies] proto = { path = "../proto" } -optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys", default-features = false } -optee-utee = { path = "../../../optee-utee", default-features = false } +optee-utee-sys = { path = "../../../optee-utee/optee-utee-sys" } +optee-utee = { path = "../../../optee-utee" } [build_dependencies] uuid = { version = "1.6.1", default-features = false } diff --git a/examples/time-rs/ta/Makefile b/examples/time-rs/ta/Makefile index a6de23e6..e86893f7 100644 --- a/examples/time-rs/ta/Makefile +++ b/examples/time-rs/ta/Makefile @@ -17,19 +17,23 @@ UUID ?= $(shell cat "../uuid.txt") -TARGET ?= aarch64-unknown-linux-gnu -CROSS_COMPILE ?= aarch64-linux-gnu- -OBJCOPY := $(CROSS_COMPILE)objcopy -LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE)ld.bfd\" +TARGET_TA ?= $(TARGET) +CROSS_COMPILE_TA ?= aarch64-linux-gnu- +OBJCOPY := $(CROSS_COMPILE_TA)objcopy +LINKER_CFG := target.$(TARGET).linker=\"$(CROSS_COMPILE_TA)ld.bfd\" TA_SIGN_KEY ?= $(TA_DEV_KIT_DIR)/keys/default_ta.pem SIGN := $(TA_DEV_KIT_DIR)/scripts/sign_encrypt.py -OUT_DIR := $(CURDIR)/target/$(TARGET)/release +OUT_DIR := $(CURDIR)/target/$(TARGET_TA)/release all: ta strip sign ta: - @cargo build --target $(TARGET) --release --config $(LINKER_CFG) + @if [ $(STD) ]; then\ + xargo build --target $(TARGET_TA) --release --config $(LINKER_CFG) --verbose;\ + else\ + cargo build --target $(TARGET_TA) --release --config $(LINKER_CFG);\ + fi strip: ta @$(OBJCOPY) --strip-unneeded $(OUT_DIR)/ta $(OUT_DIR)/stripped_ta diff --git a/examples/time-rs/ta/Xargo.toml b/examples/time-rs/ta/Xargo.toml new file mode 100644 index 00000000..1b1a113e --- /dev/null +++ b/examples/time-rs/ta/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../../../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../../../rust/libc" } +rustc-std-workspace-core = { path = "../../../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../../../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/examples/time-rs/ta/build.rs b/examples/time-rs/ta/build.rs index 5618f03c..0b70d4aa 100644 --- a/examples/time-rs/ta/build.rs +++ b/examples/time-rs/ta/build.rs @@ -44,7 +44,7 @@ fn main() -> std::io::Result<()> { )?; let mut aarch64_flag = true; - match env::var("TARGET") { + match env::var("TARGET_TA") { Ok(ref v) if v == "arm-unknown-linux-gnueabihf" => { println!("cargo:rustc-link-arg=--no-warn-mismatch"); aarch64_flag = false; diff --git a/optee-teec/optee-teec-sys/build.rs b/optee-teec/optee-teec-sys/build.rs index e8da2e28..8e822bbe 100644 --- a/optee-teec/optee-teec-sys/build.rs +++ b/optee-teec/optee-teec-sys/build.rs @@ -19,7 +19,7 @@ use std::env; use std::path::Path; fn main() { - let optee_client_dir = env::var("OPTEE_CLIENT_EXPORT").unwrap_or("../optee_client/out/export".to_string()); + let optee_client_dir = env::var("OPTEE_CLIENT_EXPORT").expect("OPTEE_CLIENT_EXPORT is not set"); let search_path = Path::new(&optee_client_dir).join("usr/lib"); println!("cargo:rustc-link-search={}", search_path.display()); println!("cargo:rustc-link-lib=dylib=teec"); diff --git a/optee-utee/Cargo.toml b/optee-utee/Cargo.toml index c477d18e..ff970f88 100644 --- a/optee-utee/Cargo.toml +++ b/optee-utee/Cargo.toml @@ -24,18 +24,13 @@ repository = "https://github.com/apache/incubator-teaclave-trustzone-sdk.git" description = "TEE internal core API." edition = "2018" -[features] -default = ["std", "sys_std"] -std = [] -sys_std = ["optee-utee-sys/std"] - [dependencies] -optee-utee-sys = { path = "optee-utee-sys", default-features = false } +optee-utee-sys = { path = "optee-utee-sys" } optee-utee-macros = { path = "macros" } bitflags = "=1.0.4" uuid = { version = "0.8", default-features = false } hex = { version = "0.4", default-features = false, features = ["alloc"] } libc_alloc = "=1.0.5" -[workspace] -members = ['systest'] +#[workspace] +#members = ['systest'] diff --git a/optee-utee/Xargo.toml b/optee-utee/Xargo.toml new file mode 100644 index 00000000..0ad721d3 --- /dev/null +++ b/optee-utee/Xargo.toml @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +[dependencies.std] +path = "../rust/rust/library/std" + +[patch.crates-io] +libc = { path = "../rust/libc" } +rustc-std-workspace-core = { path = "../rust/rust/library/rustc-std-workspace-core" } +rustc-std-workspace-alloc = { path = "../rust/rust/library/rustc-std-workspace-alloc" } diff --git a/optee-utee/macros/src/lib.rs b/optee-utee/macros/src/lib.rs index 102df7da..67cd929c 100644 --- a/optee-utee/macros/src/lib.rs +++ b/optee-utee/macros/src/lib.rs @@ -18,7 +18,7 @@ extern crate alloc; extern crate proc_macro; -#[cfg(not(feature = "std"))] +#[cfg(not(target_os = "optee"))] use alloc::vec::Vec; use proc_macro::TokenStream; use quote::quote; diff --git a/optee-utee/optee-utee-sys/Cargo.toml b/optee-utee/optee-utee-sys/Cargo.toml index 92fa4564..daa4bb0b 100644 --- a/optee-utee/optee-utee-sys/Cargo.toml +++ b/optee-utee/optee-utee-sys/Cargo.toml @@ -23,8 +23,4 @@ license = "Apache-2.0" repository = "https://github.com/apache/incubator-teaclave-trustzone-sdk.git" description = "Native bindings to the libutee library." edition = "2018" -links = "utee" - -[features] -default = ["std"] -std = [] +links = "utee" \ No newline at end of file diff --git a/optee-utee/optee-utee-sys/src/lib.rs b/optee-utee/optee-utee-sys/src/lib.rs index df98e946..20dab506 100644 --- a/optee-utee/optee-utee-sys/src/lib.rs +++ b/optee-utee/optee-utee-sys/src/lib.rs @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -#![cfg_attr(not(feature = "std"), no_std)] +#![cfg_attr(not(target_os = "optee"), no_std)] #![feature(c_size_t)] #![allow(non_camel_case_types, non_snake_case)] diff --git a/optee-utee/optee-utee-sys/src/tee_api.rs b/optee-utee/optee-utee-sys/src/tee_api.rs index 9db86ebc..0a408613 100644 --- a/optee-utee/optee-utee-sys/src/tee_api.rs +++ b/optee-utee/optee-utee-sys/src/tee_api.rs @@ -17,9 +17,9 @@ use super::*; -#[cfg(feature = "std")] -use std::os::raw::*; -#[cfg(not(feature = "std"))] +//#[cfg(target_os = "optee")] +//use libc::*; +//#[cfg(not(target_os = "optee"))] use core::ffi::*; extern "C" { diff --git a/optee-utee/optee-utee-sys/src/tee_api_types.rs b/optee-utee/optee-utee-sys/src/tee_api_types.rs index 755a173d..922d4007 100644 --- a/optee-utee/optee-utee-sys/src/tee_api_types.rs +++ b/optee-utee/optee-utee-sys/src/tee_api_types.rs @@ -17,9 +17,9 @@ // Common Definitions -#[cfg(feature = "std")] -use std::os::raw::*; -#[cfg(not(feature = "std"))] +//#[cfg(target_os = "optee")] +//use libc::*; +//#[cfg(not(target_os = "optee"))] use core::ffi::*; pub type TEE_Result = u32; diff --git a/optee-utee/optee-utee-sys/src/tee_internal_api_extensions.rs b/optee-utee/optee-utee-sys/src/tee_internal_api_extensions.rs index 017160d7..de77cf8b 100644 --- a/optee-utee/optee-utee-sys/src/tee_internal_api_extensions.rs +++ b/optee-utee/optee-utee-sys/src/tee_internal_api_extensions.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -#[cfg(feature = "std")] -use std::os::raw::*; -#[cfg(not(feature = "std"))] +//#[cfg(target_os = "optee")] +//use libc::*; +//#[cfg(not(target_os = "optee"))] use core::ffi::*; use super::*; diff --git a/optee-utee/optee-utee-sys/src/tee_isocket.rs b/optee-utee/optee-utee-sys/src/tee_isocket.rs index 672416ea..099df03a 100644 --- a/optee-utee/optee-utee-sys/src/tee_isocket.rs +++ b/optee-utee/optee-utee-sys/src/tee_isocket.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -#[cfg(feature = "std")] -use std::os::raw::*; -#[cfg(not(feature = "std"))] +//#[cfg(target_os = "optee")] +//use libc::*; +//#[cfg(not(target_os = "optee"))] use core::ffi::*; use super::*; diff --git a/optee-utee/optee-utee-sys/src/tee_tcpsocket.rs b/optee-utee/optee-utee-sys/src/tee_tcpsocket.rs index 583f3d38..80b6d649 100644 --- a/optee-utee/optee-utee-sys/src/tee_tcpsocket.rs +++ b/optee-utee/optee-utee-sys/src/tee_tcpsocket.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -#[cfg(feature = "std")] -use std::os::raw::*; -#[cfg(not(feature = "std"))] +//#[cfg(target_os = "optee")] +//use libc::*; +//#[cfg(not(target_os = "optee"))] use core::ffi::*; use super::*; diff --git a/optee-utee/optee-utee-sys/src/tee_udpsocket.rs b/optee-utee/optee-utee-sys/src/tee_udpsocket.rs index 1a6591f8..3be6add1 100644 --- a/optee-utee/optee-utee-sys/src/tee_udpsocket.rs +++ b/optee-utee/optee-utee-sys/src/tee_udpsocket.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -#[cfg(feature = "std")] -use std::os::raw::*; -#[cfg(not(feature = "std"))] +//#[cfg(target_os = "optee")] +//use libc::*; +//#[cfg(not(target_os = "optee"))] use core::ffi::*; use super::*; diff --git a/optee-utee/optee-utee-sys/src/trace.rs b/optee-utee/optee-utee-sys/src/trace.rs index 5293ff8c..45622765 100644 --- a/optee-utee/optee-utee-sys/src/trace.rs +++ b/optee-utee/optee-utee-sys/src/trace.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -#[cfg(feature = "std")] -use std::os::raw::*; -#[cfg(not(feature = "std"))] +//#[cfg(target_os = "optee")] +//use libc::*; +//#[cfg(not(target_os = "optee"))] use core::ffi::*; extern "C" { diff --git a/optee-utee/optee-utee-sys/src/user_ta_header.rs b/optee-utee/optee-utee-sys/src/user_ta_header.rs index 9868f06b..57ec6e84 100644 --- a/optee-utee/optee-utee-sys/src/user_ta_header.rs +++ b/optee-utee/optee-utee-sys/src/user_ta_header.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -#[cfg(feature = "std")] -use std::os::raw::*; -#[cfg(not(feature = "std"))] +//#[cfg(target_os = "optee")] +//use libc::*; +//#[cfg(not(target_os = "optee"))] use core::ffi::*; use super::tee_api_types::*; use super::utee_syscalls::*; diff --git a/optee-utee/optee-utee-sys/src/utee_syscalls.rs b/optee-utee/optee-utee-sys/src/utee_syscalls.rs index 5891c303..f574a743 100644 --- a/optee-utee/optee-utee-sys/src/utee_syscalls.rs +++ b/optee-utee/optee-utee-sys/src/utee_syscalls.rs @@ -16,9 +16,9 @@ // under the License. use super::*; -#[cfg(feature = "std")] -use std::os::raw::*; -#[cfg(not(feature = "std"))] +//#[cfg(target_os = "optee")] +//use libc::*; +//#[cfg(not(target_os = "optee"))] use core::ffi::*; extern "C" { diff --git a/optee-utee/src/arithmetical.rs b/optee-utee/src/arithmetical.rs index ecb3ade4..c558f9a2 100644 --- a/optee-utee/src/arithmetical.rs +++ b/optee-utee/src/arithmetical.rs @@ -18,7 +18,7 @@ use crate::{Error, Result}; use optee_utee_sys as raw; use core::{cmp::max, fmt}; -#[cfg(not(feature = "std"))] +#[cfg(not(target_os = "optee"))] use alloc::vec::Vec; pub type BigIntUnit = u32; diff --git a/optee-utee/src/crypto_op.rs b/optee-utee/src/crypto_op.rs index 1be073dd..9e0a4f52 100644 --- a/optee-utee/src/crypto_op.rs +++ b/optee-utee/src/crypto_op.rs @@ -18,9 +18,9 @@ use crate::{Attribute, Error, ObjHandle, Result, TransientObject}; use optee_utee_sys as raw; use core::{mem, ptr}; -#[cfg(not(feature = "std"))] +#[cfg(not(target_os = "optee"))] use alloc::boxed::Box; -#[cfg(not(feature = "std"))] +#[cfg(not(target_os = "optee"))] use alloc::vec::Vec; /// Specify one of the available cryptographic operations. diff --git a/optee-utee/src/error.rs b/optee-utee/src/error.rs index 0b929ed7..b71c4f5a 100644 --- a/optee-utee/src/error.rs +++ b/optee-utee/src/error.rs @@ -17,9 +17,9 @@ use optee_utee_sys as raw; use core::{fmt, result}; -#[cfg(feature = "std")] +#[cfg(target_os = "optee")] use std::error; -#[cfg(not(feature = "std"))] +#[cfg(not(target_os = "optee"))] use core::error; /// A specialized [`Result`](https://doc.rust-lang.org/std/result/enum.Result.html) diff --git a/optee-utee/src/extension.rs b/optee-utee/src/extension.rs index 0e005db2..fc92a7ba 100644 --- a/optee-utee/src/extension.rs +++ b/optee-utee/src/extension.rs @@ -17,9 +17,9 @@ use crate::{Error, Result, Uuid}; use optee_utee_sys as raw; -#[cfg(not(feature = "std"))] +#[cfg(not(target_os = "optee"))] use alloc::vec::Vec; -#[cfg(not(feature = "std"))] +#[cfg(not(target_os = "optee"))] use alloc::borrow::ToOwned; pub struct LoadablePlugin { diff --git a/optee-utee/src/lib.rs b/optee-utee/src/lib.rs index ebbaabad..b0c205e3 100644 --- a/optee-utee/src/lib.rs +++ b/optee-utee/src/lib.rs @@ -15,24 +15,26 @@ // specific language governing permissions and limitations // under the License. -#![cfg_attr(not(feature = "std"), no_std)] -#![cfg_attr(not(feature = "std"), feature(error_in_core))] +#![cfg_attr(not(target_os = "optee"), no_std)] +#![cfg_attr(not(target_os = "optee"), feature(error_in_core))] // Requires `alloc`. #[macro_use] extern crate alloc; +#[cfg(not(target_os = "optee"))] use libc_alloc::LibcAlloc; +#[cfg(not(target_os = "optee"))] #[global_allocator] static ALLOCATOR: LibcAlloc = LibcAlloc; -#[cfg(not(feature = "std"))] +#[cfg(not(target_os = "optee"))] use core::panic::PanicInfo; -#[cfg(not(feature = "std"))] +#[cfg(not(target_os = "optee"))] use optee_utee_sys as raw; -#[cfg(not(feature = "std"))] +#[cfg(not(target_os = "optee"))] #[panic_handler] fn panic(_info: &PanicInfo) -> ! { unsafe { raw::TEE_Panic(0); } @@ -63,5 +65,5 @@ pub mod arithmetical; pub mod extension; pub mod uuid; -#[cfg(feature = "std")] +#[cfg(target_os = "optee")] pub mod net; diff --git a/optee-utee/src/object.rs b/optee-utee/src/object.rs index bd1432e5..9fcdbe3d 100644 --- a/optee-utee/src/object.rs +++ b/optee-utee/src/object.rs @@ -19,9 +19,9 @@ use crate::{Error, Result}; use bitflags::bitflags; use optee_utee_sys as raw; use core::{marker, mem, ptr}; -#[cfg(not(feature = "std"))] +#[cfg(not(target_os = "optee"))] use alloc::boxed::Box; -#[cfg(not(feature = "std"))] +#[cfg(not(target_os = "optee"))] use alloc::vec::Vec; /// A general attribute (buffer or value) that can be used to populate an object or to specify diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 4663e2f5..f5affd4d 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -18,5 +18,8 @@ # Toolchain override for rustup [toolchain] -channel = "nightly-2023-12-18" +channel = "nightly-2024-05-15" +components = [ "rust-src" ] targets = ["aarch64-unknown-linux-gnu", "arm-unknown-linux-gnueabihf"] +# minimal profile: install rustc, cargo, and rust-std +profile = "minimal" \ No newline at end of file diff --git a/setup_std_dependencies.sh b/setup_std_dependencies.sh new file mode 100755 index 00000000..fc087662 --- /dev/null +++ b/setup_std_dependencies.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -xe + +########################################## +# move to project root +cd "$(dirname "$0")" + +########################################## +# install Xargo +cargo +stable install xargo + +########################################## +# initialize submodules: rust / libc +RUST_COMMIT_ID=7ee181c5199b0769414f0d0fd13f5e959ef84c27 +LIBC_COMMIT_ID=4fa30318ed3175f6ebe22da8f167f9f9b34567c3 + +if [ -d rust/ ] +then + rm -r rust/ +fi + +mkdir rust && cd rust + +git clone https://github.com/DemesneGH/rust.git && \ + (cd rust && \ + git checkout "$RUST_COMMIT_ID" && \ + git submodule update --init library/stdarch && \ + git submodule update --init library/backtrace) + +git clone https://github.com/DemesneGH/libc.git && \ + (cd libc && \ + git checkout "$LIBC_COMMIT_ID") + +echo "Rust submodules initialized" diff --git a/tests/test_acipher.sh b/tests/test_acipher.sh index c04fe16b..247abd70 100755 --- a/tests/test_acipher.sh +++ b/tests/test_acipher.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/acipher-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/acipher-rs/host/target/aarch64-unknown-linux-gnu/release/acipher-rs shared +cp ../examples/acipher-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/acipher-rs/host/target/$TARGET_HOST/release/acipher-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_aes.sh b/tests/test_aes.sh index d4233646..d50fc651 100755 --- a/tests/test_aes.sh +++ b/tests/test_aes.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/aes-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/aes-rs/host/target/aarch64-unknown-linux-gnu/release/aes-rs shared +cp ../examples/aes-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/aes-rs/host/target/$TARGET_HOST/release/aes-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_authentication.sh b/tests/test_authentication.sh index 33284a90..51ad0918 100755 --- a/tests/test_authentication.sh +++ b/tests/test_authentication.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/authentication-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/authentication-rs/host/target/aarch64-unknown-linux-gnu/release/authentication-rs shared +cp ../examples/authentication-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/authentication-rs/host/target/$TARGET_HOST/release/authentication-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_big_int.sh b/tests/test_big_int.sh index 8a1dc93c..33ffe0ae 100755 --- a/tests/test_big_int.sh +++ b/tests/test_big_int.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/big_int-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/big_int-rs/host/target/aarch64-unknown-linux-gnu/release/big_int-rs shared +cp ../examples/big_int-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/big_int-rs/host/target/$TARGET_HOST/release/big_int-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_diffie_hellman.sh b/tests/test_diffie_hellman.sh index 2a9d3bfd..4eae75cb 100755 --- a/tests/test_diffie_hellman.sh +++ b/tests/test_diffie_hellman.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/diffie_hellman-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/diffie_hellman-rs/host/target/aarch64-unknown-linux-gnu/release/diffie_hellman-rs shared +cp ../examples/diffie_hellman-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/diffie_hellman-rs/host/target/$TARGET_HOST/release/diffie_hellman-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_digest.sh b/tests/test_digest.sh index 21cd87d0..4b0e81c1 100755 --- a/tests/test_digest.sh +++ b/tests/test_digest.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/digest-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/digest-rs/host/target/aarch64-unknown-linux-gnu/release/digest-rs shared +cp ../examples/digest-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/digest-rs/host/target/$TARGET_HOST/release/digest-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_error_handling.sh b/tests/test_error_handling.sh index 8abdf923..82b83ce1 100755 --- a/tests/test_error_handling.sh +++ b/tests/test_error_handling.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/error_handling-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/error_handling-rs/host/target/aarch64-unknown-linux-gnu/release/error_handling-rs shared +cp ../examples/error_handling-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/error_handling-rs/host/target/$TARGET_HOST/release/error_handling-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_hello_world.sh b/tests/test_hello_world.sh index 05847a8a..88f7d673 100755 --- a/tests/test_hello_world.sh +++ b/tests/test_hello_world.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/hello_world-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/hello_world-rs/host/target/aarch64-unknown-linux-gnu/release/hello_world-rs shared +cp ../examples/hello_world-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/hello_world-rs/host/target/$TARGET_HOST/release/hello_world-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_hotp.sh b/tests/test_hotp.sh index b2d9a0ee..045695e0 100755 --- a/tests/test_hotp.sh +++ b/tests/test_hotp.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/hotp-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/hotp-rs/host/target/aarch64-unknown-linux-gnu/release/hotp-rs shared +cp ../examples/hotp-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/hotp-rs/host/target/$TARGET_HOST/release/hotp-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_random.sh b/tests/test_random.sh index a1e0fc05..dbc5b1da 100755 --- a/tests/test_random.sh +++ b/tests/test_random.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/random-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/random-rs/host/target/aarch64-unknown-linux-gnu/release/random-rs shared +cp ../examples/random-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/random-rs/host/target/$TARGET_HOST/release/random-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_secure_storage.sh b/tests/test_secure_storage.sh index 71d9b9c7..7bf827f3 100755 --- a/tests/test_secure_storage.sh +++ b/tests/test_secure_storage.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/secure_storage-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/secure_storage-rs/host/target/aarch64-unknown-linux-gnu/release/secure_storage-rs shared +cp ../examples/secure_storage-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/secure_storage-rs/host/target/$TARGET_HOST/release/secure_storage-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_signature_verification.sh b/tests/test_signature_verification.sh index 5a30535d..912b129f 100755 --- a/tests/test_signature_verification.sh +++ b/tests/test_signature_verification.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/signature_verification-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/signature_verification-rs/host/target/aarch64-unknown-linux-gnu/release/signature_verification-rs shared +cp ../examples/signature_verification-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/signature_verification-rs/host/target/$TARGET_HOST/release/signature_verification-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_supp_plugin.sh b/tests/test_supp_plugin.sh index 7806cf41..95294d85 100755 --- a/tests/test_supp_plugin.sh +++ b/tests/test_supp_plugin.sh @@ -23,9 +23,9 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/supp_plugin-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/supp_plugin-rs/host/target/aarch64-unknown-linux-gnu/release/supp_plugin-rs shared -cp ../examples/supp_plugin-rs/plugin/target/aarch64-unknown-linux-gnu/release/*.plugin.so shared +cp ../examples/supp_plugin-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/supp_plugin-rs/host/target/$TARGET_HOST/release/supp_plugin-rs shared +cp ../examples/supp_plugin-rs/plugin/target/$TARGET_HOST/release/*.plugin.so shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n" diff --git a/tests/test_time.sh b/tests/test_time.sh index 4184bb84..2b8fd4f9 100755 --- a/tests/test_time.sh +++ b/tests/test_time.sh @@ -23,8 +23,8 @@ set -xe source setup.sh # Copy TA and host binary -cp ../examples/time-rs/ta/target/aarch64-unknown-linux-gnu/release/*.ta shared -cp ../examples/time-rs/host/target/aarch64-unknown-linux-gnu/release/time-rs shared +cp ../examples/time-rs/ta/target/$TARGET_TA/release/*.ta shared +cp ../examples/time-rs/host/target/$TARGET_HOST/release/time-rs shared # Run script specific commands in QEMU run_in_qemu "cp *.ta /lib/optee_armtz/\n"