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

Commit 2e14843

Browse files
authored
Merge pull request #105 from registreerocks/feat-more-enclave-messages
feat(rtc_types): more enclave message work for set_access_key
2 parents f513d17 + 77479a8 commit 2e14843

File tree

11 files changed

+145
-123
lines changed

11 files changed

+145
-123
lines changed

cbindgen_enclaves.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# cbindgen config for the enclave bindings.h files
2+
#
3+
# These binding files should include all the types referenced by
4+
# the functions declared in our EDL files.
5+
#
6+
# Docs: <https://github.com/eqrion/cbindgen/blob/master/docs.md#cbindgentoml>
7+
8+
language = "C"
9+
10+
# No C standard imports for enclaves.
11+
no_includes = true
12+
13+
[export]
14+
15+
# Don't generate items for functions (sgx_edger8r will).
16+
item_types = [
17+
"constants",
18+
"globals",
19+
"enums",
20+
"structs",
21+
"unions",
22+
"typedefs",
23+
"opaque",
24+
# "functions",
25+
]
26+
27+
[enum]
28+
# Use qualified enum variant names: some of our enum types conflict, otherwise.
29+
rename_variants = "QualifiedScreamingSnakeCase"
30+
31+
# Also generate items for our local enclaves libraries.
32+
[parse]
33+
parse_deps = true
34+
include = ["rtc_types", "rtc_tenclave"]
35+
extra_bindings = ["rtc_types", "rtc_tenclave"]

codegen/auth_enclave/bindings.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
* FFI safe result type that can be converted to and from a rust result.
2323
*/
2424
typedef enum EcallResult_sgx_dh_msg1_t__sgx_status_t_Tag {
25-
Ok_sgx_dh_msg1_t__sgx_status_t,
26-
Err_sgx_dh_msg1_t__sgx_status_t,
25+
ECALL_RESULT_SGX_DH_MSG1_T_SGX_STATUS_T_OK_SGX_DH_MSG1_T_SGX_STATUS_T,
26+
ECALL_RESULT_SGX_DH_MSG1_T_SGX_STATUS_T_ERR_SGX_DH_MSG1_T_SGX_STATUS_T,
2727
} EcallResult_sgx_dh_msg1_t__sgx_status_t_Tag;
2828

