Skip to content
This repository has been archived by the owner on May 9, 2022. It is now read-only.

Add local attestation support #60

Merged
merged 31 commits into from
May 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
abe0267
feat(attestation): add functions for local dh
longtomjr May 14, 2021
1b8df41
feat: rework local attest state and add basic crypto funcs
longtomjr May 14, 2021
8274833
feat(dh): add session closing
longtomjr May 15, 2021
ae93ab6
feat(dh): update comments and invariant checking
longtomjr May 15, 2021
1d87d93
feat(dh): return channel from channel creation functions
longtomjr May 15, 2021
ff2c32b
feat(dh): add function to be used for verifying trust
longtomjr May 15, 2021
a3ad1ed
feat(dh): add ecalls and ocall handlers
longtomjr May 15, 2021
7555bb8
feat(dh): update data and auth enclave codegen
longtomjr May 15, 2021
7854508
feat(dh): update codegen to const pointer for msg2
longtomjr May 17, 2021
75be1fa
feat(dh): add sys bindings and lib for app side dh attestation
longtomjr May 17, 2021
322793f
refactor(dh): prefix enclave functions from edl
longtomjr May 17, 2021
18af0c9
feat(dh): add to uenclave and basic integration test
longtomjr May 18, 2021
ea71a55
cleanup(dh): remove debug printlines
longtomjr May 18, 2021
3074594
feat(dh): fix uenclave tests
longtomjr May 18, 2021
acf43b9
test(dh): fix tenclave unit tests by ignoring the dh mod
longtomjr May 18, 2021
f83f666
feat(dh): support testing and cleanup module structure
longtomjr May 18, 2021
d23df5c
deps(rtc_tenclave): specify sgx_1.1.3 tag for once_cell-sgx
PiDelport May 27, 2021
1a90824
docs(HACKING): add section: Aligned memory allocation for secret values
PiDelport May 28, 2021
d6619da
docs(auth-sys,data-sys): remove resolved TODO
PiDelport May 28, 2021
6e0f8be
refactor(rtc_udh): get_responder: take enclave id by value, not refer…
PiDelport May 28, 2021
0d2bfde
test(rtc_tenclave): use sgx_enclave_id_t return type for stub
PiDelport May 28, 2021
d62f352
refactor(rtc_udh): use "enclave_id: sgx_enclave_id_t" parameter conve…
PiDelport May 28, 2021
8b3d486
refactor(rtc_tenclave,dh): use sgx_enclave_id_t type for DhResponders…
PiDelport May 28, 2021
9c2d49b
refactor(rtc_tenclave,dh): use "enclave_id: sgx_enclave_id_t" paramet…
PiDelport May 28, 2021
d050e11
refactor(rtc_tenclave,dh): default to passing sgx_enclave_id_t by value
PiDelport May 28, 2021
9cefdbb
chore(rtc_udh): remove stray test code
PiDelport May 28, 2021
8de36cf
chore(rtc_tenclave): remove commented code
PiDelport May 28, 2021
b348f81
chore(rtc_tenclave,dh): remove commented code
PiDelport May 28, 2021
035359d
docs: add & update rustdoc comments
PiDelport May 28, 2021
5b6f3d5
build(rtc_auth_enclave,rtc_data_enclave): factor out ENCLAVE_NAME
PiDelport May 28, 2021
2741ebe
refactor(rtc_tenclave,protected_channel): factor out DeterministicAes…
PiDelport May 28, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ members = [
"rtc_uenclave/data-sys",
"rtc_uenclave/auth-sys",
"rtc_uenclave/rtc-ecalls",
"rtc_udh",
]
# TODO: Look at creating a seperate workspace for enclave code to share lockfile?
exclude = [
Expand Down
30 changes: 30 additions & 0 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,33 @@ However, also note that Cargo currently has this limitation:

This prevents patching a repository reference to a different revision in the same repository,
which makes some SGX-patched packages (such as `serde-sgx` and `serde-json-sgx`) tricky to deal with.


## Aligned memory allocation for secret values

In enclave code, all memory allocations for sensitive secret values (such as cryptographic keys)
must be padded and aligned to protect against certain cache timing side-channel attacks,
as detailed in the Intel's INTEL-SA-00219 Developer Guidance.

The Rust SGX SDK [provides primitives] (`AlignBox` and `sgx_align_*`) to help implement this guidance,
but other enclave secrets must also be allocated similarly.

[provides primitives]: https://github.com/apache/incubator-teaclave-sgx-sdk/wiki/Mitigation-of-Intel-SA-00219-in-Rust-SGX#rust-sgx-provided-primitive

In particular, care must be taken to allocate aligned memory _before_ initialising secrets in it,
rather than initialising secrets in unaligned memory and then moving them to aligned memory.

In this codebase, also see the `AlignedKey` type in the `rtc_tenclave::dh::types` module.

Background:

* [CVE-2019-0117](http://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-0117)
* [Intel SGX SDK Developer Guidance INTEL-SA-00219](https://software.intel.com/content/www/us/en/develop/download/intel-sgx-sdk-developer-guidance-intel-sa-00219.html)
([PDF](https://software.intel.com/content/dam/develop/public/us/en/documents/intel-sgx-sdk-developer-guidance-intel-sa-00219.pdf))


Rust SGX SDK:

* [v1.1.0 release notes](https://github.com/apache/incubator-teaclave-sgx-sdk/blob/v1.1.0/release_notes.md#rust-sgx-sdk-v110)
* [Mitigation of Intel SA 00219 in Rust SGX](https://github.com/apache/incubator-teaclave-sgx-sdk/wiki/Mitigation-of-Intel-SA-00219-in-Rust-SGX)

3 changes: 3 additions & 0 deletions buildenv.mk
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,7 @@ ENCLAVE_LDFLAGS = $(COMMON_LDFLAGS) -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefi
ENCLAVE_CFLAGS += $(MITIGATION_CFLAGS)
ENCLAVE_ASFLAGS = $(MITIGATION_ASFLAGS)

# RTC SPECIFIC
RTC_EDL_PATH = /root/rtc-data/edl
longtomjr marked this conversation as resolved.
Show resolved Hide resolved


44 changes: 44 additions & 0 deletions codegen/auth_enclave/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,50 @@
*/
#define DATA_UPLOAD_RESPONSE_LEN (16 + (24 + 16))

/**
* FFI safe result type that can be converted to and from a rust result.
*/
typedef enum EcallResult_sgx_dh_msg1_t__sgx_status_t_Tag {
Ok_sgx_dh_msg1_t__sgx_status_t,
Err_sgx_dh_msg1_t__sgx_status_t,
} EcallResult_sgx_dh_msg1_t__sgx_status_t_Tag;

typedef struct EcallResult_sgx_dh_msg1_t__sgx_status_t {
EcallResult_sgx_dh_msg1_t__sgx_status_t_Tag tag;
union {
struct {
sgx_dh_msg1_t ok;
};
struct {
sgx_status_t err;
};
};
} EcallResult_sgx_dh_msg1_t__sgx_status_t;

typedef struct EcallResult_sgx_dh_msg1_t__sgx_status_t SessionRequestResult;

/**
* FFI safe result type that can be converted to and from a rust result.
*/
typedef enum EcallResult_sgx_dh_msg3_t__sgx_status_t_Tag {
Ok_sgx_dh_msg3_t__sgx_status_t,
Err_sgx_dh_msg3_t__sgx_status_t,
} EcallResult_sgx_dh_msg3_t__sgx_status_t_Tag;

typedef struct EcallResult_sgx_dh_msg3_t__sgx_status_t {
EcallResult_sgx_dh_msg3_t__sgx_status_t_Tag tag;
union {
struct {
sgx_dh_msg3_t ok;
};
struct {
sgx_status_t err;
};
};
} EcallResult_sgx_dh_msg3_t__sgx_status_t;

typedef struct EcallResult_sgx_dh_msg3_t__sgx_status_t ExchangeReportResult;

typedef enum CreateReportResult_Tag {
Success,
Sgx,
Expand Down
Loading