Snapdragon® Telematics Application Framework (TelAF) Interface Specification
taf_ks_client.c File Reference
#include "taf_ks_interface.h"
#include "taf_ks_messages.h"
#include "taf_ks_service.h"

Data Structures

struct  _ClientThreadData_t
 

Macros

#define LOCK_INIT   le_mutex_Lock(le_ifgen_InitMutexRef);
 Locks the mutex. More...
 
#define UNLOCK_INIT   le_mutex_Unlock(le_ifgen_InitMutexRef);
 Unlocks the mutex. More...
 

Functions

 LE_MEM_DEFINE_STATIC_POOL (taf_ks_ClientThreadData, LE_CDATA_COMPONENT_COUNT, sizeof(_ClientThreadData_t))
 
static le_result_t InitClientForThread (bool isBlocking)
 
static _ClientThreadData_tGetClientThreadDataPtr (void)
 
 __attribute__ ((unused))
 
static void ClientThreadDestructor (void *objPtr)
 
static void InitCommonData (void)
 
static le_result_t DoConnectService (bool isBlocking)
 
void taf_ks_ConnectService (void)
 
le_result_t taf_ks_TryConnectService (void)
 
static void SessionCloseHandler (le_msg_SessionRef_t sessionRef, void *contextPtr)
 
void taf_ks_SetServerDisconnectHandler (taf_ks_DisconnectHandler_t disconnectHandler, void *contextPtr)
 
static void NonExitSessionCloseHandler (le_msg_SessionRef_t sessionRef, void *contextPtr)
 
void taf_ks_SetNonExitServerDisconnectHandler (taf_ks_DisconnectHandler_t disconnectHandler, void *contextPtr)
 
void taf_ks_DisconnectService (void)
 
le_result_t taf_ks_CreateKey (const char *LE_NONNULL keyName, taf_ks_KeyUsage_t keyUsage, taf_ks_KeyRef_t *keyRefPtr)
 
le_result_t taf_ks_GetKey (const char *LE_NONNULL keyName, taf_ks_KeyRef_t *keyRefPtr)
 
le_result_t taf_ks_DeleteKey (taf_ks_KeyRef_t keyRef)
 
le_result_t taf_ks_GetKeyUsage (taf_ks_KeyRef_t keyRef, taf_ks_KeyUsage_t *keyUsagePtr)
 
le_result_t taf_ks_SetKeyMaxUsesPerBoot (taf_ks_KeyRef_t keyRef, uint32_t value)
 
le_result_t taf_ks_SetKeyMinSecondsBetweenOps (taf_ks_KeyRef_t keyRef, uint32_t value)
 
le_result_t taf_ks_SetKeyAppData (taf_ks_KeyRef_t keyRef, const uint8_t *dataPtr, size_t dataSize)
 
le_result_t taf_ks_SetKeyActiveDateTime (taf_ks_KeyRef_t keyRef, uint64_t value)
 
le_result_t taf_ks_SetKeyOriginationExpireDateTime (taf_ks_KeyRef_t keyRef, uint64_t value)
 
le_result_t taf_ks_SetKeyUsageExpireDateTime (taf_ks_KeyRef_t keyRef, uint64_t value)
 
le_result_t taf_ks_ProvisionRsaEncKeyValue (taf_ks_KeyRef_t keyRef, taf_ks_RsaKeySize_t keySize, taf_ks_RsaEncPadding_t padding, const uint8_t *impDataPtr, size_t impDataSize)
 
le_result_t taf_ks_ProvisionRsaSigKeyValue (taf_ks_KeyRef_t keyRef, taf_ks_RsaKeySize_t keySize, taf_ks_RsaSigPadding_t padding, const uint8_t *impDataPtr, size_t impDataSize)
 
le_result_t taf_ks_ProvisionEcdsaKeyValue (taf_ks_KeyRef_t keyRef, taf_ks_EccKeySize_t keySize, taf_ks_Digest_t digest, const uint8_t *impDataPtr, size_t impDataSize)
 
le_result_t taf_ks_ProvisionAesKeyValue (taf_ks_KeyRef_t keyRef, taf_ks_AesKeySize_t keySize, taf_ks_AesBlockMode_t mode, const uint8_t *impDataPtr, size_t impDataSize)
 
le_result_t taf_ks_ProvisionHmacKeyValue (taf_ks_KeyRef_t keyRef, uint32_t keySize, taf_ks_Digest_t digest, const uint8_t *impDataPtr, size_t impDataSize)
 