2929
typedef struct EcallResult_sgx_dh_msg1_t__sgx_status_t {
@@ -44,8 +44,8 @@ typedef struct EcallResult_sgx_dh_msg1_t__sgx_status_t SessionRequestResult;
4444
* FFI safe result type that can be converted to and from a rust result.
4545
*/
4646
typedef enum EcallResult_sgx_dh_msg3_t__sgx_status_t_Tag {
47-
Ok_sgx_dh_msg3_t__sgx_status_t,
48-
Err_sgx_dh_msg3_t__sgx_status_t,
47+
ECALL_RESULT_SGX_DH_MSG3_T_SGX_STATUS_T_OK_SGX_DH_MSG3_T_SGX_STATUS_T,
48+
ECALL_RESULT_SGX_DH_MSG3_T_SGX_STATUS_T_ERR_SGX_DH_MSG3_T_SGX_STATUS_T,
4949
} EcallResult_sgx_dh_msg3_t__sgx_status_t_Tag;
5050

5151
typedef struct EcallResult_sgx_dh_msg3_t__sgx_status_t {
@@ -63,10 +63,10 @@ typedef struct EcallResult_sgx_dh_msg3_t__sgx_status_t {
6363
typedef struct EcallResult_sgx_dh_msg3_t__sgx_status_t ExchangeReportResult;
6464

6565
typedef enum CreateReportResult_Tag {
66-
Success,
67-
Sgx,
68-
FailedToGetPublicKey,
69-
FailedEncodePublicKey,
66+
CREATE_REPORT_RESULT_SUCCESS,
67+
CREATE_REPORT_RESULT_SGX,
68+
CREATE_REPORT_RESULT_FAILED_TO_GET_PUBLIC_KEY,
69+
CREATE_REPORT_RESULT_FAILED_ENCODE_PUBLIC_KEY,
7070
} CreateReportResult_Tag;
7171

7272
typedef struct CreateReportResult {

codegen/data_enclave/bindings.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ typedef struct DataUploadResponse {
2424
} DataUploadResponse;
2525

2626
typedef enum CryptoError_Tag {
27-
Rand,
28-
Unknown,
27+
CRYPTO_ERROR_RAND,
28+
CRYPTO_ERROR_UNKNOWN,
2929
} CryptoError_Tag;
3030

3131
typedef struct CryptoError {
@@ -38,9 +38,9 @@ typedef struct CryptoError {
3838
} CryptoError;
3939

4040
typedef enum DataUploadError_Tag {
41-
Validation,
42-
Sealing,
43-
Crypto,
41+
DATA_UPLOAD_ERROR_VALIDATION,
42+
DATA_UPLOAD_ERROR_SEALING,
43+
DATA_UPLOAD_ERROR_CRYPTO,
4444
} DataUploadError_Tag;
4545

4646
typedef struct DataUploadError {
@@ -59,8 +59,8 @@ typedef struct DataUploadError {
5959
* FFI safe result type that can be converted to and from a rust result.
6060
*/
6161
typedef enum EcallResult_DataUploadResponse__DataUploadError_Tag {
62-
Ok_DataUploadResponse__DataUploadError,
63-
Err_DataUploadResponse__DataUploadError,
62+
ECALL_RESULT_DATA_UPLOAD_RESPONSE_DATA_UPLOAD_ERROR_OK_DATA_UPLOAD_RESPONSE_DATA_UPLOAD_ERROR,
63+
ECALL_RESULT_DATA_UPLOAD_RESPONSE_DATA_UPLOAD_ERROR_ERR_DATA_UPLOAD_RESPONSE_DATA_UPLOAD_ERROR,
6464
} EcallResult_DataUploadResponse__DataUploadError_Tag;
6565

6666
typedef struct EcallResult_DataUploadResponse__DataUploadError {
@@ -86,8 +86,8 @@ typedef struct UploadMetadata {
8686
* FFI safe result type that can be converted to and from a rust result.
8787
*/
8888
typedef enum EcallResult_sgx_dh_msg1_t__sgx_status_t_Tag {
89-
Ok_sgx_dh_msg1_t__sgx_status_t,
90-
Err_sgx_dh_msg1_t__sgx_status_t,
89+
ECALL_RESULT_SGX_DH_MSG1_T_SGX_STATUS_T_OK_SGX_DH_MSG1_T_SGX_STATUS_T,
90+
ECALL_RESULT_SGX_DH_MSG1_T_SGX_STATUS_T_ERR_SGX_DH_MSG1_T_SGX_STATUS_T,
9191
} EcallResult_sgx_dh_msg1_t__sgx_status_t_Tag;
9292

9393
typedef struct EcallResult_sgx_dh_msg1_t__sgx_status_t {
@@ -108,8 +108,8 @@ typedef struct EcallResult_sgx_dh_msg1_t__sgx_status_t SessionRequestResult;
108108
* FFI safe result type that can be converted to and from a rust result.
109109
*/
110110
typedef enum EcallResult_sgx_dh_msg3_t__sgx_status_t_Tag {
111-
Ok_sgx_dh_msg3_t__sgx_status_t,
112-
Err_sgx_dh_msg3_t__sgx_status_t,
111+
ECALL_RESULT_SGX_DH_MSG3_T_SGX_STATUS_T_OK_SGX_DH_MSG3_T_SGX_STATUS_T,
112+
ECALL_RESULT_SGX_DH_MSG3_T_SGX_STATUS_T_ERR_SGX_DH_MSG3_T_SGX_STATUS_T,
113113
} EcallResult_sgx_dh_msg3_t__sgx_status_t_Tag;
114114

115115
typedef struct EcallResult_sgx_dh_msg3_t__sgx_status_t {
@@ -127,10 +127,10 @@ typedef struct EcallResult_sgx_dh_msg3_t__sgx_status_t {
127127
typedef struct EcallResult_sgx_dh_msg3_t__sgx_status_t ExchangeReportResult;
128128

129129
typedef enum CreateReportResult_Tag {
130-
Success,
131-
Sgx,
132-
FailedToGetPublicKey,
133-
FailedEncodePublicKey,
130+
CREATE_REPORT_RESULT_SUCCESS,
131+
CREATE_REPORT_RESULT_SGX,
132+
CREATE_REPORT_RESULT_FAILED_TO_GET_PUBLIC_KEY,
133+
CREATE_REPORT_RESULT_FAILED_ENCODE_PUBLIC_KEY,
134134
} CreateReportResult_Tag;
135135

136136
typedef struct CreateReportResult {

codegen/exec_enclave/bindings.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
* FFI safe result type that can be converted to and from a rust result.
2323
*/
2424
typedef enum EcallResult_sgx_dh_msg1_t__sgx_status_t_Tag {
25-
Ok_sgx_dh_msg1_t__sgx_status_t,
26-
Err_sgx_dh_msg1_t__sgx_status_t,
25+
ECALL_RESULT_SGX_DH_MSG1_T_SGX_STATUS_T_OK_SGX_DH_MSG1_T_SGX_STATUS_T,
26+
ECALL_RESULT_SGX_DH_MSG1_T_SGX_STATUS_T_ERR_SGX_DH_MSG1_T_SGX_STATUS_T,
2727
} EcallResult_sgx_dh_msg1_t__sgx_status_t_Tag;
2828

2929
typedef struct EcallResult_sgx_dh_msg1_t__sgx_status_t {
@@ -44,8 +44,8 @@ typedef struct EcallResult_sgx_dh_msg1_t__sgx_status_t SessionRequestResult;
4444
* FFI safe result type that can be converted to and from a rust result.
4545
*/
4646
typedef enum EcallResult_sgx_dh_msg3_t__sgx_status_t_Tag {
47-
Ok_sgx_dh_msg3_t__sgx_status_t,
48-
Err_sgx_dh_msg3_t__sgx_status_t,
47+
ECALL_RESULT_SGX_DH_MSG3_T_SGX_STATUS_T_OK_SGX_DH_MSG3_T_SGX_STATUS_T,
48+
ECALL_RESULT_SGX_DH_MSG3_T_SGX_STATUS_T_ERR_SGX_DH_MSG3_T_SGX_STATUS_T,
4949
} EcallResult_sgx_dh_msg3_t__sgx_status_t_Tag;
5050

5151
typedef struct EcallResult_sgx_dh_msg3_t__sgx_status_t {
@@ -63,10 +63,10 @@ typedef struct EcallResult_sgx_dh_msg3_t__sgx_status_t {
6363
typedef struct EcallResult_sgx_dh_msg3_t__sgx_status_t ExchangeReportResult;
6464

6565
typedef enum CreateReportResult_Tag {
66-
Success,
67-
Sgx,
68-
FailedToGetPublicKey,
69-
FailedEncodePublicKey,
66+
CREATE_REPORT_RESULT_SUCCESS,
67+
CREATE_REPORT_RESULT_SGX,
68+
CREATE_REPORT_RESULT_FAILED_TO_GET_PUBLIC_KEY,
69+
CREATE_REPORT_RESULT_FAILED_ENCODE_PUBLIC_KEY,
7070
} CreateReportResult_Tag;
7171

7272
typedef struct CreateReportResult {

rtc_auth_enclave/build.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
extern crate cbindgen;
22
extern crate cc;
33

4-
use cbindgen::{Config, ExportConfig, ItemType};
54
use std::env;
65

76
fn main() {
87
println!("cargo:rerun-if-changed=rtc_auth.edl");
98
println!("cargo:rerun-if-changed=src");
109

10+
let cbindgen_config_file = "../cbindgen_enclaves.toml";
11+
println!("cargo:rerun-if-changed={}", cbindgen_config_file);
1112
// Also rebuild if we delete bindings.h
1213
println!("cargo:rerun-if-changed=../codegen/auth_enclave/bindings.h");
1314

@@ -16,29 +17,11 @@ fn main() {
1617
let _sgx_rust = String::from("/root/sgx-rust");
1718
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
1819

20+
let cbindgen_config = cbindgen::Config::from_file(cbindgen_config_file).unwrap();
1921
cbindgen::Builder::new()
20-
.with_config(Config {
21-
export: ExportConfig {
22-
item_types: vec![
23-
ItemType::Constants,
24-
ItemType::Globals,
25-
ItemType::Enums,
26-
ItemType::Structs,
27-
ItemType::Unions,
28-
ItemType::Typedefs,
29-
ItemType::OpaqueItems,
30-
],
31-
..Default::default()
32-
},
33-
..Default::default()
34-
})
22+
.with_config(cbindgen_config)
3523
.with_crate(crate_dir)
3624
.with_std_types(false)
37-
.with_language(cbindgen::Language::C)
38-
.with_no_includes()
39-
.with_parse_deps(true)
40-
.with_parse_include(&["rtc_types", "rtc_tenclave"])
41-
.with_parse_extra_bindings(&["rtc_types", "rtc_tenclave"])
4225
.generate()
4326
.expect("Unable to generate bindings")
4427
.write_to_file("../codegen/auth_enclave/bindings.h");

rtc_data_enclave/build.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
extern crate cbindgen;
22
extern crate cc;
33

4-
use cbindgen::{Config, ExportConfig, ItemType};
54
use std::env;
65

76
fn main() {
87
println!("cargo:rerun-if-changed=rtc_data.edl");
98
println!("cargo:rerun-if-changed=src");
109

10+
let cbindgen_config_file = "../cbindgen_enclaves.toml";
11+
println!("cargo:rerun-if-changed={}", cbindgen_config_file);
1112
// Also rebuild if we delete bindings.h
1213
println!("cargo:rerun-if-changed=../codegen/data_enclave/bindings.h");
1314

@@ -16,29 +17,11 @@ fn main() {
1617
let _sgx_rust = String::from("/root/sgx-rust");
1718
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
1819

20+
let cbindgen_config = cbindgen::Config::from_file(cbindgen_config_file).unwrap();
1921
cbindgen::Builder::new()
20-
.with_config(Config {
21-
export: ExportConfig {
22-
item_types: vec![
23-
ItemType::Constants,
24-
ItemType::Globals,
25-
ItemType::Enums,
26-
ItemType::Structs,
27-
ItemType::Unions,
28-
ItemType::Typedefs,
29-
ItemType::OpaqueItems,
30-
],
31-
..Default::default()
32-
},
33-
..Default::default()
34-
})
22+
.with_config(cbindgen_config)
3523
.with_crate(crate_dir)
3624
.with_std_types(false)
37-
.with_language(cbindgen::Language::C)
38-
.with_no_includes()
39-
.with_parse_deps(true)
40-
.with_parse_include(&["rtc_types", "rtc_tenclave"])
41-
.with_parse_extra_bindings(&["rtc_types", "rtc_tenclave"])
4225
.generate()
4326
.expect("Unable to generate bindings")
4427
.write_to_file("../codegen/data_enclave/bindings.h");

rtc_exec_enclave/build.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
extern crate cbindgen;
22
extern crate cc;
33

4-
use cbindgen::{Config, ExportConfig, ItemType};
54
use std::env;
65

76
fn main() {
87
println!("cargo:rerun-if-changed=rtc_exec.edl");
98
println!("cargo:rerun-if-changed=src");
109

10+
let cbindgen_config_file = "../cbindgen_enclaves.toml";
11+
println!("cargo:rerun-if-changed={}", cbindgen_config_file);
1112
// Also rebuild if we delete bindings.h
1213
println!("cargo:rerun-if-changed=../codegen/exec_enclave/bindings.h");
1314

@@ -16,29 +17,11 @@ fn main() {
1617
let _sgx_rust = String::from("/root/sgx-rust");
1718
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
1819

20+
let cbindgen_config = cbindgen::Config::from_file(cbindgen_config_file).unwrap();
1921
cbindgen::Builder::new()
20-
.with_config(Config {
21-
export: ExportConfig {
22-
item_types: vec![
23-
ItemType::Constants,
24-
ItemType::Globals,
25-
ItemType::Enums,
26-
ItemType::Structs,
27-
ItemType::Unions,
28-
ItemType::Typedefs,
29-
ItemType::OpaqueItems,
30-
],
31-
..Default::default()
32-
},
33-
..Default::default()
34-
})
22+
.with_config(cbindgen_config)
3523
.with_crate(crate_dir)
3624
.with_std_types(false)
37-
.with_language(cbindgen::Language::C)
38-
.with_no_includes()
39-
.with_parse_deps(true)
40-
.with_parse_include(&["rtc_types", "rtc_tenclave"])
41-
.with_parse_extra_bindings(&["rtc_types", "rtc_tenclave"])
4225
.generate()
4326
.expect("Unable to generate bindings")
4427
.write_to_file("../codegen/exec_enclave/bindings.h");

rtc_tenclave/src/dh/sealing.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
33
use core::mem::size_of;
44

5-
use rkyv::ser::serializers::{BufferSerializer, BufferSerializerError};
5+
use rkyv::ser::serializers::BufferSerializer;
66
use rkyv::{Aligned, Archive, Deserialize, Infallible, Serialize};
77
use rtc_types::byte_formats::rkyv_format;
8+
use rtc_types::enclave_messages::errors::SealingError;
89
use rtc_types::enclave_messages::EncryptedEnclaveMessage;
9-
use sgx_types::sgx_status_t;
1010

1111
use crate::dh::ProtectedChannel;
1212

@@ -107,24 +107,6 @@ where
107107
unsafe { rkyv_format::view_array::<A>(&sealed.aad) }
108108
}
109109

110-
#[derive(Debug)]
111-
pub enum SealingError {
112-
Rkyv(BufferSerializerError),
113-
Sgx(sgx_status_t),
114-
}
115-
116-
impl From<BufferSerializerError> for SealingError {
117-
fn from(error: BufferSerializerError) -> Self {
118-
SealingError::Rkyv(error)
119-
}
120-
}
121-
122-
impl From<sgx_status_t> for SealingError {
123-
fn from(status: sgx_status_t) -> Self {
124-
SealingError::Sgx(status)
125-
}
126-
}
127-
128110
#[cfg(test)]
129111
mod tests {
130112
use proptest::prelude::*;

0 commit comments

Comments
 (0)