Files
ssw 60b6fa6f7b vault: 设备绑定密钥 + 密封存储(宿主 16 用例 / QEMU VAULT_ALL_OK / 签名验收通过)
- src/vault-core: no_std 密码学核心(HKDF 派生、AES-256-GCM、两条水位线防回滚)
- src/ta-vault / src/ca-vault: TA 薄壳与 selftest 客户端
- build/p1_vault_qemu.sh: QEMU 全链,判据 VAULT_ALL_OK
- build/p2_ta_keys_qemu.sh: TA 公钥编进 tee.bin,默认密钥签的被拒
- build/gen_ta_keys.sh: 自建签名密钥
- docs/07-VAULT-TA.md: 设计 + 已验证/未验证清单
- CLAUDE.md 雷区 11-16:user_ta_header、嵌套 workspace、ARCH=arm、SIGPIPE、TA_PUBLIC_KEY、heredoc 变量
2026-10-28 14:37:04 +08:00

69 lines
3.0 KiB
Bash
Executable File

#!/bin/bash
# 沙箱内第三段:Rust TA + CA 编译与签名
set -x
export PATH=/opt/cargo/bin:$PATH
export RUSTUP_HOME=/opt/rustup
export CARGO_HOME=/opt/cargo
export RUSTUP_TOOLCHAIN=nightly-2026-08-05
export CARGO_NET_GIT_FETCH_WITH_CLI=true
export CARGO_TARGET_ARM_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc
export CC_arm_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc
UUID=0f9c2b1a-7c1e-4d7e-9a4b-3f5c8d2e6a10
mkdir -p /root/out /root/src-rust
tar xf /root/rustsrc.tar.gz -C /root/src-rust
DK=$(find /root/optee_os -maxdepth 4 -type d -name export-ta_arm32 2>/dev/null | head -1)
echo "TA_DEV_KIT_DIR=$DK"
[ -z "$DK" ] && { echo "NO_DEV_KIT"; exit 1; }
export TA_DEV_KIT_DIR="$DK"
rm -rf /root/teaclave-sdk/examples/ta/hello_rust-rs /root/teaclave-sdk/examples/ca/hello_rust-rs
cp -a /root/src-rust/ta /root/teaclave-sdk/examples/ta/hello_rust-rs
cp -a /root/src-rust/ca /root/teaclave-sdk/examples/ca/hello_rust-rs
cd /root/teaclave-sdk/examples/ta || exit 1
grep -q 'hello_rust-rs' Cargo.toml || sed -i 's/ "hello_world-rs",/ "hello_world-rs",\n "hello_rust-rs",/' Cargo.toml
printf '{\n__elf_phdr_info;\ntrace_ext_prefix;\ntrace_level;\nta_head;\n};\n' > dyn_list
echo "=== build TA ==="
cargo build -p hello_rust-rs-ta --target arm-unknown-linux-gnueabihf --release
echo "TA_BUILD_RC=$?"
TAELF=/root/teaclave-sdk/examples/ta/target/arm-unknown-linux-gnueabihf/release/hello_rust-rs-ta
file "$TAELF"
if [ -f "$TAELF" ]; then
python3 "$DK/scripts/sign_encrypt.py" sign-enc --uuid "$UUID" \
--in "$TAELF" --out /root/out/hello_rust.ta --key "$DK/keys/default_ta.pem"
echo "SIGN_RC=$?"
python3 "$DK/scripts/sign_encrypt.py" verify --uuid "$UUID" \
--in /root/out/hello_rust.ta --key "$DK/keys/default_ta.pem"
echo "VERIFY_RC=$?"
ls -la /root/out/hello_rust.ta
fi
echo "=== build optee_client (libteec + tee-supplicant) ==="
cd /root/optee_client || exit 1
make -j"$(nproc)" CROSS_COMPILE=arm-linux-gnueabihf-
echo "CLIENT_RC=$?"
make -C tee-supplicant -j"$(nproc)" \
CC=arm-linux-gnueabihf-gcc LD=arm-linux-gnueabihf-gcc \
CROSS_COMPILE=arm-linux-gnueabihf- \
LDFLAGS="-L/root/optee_client/out/libteec"
echo "SUPPLICANT_RC=$?"
file out/libteec/libteec.so* out/tee-supplicant/tee-supplicant 2>/dev/null
echo "=== build CA ==="
mkdir -p /root/optee_client/out/export/usr/lib /root/optee_client/out/export/usr/include
cp -a /root/optee_client/out/libteec/. /root/optee_client/out/export/usr/lib/ 2>/dev/null
cp -a /root/optee_client/libteec/include/*.h /root/optee_client/out/export/usr/include/ 2>/dev/null
export OPTEE_CLIENT_EXPORT=/root/optee_client/out/export
cd /root/teaclave-sdk/examples/ca || exit 1
grep -q 'hello_rust-rs' Cargo.toml || sed -i 's/ "hello_world-rs",/ "hello_world-rs",\n "hello_rust-rs",/' Cargo.toml
cargo build -p hello_rust-rs --target arm-unknown-linux-gnueabihf --release
echo "CA_BUILD_RC=$?"
CA=/root/teaclave-sdk/examples/ca/target/arm-unknown-linux-gnueabihf/release/hello_rust-rs
file "$CA" 2>/dev/null && cp -f "$CA" /root/out/hello_ca
ls -la /root/out
echo "=== STAGE3_DONE ==="