30.12.2015 Views

Intel SGX Enclave Support in Windows 10 Fall Update (Threshold 2)

1ks6upt

1ks6upt

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Enclave</strong> Lifetime Management<br />

There are two f<strong>in</strong>al operations that can be performed on an enclave, now that it has been created. The<br />

first, and most critical, is to actually <strong>in</strong>itialize the enclave, which will beg<strong>in</strong> code execution <strong>in</strong> <strong>SGX</strong> mode,<br />

us<strong>in</strong>g all the accumulated data that has been specified so far. Related to <strong>in</strong>itialization, once <strong>SGX</strong> execution<br />

has completed, the non-enclave caller must take care to destroy the enclave, <strong>in</strong> order to release all <strong>SGX</strong><br />

resources.<br />

Initializ<strong>in</strong>g an <strong>Enclave</strong><br />

The last step that a developer must take to utilize enclave technology is to <strong>in</strong>itialize it, and the<br />

Initialize<strong>Enclave</strong> API, shown below, does exactly that:<br />

BOOL<br />

WINAPI<br />

Initialize<strong>Enclave</strong> (<br />

_In_ HANDLE hProcess,<br />

_In_ LPVOID lpAddress,<br />

_In_ LPVOID lp<strong>Enclave</strong>Information,<br />

_In_ DWORD dwInfoLength,<br />

_In_ LPDWORD lp<strong>Enclave</strong>Error<br />

);<br />

With this data, Initialize<strong>Enclave</strong> once aga<strong>in</strong> does noth<strong>in</strong>g more than perform<strong>in</strong>g the follow<strong>in</strong>g system call:<br />

_Must_<strong>in</strong>spect_result_<br />

NTSYSAPI<br />

NTSTATUS<br />

NTAPI<br />

NtInitialize<strong>Enclave</strong> (<br />

_In_ HANDLE ProcessHandle,<br />

_In_ PVOID BaseAddress,<br />

_In_reads_bytes_(<strong>Enclave</strong>InformationLength)<br />

CONST VOID *<strong>Enclave</strong>Information,<br />

_In_ ULONG <strong>Enclave</strong>InformationLength,<br />

_Out_opt_ PULONG <strong>Enclave</strong>Error<br />

);<br />

The first two, and last parameters are hopefully noth<strong>in</strong>g new by now. But there’s a new enclave<br />

<strong>in</strong>formation structure, and associated size, that must be passed <strong>in</strong>. For <strong>SGX</strong> enclaves, this corresponds to<br />

the ENCLAVE_INIT_INFO_<strong>SGX</strong> structure, shown below:<br />

typedef struct _ENCLAVE_INIT_INFO_<strong>SGX</strong><br />

{<br />

UCHAR SigStruct[1808];<br />

UCHAR Reserved1[240];

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!