Intel's documentation says here that if there is no previous launch token, an "invalid" token with all zeros should be used. This works perfectly in simulation mode, but in hardware mode it returns SGX_ERROR_INVALID_LAUNCH_TOKEN, even though that is exactly what it is asking for.
// Initialize an "invalid" first token, as the documentation specifies (all zeros)
sgx_launch_token_t token = {0};
// Create enclave
sgx_enclave_id_t id;
int updated = 0;
const auto status = sgx_create_enclave("enclave.signed.so", SGX_DEBUG_FLAG, &token, &updated, &id, NULL);
if (status != SGX_SUCCESS) {
throw "Failed to initialize enclave. (" + get_error_message(status) + ")";
}
The code returns status = SGX_ERROR_INVALID_LAUNCH_TOKEN
Failed to initialize enclave. (The launch token is not correct.)
Is there maybe anything I'm missing from the building process?