TA-REF
tee-internal-api.c File Reference
#include "tee_api_tee_types.h"
#include "tee-common.h"
#include "tee-ta-internal.h"
#include "sgx_trts.h"
#include "sgx_utils.h"
#include "edger/Enclave_t.h"
#include <string.h>
+ Include dependency graph for tee-internal-api.c:

Functions

void __attribute__ ((noreturn))
 
void TEE_GetREETime (TEE_Time *time)
 Core Functions, Time Functions. More...
 
void TEE_GetSystemTime (TEE_Time *time)
 Core Functions, Time Functions. More...
 
TEE_Result GetRelTimeStart (uint64_t start)
 Core Functions, Time Functions. More...
 
TEE_Result GetRelTimeEnd (uint64_t end)
 Core Functions, Time Functions. More...
 
static int flags2flags (int flags)
 
static int set_object_key (const void *id, unsigned int idlen, TEE_ObjectHandle object)
 
static TEE_Result OpenPersistentObject (uint32_t storageID, const void *objectID, uint32_t objectIDLen, uint32_t flags, TEE_ObjectHandle *object, int ocreat)
 
TEE_Result TEE_CreatePersistentObject (uint32_t storageID, const void *objectID, uint32_t objectIDLen, uint32_t flags, TEE_ObjectHandle attributes, const void *initialData, uint32_t initialDataLen, TEE_ObjectHandle *object)
 Core Functions, Secure Storage Functions (data is isolated for each TA) More...
 
TEE_Result TEE_OpenPersistentObject (uint32_t storageID, const void *objectID, uint32_t objectIDLen, uint32_t flags, TEE_ObjectHandle *object)
 Core Functions, Secure Storage Functions (data is isolated for each TA) More...
 
TEE_Result TEE_GetObjectInfo1 (TEE_ObjectHandle object, TEE_ObjectInfo *objectInfo)
 Core Functions, Secure Storage Functions (data is isolated for each TA) More...
 
TEE_Result TEE_WriteObjectData (TEE_ObjectHandle object, const void *buffer, uint32_t size)
 Core Functions, Secure Storage Functions (data is isolated for each TA) More...
 
TEE_Result TEE_ReadObjectData (TEE_ObjectHandle object, void *buffer, uint32_t size, uint32_t *count)
 Core Functions, Secure Storage Functions (data is isolated for each TA) More...
 
void TEE_CloseObject (TEE_ObjectHandle object)
 Core Functions, Secure Storage Functions (data is isolated for each TA) More...
 
void TEE_GenerateRandom (void *randomBuffer, uint32_t randomBufferLen)
 Crypto, common. More...
 
static WC_RNG * get_wc_rng (void)
 

Variables

static int wc_rng_init = 0
 
static WC_RNG rngstr
 

Function Documentation

◆ __attribute__()

void __attribute__ ( (noreturn)  )

TEE_Panic() - Raises a Panic in the Trusted Application instance

When a Trusted Application calls the TEE_Panic function, the current instance shall be destroyed and all the resources opened by the instance shall be reclaimed.

Parameters
ecAn informative panic code defined by the TA. May be displayed in traces if traces are available.

◆ flags2flags()

static int flags2flags ( int  flags)
inlinestatic

flags2flags() - Checks the status for reading or writing of the file operational.

This function is to check the status for reading or writing of the file operational.

Parameters
flagsFlags of the referencing node.
Returns
0 if success else error occured.

◆ get_wc_rng()

static WC_RNG * get_wc_rng ( void  )
static

get_wc_rng() - Gets the seed (from OS) and key cipher for rng(random number genertor).

This function returns the random number or unique number of "rngstr".

Returns
random number if success else error occured.

◆ GetRelTimeEnd()

TEE_Result GetRelTimeEnd ( uint64_t  end)

Core Functions, Time Functions.

GetRelTimeStart() - find the real time of the end timing.

