Security Peripheral Abstraction Layer - SECURITY PAL

Detailed Description

The SECURITY PAL provides security features over specific modules like:
-> Cryptographic Services Engine (CSEc)
-> Hardware Security Module (HSM)

Features

How to use the SECURITY PAL in your application

The SECURITY PAL is designed to be used in conjunction with CSEc driver or HSM driver, based on hardware platform. The SECURITY PAL can't be used simultaneously over different driver types.

The following table contains the matching between platforms and available IPs:

IP/MCUS32K116S32K142S32K144S32K146S32K148S32MTV MPC5746CMPC5748G
CSEC YES YES YES YES YES YES NO NO
HSM NO NO NO NO NO NO YES YES

The SECURITY PAL includes file security_pal_cfg.h, which allows the user to specify which IP is used and how many resources are allocated (state structure). The following code example shows how to configure one instance for one available security module.

#ifndef SECURITY_PAL_CFG_H
#define SECURITY_PAL_CFG_H
/* Define which IP instance will be used in current project */
#define SECURITY_OVER_CSEC
#define NO_OF_CSEC_INSTS_FOR_SECURITY 1
#endif /* SECURITY_PAL_CFG_H */

In order to use the SECURITY modules, the initialization procedure must be completed. Using the SECURITY_Init() function, the instance of the module is selected and configured using the user configuration structure.

The security features are available in two types: blocking and non-blocking. The blocking features have specified in their naming the 'blocking' attribute. All other functions are considered to be non-blocking. The blocking functions use the osif layer, providing timeout feature.

## Important Notes ##
## Example code ##
static security_user_config_t g_SecurityUserConfig;
void SecurityCallback(uint32_t completedCmd, void *callbackParam)
{
security_cmd_t securityCmd = (security_cmd_t)completedCmd;
switch (securityCmd)
{
/* Do something... */
break;
default:
/* Error... */
break;
}
}
void main()
{
static status_t status = STATUS_SUCCESS;
static uint8_t rndBuf[16];
g_SecurityUserConfig.callback = SecurityCallback;
status = SECURITY_Init(SECURITY_INSTANCE0, &g_SecurityUserConfig);
if(status != STATUS_SUCCESS)
{
/* Error... */
}
if(status != STATUS_SUCCESS)
{
/* Error... */
}
status = SECURITY_GenerateRnd(SECURITY_INSTANCE0, rndBuf, TIMEOUT);
if(status != STATUS_SUCCESS)
{
/* Error... */
}
while(1);
}

Modules

 Security PAL
 Security Peripheral Abstraction Layer.