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

Commit

Permalink
build(enclaves): cbindgen config: use qualified names for enum variants
Browse files Browse the repository at this point in the history
We need this to avoid clashes between different FFI error enums.
  • Loading branch information
PiDelport committed Jun 21, 2021
1 parent f1e3c1d commit 61b48f3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 31 deletions.
4 changes: 4 additions & 0 deletions cbindgen_enclaves.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ item_types = [
# "functions",
]

[enum]
# Use qualified enum variant names: some of our enum types conflict, otherwise.
rename_variants = "QualifiedScreamingSnakeCase"

# Also generate items for our local enclaves libraries.
[parse]
parse_deps = true
Expand Down
16 changes: 8 additions & 8 deletions codegen/auth_enclave/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* 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,
ECALL_RESULT_SGX_DH_MSG1_T_SGX_STATUS_T_OK_SGX_DH_MSG1_T_SGX_STATUS_T,
ECALL_RESULT_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 {
Expand All @@ -44,8 +44,8 @@ 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,
ECALL_RESULT_SGX_DH_MSG3_T_SGX_STATUS_T_OK_SGX_DH_MSG3_T_SGX_STATUS_T,
ECALL_RESULT_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 {
Expand All @@ -63,10 +63,10 @@ typedef struct 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,
FailedToGetPublicKey,
FailedEncodePublicKey,
CREATE_REPORT_RESULT_SUCCESS,
CREATE_REPORT_RESULT_SGX,
CREATE_REPORT_RESULT_FAILED_TO_GET_PUBLIC_KEY,
CREATE_REPORT_RESULT_FAILED_ENCODE_PUBLIC_KEY,
} CreateReportResult_Tag;

typedef struct CreateReportResult {
Expand Down
30 changes: 15 additions & 15 deletions codegen/data_enclave/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ typedef struct DataUploadResponse {
} DataUploadResponse;

typedef enum CryptoError_Tag {
Rand,
Unknown,
CRYPTO_ERROR_RAND,
CRYPTO_ERROR_UNKNOWN,
} CryptoError_Tag;

typedef struct CryptoError {
Expand All @@ -38,9 +38,9 @@ typedef struct CryptoError {
} CryptoError;

typedef enum DataUploadError_Tag {
Validation,
Sealing,
Crypto,
DATA_UPLOAD_ERROR_VALIDATION,
DATA_UPLOAD_ERROR_SEALING,
DATA_UPLOAD_ERROR_CRYPTO,
} DataUploadError_Tag;

typedef struct DataUploadError {
Expand All @@ -59,8 +59,8 @@ typedef struct DataUploadError {
* FFI safe result type that can be converted to and from a rust result.
*/
typedef enum EcallResult_DataUploadResponse__DataUploadError_Tag {
Ok_DataUploadResponse__DataUploadError,
Err_DataUploadResponse__DataUploadError,
ECALL_RESULT_DATA_UPLOAD_RESPONSE_DATA_UPLOAD_ERROR_OK_DATA_UPLOAD_RESPONSE_DATA_UPLOAD_ERROR,
ECALL_RESULT_DATA_UPLOAD_RESPONSE_DATA_UPLOAD_ERROR_ERR_DATA_UPLOAD_RESPONSE_DATA_UPLOAD_ERROR,
} EcallResult_DataUploadResponse__DataUploadError_Tag;

typedef struct EcallResult_DataUploadResponse__DataUploadError {
Expand All @@ -86,8 +86,8 @@ typedef struct UploadMetadata {
* 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,
ECALL_RESULT_SGX_DH_MSG1_T_SGX_STATUS_T_OK_SGX_DH_MSG1_T_SGX_STATUS_T,
ECALL_RESULT_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 {
Expand All @@ -108,8 +108,8 @@ 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,
ECALL_RESULT_SGX_DH_MSG3_T_SGX_STATUS_T_OK_SGX_DH_MSG3_T_SGX_STATUS_T,
ECALL_RESULT_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 {
Expand All @@ -127,10 +127,10 @@ typedef struct 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,
FailedToGetPublicKey,
FailedEncodePublicKey,
CREATE_REPORT_RESULT_SUCCESS,
CREATE_REPORT_RESULT_SGX,
CREATE_REPORT_RESULT_FAILED_TO_GET_PUBLIC_KEY,
CREATE_REPORT_RESULT_FAILED_ENCODE_PUBLIC_KEY,
} CreateReportResult_Tag;

typedef struct CreateReportResult {
Expand Down
16 changes: 8 additions & 8 deletions codegen/exec_enclave/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* 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,
ECALL_RESULT_SGX_DH_MSG1_T_SGX_STATUS_T_OK_SGX_DH_MSG1_T_SGX_STATUS_T,
ECALL_RESULT_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 {
Expand All @@ -44,8 +44,8 @@ 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,
ECALL_RESULT_SGX_DH_MSG3_T_SGX_STATUS_T_OK_SGX_DH_MSG3_T_SGX_STATUS_T,
ECALL_RESULT_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 {
Expand All @@ -63,10 +63,10 @@ typedef struct 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,
FailedToGetPublicKey,
FailedEncodePublicKey,
CREATE_REPORT_RESULT_SUCCESS,
CREATE_REPORT_RESULT_SGX,
CREATE_REPORT_RESULT_FAILED_TO_GET_PUBLIC_KEY,
CREATE_REPORT_RESULT_FAILED_ENCODE_PUBLIC_KEY,
} CreateReportResult_Tag;

typedef struct CreateReportResult {
Expand Down

0 comments on commit 61b48f3

Please sign in to comment.