This function prints the End timing.

Parameters
endEnd timing
Returns
0 if success else error occured

◆ GetRelTimeStart()

TEE_Result GetRelTimeStart ( uint64_t  start)

Core Functions, Time Functions.

GetRelTimeStart() - Gets the real time of the start timing.

Ths function prints the start timing.

Parameters
startstart timing
Returns
0 if success else error occured.

◆ OpenPersistentObject()

static TEE_Result OpenPersistentObject ( uint32_t  storageID,
const void *  objectID,
uint32_t  objectIDLen,
uint32_t  flags,
TEE_ObjectHandle object,
int  ocreat 
)
static

OpenPersistentObject() - Opens a handle on an existing persistent object.

The flags parameter is a set of flags that controls the access rights and sharing permissions with which the object handle is opened. The value of the flags parameter is constructed by a bitwise-inclusive OR of flags TEE_DATA_FLAG_ACCESS_READ, the object is opened with the read access right. This allows the Trusted Application to call the function TEE_ReadObjectData. TEE_DATA_FLAG_ACCESS_WRITE, the object is opened with the write access right. TEE_DATA_FLAG_ACCESS_WRITE_META, the object is opened with the write-meta access right.

Parameters
storageIDThe storage to use.
objectIDThe object identifier
objectIDLenlength of the identifier
flagsThe flags which determine the settings under which the object is opened.
objectA pointer to the handle, which contains the opened handle upon successful completion.
Returns
0 if success else error occured.

◆ set_object_key()

static int set_object_key ( const void *  id,
unsigned int  idlen,
TEE_ObjectHandle  object 
)
static

set_object_key - To initalize report and then attest enclave with file.

This function describes objectID as key_id to make the key dependent on it sgx report key is 128-bit. Fill another 128-bit with seal key. seal key doesn't change with enclave. Better than nothing, though. random nonce can not use for AES here because of persistency. the digest of attestation report and objectID as the last resort has been used.

Parameters
idid of the object.
idlenlength of the id.
objectTEE_ObjectHandle type handle.
Returns
0 if success else error occured.

◆ TEE_CloseObject()

void TEE_CloseObject ( TEE_ObjectHandle  object)

Core Functions, Secure Storage Functions (data is isolated for each TA)

TEE_CloseObject() - Function closes an opened object handle.

The object can be persistent or transient.For transient objects, TEE_CloseObject is equivalent to TEE_FreeTransientObject.

Parameters
objectHandle of the object
Returns
TEE_SUCCESS if success else error occured.

◆ TEE_CreatePersistentObject()

TEE_Result TEE_CreatePersistentObject ( uint32_t  storageID,
const void *  objectID,
uint32_t  objectIDLen,
uint32_t  flags,
TEE_ObjectHandle  attributes,
const void *  initialData,
uint32_t  initialDataLen,
TEE_ObjectHandle object 
)

Core Functions, Secure Storage Functions (data is isolated for each TA)

TEE_CreatePersistentObject() - Creates a persistent object with initial attributes.

An initial data stream content, and optionally returns either a handle on the created object, or TEE_HANDLE_NULL upon failure.

Parameters
storageIDThe storage to use.
objectIDThe object identifier
objectIDLenThe object identifier
flagsThe flags which determine the settings under which the object is opened.
attributesA handle on a persistent object or an initialized transient object from which to take the persistent object attributes
initialDataThe initial data content of the persistent object
initialDataLenThe initial data content of the persistent object
objectA pointer to the handle, which contains the opened handle upon successful completion
Returns
0 if success, else error occured.

◆ TEE_GenerateRandom()

void TEE_GenerateRandom ( void *  randomBuffer,
uint32_t  randomBufferLen 
)

Crypto, common.

TEE_GenerateRandom() - Generates random data.

This function generates random data of random bufferlength and is stored in to randomBuffer by calling sgx_read_rand().