le_result_t taf_ks_ExportKey (taf_ks_KeyRef_t keyRef, const uint8_t *appDataPtr, size_t appDataSize, uint8_t *expDataPtr, size_t *expDataSizePtr)
 
le_result_t taf_ks_CryptoSessionCreate (taf_ks_KeyRef_t keyRef, taf_ks_CryptoSessionRef_t *sessionRefPtr)
 
le_result_t taf_ks_CryptoSessionSetAesNonce (taf_ks_CryptoSessionRef_t sessionRef, const uint8_t *dataPtr, size_t dataSize)
 
le_result_t taf_ks_CryptoSessionSetAppData (taf_ks_CryptoSessionRef_t sessionRef, const uint8_t *dataPtr, size_t dataSize)
 
le_result_t taf_ks_CryptoSessionStart (taf_ks_CryptoSessionRef_t sessionRef, taf_ks_CryptoPurpose_t cryptoPurpose)
 
le_result_t taf_ks_CryptoSessionProcessAead (taf_ks_CryptoSessionRef_t sessionRef, const uint8_t *dataPtr, size_t dataSize)
 
le_result_t taf_ks_CryptoSessionProcess (taf_ks_CryptoSessionRef_t sessionRef, const uint8_t *inputDataPtr, size_t inputDataSize, uint8_t *outputDataPtr, size_t *outputDataSizePtr)
 
le_result_t taf_ks_CryptoSessionEnd (taf_ks_CryptoSessionRef_t sessionRef, const uint8_t *inputDataPtr, size_t inputDataSize, uint8_t *outputDataPtr, size_t *outputDataSizePtr)
 
le_result_t taf_ks_CryptoSessionAbort (taf_ks_CryptoSessionRef_t sessionRef)
 

Variables

static le_mem_PoolRef_t _ClientThreadDataPool
 
static pthread_key_t _ThreadDataKey
 
static bool CommonDataInitialized = false
 
le_mutex_Ref_t le_ifgen_InitMutexRef
 

Macro Definition Documentation

◆ LOCK_INIT

#define LOCK_INIT   le_mutex_Lock(le_ifgen_InitMutexRef);

Locks the mutex.

◆ UNLOCK_INIT

#define UNLOCK_INIT   le_mutex_Unlock(le_ifgen_InitMutexRef);

Unlocks the mutex.

Function Documentation

◆ LE_MEM_DEFINE_STATIC_POOL()

