From 83ad706ad74f11bd6961f795ded49a910b49a464 Mon Sep 17 00:00:00 2001 From: Sascha Tommasone Date: Tue, 2 Jul 2024 23:08:24 +0200 Subject: [PATCH] [Assignment-7] size ecalls --- .../src/enclave/enclave.c | 27 +++++++++++++++++++ .../src/enclave/enclave.edl | 4 +++ .../src/enclave/enclave.h | 7 ++++- 3 files changed, 37 insertions(+), 1 deletion(-) diff --git a/Assignment 7 - SGX Hands-on/src/enclave/enclave.c b/Assignment 7 - SGX Hands-on/src/enclave/enclave.c index 5c74dff..12a4a3a 100644 --- a/Assignment 7 - SGX Hands-on/src/enclave/enclave.c +++ b/Assignment 7 - SGX Hands-on/src/enclave/enclave.c @@ -41,6 +41,33 @@ #include #include +#ifndef SK_SIZE +#define SK_SIZE SGX_ECP256_KEY_SIZE +#endif + +#ifndef PK_SIZE +#define PK_SIZE 2*SK_SIZE +#endif + +#ifndef SI_SIZE +#define SI_SIZE 2*SK_SIZE +#endif + +int get_sealed_size() { + return sgx_calc_sealed_data_size(PK_SIZE, SK_SIZE); +} + +int get_signature_size() { + return SI_SIZE; +} + +int get_public_key_size() { + return PK_SIZE; +} + +int get_private_key_size() { + return SK_SIZE; +} sgx_status_t seal_key_pair(sgx_ec256_private_t *private, sgx_ec256_public_t *public, uint8_t *sealed, uint32_t *sealed_size) { // handle missing keypair diff --git a/Assignment 7 - SGX Hands-on/src/enclave/enclave.edl b/Assignment 7 - SGX Hands-on/src/enclave/enclave.edl index 1764531..81363d4 100644 --- a/Assignment 7 - SGX Hands-on/src/enclave/enclave.edl +++ b/Assignment 7 - SGX Hands-on/src/enclave/enclave.edl @@ -40,6 +40,10 @@ enclave { */ trusted { + public int get_sealed_size(); + public int get_signature_size(); + public int get_public_key_size(); + public int get_private_key_size(); public sgx_status_t public_key([in, size=sealed_size]const uint8_t *sealed, size_t sealed_size, [out]uint8_t *gx, [out]uint8_t *gy); public sgx_status_t sign_firmware([in, size=data_size]const uint8_t *sealed, size_t sealed_size, [in, size=data_size]uint8_t *data, size_t data_size, [out, size=signature_size]uint8_t *signature, size_t signature_size); }; diff --git a/Assignment 7 - SGX Hands-on/src/enclave/enclave.h b/Assignment 7 - SGX Hands-on/src/enclave/enclave.h index 9a6fb95..2a26180 100644 --- a/Assignment 7 - SGX Hands-on/src/enclave/enclave.h +++ b/Assignment 7 - SGX Hands-on/src/enclave/enclave.h @@ -33,12 +33,17 @@ #ifndef _ENCLAVE_H_ #define _ENCLAVE_H_ +#include #include #include #include -#include #include +int get_sealed_size(); +int get_signature_size(); +int get_public_key_size(); +int get_private_key_size(); + sgx_status_t public_key(const uint8_t *sealed, const size_t sealed_size, uint8_t *gx, uint8_t *gy); sgx_status_t sign_firmware(const uint8_t *sealed, size_t sealed_size, uint8_t *data, size_t data_size, uint8_t *signature, size_t signature_size);