Parameters
randomBufferReference to generated random data
randomBufferLenByte length of requested random data

◆ TEE_GetObjectInfo1()

TEE_Result TEE_GetObjectInfo1 ( TEE_ObjectHandle  object,
TEE_ObjectInfo objectInfo 
)

Core Functions, Secure Storage Functions (data is isolated for each TA)

TEE_GetObjectInfo1() - Function returns the characteristics of an object.

It returns a handle that can be used to access the object’s attributes and data stream.

Parameters
objectInfoPointer to a structure filled with the object information
objectHandle of the object
Returns
0 if success else error occured.

◆ TEE_GetREETime()

void TEE_GetREETime ( TEE_Time time)

Core Functions, Time Functions.

TEE_GetREETime() - Function retrieves the current REE system time.

This function retrieves the current time as seen from the point of view of the REE.

Parameters
timeFilled with the number of seconds and milliseconds.

◆ TEE_GetSystemTime()

void TEE_GetSystemTime ( TEE_Time time)

Core Functions, Time Functions.

TEE_GetSystemTime() - Retrieves the current system time.

The system time has an arbitrary implementation-defined origin that can vary across TA instances

Parameters
timeFilled with the number of seconds and milliseconds.

◆ TEE_OpenPersistentObject()

TEE_Result TEE_OpenPersistentObject ( uint32_t  storageID,
const void *  objectID,
uint32_t  objectIDLen,
uint32_t  flags,
TEE_ObjectHandle object 
)

Core Functions, Secure Storage Functions (data is isolated for each TA)

TEE_OpenPersistentObject() - Opens a handle on an existing persistent object.

This function returns a handle that can be used to access the object’s attributes and data stream.

Parameters
storageIDThe storage to use.
objectIDThe object identifier
objectIDLenThe object identifier
flagsThe flags which determine the settings under which the object is opened.
objectA pointer to the handle, which contains the opened handle upon successful completion
Returns
0 if success, else error occured.

◆ TEE_ReadObjectData()

TEE_Result TEE_ReadObjectData ( TEE_ObjectHandle  object,
void *  buffer,
uint32_t  size,
uint32_t *  count 
)

Core Functions, Secure Storage Functions (data is isolated for each TA)

TEE_ReadObjectData() - Attempts to read size bytes from the data stream associated with the object object into the buffer pointed to by buffer.

The bytes are read starting at the position in the data stream currently stored in the object handle. The handle’s position is incremented by the number of bytes actually read. On completion TEE_ReadObjectData sets the number of bytes actually read in the uint32_t pointed to by count. The value written to *count may be less than size if the number of bytes until the end-of3067 stream is less than size. It is set to 0 if the position at the start of the read operation is at or beyond the end-of-stream. These are the only cases where *count may be less than size.

Parameters
objectHandle of the object
bufferThe buffer containing the data to be written
sizeThe number of bytes to write
countsize of the buffer.
Returns
TEE_SUCCESS if success, else error occured.

◆ TEE_WriteObjectData()

TEE_Result TEE_WriteObjectData ( TEE_ObjectHandle  object,
const void *  buffer,
uint32_t  size 
)

Core Functions, Secure Storage Functions (data is isolated for each TA)

TEE_WriteObjectData() - writes size bytes from the buffer pointed to by buffer to the data stream associated with the open object handle object.

If the current data position points before the end-of-stream, then size bytes are written to the data stream, overwriting bytes starting at the current data position. If the current data position points beyond the stream’s end, then the data stream is first extended with zero bytes until the length indicated by the data position indicator is reached, and then size bytes are written to the stream.

Parameters
objectHandle of the object
bufferThe buffer containing the data to be written
sizeThe number of bytes to write
Returns
TEE_SUCCESS if success else error occured.

Variable Documentation

◆ rngstr

WC_RNG rngstr
static

◆ wc_rng_init

int wc_rng_init = 0
static