Widen XML parameters to 64 bits

The signing tool parses values in the enclave configuration as 32-bit
integers. This patch changes it to parse them as 64-bit integers, so
that it can process larger enclaves. This only affects properties such
as MaxStackSize and MaxHeapSize, while subsequent 32-bit bookkeeping,
such as TCSPolicy, MiscSelect, and MiscMask are unchanged.

Signed-off-by: Warren He <-w@berkeley.edu>
This commit is contained in:
Warren He 2016-08-01 08:39:17 -07:00
parent 8bde48e653
commit b57e8d0469
3 changed files with 14 additions and 14 deletions

View File

@ -58,7 +58,7 @@
static bool traverser_parameter(const char *temp_name, const char *temp_text, xml_parameter_t *parameter, int parameter_count)
{
assert(temp_name != NULL && parameter != NULL);
uint32_t temp_value=0;
uint64_t temp_value=0;
if(temp_text == NULL)
{
se_trace(SE_TRACE_ERROR, LACK_VALUE_FOR_ELEMENT_ERROR, temp_name);
@ -74,7 +74,7 @@ static bool traverser_parameter(const char *temp_name, const char *temp_text, xm
errno = 0;
char* endptr = NULL;
temp_value = (uint32_t)strtoul(temp_text, &endptr, 0);
temp_value = (uint64_t)strtoull(temp_text, &endptr, 0);
if(*endptr!='\0'||errno!=0) //Invalid value or valid value but out of the representable range
{
se_trace(SE_TRACE_ERROR, INVALID_VALUE_FOR_ELEMENT_ERROR, temp_name);
@ -212,7 +212,7 @@ bool CMetadata::modify_metadata(const xml_parameter_t *parameter)
assert(parameter != NULL);
m_metadata->version = META_DATA_MAKE_VERSION(MAJOR_VERSION,MINOR_VERSION );
m_metadata->size = offsetof(metadata_t, data);
m_metadata->tcs_policy = parameter[TCSPOLICY].value;
m_metadata->tcs_policy = (uint32_t)parameter[TCSPOLICY].value;
m_metadata->ssa_frame_size = SSA_FRAME_SIZE;
//stack/heap must be page-align
if(parameter[STACKMAXSIZE].value % ALIGN_SIZE)
@ -237,13 +237,13 @@ bool CMetadata::modify_metadata(const xml_parameter_t *parameter)
m_metadata->max_save_buffer_size = MAX_SAVE_BUF_SIZE;
m_metadata->magic_num = METADATA_MAGIC;
m_metadata->desired_misc_select = 0;
m_metadata->enclave_css.body.misc_select = parameter[MISCSELECT].value;
m_metadata->enclave_css.body.misc_mask = parameter[MISCMASK].value;
m_metadata->enclave_css.body.misc_select = (uint32_t)parameter[MISCSELECT].value;
m_metadata->enclave_css.body.misc_mask = (uint32_t)parameter[MISCMASK].value;
m_create_param.heap_max_size = parameter[HEAPMAXSIZE].value;
m_create_param.ssa_frame_size = SSA_FRAME_SIZE;
m_create_param.stack_max_size = parameter[STACKMAXSIZE].value;
m_create_param.tcs_max_num = parameter[TCSNUM].value;
m_create_param.tcs_max_num = (uint32_t)parameter[TCSNUM].value;
m_create_param.tcs_policy = m_metadata->tcs_policy;
return true;
}

View File

@ -68,9 +68,9 @@ typedef enum _para_type_t
typedef struct _xml_parameter_t
{
const char* name; //the element name
uint32_t max_value;
uint32_t min_value;
uint32_t value; //parameter value. Initialized with the default value.
uint64_t max_value;
uint64_t min_value;
uint64_t value; //parameter value. Initialized with the default value.
uint32_t flag; //Show whether it has been matched
} xml_parameter_t;

View File

@ -309,12 +309,12 @@ static bool fill_enclave_css(const IppsRSAPublicKeyState *pub_key, const xml_par
}
//hardware version
enclave_css.header.hw_version = para[HW].value;
enclave_css.header.hw_version = (uint32_t)para[HW].value;
//****************************fill the body***********************
// Misc_select/Misc_mask
enclave_css.body.misc_select = para[MISCSELECT].value;
enclave_css.body.misc_mask = para[MISCMASK].value;
enclave_css.body.misc_select = (uint32_t)para[MISCSELECT].value;
enclave_css.body.misc_mask = (uint32_t)para[MISCMASK].value;
//low 64 bit
enclave_css.body.attributes.flags = 0;
enclave_css.body.attribute_mask.flags = ~SGX_FLAGS_DEBUG;
@ -1088,8 +1088,8 @@ int main(int argc, char* argv[])
{"HW", 0x10,0,0,0},
{"TCSNum",0xFFFFFFFF,TCS_NUM_MIN,1,0},
{"TCSPolicy",TCS_POLICY_UNBIND,TCS_POLICY_BIND,TCS_POLICY_UNBIND,0},
{"StackMaxSize",0xFFFFFFFF,STACK_SIZE_MIN,0x40000,0},
{"HeapMaxSize",0xFFFFFFFF,HEAP_SIZE_MIN,0x100000,0},
{"StackMaxSize",0x1FFFFFFFFF,STACK_SIZE_MIN,0x40000,0},
{"HeapMaxSize",0x1FFFFFFFFF,HEAP_SIZE_MIN,0x100000,0},
{"MiscSelect", 0xFFFFFFFF, 0, DEFAULT_MISC_SELECT, 0},
{"MiscMask", 0xFFFFFFFF, 0, DEFAULT_MISC_MASK, 0}};