My Project
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Functions
otz_tee_api.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <string.h>
#include <otz_tee_client_api.h>
#include <otz_client.h>
#include <otz_id.h>
#include <otz_common.h>

Functions

char * TEEC_GetError (int error, int returnOrigin)
 Returns error string. More...
 
TEEC_Result TEEC_InitializeContext (const char *name, TEEC_Context *context)
 Initialize Context. More...
 
void TEEC_FinalizeContext (TEEC_Context *context)
 Finalizes an initialized TEE context. More...
 
TEEC_Result TEEC_AllocateSharedMemory (TEEC_Context *context, TEEC_SharedMemory *sharedMem)
 Allocate a shared memory block. More...
 
TEEC_Result TEEC_RegisterSharedMemory (TEEC_Context *context, TEEC_SharedMemory *sharedMem)
 Register a allocated shared memory block. More...
 
void TEEC_ReleaseSharedMemory (TEEC_SharedMemory *sharedMem)
 Release a shared memory block. More...
 
TEEC_Result TEEC_OpenSession (TEEC_Context *context, TEEC_Session *session, const TEEC_UUID *destination, uint32_t connectionMethod, const void *connectionData, TEEC_Operation *operation, uint32_t *returnOrigin)
 Open a session with a Trusted application. More...
 
void TEEC_CloseSession (TEEC_Session *session)
 Closes a session which has been opened with trusted application. More...
 
TEEC_Result TEEC_InvokeCommand (TEEC_Session *session, uint32_t commandID, TEEC_Operation *operation, uint32_t *returnOrigin)
 Invokes a command within the specified session. More...
 
void TEEC_RequestCancellation (TEEC_Operation *operation)
 Requests the cancellation of a pending open Session operation or a Command invocation operation. More...
 
void strncpy_safe (char *dst, const char *src, size_t n)
 copies n size of string src to string dst More...
 
void * memncpy (void *dst, const void *src, unsigned int count, unsigned int dst_len, unsigned int src_len)
 

Function Documentation

void* memncpy ( void *  dst,
const void *  src,
unsigned int  count,
unsigned int  dst_len,
unsigned int  src_len 
)
void strncpy_safe ( char *  dst,
const char *  src,
size_t  n 
)

copies n size of string src to string dst

Parameters
dstdestination string
srcsource string
nlength of string to be copied
TEEC_Result TEEC_AllocateSharedMemory ( TEEC_Context context,
TEEC_SharedMemory sharedMem 
)

Allocate a shared memory block.

Parameters
contextPointer to the context
sharedMemPointer to the shared memory
Returns
TEEC_Result: TEEC_SUCCESS: The allocation was successful.
TEEC_ERROR_*: An implementation-defined error code for any other error.
void TEEC_CloseSession ( TEEC_Session session)

Closes a session which has been opened with trusted application.

Close a opened session between client and trusted application.

Parameters
sessionPointer to the session structure
void TEEC_FinalizeContext ( TEEC_Context context)

Finalizes an initialized TEE context.

Parameters
contextAn initialized TEEC_Context structure which is to be finalized.
char* TEEC_GetError ( int  error,
int  returnOrigin 
)

Returns error string.

This function returns the error string value based on error number and return origin.

Parameters
errorError number.
returnOriginOrigin of the return.
Returns
char*: Error string value.
TEEC_Result TEEC_InitializeContext ( const char *  name,
TEEC_Context context 
)

Initialize Context.

Parameters
nameA zero-terminated string that describes the TEE to connect to. If this parameter is set to NULL the Implementation MUST select a default TEE.
contextA TEEC_Context structure that MUST be initialized by the Implementation.
Returns
TEEC_Result: TEEC_SUCCESS: The initialization was successful.
TEEC_ERROR_*: An implementation-defined error code for any other error.
TEEC_Result TEEC_InvokeCommand ( TEEC_Session session,
uint32_t  commandID,
TEEC_Operation operation,
uint32_t returnOrigin 
)

Invokes a command within the specified session.

Invokes a command within the session.

Parameters
sessionPointer to session
commandIDCommand ID
operationPointer to operation structure
returnOriginPointer to the return origin
Returns
TEEC_Result: TEEC_SUCCESS: The command was successfully invoked.
TEEC_ERROR_*: An implementation-defined error code for any other error.
TEEC_Result TEEC_OpenSession ( TEEC_Context context,
TEEC_Session session,
const TEEC_UUID destination,
uint32_t  connectionMethod,
const void *  connectionData,
TEEC_Operation operation,
uint32_t returnOrigin 
)

Open a session with a Trusted application.

Opens a new session between client and trusted application.

Parameters
contextPointer to the context
sessionPointer to the session
destinationService UUID
connectionMethodConnection method
connectionDataConnection data used for authentication
operationPointer to optional operation structure
returnOriginPointer to the return origin
Returns
TEEC_Result: TEEC_SUCCESS: The session was successfully opened.
TEEC_ERROR_*: An implementation-defined error code for any other error.
TEEC_Result TEEC_RegisterSharedMemory ( TEEC_Context context,
TEEC_SharedMemory sharedMem 
)

Register a allocated shared memory block.

Parameters
contextPointer to the context
sharedMemPointer to the shared memory
Returns
TEEC_Result: TEEC_SUCCESS: The device was successfully opened.
TEEC_ERROR_*: An implementation-defined error code for any other error.
void TEEC_ReleaseSharedMemory ( TEEC_SharedMemory sharedMem)

Release a shared memory block.

Parameters
sharedMemPointer to the shared memory
void TEEC_RequestCancellation ( TEEC_Operation operation)

Requests the cancellation of a pending open Session operation or a Command invocation operation.

Request cancellation of pending open session or command invocation.

Parameters
operationPointer to TEEC operation structure