POST
HelloWorld: my first SGX application
A simple sample code to get started with the SGX application development.
- New create VC++
Win32 Console Application
. The project name isHelloWorld
. - Create new VC++
Intel SGX Enclave project
. Use default project nameEnclave1
. - Edit
Enclave1.edl
file with below code. This piece of code declares thefoo()
method as a trusted method and executes at trusted zone.
Edit Enclave1.cpp
. Realize the foo()
method.
- Set the
Enclave1
project configuration as below. - Build the
Enclave1
project. Above result shows theEnclave1
project has been build successfully. Next I need to add it into theHelloWorld
project and call thefoo()
methods. - Edit the
main()
method ofHelloWorld.cpp
file.
- Set the
HelloWorld
project configuration. - Add the
Enclave1
project into theHelloWorld
project. Right click ‘Solution HelloWorld’ -> add -> existing project and selectEnclave1
project. Now there are two projects under the ‘Solution HelloWorld’. right clickHelloWorld
project -> Intel SGX Configuration -> Import Enclave SelectEnclave1.edl
.
TheEnclave1.edl
file will be envoloved into the source ofHelloWorld
project. - Since the
HelloWorld
project is the main project, I need to add the dependency ofEnclave1
project. Set the main project. Set the dependency. - The configuration is done!
Build the main project and start to run. - Unfortunately, the trying is failed with the below error.
That is because my CPU cannot support SGX at present. I have to change the running mode to Simulation.
I got below result, which means my first app was runing well.