intel / intel/confidential-computing.sgx.sdk

How to capture the time duration inside an enclave?

Open
#146 5 comments 0 reactions 0 assignees View on GitHub
question
Dominant language
C++
Stars
2
Forks
3
PR merge metrics
No merged PRs in 30d

Description

I'm new to intel sgx. I need an accurate timekeeper in enclave, preferably down to the millisecond.

1. I trying to use **std::chrono**.
I write ` #include ` in enclave.cpp and test it inside an enclave function, but the error is reported as below:
```
Enclave/Enclave.cpp:476:24: error: ‘std::chrono’ has not been declared
476 | auto begin1 = std::chrono::high_resolution_clock::now();
| ^~~~~~
```

2. I trying to use **time.h**.
I write` #include ` in enclave.cpp, but it still gives me the following error:
```
Enclave/Enclave.cpp:482:5: error: ‘time’ was not declared in this scope
482 | time(&t1);
| ^~~~
```

The Enclave_Link_Flags in makefile:
```
Enclave_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \
$(SgxSSL_Link_Libraries) \
-L/opt/intel/sgxsdk/lib64 \
-L/opt/gmp/6.1.2/lib \
$(Enclave_Security_Link_Flags) \
-L$(SGX_LIBRARY_PATH) \
-Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \
-Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \
-Wl,--start-group -lsgx_tstdc -lsgx_tgmp -lsgx_pthread -lsgx_tcxx -l$(Crypto_Library_Name) -l$(Service_Library_Name) \
-l$(SGX_TVL_Library_Name) -lsgx_ttls -Wl,--end-group \
-Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \
-Wl,-pie,-eenclave_entry -Wl,--export-dynamic \
-Wl,--defsym,__ImageBase=0 -Wl,--gc-sections \
-Wl,--version-script=Enclave/Enclave.lds
```

Contributor guide

Open the contributing guide

Research direction

Start with Enclave/Enclave.cpp and the shown Enclave_Link_Flags in the Makefile, then review which timing facilities the SGX enclave environment supports. Reproduce the reported std::chrono and time.h compilation errors and determine a supported approach with millisecond accuracy; done means the approach is documented and works inside an enclave.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
security
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.