Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
9 Views

Pass variable-size buffer from SGX enclave to outside

I am trying to do a function with the following prototype:

void pass_buffer(void** buffer_out, size_t* buffer_out_len, const void* buffer_in, size_t buffer_in_len);

So the idea is to pass a buffer into the enclave, and then return a response in another buffer, which can vary in size, that size being stored in buffer_out_len.

I'm having trouble in defining the EDL function. So my idea was to do something like:

public void pass_buffer([out]void** buffer_out, [out]size_t* buffer_out_len, [in, size = buffer_in_len]const void* buffer_in, size_t buffer_in_len);

Now, that only returns a buffer filled with 0xff. I know I'm supposed to pass the length of the buffer with the size parameter, but using a pointer in size was not allowed:

public void pass_buffer([out, size = *buffer_out_len]void** buffer_out, [out]size_t* buffer_out_len, [in, size = buffer_in_len]const void* buffer_in, size_t buffer_in_len);

Is my last solution possible with another syntax? Or maybe by making the return value that size_t buffer_out_len? If so, how do I reference it from the size parameter in [out]?

Or maybe there is another way to do this kind of behaviour? Initialise a buffer of variable size and pass it to the outside?

Thanks so much.

0 Kudos
0 Replies