Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
681 views
in Technique[技术] by (71.8m points)

stl - C++ Arguments to SGX Enclave Edge Functions

I'm trying to write a simple SGX enclave that takes in a vector of booleans, but apparently edger8r creates c code; so the edl code

enclave{

  from "sgx_tstdc.edl" import *;
  include "BetaDist.h"
  include <vector>

  trusted {
         BetaDist Estimate(std::vector<bool> X, double max_z, double max_delta); 
  };

  untrusted {
  };
};

produces a compile error (Amusingly, the Intel compiler reports it under the title "catastrophic error") saying header vector can't be found.

It seems to me that the problem can be solved just by compiling the output edge code with a c++ flag. Would that work? Even if so, is there a cleaner way to do this (i.e. having edge functions with C++ standard-typed parameters)?

PS: I don't have enough rep to add a new tag, would anyone tag this with 'edger8r'? It'll be helpful I think.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

#include is incorrect EDL syntax. No need for hash - include

Arguments in ecalls and ocalls have to be C type - so, vector and bool are not supported.

For vector you need to convert it into C type (maybe create a struct or void pointer), then pass a pointer with its length.

For bool, I guess, better to pass an int to represent a Boolean value.

You also have to specify special attribute for pointers:

  • [in] - if you want to copy it into enclave (you also need to specify its length) (aka pass by value)
  • [out] - if you want to copy back from enclave
  • [user_check] - the easiest option - you just pass a pointer and enclave will read from and write to untrusted memory. (aka pass by pointer)

Do not forget to cast arguments back into C++ types!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...