| Samsung Internal API reference 2.0

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

Data Structures | Functions
Miscellaneous extensions
Samsung Internal API

## Data Structures
struct | TEES_ClientCredentials
| Client credentials structure. Used by TEES_GetClientCredentials(). More...

## Functions
int | TEES_GetTaskDataSize (size_t *data_size)
| Get used size of data memory of the current Trusted Application instance. More...
void * | TEES_DupIwshmem (void *address, uint32_t size)
| Make long-life duplicate of an Interworld Shared memory buffer. More...
TEE_Result | TEES_IsREESharedMemory (uint32_t accessFlags, const void *buffer, size_t size)
| Check is buffer shared with REE. More...
TEE_Result | TEES_GetClientCredentials (struct TEES_ClientCredentials *credentials)
| Get client credentials (pid, gid, uid) More...

## Detailed Description

Provides set of miscellaneous Samsung's extension of TEE Internal API.

## Data Structure Documentation

struct TEES_ClientCredentials

Client credentials structure. Used by TEES_GetClientCredentials().

Data Fields
int | gid | Group ID of client caller
int | pid | Process ID of client
int | uid | User ID of client caller

## Function Documentation

void* TEES_DupIwshmem | ( | void * | address,
|  | uint32_t | size
| ) |  |

`#include <tees_extension.h>`

Make long-life duplicate of an Interworld Shared memory buffer.

The TEES_DupIwshmem will make a copy of Interworld Shared memory buffer, that was passed in TEE_Param[] on TA entry. This copy became accessible by current Trusted Application instance during current and all the following TA entries, even if the buffer is not passed in TEE_Param[] anymore or TA entry have no TEE_Param argument at all. If buffer became not needed, TA may release it by calling munmap().

Parameters

  [in] | address | Interworld Shared memory buffer.
  [in] | size | Buffer size.

Returns
  Pointer to a copied buffer or NULL on error.

TEE_Result TEES_GetClientCredentials | ( | struct TEES_ClientCredentials * | credentials | ) |

`#include <tees_extension.h>`

Get client credentials (pid, gid, uid)

TEES_GetClientCredentials fills struct pointed to by a parameter `credentials` with client's credentials. The client can be a CA employing TEE Client API or TA using Internal Client API. For full list of values see definition of `struct TEES_ClientCredentials`.

Parameters

  [out] | credentials | Structure to fill with values of client credentials

Return values

  TEE_SUCCESS | On success.
  TEE_ERROR_BAD_PARAMETERS | When called with `credentials == NULL`.
  TEE_RESULT_NOT_READY | If called when client session does not exist, i.e. in TA_CreateEntryPoint() or TA_DestroyEntryPoint().

Example:

struct TEES_ClientCredentials creds;
TEE_Result res;
if ((res = TEES_GetClientCredentials(&creds)) == TEE_SUCCESS) {
printf("CA pid = %d, ...\n", creds.pid);
} else {
// handle error
}

int TEES_GetTaskDataSize | ( | size_t * | data_size | ) |

`#include <tees_extension.h>`

Get used size of data memory of the current Trusted Application instance.

Parameters

  [out] | data_size | Output data memory size.

Return values

  0 | On success.
  -1 | On error. In this case errno is set with appropriate error code.

TEE_Result TEES_IsREESharedMemory | ( | uint32_t | accessFlags,
|  | const void * | buffer,
|  | size_t | size
| ) |  |

`#include <tees_extension.h>`

Check is buffer shared with REE.

The TEES_IsREESharedMemory examines memory buffer passed in a parameters buffer and size to determine whether Trusted Application instance can access buffer accordingly to requested accessFlags and buffer can be accessed by REE. If the characteristics of the buffer are compatible with accessFlags and REE can access this buffer, then the function returns TEE_SUCCESS. Otherwise, it returns TEE_ERROR_ACCESS_DENIED. Function should be used only to determine whether buffer shared. To determine whether buffer accessible exclusively by Trusted Application (not shared) use the TEE_CheckMemoryAccessRights.

The parameter accessFlags can contain one or more of the following flags:

- TEE_MEMORY_ACCESS_READ: Check that the buffer is entirely readable by the current Trusted Application instance.
- TEE_MEMORY_ACCESS_WRITE: Check that the buffer is entirely writable by the current Trusted Application instance. All other flags are reserved for future use and MUST be set to 0.

This function MUST NOT panic for any reason.

Parameters

  [in] | accessFlags | The access flags to check.
  [in] | buffer | Pointer of the buffer to check.
  [in] | size | Size of the buffer to check.

Return values

  TEE_SUCCESS | If the entire buffer allows the requested accesses.
  TEE_ERROR_ACCESS_DENIED | If at least one byte in the buffer is not accessible with the requested accesses or REE may not access this buffer.
  TEE_ERROR_BAD_PARAMETERS | If passed zero or unknown accessFlags.