Browse Source

Put back the sgx_stub_t type

Don Porter 6 years ago
parent
commit
f35d690992

+ 3 - 3
Pal/src/host/Linux-SGX/db_files.c

@@ -65,7 +65,7 @@ static int file_open (PAL_HANDLE * handle, const char * type, const char * uri,
     get_norm_path(uri, path, 0, len + 1);
     hdl->file.realpath = (PAL_STR) path;
 
-    sgx_arch_mac_t * stubs;
+    sgx_stub_t * stubs;
     uint64_t total;
     int ret = load_trusted_file(hdl, &stubs, &total);
     if (ret < 0) {
@@ -86,7 +86,7 @@ static int file_open (PAL_HANDLE * handle, const char * type, const char * uri,
 static int file_read (PAL_HANDLE handle, int offset, int count,
                       void * buffer)
 {
-    sgx_arch_mac_t * stubs = (sgx_arch_mac_t *) handle->file.stubs;
+    sgx_stub_t * stubs = (sgx_stub_t *) handle->file.stubs;
     unsigned int total = handle->file.total;
     int ret;
 
@@ -179,7 +179,7 @@ static int file_delete (PAL_HANDLE handle, int access)
 static int file_map (PAL_HANDLE handle, void ** addr, int prot,
                      uint64_t offset, uint64_t size)
 {
-    sgx_arch_mac_t * stubs = (sgx_arch_mac_t *) handle->file.stubs;
+    sgx_stub_t * stubs = (sgx_stub_t *) handle->file.stubs;
     unsigned int total = handle->file.total;
     void * mem = *addr;
     void * umem;

+ 7 - 7
Pal/src/host/Linux-SGX/enclave_framework.c

@@ -112,14 +112,14 @@ struct trusted_file {
     int             uri_len;
     char            uri[URI_MAX];
     sgx_checksum_t  checksum;
-    sgx_arch_mac_t *    stubs;
+    sgx_stub_t *    stubs;
 };
 
 static LIST_HEAD(trusted_file_list);
 static struct spinlock trusted_file_lock = LOCK_INIT;
 static int trusted_file_indexes = 0;
 
-int load_trusted_file (PAL_HANDLE file, sgx_arch_mac_t ** stubptr,
+int load_trusted_file (PAL_HANDLE file, sgx_stub_t ** stubptr,
                        uint64_t * sizeptr)
 {
     struct trusted_file * tf = NULL, * tmp;
@@ -169,10 +169,10 @@ int load_trusted_file (PAL_HANDLE file, sgx_arch_mac_t ** stubptr,
 
     _DkSpinUnlock(&trusted_file_lock);
 
-    if (!tf) 
+    if (!tf)
         return -PAL_ERROR_DENIED;
 
-    if (tf->index < 0) 
+    if (tf->index < 0)
         return tf->index;
 
 #if CACHE_FILE_STUBS == 1
@@ -197,11 +197,11 @@ int load_trusted_file (PAL_HANDLE file, sgx_arch_mac_t ** stubptr,
     int nstubs = tf->size / TRUSTED_STUB_SIZE +
                 (tf->size % TRUSTED_STUB_SIZE ? 1 : 0);
 
-    sgx_arch_mac_t * stubs = malloc(sizeof(sgx_arch_mac_t) * nstubs);
+    sgx_stub_t * stubs = malloc(sizeof(sgx_stub_t) * nstubs);
     if (!stubs)
         return -PAL_ERROR_NOMEM;
 
-    sgx_arch_mac_t * s = stubs;
+    sgx_stub_t * s = stubs;
     uint64_t offset = 0;
     PAL_SHA256_CONTEXT sha;
     void * umem;
@@ -278,7 +278,7 @@ failed:
 
 int verify_trusted_file (const char * uri, void * mem,
                          unsigned int offset, unsigned int size,
-                         sgx_arch_mac_t * stubs,
+                         sgx_stub_t * stubs,
                          unsigned int total_size)
 {
     unsigned long checking = offset;

+ 3 - 2
Pal/src/host/Linux-SGX/pal_linux.h

@@ -92,13 +92,14 @@ extern char __text_start, __text_end, __data_start, __data_end;
 #define DATA_END   (void *) (&__text_end)
 
 typedef struct { char bytes[32]; } sgx_checksum_t;
+typedef struct { char bytes[16]; } sgx_stub_t;
 
 int init_trusted_files (void);
 int load_trusted_file
-    (PAL_HANDLE file, sgx_arch_mac_t ** stubptr, uint64_t * sizeptr);
+    (PAL_HANDLE file, sgx_stub_t ** stubptr, uint64_t * sizeptr);
 int verify_trusted_file
     (const char * uri, void * mem, unsigned int offset, unsigned int size,
-     sgx_arch_mac_t * stubs, unsigned int total_size);
+     sgx_stub_t * stubs, unsigned int total_size);
 
 int init_trusted_children (void);
 int register_trusted_child (const char * uri, const char * mrenclave_str);