Skip to content

Commit

Permalink
Changes as per PR review
Browse files Browse the repository at this point in the history
- Incidentally adding some files to SGX's .gitignore
  • Loading branch information
amendelzon committed Sep 2, 2024
1 parent 754f5cc commit c8407e7
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 16 deletions.
1 change: 0 additions & 1 deletion firmware/src/powhsm/src/bc_err.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ void show_error(err_code_t errcode) {
break;
}
}
(void)(msg);
LOG("*** ERROR: %s\n", msg);
}
#else
Expand Down
9 changes: 9 additions & 0 deletions firmware/src/sgx/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# Private key file
private.pem

# OE generated files
src/trusted/hsm_args.h
src/trusted/hsm_t.c
src/trusted/hsm_t.h
src/untrusted/hsm_args.h
src/untrusted/hsm_u.c
src/untrusted/hsm_u.h

6 changes: 3 additions & 3 deletions firmware/src/sgx/src/untrusted/enclave_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
static char* G_enclave_path = NULL;
static oe_enclave_t* G_enclave = NULL;

bool ep_init(char* enclave_path) {
bool epro_init(char* enclave_path) {
G_enclave_path = enclave_path;
if (access(G_enclave_path, F_OK) != 0) {
LOG("Invalid enclave path given: %s\n", G_enclave_path);
Expand All @@ -42,7 +42,7 @@ bool ep_init(char* enclave_path) {
return true;
}

oe_enclave_t* ep_get_enclave() {
oe_enclave_t* epro_get_enclave() {
if (NULL == G_enclave) {
oe_enclave_t *enclave = NULL;
LOG("Creating HSM enclave...\n");
Expand All @@ -61,7 +61,7 @@ oe_enclave_t* ep_get_enclave() {
return G_enclave;
}

void ep_finalize_enclave() {
void epro_finalize_enclave() {
if (NULL != G_enclave) {
oe_terminate_enclave(G_enclave);
LOG("HSM enclave terminated\n");
Expand Down
6 changes: 3 additions & 3 deletions firmware/src/sgx/src/untrusted/enclave_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* @returns Whether initialization succeeded
*/
bool ep_init(char* enclave_path);
bool epro_init(char* enclave_path);

/**
* @brief Returns a pointer to the HSM enclave. This function should always
Expand All @@ -41,12 +41,12 @@ bool ep_init(char* enclave_path);
*
* @returns A valid pointer to the HSM enclave, or NULL if an error occurred
*/
oe_enclave_t* ep_get_enclave();
oe_enclave_t* epro_get_enclave();

/**
* @brief Terminates the HSM enclave. After this function is called,
* all ecall operations will fail.
*/
void ep_finalize_enclave();
void epro_finalize_enclave();

#endif // __ENCLAVE_PROVIDER_H
8 changes: 4 additions & 4 deletions firmware/src/sgx/src/untrusted/enclave_proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* ECALLS
*/

bool ep_system_init(unsigned char *msg_buffer, size_t msg_buffer_size) {
oe_enclave_t *enclave = ep_get_enclave();
bool eprx_system_init(unsigned char *msg_buffer, size_t msg_buffer_size) {
oe_enclave_t *enclave = epro_get_enclave();
if (enclave == NULL) {
LOG("Failed to retrieve the enclave. "
"Unable to call system_init().\n");
Expand All @@ -37,8 +37,8 @@ bool ep_system_init(unsigned char *msg_buffer, size_t msg_buffer_size) {
return result;
}

unsigned int ep_system_process_apdu(unsigned int rx) {
oe_enclave_t *enclave = ep_get_enclave();
unsigned int eprx_system_process_apdu(unsigned int rx) {
oe_enclave_t *enclave = epro_get_enclave();
if (enclave == NULL) {
LOG("Failed to retrieve the enclave. "
"Unable to call system_process_command().\n");
Expand Down
4 changes: 2 additions & 2 deletions firmware/src/sgx/src/untrusted/enclave_proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
/**
* @brief See system_init in system.h within the trusted sources
*/
bool ep_system_init(unsigned char *msg_buffer, size_t msg_buffer_size);
bool eprx_system_init(unsigned char *msg_buffer, size_t msg_buffer_size);

/**
* @brief See system_process_apdu in system.h within the trusted sources
*/
unsigned int ep_system_process_apdu(unsigned int rx);
unsigned int eprx_system_process_apdu(unsigned int rx);

#endif // __HSM_PROXY
6 changes: 3 additions & 3 deletions firmware/src/sgx/src/untrusted/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,13 +129,13 @@ int main(int argc, char **argv) {
LOG("SGX powHSM starting...\n");

LOG("Initialising enclave provider...\n");
if (!ep_init(arguments.enclave_path)) {
if (!epro_init(arguments.enclave_path)) {
LOG("Error initialising enclave provider\n");
goto main_error;
}

LOG("Initialising system...\n");
if (!ep_system_init(io_apdu_buffer, sizeof(io_apdu_buffer))) {
if (!eprx_system_init(io_apdu_buffer, sizeof(io_apdu_buffer))) {
LOG("Error initialising system\n");
goto main_error;
}
Expand All @@ -157,7 +157,7 @@ int main(int argc, char **argv) {
rx = io_exchange(tx);

if (rx) {
tx = ep_system_process_apdu(rx);
tx = eprx_system_process_apdu(rx);
}
}

Expand Down

0 comments on commit c8407e7

Please sign in to comment.