From 61b48f35e7518219d4cb7db5061cfe9e1aa49730 Mon Sep 17 00:00:00 2001 From: Pi Delport Date: Fri, 18 Jun 2021 21:08:06 +0200 Subject: [PATCH] build(enclaves): cbindgen config: use qualified names for enum variants We need this to avoid clashes between different FFI error enums. --- cbindgen_enclaves.toml | 4 ++++ codegen/auth_enclave/bindings.h | 16 ++++++++-------- codegen/data_enclave/bindings.h | 30 +++++++++++++++--------------- codegen/exec_enclave/bindings.h | 16 ++++++++-------- 4 files changed, 35 insertions(+), 31 deletions(-) diff --git a/cbindgen_enclaves.toml b/cbindgen_enclaves.toml index 6efb38ad..31de9d70 100644 --- a/cbindgen_enclaves.toml +++ b/cbindgen_enclaves.toml @@ -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 diff --git a/codegen/auth_enclave/bindings.h b/codegen/auth_enclave/bindings.h index 9820e422..949ef402 100644 --- a/codegen/auth_enclave/bindings.h +++ b/codegen/auth_enclave/bindings.h @@ -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 { @@ -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 { @@ -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 { diff --git a/codegen/data_enclave/bindings.h b/codegen/data_enclave/bindings.h index 63570f99..f84efde4 100644 --- a/codegen/data_enclave/bindings.h +++ b/codegen/data_enclave/bindings.h @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -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 { diff --git a/codegen/exec_enclave/bindings.h b/codegen/exec_enclave/bindings.h index 9820e422..949ef402 100644 --- a/codegen/exec_enclave/bindings.h +++ b/codegen/exec_enclave/bindings.h @@ -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 { @@ -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 { @@ -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 {