S32 SDK
csec_driver.c File Reference
#include "csec_driver.h"

Go to the source code of this file.

Macros

#define CSEC_PAGE_SIZE_IN_BYTES   (16U)
 
#define CSEC_DATA_PAGES_AVAILABLE   (7U)
 
#define CSEC_DATA_BYTES_AVAILABLE   (112U)
 
#define CSEC_BYTES_TO_FROM_PAGES_SHIFT   (4U)
 
#define CSEC_BYTES_TO_FROM_BITS_SHIFT   (3U)
 
#define CSEC_M1_SIZE_IN_BYTES   (16U)
 
#define CSEC_M2_SIZE_IN_BYTES   (32U)
 
#define CSEC_M3_SIZE_IN_BYTES   (16U)
 
#define CSEC_M4_SIZE_IN_BYTES   (32U)
 
#define CSEC_M5_SIZE_IN_BYTES   (16U)
 

Functions

void FTFC_IRQHandler (void)
 
static void CSEC_DRV_InitState (csec_key_id_t keyId, csec_cmd_t cmd, const uint8_t *inBuff, uint8_t *outBuff, uint32_t length)
 
static uint32_t CSEC_DRV_RoundTo (uint32_t value, uint32_t roundTo)
 
static void CSEC_DRV_StartEncDecECBCmd (void)
 
static void CSEC_DRV_ContinueEncDecECBCmd (void)
 
static void CSEC_DRV_StartEncDecCBCCmd (void)
 
static void CSEC_DRV_ContinueEncDecCBCCmd (void)
 
static void CSEC_DRV_StartGenMACCmd (void)
 
static void CSEC_DRV_ContinueGenMACCmd (void)
 
static void CSEC_DRV_StartVerifMACCmd (void)
 
static void CSEC_DRV_ContinueVerifMACCmd (void)
 
void CSEC_DRV_Init (csec_state_t *state)
 Initializes the internal state of the driver and enables the FTFC interrupt. More...
 
void CSEC_DRV_Deinit ()
 Clears the internal state of the driver and disables the FTFC interrupt. More...
 
status_t CSEC_DRV_EncryptECB (csec_key_id_t keyId, const uint8_t *plainText, uint32_t length, uint8_t *cipherText)
 Performs the AES-128 encryption in ECB mode. More...
 
status_t CSEC_DRV_DecryptECB (csec_key_id_t keyId, const uint8_t *cipherText, uint32_t length, uint8_t *plainText)
 Performs the AES-128 decryption in ECB mode. More...
 
status_t CSEC_DRV_EncryptCBC (csec_key_id_t keyId, const uint8_t *plainText, uint32_t length, const uint8_t *iv, uint8_t *cipherText)
 Performs the AES-128 encryption in CBC mode. More...
 
status_t CSEC_DRV_DecryptCBC (csec_key_id_t keyId, const uint8_t *cipherText, uint16_t length, const uint8_t *iv, uint8_t *plainText)
 Performs the AES-128 decryption in CBC mode. More...
 
status_t CSEC_DRV_GenerateMAC (csec_key_id_t keyId, const uint8_t *msg, uint32_t msgLen, uint8_t *cmac)
 Calculates the MAC of a given message using CMAC with AES-128. More...
 
status_t CSEC_DRV_GenerateMACAddrMode (csec_key_id_t keyId, const uint8_t *msg, uint32_t msgLen, uint8_t *cmac)
 Calculates the MAC of a given message (located in Flash) using CMAC with AES-128. More...
 
status_t CSEC_DRV_VerifyMAC (csec_key_id_t keyId, const uint8_t *msg, uint32_t msgLen, const uint8_t *mac, uint16_t macLen, bool *verifStatus)
 Verifies the MAC of a given message using CMAC with AES-128. More...
 
status_t CSEC_DRV_VerifyMACAddrMode (csec_key_id_t keyId, const uint8_t *msg, uint32_t msgLen, const uint8_t *mac, uint16_t macLen, bool *verifStatus)
 Verifies the MAC of a given message (located in Flash) using CMAC with AES-128. More...
 
status_t CSEC_DRV_LoadKey (csec_key_id_t keyId, const uint8_t *m1, const uint8_t *m2, const uint8_t *m3, uint8_t *m4, uint8_t *m5)
 Updates an internal key per the SHE specification. More...
 
status_t CSEC_DRV_LoadPlainKey (const uint8_t *plainKey)
 Updates the RAM key memory slot with a 128-bit plaintext. More...
 
status_t CSEC_DRV_ExportRAMKey (uint8_t *m1, uint8_t *m2, uint8_t *m3, uint8_t *m4, uint8_t *m5)
 Exports the RAM_KEY into a format protected by SECRET_KEY. More...
 
status_t CSEC_DRV_InitRNG ()
 Initializes the seed and derives a key for the PRNG. More...
 
status_t CSEC_DRV_ExtendSeed (const uint8_t *entropy)
 Extends the seed of the PRNG. More...
 
status_t CSEC_DRV_GenerateRND (uint8_t *rnd)
 Generates a vector of 128 random bits. More...
 
status_t CSEC_DRV_BootFailure ()
 Signals a failure detected during later stages of the boot process. More...
 
status_t CSEC_DRV_BootOK ()
 Marks a successful boot verification during later stages of the boot process. More...
 
status_t CSEC_DRV_BootDefine (uint32_t bootSize, csec_boot_flavor_t bootFlavor)
 Implements an extension of the SHE standard to define both the user boot size and boot method. More...
 
