Skip to content

Commit 736d892

Browse files
Merge #381
381: [PLAT-66] Nitro nsm r=Pagten a=raoulstrackx The AWS `nsm-driver` and `nsm-io` crates provide an interface to the AWS Nitro Security Module (NSM), but this is not Rust friendly. This new `nsm` crate avoids having the same conversion everywhere. Co-authored-by: Raoul Strackx <[email protected]>
2 parents 3c3158a + 9eda567 commit 736d892

File tree

14 files changed

+434
-29
lines changed

14 files changed

+434
-29
lines changed

Cargo.lock

Lines changed: 60 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@ members = [
44
"fortanix-vme/eif-tools",
55
"fortanix-vme/fortanix-vme-abi",
66
"fortanix-vme/fortanix-vme-runner",
7+
"fortanix-vme/nsm",
78
"fortanix-vme/nitro-attestation-verify",
89
"fortanix-vme/tests/hello_world",
910
"fortanix-vme/tests/outgoing_connection",
1011
"fortanix-vme/tests/incoming_connection",
1112
"fortanix-vme/tests/iron",
13+
"fortanix-vme/tests/nsm-test",
1214
"intel-sgx/aesm-client",
1315
"intel-sgx/dcap-provider",
1416
"intel-sgx/dcap-ql-sys",
@@ -34,6 +36,7 @@ exclude = ["examples"]
3436
[patch.crates-io]
3537
libc = { git = "https://github.com/fortanix/libc.git", branch = "fortanixvme" }
3638
mbedtls = { git = "https://github.com/fortanix/rust-mbedtls", branch = "master" }
39+
nix = { git = "https://github.com/fortanix/nix.git", branch = "raoul/fortanixvme_r0.20.2" }
3740
serde = { git = "https://github.com/fortanix/serde.git", branch = "master" }
3841
vsock = { git = "https://github.com/fortanix/vsock-rs.git", branch = "fortanixvme" }
3942
rustc-serialize = { git = "https://github.com/jethrogb/rustc-serialize.git", branch = "portability" }

doc/generate-api-docs.sh

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ LIBS_SORTED=$(
5050
)
5151

5252
for LIB in $LIBS_SORTED; do
53+
echo ${LIB}
5354
LIB_DIR=$(find . -maxdepth 2 -name ${LIB} -type d)
54-
cd ${LIB_DIR}
55-
ARGS=""
56-
if FEATURES="$(cargo read-manifest|jq -r '.metadata.docs.rs.features | join(",")' 2> /dev/null)"; then
57-
ARGS="--features $FEATURES"
55+
if [[ -d "${LIB_DIR}" ]]; then
56+
pushd ${LIB_DIR}
57+
ARGS=""
58+
if FEATURES="$(cargo read-manifest|jq -r '.metadata.docs.rs.features | join(",")' 2> /dev/null)"; then
59+
ARGS="--features $FEATURES"
60+
fi
61+
cargo doc --no-deps --lib $ARGS
62+
popd
5863
fi
59-
cargo doc --no-deps --lib $ARGS
60-
cd -
6164
done

fortanix-vme/ci-common.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,20 @@ function cargo_test {
108108
scp ./test_interaction.sh ubuntu@${AWS_VM}:/home/ubuntu/ci-fortanixvme/${name}/
109109
fi
110110
fi
111-
RUST_BACKTRACE=full ${elf} -- --nocapture > ${out} 2> ${err}
111+
if [ ! -f ./skip_on_dev_platform ]; then
112+
RUST_BACKTRACE=full ${elf} -- --nocapture > ${out} 2> ${err}
112113

113-
out=$(cat ${out} | grep -v "^#" || true)
114-
expected=$(cat ./out.expected)
114+
out=$(cat ${out} | grep -v "^#" || true)
115+
expected=$(cat ./out.expected)
115116

116-
if [ "${out}" == "${expected}" ]; then
117-
echo "Test ${name}: Success"
118-
else
119-
echo "Test ${name}: Failed"
120-
echo "Got: ${out}"
121-
echo "Expected: ${expected}"
122-
exit -1
117+
if [ "${out}" == "${expected}" ]; then
118+
echo "Test ${name}: Success"
119+
else
120+
echo "Test ${name}: Failed"
121+
echo "Got: ${out}"
122+
echo "Expected: ${expected}"
123+
exit -1
124+
fi
123125
fi
124126
fi
125127

fortanix-vme/ci-fortanixvme.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ run_tests\
7070
hello_world \
7171
outgoing_connection \
7272
incoming_connection \
73-
iron
73+
iron \
74+
nsm-test
7475

7576
echo "********************************"
7677
echo "** All tests succeeded! **"

fortanix-vme/nitro-attestation-verify/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ serde_cbor = "0.11"
1010
# Required until PR36 is accepted
1111
# https://github.com/awslabs/aws-nitro-enclaves-cose/pull/36
1212
aws-nitro-enclaves-cose = { version = "0.5.0", git = "https://github.com/fortanix/aws-nitro-enclaves-cose.git", branch = "raoul/crypto_abstraction_pinned", default-features = false }
13-
mbedtls = { version = "0.8.2", features = ["rdrand", "std", "dsa", "time"], default-features = false, optional = true }
13+
mbedtls = { version = "0.8.2", features = ["rdrand", "std", "time"], default-features = false, optional = true }
1414
num-bigint = "0.4"
1515
serde = { version = "1.0", features = ["derive"] }
1616
serde_bytes = "0.11"

fortanix-vme/nitro-attestation-verify/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use ::mbedtls::{alloc::List as MbedtlsList, x509::{Certificate, VerifyError}};
2222
mod mbedtls;
2323

2424
#[cfg(feature = "mbedtls")]
25-
use crate::mbedtls::Mbedtls;
25+
pub use crate::mbedtls::Mbedtls;
2626

2727
pub trait VerificationType {}
2828

fortanix-vme/nitro-attestation-verify/src/mbedtls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use num_bigint::BigUint;
1313
use std::sync::Mutex;
1414
use std::ops::Deref;
1515

16-
pub(crate) struct Mbedtls;
16+
pub struct Mbedtls;
1717

1818
struct MdType(hash::Type);
1919

fortanix-vme/nsm/Cargo.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "nsm"
3+
version = "0.1.0"
4+
authors = ["Raoul Strackx <[email protected]>"]
5+
edition = "2021"
6+
7+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
8+
9+
[dependencies]
10+
nitro-attestation-verify = { path = "../nitro-attestation-verify" }
11+
nsm-driver = { git = "https://github.com/aws/aws-nitro-enclaves-nsm-api" }
12+
nsm-io = { git = "https://github.com/aws/aws-nitro-enclaves-nsm-api" }
13+
serde_bytes = "0.11"

0 commit comments

Comments
 (0)