From 118d7385e8df5e0d7feb3441320630f22b009d7e Mon Sep 17 00:00:00 2001 From: Sascha Tommasone Date: Wed, 3 Jul 2024 16:45:54 +0200 Subject: [PATCH] [Assignment-7] hardcoded authorized public keys --- 7-SGX_Hands-on/src/enclave/enclave.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/7-SGX_Hands-on/src/enclave/enclave.c b/7-SGX_Hands-on/src/enclave/enclave.c index 14f6a8a..7ab26cb 100644 --- a/7-SGX_Hands-on/src/enclave/enclave.c +++ b/7-SGX_Hands-on/src/enclave/enclave.c @@ -53,6 +53,17 @@ #define SI_SIZE 2*SK_SIZE #endif +const sgx_ec256_public_t authorized[2] = { + { + 0, + 0 + }, + { + 0, + 0 + } +}; + int get_sealed_size() { return sgx_calc_sealed_data_size(PK_SIZE, SK_SIZE); } @@ -238,6 +249,7 @@ sgx_status_t verify_firmware(const uint8_t *data, uint32_t data_size, const uint if(public_key != NULL) { // invalid public key if(public_key_size != PK_SIZE) { + sgx_ecc256_close_context(ecc_handle); return SGX_ERROR_INVALID_PARAMETER; } @@ -253,7 +265,7 @@ sgx_status_t verify_firmware(const uint8_t *data, uint32_t data_size, const uint // verify signature uint8_t result; - sgx_status_t verification_status = sgx_ecdsa_verify((const uint8_t *)data, data_size, (const sgx_ec256_public_t *)&public, (const sgx_ec256_signature_t *)&ecc_signature, &result, ecc_handle); + sgx_status_t verification_status = sgx_ecdsa_verify(data, data_size, (const sgx_ec256_public_t *)&public, (const sgx_ec256_signature_t *)&ecc_signature, &result, ecc_handle); // handle failed verification process if(verification_status != SGX_SUCCESS) {