Skip to content

Commit 60671e7

Browse files
committed
add implementations
Signed-off-by: Jun Kimura <junkxdev@gmail.com>
1 parent c68a56e commit 60671e7

File tree

142 files changed

+3783
-8005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+3783
-8005
lines changed

.github/scripts/install_sgx_sdk.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
set -eox pipefail
3+
4+
if [ $# -eq 0 ]; then
5+
echo "No arguments supplied"
6+
exit 1
7+
fi
8+
SDK_DIR_PREFIX=$1
9+
10+
DCAP_VERSION=1.23.100.0-jammy1
11+
# create tmp dir
12+
TMP_DIR=$(mktemp -d)
13+
echo "Created temp dir: $TMP_DIR"
14+
cd $TMP_DIR
15+
16+
wget https://download.01.org/intel-sgx/sgx-dcap/1.21/linux/distro/ubuntu22.04-server/sgx_linux_x64_sdk_2.24.100.3.bin -O sgx_linux_x64_sdk.bin
17+
chmod a+x sgx_linux_x64_sdk.bin
18+
./sgx_linux_x64_sdk.bin --prefix=$SDK_DIR_PREFIX
19+
rm -rf ./sgx_linux_x64_sdk.bin
20+
21+
wget https://download.01.org/intel-sgx/sgx_repo/ubuntu/intel-sgx-deb.key
22+
cat intel-sgx-deb.key | tee /etc/apt/keyrings/intel-sgx-keyring.asc > /dev/null
23+
echo 'deb [signed-by=/etc/apt/keyrings/intel-sgx-keyring.asc arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu jammy main' | tee /etc/apt/sources.list.d/intel-sgx.list
24+
25+
apt-get update -y
26+
apt-get install -y libsgx-dcap-ql=$DCAP_VERSION libsgx-dcap-ql-dev=$DCAP_VERSION

.github/workflows/test.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-22.04
12+
env:
13+
SGX_MODE: SW
14+
steps:
15+
- uses: actions/checkout@v4
16+
- uses: actions-rust-lang/setup-rust-toolchain@v1
17+
with:
18+
toolchain: nightly-2025-05-10
19+
components: rust-src, rustfmt, clippy
20+
- run: cargo install taplo-cli --version 0.10.0
21+
- run: cargo install --path ./cargo-sgx
22+
- run: sudo bash .github/scripts/install_sgx_sdk.sh /opt/intel
23+
- run: source /opt/intel/sgxsdk/environment && make test
24+
- name: Test cargo sgx init
25+
run: |
26+
source /opt/intel/sgxsdk/environment
27+
# Create a test directory
28+
mkdir -p test-init-project
29+
cd test-init-project
30+
# Initialize a new enclave project
31+
cargo sgx init --path test-enclave --sgx-sdk-path ..
32+
# Build the generated project
33+
cd test-enclave
34+
cargo sgx build --release
35+
# Clean up
36+
cd ../..
37+
rm -rf test-init-project
38+
- name: Lint
39+
run: make check
40+
- name: Check TOML formatting
41+
run: make toml-check

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
target/
2-
Cargo.lock
2+
Cargo.lock

Makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.PHONY: fmt
2+
fmt:
3+
@find . -name Cargo.toml -not -path "./target/*" -exec dirname {} \; | while read dir; do \
4+
echo "Formatting $$dir..."; \
5+
(cd "$$dir" && cargo fmt) || exit 1; \
6+
done
7+
8+
.PHONY: fmt-check
9+
fmt-check:
10+
@find . -name Cargo.toml -not -path "./target/*" -exec dirname {} \; | while read dir; do \
11+
echo "Checking $$dir..."; \
12+
(cd "$$dir" && cargo fmt -- --check) || exit 1; \
13+
done
14+
15+
.PHONY: clippy
16+
clippy:
17+
@find . -name Cargo.toml -not -path "./target/*" -exec dirname {} \; | while read dir; do \
18+
echo "Running clippy on $$dir..."; \
19+
if echo "$$dir" | grep -E -q "(enclave$$|sgx-ert)"; then \
20+
echo "Skipping $$dir"; \
21+
else \
22+
(cd "$$dir" && cargo clippy --all-targets --all-features -- -D warnings) || exit 1; \
23+
fi; \
24+
done
25+
26+
.PHONY: check
27+
check: fmt clippy
28+
29+
.PHONY: test
30+
test:
31+
@echo "Building and running unit tests..."
32+
@cd unit-test && make clean all
33+
@cd unit-test/bin && ./app
34+
35+
.PHONY: toml-fmt
36+
toml-fmt:
37+
@echo "Formatting TOML files..."
38+
@taplo fmt --config ./taplo.toml ./**/Cargo.toml
39+
40+
.PHONY: toml-check
41+
toml-check:
42+
@echo "Verifying TOML syntax..."
43+
@taplo check --config ./taplo.toml ./**/Cargo.toml

README.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,59 @@
11
# sgx-sdk-rs
22

3-
This is a fork of the [teaclave-sgx-sdk](https://github.com/apache/incubator-teaclave-sgx-sdk) project.
3+
Rust SDK for [Intel SGX (Software Guard Extensions)](https://github.com/intel/linux-sgx) - A collection of tools and libraries for building secure enclaves in Rust.
4+
5+
## Features
6+
7+
- **Rust SGX Libraries**: Core libraries for developing SGX enclaves
8+
- **cargo-sgx**: A Cargo subcommand that streamlines SGX enclave development by providing:
9+
- Project initialization with templates (`cargo sgx init`)
10+
- Automated enclave building command (`cargo sgx build`)
11+
- Seamless integration with the Rust toolchain using custom target `x86_64-unknown-unknown-sgx`
12+
13+
## Getting Started
14+
15+
### Install cargo-sgx
16+
17+
```bash
18+
cargo install --git https://github.com/datachainlab/sgx-sdk-rs --branch main cargo-sgx
19+
```
20+
21+
Or install from local directory:
22+
23+
```bash
24+
cargo install --path ./cargo-sgx
25+
```
26+
27+
### Create Your First Enclave
28+
29+
```bash
30+
cargo sgx init
31+
cd enclave
32+
cargo sgx build
33+
```
34+
35+
## Project Structure
36+
37+
- `sgx-*` - Core SGX libraries (types, ert, trts, tseal, urts, etc.)
38+
- [`cargo-sgx/`](cargo-sgx/) - Cargo subcommand for SGX development
39+
- [`sgx-build/`](sgx-build/) - Build utilities for SGX enclaves
40+
- [`unit-test/`](unit-test/) - Unit tests for core SGX libraries
41+
- [`samples/hello-rust/`](samples/hello-rust/) - Basic SGX enclave example
42+
43+
## Documentation
44+
45+
- [cargo-sgx README](cargo-sgx/README.md) - Learn about the cargo-sgx tool
46+
- [sgx-build README](sgx-build/README.md) - Learn about the sgx-build crate
47+
48+
## Requirements
49+
50+
- Rust nightly toolchain
51+
- Intel SGX SDK
52+
- Intel SGX Driver(only for Hardware Mode)
53+
54+
## Acknowledgements
55+
56+
This project is based on the excellent work done by the [Apache Teaclave SGX SDK](https://github.com/apache/incubator-teaclave-sgx-sdk/tree/1b1d03376056321441ef99716aa0888bd5ef19f7) project. We are grateful for their foundational contributions to the Rust SGX ecosystem.
457

558
## License
659

buildenv.mk

Lines changed: 0 additions & 208 deletions
This file was deleted.

0 commit comments

Comments
 (0)