LE_MEM_DEFINE_STATIC_POOL ( taf_ks_ClientThreadData  ,
LE_CDATA_COMPONENT_COUNT  ,
sizeof(_ClientThreadData_t  
)

Static pool for client threads.

◆ InitClientForThread()

static le_result_t InitClientForThread ( bool  isBlocking)
static

Initialize thread specific data, and connect to the service for the current thread.

Returns
  • LE_OK if the client connected successfully to the service.
  • LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
  • LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
  • LE_COMM_ERROR if the Service Directory cannot be reached.

◆ GetClientThreadDataPtr()

static _ClientThreadData_t* GetClientThreadDataPtr ( void  )
static

Get a pointer to the client thread data for the current thread.

If the current thread does not have client data, then NULL is returned

◆ __attribute__()

__attribute__ ( (unused)  )

Return the sessionRef for the current thread.

If the current thread does not have a session ref, then this is a fatal error.

◆ ClientThreadDestructor()

static void ClientThreadDestructor ( void *  objPtr)
static

Destructor function for client thread objects.

◆ InitCommonData()

static void InitCommonData ( void  )
static

Init data that is common across all threads.

◆ DoConnectService()

static le_result_t DoConnectService ( bool  isBlocking)
static

Connect to the service, using either blocking or non-blocking calls.

This function implements the details of the public ConnectService functions.

Returns
  • LE_OK if the client connected successfully to the service.
  • LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
  • LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
  • LE_COMM_ERROR if the Service Directory cannot be reached.

◆ taf_ks_ConnectService()

void taf_ks_ConnectService ( void  )

Connect the current client thread to the service providing this API. Block until the service is available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see apiFilesC_client.

This function is created automatically.

◆ taf_ks_TryConnectService()

le_result_t taf_ks_TryConnectService ( void  )

Try to connect the current client thread to the service providing this API. Return with an error if the service is not available.

For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see apiFilesC_client.

This function is created automatically.

Returns
  • LE_OK if the client connected successfully to the service.
  • LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
  • LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
  • LE_COMM_ERROR if the Service Directory cannot be reached.

◆ SessionCloseHandler()

static void SessionCloseHandler ( le_msg_SessionRef_t  sessionRef,
void *  contextPtr 
)
static

◆ taf_ks_SetServerDisconnectHandler()

void taf_ks_SetServerDisconnectHandler ( taf_ks_DisconnectHandler_t  disconnectHandler,
void *  contextPtr 
)

Set handler called when server disconnection is detected.

When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants to continue without exiting, it should call longjmp() from inside the handler.

◆ NonExitSessionCloseHandler()

static void NonExitSessionCloseHandler ( le_msg_SessionRef_t  sessionRef,
void *  contextPtr 
)
static

◆ taf_ks_SetNonExitServerDisconnectHandler()

void taf_ks_SetNonExitServerDisconnectHandler ( taf_ks_DisconnectHandler_t  disconnectHandler,
void *  contextPtr 
)

Set handler called when server disconnection is detected without exiting.

When a server connection is lost, call this handler without exit.

Warning
When using the API, it needs the application developer to handle some cases like re-connecting and recycling the resources. For most of cases, it is safe to use SetServerDisconnectHandler.

◆ taf_ks_DisconnectService()

void taf_ks_DisconnectService ( void  )

Disconnect the current client thread from the service providing this API.

Normally, this function doesn't need to be called. After this function is called, there's no longer a connection to the service, and the functions in this API can't be used. For details, see apiFilesC_client.

This function is created automatically.

◆ taf_ks_CreateKey()

le_result_t taf_ks_CreateKey ( const char *LE_NONNULL  keyName,
taf_ks_KeyUsage_t  keyUsage,
taf_ks_KeyRef_t keyRefPtr 
)

Creates a new key.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_PERMITTED – Key already exists.
  • LE_FAULT – Error.
Parameters
[in]keyNameKey name.
[in]keyUsageKey usage.
[out]keyRefPtrKey reference.

◆ taf_ks_GetKey()

le_result_t taf_ks_GetKey ( const char *LE_NONNULL  keyName,
taf_ks_KeyRef_t keyRefPtr 
)

Gets a key by key name.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – The key does not exist or is not provisioned.
  • LE_FAULT – Error.
Parameters
[in]keyNameKey name.
[out]keyRefPtrKey reference.

◆ taf_ks_DeleteKey()

le_result_t taf_ks_DeleteKey ( taf_ks_KeyRef_t  keyRef)

Deletes a key by key reference.

Returns
  • LE_OK – Succeeded.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key has a running cryptography session.
  • LE_FAULT – Error.
Parameters
[in]keyRefKey reference.

◆ taf_ks_GetKeyUsage()

le_result_t taf_ks_GetKeyUsage ( taf_ks_KeyRef_t  keyRef,
taf_ks_KeyUsage_t keyUsagePtr 
)

Gets a key's usage.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Key does not exist.
  • LE_FAULT – Error.
Parameters
[in]keyRefKey reference.
[out]keyUsagePtrKey usage.

◆ taf_ks_SetKeyMaxUsesPerBoot()

le_result_t taf_ks_SetKeyMaxUsesPerBoot ( taf_ks_KeyRef_t  keyRef,
uint32_t  value 
)

Sets the maximum number of times a key may be used between system reboots.

Returns
  • LE_OK – Succeeded.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is already provisioned.
Parameters
[in]keyRefKey reference.
[in]valueUses per boot.

◆ taf_ks_SetKeyMinSecondsBetweenOps()

le_result_t taf_ks_SetKeyMinSecondsBetweenOps ( taf_ks_KeyRef_t  keyRef,
uint32_t  value 
)

Sets the minimum amount of time that elapses between allowed operations using a key.

Returns
  • LE_OK – Succeeded.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is already provisioned.
Parameters
[in]keyRefKey reference.
[in]valueSeconds interval between allowed operations.

◆ taf_ks_SetKeyAppData()

le_result_t taf_ks_SetKeyAppData ( taf_ks_KeyRef_t  keyRef,
const uint8_t *  dataPtr,
size_t  dataSize 
)

Sets application data to the key.

When this attribute is provided to the key, the same data must be also provided through taf_ks_CryptoSessionSetAppData() for each cryptographic operation using the key.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is already provisioned.
Parameters
[in]keyRefKey reference.
[in]dataPtrData buffer to hold the application data.
[in]dataSize

◆ taf_ks_SetKeyActiveDateTime()

le_result_t taf_ks_SetKeyActiveDateTime ( taf_ks_KeyRef_t  keyRef,
uint64_t  value 
)

Sets the date and time at which the key becomes active. Any attempt to use the key prior to this time will fail.

Returns
  • LE_OK – Succeeded.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is already provisioned.
Parameters
[in]keyRefKey reference.
[in]valueMilliseconds since January 1, 1970.

◆ taf_ks_SetKeyOriginationExpireDateTime()

le_result_t taf_ks_SetKeyOriginationExpireDateTime ( taf_ks_KeyRef_t  keyRef,
uint64_t  value 
)

Sets the date and time at which the key expires for signing and encryption. Any attempt to use a key for signing or encryption after this time will fail.

Returns
  • LE_OK – Succeeded.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is already provisioned.
Parameters
[in]keyRefKey reference.
[in]valueMilliseconds since January 1, 1970.

◆ taf_ks_SetKeyUsageExpireDateTime()

le_result_t taf_ks_SetKeyUsageExpireDateTime ( taf_ks_KeyRef_t  keyRef,
uint64_t  value 
)

Sets the date and time at which the key expires for verification and decryption. Any attempt to use a key for verification and decryption after this time will fail.

Returns
  • LE_OK – Succeeded.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is already provisioned.
Parameters
[in]keyRefKey reference.
[in]valueMilliseconds since January 1, 1970.

◆ taf_ks_ProvisionRsaEncKeyValue()

le_result_t taf_ks_ProvisionRsaEncKeyValue ( taf_ks_KeyRef_t  keyRef,
taf_ks_RsaKeySize_t  keySize,
taf_ks_RsaEncPadding_t  padding,
const uint8_t *  impDataPtr,
size_t  impDataSize 
)

Provisons or imports a RSA encryption key value to the newly created key.

The impData parameter, if provided, shall hold PKCS#8 DER format of RSA key data for import.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is already provisioned, is not suitable for this provision, or is not created by the client.
  • LE_FAULT – Error.
Parameters
[in]keyRefKey reference.
[in]keySizeKey size. Shall match the import key size if impData is provided.
[in]paddingPadding type of RSA encryption key.
[in]impDataPtrImported key data.
[in]impDataSize

◆ taf_ks_ProvisionRsaSigKeyValue()

le_result_t taf_ks_ProvisionRsaSigKeyValue ( taf_ks_KeyRef_t  keyRef,
taf_ks_RsaKeySize_t  keySize,
taf_ks_RsaSigPadding_t  padding,
const uint8_t *  impDataPtr,
size_t  impDataSize 
)

Provisions or imports a RSA signing key value to the newly created key.

The impData parameter, if provided, shall hold PKCS#8 DER format of RSA key data for import.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is already provisioned, is not suitable for this provision, or is not created by the client.
  • LE_FAULT – Error.
Parameters
[in]keyRefKey reference.
[in]keySizeKey size. Shall match the import key size if impData is provided.
[in]paddingPadding type of RSA signing key.
[in]impDataPtrImported key data.
[in]impDataSize

◆ taf_ks_ProvisionEcdsaKeyValue()

le_result_t taf_ks_ProvisionEcdsaKeyValue ( taf_ks_KeyRef_t  keyRef,
taf_ks_EccKeySize_t  keySize,
taf_ks_Digest_t  digest,
const uint8_t *  impDataPtr,
size_t  impDataSize 
)

Provisions or imports an ECDSA key value to the newly created key.

The impData parameter, if provided, shall hold PKCS#8 DER format of ECDSA key data for import.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is already provisioned, is not suitable for this provision, or is not created by the client.
  • LE_FAULT – Error.
Parameters
[in]keyRefKey reference.
[in]keySizeKey size. Shall match the import key size if impData is provided.
[in]digestDigest.
[in]impDataPtrImported key data.
[in]impDataSize

◆ taf_ks_ProvisionAesKeyValue()

le_result_t taf_ks_ProvisionAesKeyValue ( taf_ks_KeyRef_t  keyRef,
taf_ks_AesKeySize_t  keySize,
taf_ks_AesBlockMode_t  mode,
const uint8_t *  impDataPtr,
size_t  impDataSize 
)

Provisions or imports an AES key value to the newly created key.

The impData parameter, if provided, shall hold the AES raw key data for import.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is already provisioned, is not suitable for this provision, or is not created by the client.
  • LE_FAULT – Error.
Parameters
[in]keyRefKey reference.
[in]keySizeKey size. Shall match the import key size if impData is provided.
[in]modeAES block mode.
[in]impDataPtrImported key data.
[in]impDataSize

◆ taf_ks_ProvisionHmacKeyValue()

le_result_t taf_ks_ProvisionHmacKeyValue ( taf_ks_KeyRef_t  keyRef,
uint32_t  keySize,
taf_ks_Digest_t  digest,
const uint8_t *  impDataPtr,
size_t  impDataSize 
)

Provisions or imports a HMAC key value to the newly created key.

The impData parameter, if provided, shall hold the HMAC raw key data for import.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is already provisioned, is not suitable for this provision, or is not created by the client.
  • LE_FAULT – Error.
Parameters
[in]keyRefKey reference.
[in]keySizeKey size. Shall match the import key size if impData is provided.
[in]digestDigest.
[in]impDataPtrImported key data.
[in]impDataSize

◆ taf_ks_ExportKey()

le_result_t taf_ks_ExportKey ( taf_ks_KeyRef_t  keyRef,
const uint8_t *  appDataPtr,
size_t  appDataSize,
uint8_t *  expDataPtr,
size_t *  expDataSizePtr 
)

Exports a key into the specified key data format.

For asymmetric key exports the x.509 DER format (SubjectPublicKeyInfo) public key. Currently symmetric key exports are not supported.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameter(s).
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is not provisioned or the key is not created by the client.
  • LE_FAULT – Error.
Parameters
[in]keyRefKey reference.
[in]appDataPtrData buffer to hold the application data.
[in]appDataSize
[out]expDataPtrExported key data.
[in,out]expDataSizePtr

◆ taf_ks_CryptoSessionCreate()

le_result_t taf_ks_CryptoSessionCreate ( taf_ks_KeyRef_t  keyRef,
taf_ks_CryptoSessionRef_t sessionRefPtr 
)

Creates a cryptographic operation session for a key.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Key does not exist.
  • LE_NOT_PERMITTED – Key is not provisioned.
Parameters
[in]keyRefKey to use for this cryptographic session.
[out]sessionRefPtrSession reference.

◆ taf_ks_CryptoSessionSetAesNonce()

le_result_t taf_ks_CryptoSessionSetAesNonce ( taf_ks_CryptoSessionRef_t  sessionRef,
const uint8_t *  dataPtr,
size_t  dataSize 
)

Sets the nonce or IVs for AES GCM, CBC, CTR for a cryptographic session. For AES GCM the nonce size must be 12 bytes, for AES CBC, CTR the IV must be 16 bytes.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Session or key does not exist.
  • LE_NOT_PERMITTED – Key is not provisioned or the session is not created by the client.
Parameters
[in]sessionRefSession reference.
[in]dataPtrData buffer to hold the nonce or IV.
[in]dataSize

◆ taf_ks_CryptoSessionSetAppData()

le_result_t taf_ks_CryptoSessionSetAppData ( taf_ks_CryptoSessionRef_t  sessionRef,
const uint8_t *  dataPtr,
size_t  dataSize 
)

Sets the application data for a cryptographic session.

This API must be called before taf_ks_CryptoSessionStart() if the key has set the attribute of application data by taf_ks_SetKeyAppData().

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Session or key does not exist.
  • LE_NOT_PERMITTED – Key is not provisioned or the session is not created by the client.
Parameters
[in]sessionRefSession reference.
[in]dataPtrData buffer to hold the application data.
[in]dataSize

◆ taf_ks_CryptoSessionStart()

le_result_t taf_ks_CryptoSessionStart ( taf_ks_CryptoSessionRef_t  sessionRef,
taf_ks_CryptoPurpose_t  cryptoPurpose 
)

Starts the cryptographic session for the given operation. The cryptographic session is automatically deleted if an error occurs.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Session or key does not exist.
  • LE_NOT_PERMITTED – Key is not provisioned or the session is not created by the client.
  • LE_DUPLICATE – Session is already started.
  • LE_FAULT – Error.
Parameters
[in]sessionRefSession reference.
[in]cryptoPurposeCryptographic operation purpose.

◆ taf_ks_CryptoSessionProcessAead()

le_result_t taf_ks_CryptoSessionProcessAead ( taf_ks_CryptoSessionRef_t  sessionRef,
const uint8_t *  dataPtr,
size_t  dataSize 
)

Provides AEAD to an AES GCM crypto session started with taf_ks_CryptoSessionStart(). This API can be called multiple times before taf_ks_CryptoSessionProcess() and the cryptographic session will be automatically deleted if an error occurs.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Session or key does not exist.
  • LE_NOT_PERMITTED – Key is not provisioned, the session is not created by the client, or the session is not started.
  • LE_FAULT – Error.
Parameters
[in]sessionRefSession reference.
[in]dataPtrData buffer to hold the AEAD data.
[in]dataSize

◆ taf_ks_CryptoSessionProcess()

le_result_t taf_ks_CryptoSessionProcess ( taf_ks_CryptoSessionRef_t  sessionRef,
const uint8_t *  inputDataPtr,
size_t  inputDataSize,
uint8_t *  outputDataPtr,
size_t *  outputDataSizePtr 
)

Provides data to, and possibly receives output from, a running cryptographic session started with taf_ks_CryptoSessionStart(). It can be called multiple times before taf_ks_CryptoSessionEnd() is called. The crypto session is automatically deleted if an error occurs.

Returns
  • LE_OK – Succeeded.
  • LE_BAD_PARAMETER – Bad parameters.
  • LE_NOT_FOUND – Session or the key does not exist.
  • LE_NOT_PERMITTED – Key is not provisioned, the session is not created by the client, or the session is not started.
  • LE_FAULT – Error.
Parameters
[in]sessionRefSession reference.
[in]inputDataPtrInputData can be one of the following cases.
  1. Plain text for encryption session.
  2. Cipher text for decryption session.
  3. Message to sign for signing session.
  4. Message to verify for verification session.
[in]inputDataSize
[out]outputDataPtrOutputData can be one of the following cases.
  1. Encrypted data for encryption session.
  2. Decrypted data for decryption session.
  3. Shall set NULL for signing and verification sessions.
[in,out]outputDataSizePtr

◆ taf_ks_CryptoSessionEnd()

le_result_t taf_ks_CryptoSessionEnd ( taf_ks_CryptoSessionRef_t  sessionRef,
const uint8_t *  inputDataPtr,
size_t  inputDataSize,
uint8_t *  outputDataPtr,
size_t *  outputDataSizePtr 
)

Finalizes the cryptographic session started with taf_ks_CryptoSessionStart(). This API shall be called once all input data is processed by taf_ks_CryptoSessionProcess(). The cryptographic session will be deleted automatically.

Returns
  • LE_OK – Succeeded.
  • LE_NOT_FOUND – Session or key does not exist.
  • LE_NOT_PERMITTED – Key is not provisioned, the session is not created by the client, or the session is not started.
  • LE_FAULT – Error.
Parameters
[in]sessionRefSession reference.
[in]inputDataPtrSignature to verify for verification session and shall set to NULL for other sessions.
[in]inputDataSize
[out]outputDataPtrOutputData can be one of the following cases.
  1. Encrypted data for encryption session.
  2. Decrypted data for decryption session.
  3. Signature for signing session.
  4. Shall set to NULL for verfication session.
[in,out]outputDataSizePtr

◆ taf_ks_CryptoSessionAbort()

le_result_t taf_ks_CryptoSessionAbort ( taf_ks_CryptoSessionRef_t  sessionRef)

Aborts the cryptographic session started with taf_ks_CryptoSessionStart(). The cryptographic session will be deleted automatically.

Returns
  • LE_OK – Succeeded.
  • LE_NOT_FOUND – Session or key does not exist.
  • LE_NOT_PERMITTED – Key is not provisioned, the session is not created by the client, or the session is not started.
  • LE_FAULT – Error.
Parameters
[in]sessionRefSession reference.

Variable Documentation

◆ _ClientThreadDataPool

le_mem_PoolRef_t _ClientThreadDataPool
static

The memory pool for client thread objects

◆ _ThreadDataKey

pthread_key_t _ThreadDataKey
static

Key under which the pointer to the Thread Object (_ClientThreadData_t) will be kept in thread-local storage. This allows a thread to quickly get a pointer to its own Thread Object.

◆ CommonDataInitialized

bool CommonDataInitialized = false
static

This global flag is shared by all client threads, and is used to indicate whether the common data has been initialized.

Warning
Use InitMutex, defined below, to protect accesses to this data.

◆ le_ifgen_InitMutexRef

le_mutex_Ref_t le_ifgen_InitMutexRef

Mutex and associated macros for use with the above CommonDataInitialized.