status_t CSEC_DRV_GetID (const uint8_t *challenge, uint8_t *uid, uint8_t *sreg, uint8_t *mac)
 Returns the identity (UID) and the value of the status register protected by a MAC over a challenge and the data. More...
 
status_t CSEC_DRV_DbgChal (uint8_t *challenge)
 Obtains a random number which the user shall use along with the MASTER_ECU_KEY and UID to return an authorization request. More...
 
status_t CSEC_DRV_DbgAuth (const uint8_t *authorization)
 Erases all keys (actual and outdated) stored in NVM Memory if the authorization is confirmed by CSEc. More...
 
status_t CSEC_DRV_MPCompress (const uint8_t *msg, uint16_t msgLen, uint8_t *mpCompress)
 Compresses the given messages by accessing the Miyaguchi-Prenell compression feature with in the CSEc feature set. More...
 
status_t CSEC_DRV_EncryptECBAsync (csec_key_id_t keyId, const uint8_t *plainText, uint32_t length, uint8_t *cipherText)
 Asynchronously performs the AES-128 encryption in ECB mode. More...
 
status_t CSEC_DRV_DecryptECBAsync (csec_key_id_t keyId, const uint8_t *cipherText, uint32_t length, uint8_t *plainText)
 Asynchronously performs the AES-128 decryption in ECB mode. More...
 
status_t CSEC_DRV_EncryptCBCAsync (csec_key_id_t keyId, const uint8_t *cipherText, uint16_t length, const uint8_t *iv, uint8_t *plainText)
 Asynchronously performs the AES-128 encryption in CBC mode. More...
 
status_t CSEC_DRV_DecryptCBCAsync (csec_key_id_t keyId, const uint8_t *cipherText, uint32_t length, const uint8_t *iv, uint8_t *plainText)
 Asynchronously performs the AES-128 decryption in CBC mode. More...
 
status_t CSEC_DRV_GenerateMACAsync (csec_key_id_t keyId, const uint8_t *msg, uint32_t msgLen, uint8_t *cmac)
 Asynchronously calculates the MAC of a given message using CMAC with AES-128. More...
 
status_t CSEC_DRV_VerifyMACAsync (csec_key_id_t keyId, const uint8_t *msg, uint32_t msgLen, const uint8_t *mac, uint16_t macLen, bool *verifStatus)
 Asynchronously verifies the MAC of a given message using CMAC with AES-128. More...
 
status_t CSEC_DRV_GetAsyncCmdStatus ()
 Checks the status of the execution of an asynchronous command. More...
 
void CSEC_DRV_InstallCallback (csec_callback_t callbackFunc, void *callbackParam)
 Installs a callback function which will be invoked when an asynchronous command finishes its execution. More...
 

Variables

static csec_state_tg_csecStatePtr = NULL
 

Macro Definition Documentation

#define CSEC_BYTES_TO_FROM_BITS_SHIFT   (3U)

Definition at line 75 of file csec_driver.c.

#define CSEC_BYTES_TO_FROM_PAGES_SHIFT   (4U)

Definition at line 73 of file csec_driver.c.

#define CSEC_DATA_BYTES_AVAILABLE   (112U)

Definition at line 70 of file csec_driver.c.

#define CSEC_DATA_PAGES_AVAILABLE   (7U)

Definition at line 67 of file csec_driver.c.

#define CSEC_M1_SIZE_IN_BYTES   (16U)

Definition at line 78 of file csec_driver.c.

#define CSEC_M2_SIZE_IN_BYTES   (32U)

Definition at line 80 of file csec_driver.c.

#define CSEC_M3_SIZE_IN_BYTES   (16U)

Definition at line 82 of file csec_driver.c.

#define CSEC_M4_SIZE_IN_BYTES   (32U)

Definition at line 84 of file csec_driver.c.

#define CSEC_M5_SIZE_IN_BYTES   (16U)

Definition at line 86 of file csec_driver.c.

#define CSEC_PAGE_SIZE_IN_BYTES   (16U)

Definition at line 63 of file csec_driver.c.

Function Documentation

static void CSEC_DRV_ContinueEncDecCBCCmd ( void  )
static

Definition at line 1471 of file csec_driver.c.

static void CSEC_DRV_ContinueEncDecECBCmd ( void  )
static

Definition at line 1435 of file csec_driver.c.

static void CSEC_DRV_ContinueGenMACCmd ( void  )
static

Definition at line 1518 of file csec_driver.c.

static void CSEC_DRV_ContinueVerifMACCmd ( void  )
static

Definition at line 1558 of file csec_driver.c.

static void CSEC_DRV_InitState ( csec_key_id_t  keyId,
csec_cmd_t  cmd,
const uint8_t *  inBuff,
uint8_t *  outBuff,
uint32_t  length 
)
static

Definition at line 1243 of file csec_driver.c.

static uint32_t CSEC_DRV_RoundTo ( uint32_t  value,
uint32_t  roundTo 
)
inlinestatic

Definition at line 105 of file csec_driver.c.

static void CSEC_DRV_StartEncDecCBCCmd ( void  )
static

Definition at line 1339 of file csec_driver.c.

static void CSEC_DRV_StartEncDecECBCmd ( void  )
static

Definition at line 1315 of file csec_driver.c.

static void CSEC_DRV_StartGenMACCmd ( void  )
static

Definition at line 1377 of file csec_driver.c.

static void CSEC_DRV_StartVerifMACCmd ( void  )
static

Definition at line 1400 of file csec_driver.c.

void FTFC_IRQHandler ( void  )

Definition at line 1267 of file csec_driver.c.

Variable Documentation

csec_state_t* g_csecStatePtr = NULL
static

Definition at line 89 of file csec_driver.c.