Skip to content

Commit

Permalink
Ensure OE_FORMAT_UUID_SGX_ECDSA is available after initializing attes…
Browse files Browse the repository at this point in the history
…tation
  • Loading branch information
eager-signal committed May 15, 2024
1 parent 9e585c3 commit 6a97ddb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions c/enclave/enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ int enclave_init(size_t available_memory, double load_factor, size_t num_shards,
error_t err = err_SUCCESS;
ASSERT_ERR(load_factor >= 1.0 && load_factor <= 3.0, err_ENCLAVE__GENERAL__INVALID_LOAD_FACTOR);
ASSERT_ERR(OE_OK == oe_attester_initialize(), err_ENCLAVE__GENERAL__OE_ATTESTER_INITIALIZE);
// oe_attester_initialize() is basic, and it will succeed as long as one attester plugin loads.
// We want to fail fast if the format that we use is not available, so we check that it is.
oe_uuid_t ignored;
ASSERT_ERR(OE_OK == oe_attester_select_format(&sgx_remote_uuid, 1, &ignored), err_ENCLAVE__GENERAL__OE_ATTESTER_SELECT_FORMAT);
uint8_t init_expected = ENCLAVE_INIT_UNINITIALIZED;
ASSERT_ERR(__atomic_compare_exchange_n(&g_init_done, &init_expected, ENCLAVE_INIT_INITIALIZING, false, __ATOMIC_ACQ_REL, __ATOMIC_ACQ_REL), err_ENCLAVE__GENERAL__REINIT);
GOTO_IF_ERROR(err = generate_privkey(sizeof(g_privkey), g_privkey), done);
Expand Down
11 changes: 11 additions & 0 deletions c/enclave/shim.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ inline const char* oe_result_str(oe_result_t result) {
oe_result_t oe_attester_initialize();
inline oe_result_t oe_attester_initialize() { return OE_OK; }

oe_result_t oe_attester_select_format(
const oe_uuid_t* format_ids,
size_t format_ids_length,
oe_uuid_t* selected_format_id);
inline oe_result_t oe_attester_select_format(
const oe_uuid_t* format_ids,
size_t format_ids_length,
oe_uuid_t* selected_format_id) {
memcpy(selected_format_id, format_ids, sizeof(oe_uuid_t));
return OE_OK;
}
oe_result_t oe_serialize_custom_claims(
const oe_claim_t* custom_claims,
size_t custom_claims_length,
Expand Down
1 change: 1 addition & 0 deletions c/util/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ typedef enum {
err_ENCLAVE__GENERAL__CLIENT_REMOVE_FAILED,
err_ENCLAVE__GENERAL__CLIENT_LOCK_FAILED,
err_ENCLAVE__GENERAL__NOINIT,
err_ENCLAVE__GENERAL__OE_ATTESTER_SELECT_FORMAT,

err_ENCLAVE__LOADPB__ = 200, // enclave_load_pb
err_ENCLAVE__LOADPB__REQUEST_PB_NEW,
Expand Down

0 comments on commit 6a97ddb

Please sign in to comment.