Rtos API example

Embed: (wiki syntax)

« Back to documentation index

ccmLIB.h File Reference

ccmLIB.h File Reference

CCM Library API. More...

Go to the source code of this file.

Data Structures

struct  ccm_globals_t
 CCM global structure. The structure is used for configuring NONCE, adata and data before calling ccm_process_run(). More...

Functions

void arm_ccm_mutex_lock (void)
 A function for locking CCM mutex if the OS is multi thread.
void arm_ccm_mutex_unlock (void)
 A function for unlocking CCM mutex if the OS is multi thread.
ccm_globals_tccm_sec_init (uint8_t sec_level, const uint8_t *ccm_key, uint8_t mode, uint8_t ccm_l)
 A function to initialize the CCM library.
int8_t ccm_process_run (ccm_globals_t *ccm_params)
 A function to run the configured CCM process.

Detailed Description

CCM Library API.

CCM Library API:

CCM process sequence:

1. Init CCM library by, ccm key, ccm_sec_init()

  • security level
  • 128-bit CCM key
  • mode: AES_CCM_ENCRYPT or AES_CCM_DECRYPT
  • CCM L parameter: 2 or 3 depending on the nonce length (802.15.4 use 2 and TLS security use 3) 2. Define ADATA pointer and length, if returned global structure mic_len field is > 0 3. Set data pointer and length 4. Do configured CCM process ccm_process_run() 5. Check return value: -If 0 Process ok -< 0 MIC fail or parameter fail

CCM Mutex for Multi Thread System

If you are running a multi thread system and the CCM library will be used for multiple thread, do the following: 1. Add compiler flag to library build process CCM_USE_MUTEX. 2. Define OS-specific mutex at the application. 3. Implement arm_ccm_mutex_lock() arm_ccm_mutex_unlock() function for using the generated and initialized mutex.

Definition in file ccmLIB.h.


Function Documentation

void arm_ccm_mutex_lock ( void   )

A function for locking CCM mutex if the OS is multi thread.

If you are using single thread create an empty function.

void arm_ccm_mutex_unlock ( void   )

A function for unlocking CCM mutex if the OS is multi thread.

If you are using single thread create an empty function

int8_t ccm_process_run ( ccm_globals_t ccm_params )

A function to run the configured CCM process.

When AES_CCM_ENCRYPT mode is selected and MIC is needed, the library saves MIC right after the encrypted data.

Parameters:
ccm_paramsCCM parameters
Returns:
0 CCM process OK and when AES_CCM_DECRYPT mode was selected also MIC was correct.
-1 Init not called or data or adata pointers or lengths are zero.
-2 Null pointer given to function.
ccm_globals_t* ccm_sec_init ( uint8_t  sec_level,
const uint8_t *  ccm_key,
uint8_t  mode,
uint8_t  ccm_l 
)

A function to initialize the CCM library.

Parameters:
sec_levelUsed CCM security level (0-7).
ccm_keyPointer to 128-key.
modeAES_CCM_ENCRYPT or AES_CCM_DECRYPT.
ccm_lCan be 2 or 3. 2 when NONCE length is 13 and 3 when 12. (NONCE length = (15-ccm_l))
Returns:
Pointer to Global CCM parameter buffer.
0 When parameter fails or CCM is busy.