Unsupported C++ Standard Libraries in Intel® SGX enclaves
Why is it not possible to use std::stringstream in an enclave?
Stringstream is part of <iostream> which is not supported by Intel SGX. The Intel SGX SDK Developer Reference Guide states:
"As for the C++ standard library, most functions will work just as its untrusted counterpart, but here is a high-level summary of features that are not supported inside the enclave:
- I/O related functions and classes, like <iostream>;
- Functions depending on a locale library;
- Any other functions that require system calls."
The Unsupported C++ Standard Classes and Functions section contains a table, titled Input/Output Library, in which iostream is listed as not supported.
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 SampleEnclave example in the SGX Software Development Kit (SGX SDK) demonstrates how to implement an ocall for using printf within an enclave.