- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Intel Community,
May I ask how can I use std::cout at Enclave.cpp? And time(), rand() and srand() of C standard libraries?
I have tried above functions, but it reports undefined reference error for time(), rand() and srand(). And error: cout is not a member of std, when I has written #include <iostream> reference. Thank you!
I attach the code for your review:) if needed. You can make at the root, and then ./app
Have a nice day!
Best Regards,
Jin Xin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello MoonHasSevenColor,
Thanks for your patience.
Referring to Page 472 in Intel® SGX Developer Reference Linux 2.20 Open Source document, std::cout from class <iostream> is not supported by Intel® SGX. As a workaround to accessing <iostream> functions within an Enclave, create an Ocall that calls the <iostream> functions in the untrusted app on behalf of the enclave.
The following example in the Intel® SGX Software Development Kit (Intel® SGX) demonstrates how to implement an Ocall for using printf within an enclave:
https://github.com/intel/linux-sgx/tree/master/SampleCode/SampleEnclave
On another note, referring to pages 468 and 469 in Intel® SGX Developer Reference Linux 2.20 Open Source document, time(), rand(), and srand() are not supported by Intel® SGX. As a workaround for rand() and srand(), enclave developers should use the sgx_read_rand function to get true random numbers.
For more information, please refer to the following page in Intel® SGX Developer Reference Linux 2.20 Open Source document and links:
- Page 466 - Unsupported C Standard Functions
- Page 469 - Unsupported C++ Standard Classes and Functions
- https://www.intel.com/content/www/us/en/support/articles/000058765/software/intel-security-products.html
- https://github.com/intel/linux-sgx/tree/master/SampleCode
Regards,
Wan
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello MoonHasSevenColor,
Thanks for reaching out to us.
Let me check with relevant team and I'll update you as soon as possible.
Regards,
Wan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello MoonHasSevenColor,
Thanks for your patience.
Referring to Page 472 in Intel® SGX Developer Reference Linux 2.20 Open Source document, std::cout from class <iostream> is not supported by Intel® SGX. As a workaround to accessing <iostream> functions within an Enclave, create an Ocall that calls the <iostream> functions in the untrusted app on behalf of the enclave.
The following example in the Intel® SGX Software Development Kit (Intel® SGX) demonstrates how to implement an Ocall for using printf within an enclave:
https://github.com/intel/linux-sgx/tree/master/SampleCode/SampleEnclave
On another note, referring to pages 468 and 469 in Intel® SGX Developer Reference Linux 2.20 Open Source document, time(), rand(), and srand() are not supported by Intel® SGX. As a workaround for rand() and srand(), enclave developers should use the sgx_read_rand function to get true random numbers.
For more information, please refer to the following page in Intel® SGX Developer Reference Linux 2.20 Open Source document and links:
- Page 466 - Unsupported C Standard Functions
- Page 469 - Unsupported C++ Standard Classes and Functions
- https://www.intel.com/content/www/us/en/support/articles/000058765/software/intel-security-products.html
- https://github.com/intel/linux-sgx/tree/master/SampleCode
Regards,
Wan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear Wan,
Sorry for the late reply! Thank you for your patient and nice answer, it helps a lot. Thank you!
Best Regards,
Jin Xin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello MoonHasSevenColor,
Thanks for your question.
If you need additional information from Intel, please submit a new question as this thread will no longer be monitored.
Regards,
Wan
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page