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

Commit 3f9331b

Browse files
authored
Merge pull request #99 from registreerocks/he-issue-exec-token
Add implementation for execution token issuance
2 parents 2e14843 + bd03587 commit 3f9331b

File tree

26 files changed

+1770
-123
lines changed

26 files changed

+1770
-123
lines changed

HACKING.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,37 @@ so these references must be patched like this:
2323
sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk.git", rev = "b9d1bda" }
2424
```
2525

26-
However, also note that Cargo currently has this limitation:
26+
### Cargo patch limitation workaround
27+
28+
Ideally, we want to explicitly specify the tag or revision of the SGX-forked packages we use,
29+
like this:
30+
31+
```toml
32+
serde = { git = "https://github.com/mesalock-linux/serde-sgx", tag = "sgx_1.1.3" }
33+
```
34+
35+
However, this fails for packages that are also listed as dependencies of other SGX-forked packages
36+
_without_ the explicit tag: Cargo will resolve these as different crates, which causes problems
37+
(such as different crates referring to different versions of `serde`'s traits).
38+
39+
We cannot use `[patch]` to override these dependencies to use the same specifiers,
40+
because of this Cargo limitation:
2741

2842
* [Cannot patch underspecified git dependency #7670](https://github.com/rust-lang/cargo/issues/7670)
43+
* Comment: <https://github.com/rust-lang/cargo/issues/7670#issuecomment-841722488>
44+
45+
To work around this problem, our specifiers must exactly match the specifiers used by our dependencies'
46+
dependency declarations. (That is, the `rev` / `tag` / `branch` values (or lack of them) must match.)
47+
48+
Currently, at least these transitively-used dependencies must be specified exactly:
2949

30-
This prevents patching a repository reference to a different revision in the same repository,
31-
which makes some SGX-patched packages (such as `serde-sgx` and `serde-json-sgx`) tricky to deal with.
50+
```toml
51+
once_cell = { git = "https://github.com/mesalock-linux/once_cell-sgx" }
52+
serde = { git = "https://github.com/mesalock-linux/serde-sgx" }
53+
serde-big-array = { git = "https://github.com/mesalock-linux/serde-big-array-sgx" }
54+
serde_derive = { git = "https://github.com/mesalock-linux/serde-sgx" }
55+
serde_json = { git = "https://github.com/mesalock-linux/serde-json-sgx" }
56+
```
3257

3358

3459
## Aligned memory allocation for secret values

codegen/auth_enclave/bindings.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,43 @@
1818

1919
#define SET_ACCESS_KEY_RESPONSE_SIZE 1
2020

21+
typedef enum ExecTokenError {
22+
EXEC_TOKEN_ERROR_GENERATE,
23+
EXEC_TOKEN_ERROR_VALIDATION,
24+
EXEC_TOKEN_ERROR_OUTPUT_BUFFER_SIZE,
25+
EXEC_TOKEN_ERROR_CRYPTO,
26+
EXEC_TOKEN_ERROR_IO,
27+
} ExecTokenError;
28+
29+
typedef uint8_t Nonce[24];
30+
31+
/**
32+
* FFI safe result type that can be converted to and from a rust result.
33+
*/
34+
typedef enum EcallResult_Nonce__ExecTokenError_Tag {
35+
ECALL_RESULT_NONCE_EXEC_TOKEN_ERROR_OK_NONCE_EXEC_TOKEN_ERROR,
36+
ECALL_RESULT_NONCE_EXEC_TOKEN_ERROR_ERR_NONCE_EXEC_TOKEN_ERROR,
37+
} EcallResult_Nonce__ExecTokenError_Tag;
38+
39+
typedef struct EcallResult_Nonce__ExecTokenError {
40+
EcallResult_Nonce__ExecTokenError_Tag tag;
41+
union {
42+
struct {
43+
Nonce ok;
44+
};
45+
struct {
46+
enum ExecTokenError err;
47+
};
48+
};
49+
} EcallResult_Nonce__ExecTokenError;
50+
51+
typedef struct EcallResult_Nonce__ExecTokenError IssueTokenResult;
52+
53+
typedef struct ExecReqMetadata {
54+
uint8_t uploader_pub_key[32];
55+
Nonce nonce;
56+
} ExecReqMetadata;
57+
2158
/**
2259
* FFI safe result type that can be converted to and from a rust result.
2360
*/

0 commit comments

Comments
 (0)