|
Safeheron-SGX-Native-Development-Framework v1.2.0
|
This module provides a comprehensive set of utility classes and functions for secure memory management, time handling, formatted operations, thread management, and other foundational functionalities in a Trusted Execution Environment (TEE). More...
Classes | |
| class | DateTime |
| Represents a specific point in time. Supports UTC/GMT time only. More... | |
| class | EnclaveInfo |
| Used to store some information related to the running enclave. (the eid corresponding to the running enclave) More... | |
| class | PreciseTime |
| Provides high-resolution time utilities for nanoseconds and milliseconds. More... | |
| class | SealHandler |
| Provides SGX sealing and unsealing operations. More... | |
| class | TimeSpan |
| Represents a span of time, providing utility functions for calculating days, hours, minutes, and seconds. More... | |
| struct | UnsealedData |
| Represents unsealed data, including decrypted text and optional additional MAC text. More... | |
| class | UUIDGenerator |
| A thread-safe UUID Generator that generates only UUID V4 (random-based). More... | |
Functions | |
| int | Printf (const char *fmt,...) |
| Print formatted data to stdout. | |
| std::string | FormatStr (const char *fmt,...) |
| Format args according to the format string fmt, and return the result as a string. | |
| void * | MallocOutside (size_t size) |
| Allocates size bytes of uninitialized storage outside the enclave. | |
| void * | CallocOutside (size_t num, size_t size) |
| Allocates memory outside the enclave for an array of num objects of size and initializes all bytes in the allocated storage to zero. | |
| void | FreeOutside (void *ptr_outside, size_t size) |
| Deallocates the space previously allocated by MallocOutside(), CallocOutside(). | |
| char * | StrndupOutside (const char *str_ptr, std::size_t str_len) |
| Duplicates a fixed-length C-style string to memory allocated outside the enclave. | |
| void * | MemcpyToOutside (void *dest_outside_enclave, const void *src, std::size_t count) |
| Copies count bytes from the object pointed to by src to the object outside the enclave pointed to by dest_outside_enclave. | |
| void * | MemdupOutside (const void *buf_ptr, std::size_t buf_size) |
| Duplicates a raw memory buffer to memory allocated outside the enclave. | |
| void | Sleep (uint32_t seconds) |
| Sleep for a specified number of seconds using OCall. | |
This module provides a comprehensive set of utility classes and functions for secure memory management, time handling, formatted operations, thread management, and other foundational functionalities in a Trusted Execution Environment (TEE).
The main functions are as follows:
| void * ssgx::utils_t::CallocOutside | ( | size_t | num, |
| size_t | size ) |
Allocates memory outside the enclave for an array of num objects of size and initializes all bytes in the allocated storage to zero.
| [in] | num | number of objects |
| [in] | size | size of each object |
| std::runtime_error | Throw the exception if the allocated memory is not outside the Enclave. |
| std::string ssgx::utils_t::FormatStr | ( | const char * | fmt, |
| ... ) |
Format args according to the format string fmt, and return the result as a string.
| [in] | format | C string that contains the text to be written to stdout. |
| std::bad_alloc | Throw the exception if memory allocation fails. |
| std::invalid_argument | Throw the exception if format string is null. |
| std::runtime_error | Throw the exception if formatting error in format_str. |
| void ssgx::utils_t::FreeOutside | ( | void * | ptr_outside, |
| size_t | size ) |
Deallocates the space previously allocated by MallocOutside(), CallocOutside().
| [in] | ptr | pointer to the memory to deallocate. |
| std::runtime_error | Throw the exception if the allocated memory is not outside the Enclave. |
| void * ssgx::utils_t::MallocOutside | ( | size_t | size | ) |
Allocates size bytes of uninitialized storage outside the enclave.
| [in] | size | number of bytes to allocate |
| std::runtime_error | Throw the exception if the allocated memory is not outside the Enclave. |
| void * ssgx::utils_t::MemcpyToOutside | ( | void * | dest_outside_enclave, |
| const void * | src, | ||
| std::size_t | count ) |
Copies count bytes from the object pointed to by src to the object outside the enclave pointed to by dest_outside_enclave.
Both objects are reinterpreted as arrays of unsigned char.
| [in] | dest_outside_enclave | pointer to the memory location to copy to. |
| [in] | src | pointer to the memory location to copy from. |
| [in] | count | number of bytes to copy. |
| std::runtime_error | Throw the exception if the allocated memory is not outside the Enclave. |
| void * ssgx::utils_t::MemdupOutside | ( | const void * | buf_ptr, |
| std::size_t | buf_size ) |
Duplicates a raw memory buffer to memory allocated outside the enclave.
This function allocates a buffer of buf_size bytes outside the enclave and performs a direct byte-wise copy from the source buf_ptr.
It is intended for transferring raw data (not necessarily strings) from enclave memory to untrusted memory regions, such as for returning binary data in OCALLs.
| [in] | buf_ptr | Pointer to the source memory. |
| [in] | buf_size | Number of bytes to copy. |
| int ssgx::utils_t::Printf | ( | const char * | fmt, |
| ... ) |
Print formatted data to stdout.
Writes the C string pointed by format to the standard output (stdout). If format includes format specifiers (subsequences beginning with %), the additional arguments following format are formatted and inserted in the resulting string replacing their respective specifiers.
| [in] | format | C string that contains the text to be written to stdout. |
| void ssgx::utils_t::Sleep | ( | uint32_t | seconds | ) |
Sleep for a specified number of seconds using OCall.
| seconds | The number of seconds to sleep. |
| char * ssgx::utils_t::StrndupOutside | ( | const char * | str_ptr, |
| std::size_t | str_len ) |
Duplicates a fixed-length C-style string to memory allocated outside the enclave.
This function allocates a new buffer outside the enclave and copies exactly str_len bytes from the input string str_ptr. A null terminator (‘’\0'`) is appended at the end to ensure the returned pointer is a valid null-terminated C string.
Security check is performed using strnlen(str_ptr, str_len + 1) to ensure the input buffer contains a valid string of exactly str_len characters.
| [in] | str_ptr | Pointer to the source C-string (need to be null-terminated). |
| [in] | str_len | Length of the string content (not including null terminator). |