EDL (enclave definition language) is an open file format created by Intel, originally for their
SGX hardware enclaves. It's a text format (loosely resembling C), with a simple grammar, that
can be used as an intermediary definition language (idl) to declare functions that can be called
between both the hostApp and the enclave. You define your own types (such as enums and structs),
declare host-to-enclave function calls in the trusted scope, and enclave-to-host function calls
in the untrusted scope.
An .edl file is what our code generation tool uses to generate functions that interact with our ABI
layer to marshal data between the hostApp and the enclave.
The tool generates stub functions and function declarations based on the content of the .edl file. The developer is expected to implement the generated function declarations.
Note
Both Open Enclave's and Intel's parsers were made specifically for working in a C environment, however we're using it for higher level languages like C++. Because of this, we have updated our parser to be C++ centric, to allow for more types. See the supported types below for more information.
Here is the general structure and grammar of our .edl format.
\\ Single line comment
\* Multi line comment *\
enclave
{
import "<path_to_edl_file.edl>"; // Importing another edl file
enum // Anonymous enum
{
<enum_name>,
};
enum <Enum> // Regular enum
{
// enum_value can only be a decimal, Hexidecimal or value from an anonymous enum
<enum_field> = <enum_value>,
};
struct <Struct>
{
// field_type can be any supported edl type.
<field_type> <field_name>;
};
trusted
{
<return_type> <EnclaveMethod>(
[attr] <parameter_type> <parameter_name>
);
};
untrusted
{
<return_type> <HostappMethod>(
[attr] <parameter_type> <parameter_name>
);
};
};
| Term | Description |
|---|---|
return_type |
Defines the return value type, which must be one of the supported types. |
parameter_type |
Defines a parameter's type. Must be one of the supported types. |
parameter_name |
Defines a parameter's name. |
attr |
Directives describing the parameter's direction (e.g., [in], [in, out], [out]). |
EnclaveMethod |
Methods exposed from the secure enclave to the unsecure hostApp.The hostApp calls stub functions, while the implementation is inside the enclave. |
HostappMethod |
Methods exposed from the unsecure hostApp to the secure enclave.The enclave calls stub functions, while the implementation is inside the hostApp. |
A simple example of a .edl file.
enclave {
import "EdlFiles\Crypto\Types.edl";
struct ExampleStruct
{
int32_t int_field;
vector<wstring> wstrings;
};
trusted {
int32_t EnclaveAddTwoNums(
int32_t num1,
int32_t num2
);
HRESULT SecondaryExample (
[in, out] ExampleStruct,
vector<int8_t> bytes // a data blob
);
};
untrusted {
int32_t HostAddTwoNums(
int32_t num1,
int32_t num2
);
};
};
| Category | Types |
|---|---|
| Basic Types | char, wchar_t, float, double, size_t, HRESULT |
| Integer Types | int8_t, int16_t, int32_t, int64_tuint8_t, uint16_t,uint32_t, uint64_t, uintptr_t |
| String Types | string, wstring |
| Complex Types | enum, struct |
| Array Types | Arrays in the form of type name[value] (e.g., uint8_t numbers[10]) |
| Vector Types | Vectors in the form of vector<type> (e.g., vector<string>) |
| Optional Types | Optionals in the form of optional<type> (e.g., optional<MyStruct>) |
Note
vectors,arraysandstructsonly support the types outlined above.vectorsandarrayscan be used as internal struct fields or function parameters.arrayscan contain a non-numeric value within the edl file. The only value it supports other than numeric values is a value from an anonymous enum.arraysare considered fixed-sized, and inC++are generated as astd::arrayduring code generation.optionaltypes only supportbasic types,integer types,enumsandstructtypes.
Example showing how using an anonymous enum value can be used with an array in a .edl file.
enum
{
my_number = 50
};
struct
{
uint32_t my_array[my_number]; // This also works in a function declaration.
};| Applies To | C++ Generated Type |
|---|---|
| All types | <Type> |
With [in] attribute
| Applies To | C++ Generated Type |
|---|---|
string, wstring, array, vector, struct, optional |
const <Type>& |
basic, integer, enum |
<Type> |
With [in, out] attribute
| Applies To | C++ Generated Type |
|---|---|
| All types | <Type>& |
With [out] attribute
| Applies To | C++ Generated Type |
|---|---|
| All types | <Type>& |
| Applies To | C++ Generated Type |
|---|---|
| All types | <Type> |
You can import other .edl files into your .edl file using the import keyword. This allows you
to reuse types and function declarations across multiple .edl files.
Note
The edlcodegen.exe provides the --ImportDirectories option to specify the directories where it should
look for imported .edl files.
The paths inside --ImportDirectories must be absolute paths to directories that exist.
You can specify multiple directories by separating them with a semicolon (;).
While our .edl parser is based on Open Enclave's implementation of Intel's .edl parser, there are some
things we do not support:
privateandpublickeywords for the function names of both trusted and untrusted functions.COM\WinRTis not supported inside avbs enclave. e.gEvents,RuntimeClassesetc.- The concept of switchless calls is not encouraged, so the
switchlesskeyword is unsupported. - Calling conventions (like
cdecl,stdcall,fastcall) are not supported. - Ability to import
C headersinto an.edlfile to allow for types defined outside the.edlfile is not supported. Only types defined in the.edlare supported. - The words
stringandwstringare supported type keywords within an.edlfile. Using the wordstringorwstringas an attribute is not supported. - Only the following attributes are supported
[in],[in, out],[out]in function declarations. The[in]attribute means the parameter is expected to only be used in the function as input. The[out]attribute means the parameter is expected to be used as output and lastly[in, out]means the parameter can be used for both. If no attributes are specified, parameters default to[in]. - Pointers (
*) are not supported. void*is not supported instruct fieldsorfunction parameters. Useuintptr_tfor arbitrary pointers or handles, and manually cast and manage the memory when moving data into or out of the enclave- The
constkeyword is not supported.