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

Functions

void * TEE_Malloc (uint32_t size, uint32_t hint)
 
void * TEE_Realloc (void *buffer, uint32_t newSize)
 
void TEE_Free (void *buffer)
 
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 (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...
 
WC_RNG * get_wc_rng (void)
 
int wc_ocall_genseed (void *nonce, uint32_t len)
 
void TEE_GenerateRandom (void *randomBuffer, uint32_t randomBufferLen)
 Crypto, common. More...
 

Variables

static int wc_rng_init = 0
 
static WC_RNG rngstr
 

Function Documentation

◆ flags2flags()

static int flags2flags ( int  flags)
inlinestatic

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

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

Parameters
flagsFlags of the referencing node.
Returns
ret if success.

◆ get_wc_rng()

WC_RNG * get_wc_rng ( void  )

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.

GetRelTimeEnd() - finds the real time of the end timing.

This function prints the ending time.

Parameters
endEnd timing
Returns
0 If success

◆ GetRelTimeStart()

TEE_Result GetRelTimeStart ( uint64_t  start)

Core Functions, Time Functions.

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

This function prints the starting time.

Parameters
startStart timing
Returns
0 on success

◆ 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 ( void *  id,
unsigned int  idlen,
TEE_ObjectHandle  object 
)
static

set_object_key() - Initialize report and then attest enclave with file.

This function describes the intialization of report, attest the enclave with file id and its length then assigned to ret. Based on "mbedtls" key encryption and decryption position of the object will be copied. Finally ret value returns on success else signature too short error will appear on failure.

Parameters
idid of the object.
idlenlength of the id.
objectTEE_ObjectHandle type handle.
Returns
ret if success.

◆ TEE_CloseObject()

void TEE_CloseObject ( TEE_ObjectHandle  object)

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

TEE_CloseObject() - 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.

In this function an initial data stream content 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_Free()

void TEE_Free ( void *  buffer)

TEE_Free() - causes the space pointed to by buffer to be deallocated;that is made available for further allocation.

This function describes if buffer is a NULL pointer, TEE_Free does nothing. Otherwise, it is a Programmer Error if the argument does not match a pointer previously returned by the TEE_Malloc or TEE_Realloc if the space has been deallocated by a call to TEE_Free or TEE_Realloc.

Parameters
bufferThe pointer to the memory block to be freed.

◆ TEE_GenerateRandom()

void TEE_GenerateRandom ( void *  randomBuffer,
uint32_t  randomBufferLen 
)

Crypto, common.

TEE_GenerateRandom() - Generates random data.

This function generates random data of random buffer length and is stored in to random Buffer by calling wc_RNG_GenerateBlock().If ret is not equal
to 0 then TEE_Panic is called.

Parameters
randomBufferReference to generated random data
randomBufferLenByte length of requested random data
Returns
random data random data will be returned.

◆ 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() - Returns the characteristics of an object.

This function returns a handle which 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() - 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.

This function describes the system time has an arbitrary implementation
defined origin that can vary across TA instances. The minimum guarantee
is that the system time shall be monotonic for a given TA instance.

Parameters
timeFilled with the number of seconds and milliseconds

◆ TEE_Malloc()

void * TEE_Malloc ( uint32_t  size,
uint32_t  hint 
)

TEE_Malloc() - Allocates space for an object whose size in bytes is specified in the parameter size.

This function describes the pointer returned is guaranteed to be aligned
such that it may be assigned as a pointer to any basic C type.The valid hint values are a bitmask and can be independently set. This parameter allows Trusted Applications to refer to various pools of memory or to
request special characteristics for the allocated memory by using an
implementation-defined hint. Future versions of this specification may introduce additional standard hints.

Parameters
sizeThe size of the buffer to be allocated.
hintA hint to the allocator.
Returns
Upon successful completion, with size not equal to zero, the function returns a pointer to the allocated space.

◆ 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 which 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 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 of 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_Realloc()

void * TEE_Realloc ( void *  buffer,
uint32_t  newSize 
)

TEE_Realloc() - Changes the size of the memory object pointed to by buffer to the size specified by new size.

This function describes the content of the object remains unchanged up to the lesser of the new and old sizes. Space in excess of the old size contains unspecified content. If the new size of the memory object requires movement of the object, the space for the previous instantiation of the object is deallocated. If the space cannot be allocated, the original object remains allocated, and this function returns a NULL pointer.

Parameters
bufferThe pointer to the object to be reallocated.
newSizeThe new size required for the object
Returns
Upon successful completion, TEE_Realloc returns a pointer to the (possibly moved) allocated space. If there is not enough available memory, TEE_Realloc returns a NULL pointer and the original buffer is still allocated and unchanged.

◆ 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 the buffer data in to persistent objects.

In this function it checks if object is present or not, the encryption/ decryption buffer is taken by calling mbedtls_aes_crypt_cbc() then that buffer data is encrypted and mapped to object.On the base of object creation TEE_SUCCESS appears else TEE_ERROR_GENERIC appears.

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.

◆ wc_ocall_genseed()

int wc_ocall_genseed ( void *  nonce,
uint32_t  len 
)

wc_ocall_genseed() To generate random data.

This function describes the return value of random generated data. if generated random value is not equal to length of buffer then panic
reason occurs.

Parameters
noncepointer of buffer
lenlength of the buffer.
Returns
0 on success else error will occur based on panic raised inside trusted application.

Variable Documentation

◆ rngstr

WC_RNG rngstr
static

◆ wc_rng_init

int wc_rng_init = 0
static

ocall_getrandom() - For getting random data.

This function describes that the retval is returned based on the size of buffer by calling the functions ocall_getrandom196 and ocall_getrandom16

Parameters
bufcharacter type buffer
lensize of the buffer
flagsunassigned integer flag
Returns
retval value will be returned based on length of buffer.