Skip to content

Commit 8cbcbec

Browse files
committed
Initial commit
Signed-off-by: Jukka Julku <[email protected]>
0 parents  commit 8cbcbec

Some content is hidden

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

51 files changed

+5437
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/target
2+
Cargo.lock
3+
*~

Cargo.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
cargo-features = ["per-package-target"]
2+
3+
[workspace]
4+
members = [
5+
"libedge",
6+
"libeapp",
7+
"libhapp",
8+
]
9+
10+
[workspace.package]
11+
version = "0.2.0"
12+
edition = "2021"
13+
authors = ["Jukka Julku <[email protected]>",
14+
"Markku Kylänpää <[email protected]>"]
15+
repository = "https://github.com/vector-sdk/rust-sdk"
16+
readme = "README.md"
17+
license = "MIT"
18+
description = "Rust SDK for Keystone Enclaves"
19+
20+
[profile.dev]
21+
opt-level = 1
22+
debug = false
23+
24+
[profile.release]
25+
opt-level = 1
26+
debug = false

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 VTT Technical Research Centre of Finland Ltd.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# List of subdirectories. Not used for build, but cleanup!
2+
SUBDIRS := .cargo \
3+
libedge \
4+
libedge/src \
5+
libeapp \
6+
libeapp/.cargo \
7+
libeapp/macros \
8+
libeapp/macros/src \
9+
libeapp/src \
10+
libeapp/src/internal \
11+
libhapp \
12+
libhapp/.cargo \
13+
libhapp/src \
14+
libhapp/src/internal \
15+
16+
# Target architecture for the host application libraries
17+
TARGET_ARCH := riscv64gc-unknown-linux-gnu
18+
x86_64: TARGET_ARCH := x86_64-unknown-linux-gnu
19+
20+
# Common build options. Always build for release to minimize binary size!
21+
CARGO_FLAGS := -v --release
22+
CARGO_DEBUG_FLAGS := --features debug_memory
23+
24+
dir2tgt = $(patsubst %, ./%/$(strip $(2)),$(strip $(1)))
25+
26+
all: riscv64
27+
28+
riscv64:
29+
cargo build --target $(TARGET_ARCH) $(CARGO_FLAGS)
30+
31+
# This target builds the host application libraries for x86_64 architecture.
32+
# Enclave application libraries will still be built for the RISC-V target.
33+
x86_64:
34+
cargo build --target $(TARGET_ARCH) $(CARGO_FLAGS)
35+
36+
# Build with SDK's internal enclave memory debugging support
37+
debug:
38+
cargo build --target $(TARGET_ARCH) $(CARGO_DEBUG_FLAGS) $(CARGO_FLAGS)
39+
40+
# Clean build and temporary files:
41+
clean:
42+
cargo clean
43+
rm -f *~ $(call dir2tgt, $(strip $(SUBDIRS)), *~)

README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# A Rust SDK for building Keystone enclave applications
2+
3+
This project aims to provide a Rust programming language SDK for building
4+
[Keystone](https://keystone-enclave.org/) enclave and host applications for the
5+
RISC-V architecture.
6+
7+
The SDK is designed to be compatible with the
8+
[Keystone Eyrie Modular Runtime](https://github.com/keystone-enclave/keystone-runtime).
9+
10+
**NOTE**: This work is experimental and on a very early stage. The security of
11+
the API or its implementation has not been properly verified yet.
12+
Therefore, **Do not use in production!**
13+
14+
# Prequisites
15+
16+
### Bulding Keystone
17+
18+
Download and build [Keystone](https://github.com/keystone-enclave/keystone) for QEMU
19+
environment using [instructions](http://docs.keystone-enclave.org/en/latest/Getting-Started/Install-Dependencies.html)
20+
given in [Keystone documentation](http://docs.keystone-enclave.org).
21+
22+
**NOTE:** The code in this repository has only been tested using QEMU!
23+
24+
### Install Rust
25+
26+
This project uses experimental Rust features currently only available in Rust's
27+
nightly build.
28+
29+
Use [rustup](https://www.rust-lang.org/tools/install) to install the Rust
30+
environment and add required RISC-V targets:
31+
32+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
33+
rustup default nightly
34+
rustup target add riscv64gc-unknown-none-elf
35+
rustup target add riscv64gc-unknown-linux-gnu
36+
37+
# Build SDK crates
38+
39+
cargo build --release
40+
41+
# Test
42+
43+
Test with Rust SDK [demo application](https://github.com/vector-sdk/rust-sdk-demo)!

libeapp/.cargo/config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[build]
2+
target = "riscv64gc-unknown-none-elf"

libeapp/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/target
2+
Cargo.lock
3+
*~

libeapp/Cargo.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
cargo-features = ["per-package-target"]
2+
3+
[package]
4+
name = "eapp"
5+
version.workspace = true
6+
edition.workspace = true
7+
authors.workspace = true
8+
repository.workspace = true
9+
readme.workspace = true
10+
license.workspace = true
11+
description = """
12+
A library for enclave application development
13+
"""
14+
forced-target = "riscv64gc-unknown-none-elf"
15+
16+
[dependencies]
17+
buddy_system_allocator = "0.8"
18+
spin = {version = "0.9.3" }
19+
20+
[dependencies.eapp-macros]
21+
path = "./macros"
22+
23+
[dependencies.edge]
24+
path = "../libedge"
25+
26+
[features]
27+
default = ["heap", "heap_rt"]
28+
heap = [] # Application has heap available
29+
heap_rt = ["heap"] # Runtime has heap available
30+
debug_memory = ["heap", "edge/debug_memory"]

libeapp/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# libeapp
2+
3+
A Rust library for building enclave applications

libeapp/build.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//! Build options
2+
//
3+
// SPDX-License-Identifier: MIT
4+
// Copyright (C) 2022 VTT Technical Research Centre of Finland Ltd
5+
6+
fn main() {
7+
// Always link statically as no libraries are available in the enclave
8+
println!("cargo:rustc-link-arg=-static");
9+
// No standard libraries available in the enclave
10+
println!("cargo:rustc-link-arg=-nostdlib");
11+
}

0 commit comments

Comments
 (0)