S32 SDK

Detailed Description

Macros

#define CSEC_STATUS_BUSY   (0x1U)
 The bit is set whenever SHE is processing a command. More...
 
#define CSEC_STATUS_SECURE_BOOT   (0x2U)
 The bit is set if the secure booting is activated. More...
 
#define CSEC_STATUS_BOOT_INIT   (0x4U)
 The bit is set if the secure booting has been personalized during the boot sequence. More...
 
#define CSEC_STATUS_BOOT_FINISHED   (0x8U)
 The bit is set when the secure booting has been finished by calling either CMD_BOOT_FAILURE or CMD_BOOT_OK or if CMD_SECURE_BOOT failed in verifying BOOT_MAC. More...
 
#define CSEC_STATUS_BOOT_OK   (0x10U)
 The bit is set if the secure booting (CMD_SECURE_BOOT) succeeded. If CMD_BOOT_FAILURE is called the bit is erased. More...
 
#define CSEC_STATUS_RND_INIT   (0x20U)
 The bit is set if the random number generator has been initialized. More...
 
#define CSEC_STATUS_EXT_DEBUGGER   (0x40U)
 The bit is set if an external debugger is connected to the chip. More...
 
#define CSEC_STATUS_INT_DEBUGGER   (0x80U)
 The bit is set if the internal debugging mechanisms of SHE are activated. More...
 
#define CSEC_NO_ERROR   0x1U
 Represents the result of the execution of a command. Provides one bit for each error code as per SHE specification. More...
 
#define CSEC_SEQUENCE_ERROR   0x2U
 
#define CSEC_KEY_NOT_AVAILABLE   0x4U
 
#define CSEC_KEY_INVALID   0x8U
 
#define CSEC_KEY_EMPTY   0x10U
 
#define CSEC_NO_SECURE_BOOT   0x20U
 
#define CSEC_KEY_WRITE_PROTECTED   0x40U
 
#define CSEC_KEY_UPDATE_ERROR   0x80U
 
#define CSEC_RNG_SEED   0x100U
 
#define CSEC_NO_DEBUGGING   0x200U
 
#define CSEC_MEMORY_FAILURE   0x400U
 
#define CSEC_GENERAL_ERROR   0x800U
 

Typedefs

typedef uint8_t csec_status_t
 Represents the status of the CSEc module. Provides one bit for each status code as per SHE specification. CSEC_STATUS_* masks can be used for verifying the status. More...
 

Enumerations

enum  csec_cmd_t {
  CSEC_CMD_ENC_ECB = 0x1U, CSEC_CMD_ENC_CBC, CSEC_CMD_DEC_ECB, CSEC_CMD_DEC_CBC,
  CSEC_CMD_GENERATE_MAC, CSEC_CMD_VERIFY_MAC, CSEC_CMD_LOAD_KEY, CSEC_CMD_LOAD_PLAIN_KEY,
  CSEC_CMD_EXPORT_RAM_KEY, CSEC_CMD_INIT_RNG, CSEC_CMD_EXTEND_SEED, CSEC_CMD_RND,
  CSEC_CMD_RESERVED_1, CSEC_CMD_BOOT_FAILURE, CSEC_CMD_BOOT_OK, CSEC_CMD_GET_ID,
  CSEC_CMD_BOOT_DEFINE, CSEC_CMD_DBG_CHAL, CSEC_CMD_DBG_AUTH, CSEC_CMD_TRNG_RND,
  CSEC_CMD_RESERVED_2, CSEC_CMD_MP_COMPRESS
}
 CSEc commands which follow the same values as the SHE command definition. More...
 
enum  csec_key_id_t {
  CSEC_SECRET_KEY = 0x0U, CSEC_MASTER_ECU, CSEC_BOOT_MAC_KEY, CSEC_BOOT_MAC,
  CSEC_KEY_1, CSEC_KEY_2, CSEC_KEY_3, CSEC_KEY_4,
  CSEC_KEY_5, CSEC_KEY_6, CSEC_KEY_7, CSEC_KEY_8,
  CSEC_KEY_9, CSEC_KEY_10, CSEC_RAM_KEY = 0xFU, CSEC_KEY_11 = 0x14U,
  CSEC_KEY_12, CSEC_KEY_13, CSEC_KEY_14, CSEC_KEY_15,
  CSEC_KEY_16, CSEC_KEY_17, CSEC_KEY_18, CSEC_KEY_19,
  CSEC_KEY_20, CSEC_KEY_21
}
 Specify the KeyID to be used to implement the requested cryptographic operation. More...
 
enum  csec_func_format_t { CSEC_FUNC_FORMAT_COPY, CSEC_FUNC_FORMAT_ADDR }
 Specifies how the data is transferred to/from the CSE. There are two use cases. One is to copy all data and the command function call method and the other is a pointer and function call method. More...
 
enum  csec_call_sequence_t { CSEC_CALL_SEQ_FIRST, CSEC_CALL_SEQ_SUBSEQUENT }
 Specifies if the information is the first or a following function call. More...
 

Functions

static void CSEC_HAL_WriteCommandHeader (csec_cmd_t funcId, csec_func_format_t funcFormat, csec_call_sequence_t callSeq, csec_key_id_t keyId)
 Writes the command header to CSE_PRAM. More...
 
void CSEC_HAL_WriteCommandBytes (uint8_t offset, const uint8_t *bytes, uint8_t numBytes)
 Writes command bytes to CSE_PRAM. More...
 
void CSEC_HAL_WriteCommandHalfWord (uint8_t offset, uint16_t halfWord)
 Writes a command half word to CSE_PRAM. More...
 
void CSEC_HAL_WriteCommandByte (uint8_t offset, uint8_t byte)
 Writes a command byte to CSE_PRAM. More...
 
void CSEC_HAL_WriteCommandWords (uint8_t offset, const uint32_t *words, uint8_t numWords)
 Writes command words to CSE_PRAM. More...
 
void CSEC_HAL_ReadCommandBytes (uint8_t offset, uint8_t *bytes, uint8_t numBytes)
 Reads command bytes from CSE_PRAM. More...
 
uint16_t CSEC_HAL_ReadCommandHalfWord (uint8_t offset)
 Reads a command half word from CSE_PRAM. More...
 
uint8_t CSEC_HAL_ReadCommandByte (uint8_t offset)
 Reads a command byte from CSE_PRAM. More...
 
void CSEC_HAL_ReadCommandWords (uint8_t offset, uint32_t *words, uint8_t numWords)
 Reads command words from CSE_PRAM. More...
 
static void CSEC_HAL_WaitCommandCompletion (void)
 Waits for the completion of a CSEc command. More...
 
static status_t CSEC_HAL_ReadErrorBits (void)
 Reads the error bits from PRAM. More...
 
static csec_status_t CSEC_HAL_ReadStatus (void)
 Reads the status of the CSEc module. More...
 
START_FUNCTION_DECLARATION_RAMSECTION void CSEC_HAL_WriteCmdAndWait (csec_cmd_t funcId, csec_func_format_t funcFormat, csec_call_sequence_t callSeq, csec_key_id_t keyId) END_FUNCTION_DECLARATION_RAMSECTION static inline void CSEC_HAL_SetInterrupt(bool enable)
 Writes the command header to CSE_PRAM and waits for completion. More...
 

Macro Definition Documentation

#define CSEC_GENERAL_ERROR   0x800U

Definition at line 203 of file csec_hal.h.

#define CSEC_KEY_EMPTY   0x10U

Definition at line 196 of file csec_hal.h.

#define CSEC_KEY_INVALID   0x8U

Definition at line 195 of file csec_hal.h.

#define CSEC_KEY_NOT_AVAILABLE   0x4U

Definition at line 194 of file csec_hal.h.

#define CSEC_KEY_UPDATE_ERROR   0x80U

Definition at line 199 of file csec_hal.h.

#define CSEC_KEY_WRITE_PROTECTED   0x40U

Definition at line 198 of file csec_hal.h.

#define CSEC_MEMORY_FAILURE   0x400U

Definition at line 202 of file csec_hal.h.

#define CSEC_NO_DEBUGGING   0x200U

Definition at line 201 of file csec_hal.h.

#define CSEC_NO_ERROR   0x1U

Represents the result of the execution of a command. Provides one bit for each error code as per SHE specification.

Definition at line 192 of file csec_hal.h.

#define CSEC_NO_SECURE_BOOT   0x20U

Definition at line 197 of file csec_hal.h.

#define CSEC_RNG_SEED   0x100U

Definition at line 200 of file csec_hal.h.

#define CSEC_SEQUENCE_ERROR   0x2U

Definition at line 193 of file csec_hal.h.

#define CSEC_STATUS_BOOT_FINISHED   (0x8U)

The bit is set when the secure booting has been finished by calling either CMD_BOOT_FAILURE or CMD_BOOT_OK or if CMD_SECURE_BOOT failed in verifying BOOT_MAC.

Definition at line 82 of file csec_hal.h.

#define CSEC_STATUS_BOOT_INIT   (0x4U)

The bit is set if the secure booting has been personalized during the boot sequence.

Definition at line 78 of file csec_hal.h.

#define CSEC_STATUS_BOOT_OK   (0x10U)

The bit is set if the secure booting (CMD_SECURE_BOOT) succeeded. If CMD_BOOT_FAILURE is called the bit is erased.

Definition at line 85 of file csec_hal.h.

#define CSEC_STATUS_BUSY   (0x1U)

The bit is set whenever SHE is processing a command.

Definition at line 73 of file csec_hal.h.

#define CSEC_STATUS_EXT_DEBUGGER   (0x40U)

The bit is set if an external debugger is connected to the chip.

Definition at line 89 of file csec_hal.h.

#define CSEC_STATUS_INT_DEBUGGER   (0x80U)

The bit is set if the internal debugging mechanisms of SHE are activated.

Definition at line 92 of file csec_hal.h.

#define CSEC_STATUS_RND_INIT   (0x20U)

The bit is set if the random number generator has been initialized.

Definition at line 87 of file csec_hal.h.

#define CSEC_STATUS_SECURE_BOOT   (0x2U)

The bit is set if the secure booting is activated.

Definition at line 75 of file csec_hal.h.

Typedef Documentation

typedef uint8_t csec_status_t

Represents the status of the CSEc module. Provides one bit for each status code as per SHE specification. CSEC_STATUS_* masks can be used for verifying the status.

Implements : csec_status_t_Class

Definition at line 101 of file csec_hal.h.

Enumeration Type Documentation

Specifies if the information is the first or a following function call.

Implements : csec_call_sequence_t_Class

Enumerator
CSEC_CALL_SEQ_FIRST 
CSEC_CALL_SEQ_SUBSEQUENT 

Definition at line 185 of file csec_hal.h.

enum csec_cmd_t

CSEc commands which follow the same values as the SHE command definition.

Implements : csec_cmd_t_Class

Enumerator
CSEC_CMD_ENC_ECB 
CSEC_CMD_ENC_CBC 
CSEC_CMD_DEC_ECB 
CSEC_CMD_DEC_CBC 
CSEC_CMD_GENERATE_MAC 
CSEC_CMD_VERIFY_MAC 
CSEC_CMD_LOAD_KEY 
CSEC_CMD_LOAD_PLAIN_KEY 
CSEC_CMD_EXPORT_RAM_KEY 
CSEC_CMD_INIT_RNG 
CSEC_CMD_EXTEND_SEED 
CSEC_CMD_RND 
CSEC_CMD_RESERVED_1 
CSEC_CMD_BOOT_FAILURE 
CSEC_CMD_BOOT_OK 
CSEC_CMD_GET_ID 
CSEC_CMD_BOOT_DEFINE 
CSEC_CMD_DBG_CHAL 
CSEC_CMD_DBG_AUTH 
CSEC_CMD_TRNG_RND 
CSEC_CMD_RESERVED_2 
CSEC_CMD_MP_COMPRESS 

Definition at line 108 of file csec_hal.h.

Specifies how the data is transferred to/from the CSE. There are two use cases. One is to copy all data and the command function call method and the other is a pointer and function call method.

Implements : csec_func_format_t_Class

Enumerator
CSEC_FUNC_FORMAT_COPY 
CSEC_FUNC_FORMAT_ADDR 

Definition at line 175 of file csec_hal.h.

Specify the KeyID to be used to implement the requested cryptographic operation.

Implements : csec_key_id_t_Class

Enumerator
CSEC_SECRET_KEY 
CSEC_MASTER_ECU 
CSEC_BOOT_MAC_KEY 
CSEC_BOOT_MAC 
CSEC_KEY_1 
CSEC_KEY_2 
CSEC_KEY_3 
CSEC_KEY_4 
CSEC_KEY_5 
CSEC_KEY_6 
CSEC_KEY_7 
CSEC_KEY_8 
CSEC_KEY_9 
CSEC_KEY_10 
CSEC_RAM_KEY 
CSEC_KEY_11 
CSEC_KEY_12 
CSEC_KEY_13 
CSEC_KEY_14 
CSEC_KEY_15 
CSEC_KEY_16 
CSEC_KEY_17 
CSEC_KEY_18 
CSEC_KEY_19 
CSEC_KEY_20 
CSEC_KEY_21 

Definition at line 139 of file csec_hal.h.

Function Documentation

uint8_t CSEC_HAL_ReadCommandByte ( uint8_t  offset)

Reads a command byte from CSE_PRAM.

This function reads a command byte from CSE_PRAM.

Parameters
[in]offsetThe offset (in bytes) from which the byte shall be read.
Returns
The byte read.

Definition at line 224 of file csec_hal.c.

void CSEC_HAL_ReadCommandBytes ( uint8_t  offset,
uint8_t *  bytes,
uint8_t  numBytes 
)

Reads command bytes from CSE_PRAM.

This function reads command bytes from CSE_PRAM, from a 32-bit aligned offset.

Parameters
[in]offsetThe offset (in bytes) from which the bytes shall be read.
[out]bytesThe buffer containing the bytes read.
[in]numBytesThe number of bytes to be read.

Definition at line 170 of file csec_hal.c.

uint16_t CSEC_HAL_ReadCommandHalfWord ( uint8_t  offset)

Reads a command half word from CSE_PRAM.

This function reads a command half word from CSE_PRAM, from a 16-bit aligned offset.

Parameters
[in]offsetThe offset (in bytes) from which the half word shall be read.
Returns
The half word read.

Definition at line 201 of file csec_hal.c.

void CSEC_HAL_ReadCommandWords ( uint8_t  offset,
uint32_t *  words,
uint8_t  numWords 
)

Reads command words from CSE_PRAM.

This function reads command words from CSE_PRAM, from a 32-bit aligned offset.

Parameters
[in]offsetThe offset (in bytes) from which the words shall be read.
[out]wordsThe buffer containing the words read.
[in]numWordsThe number of words to be read.

Definition at line 258 of file csec_hal.c.

static status_t CSEC_HAL_ReadErrorBits ( void  )
inlinestatic

Reads the error bits from PRAM.

This function reads the error bits reported after running a CSEc command.

Returns
Error Code after command execution.

Implements : CSEC_HAL_ReadErrorBits_Activity

Definition at line 353 of file csec_hal.h.

static csec_status_t CSEC_HAL_ReadStatus ( void  )
inlinestatic

Reads the status of the CSEc module.

This function reads the contents od the status register.

Returns
Status represented as a mask of CSEC_STATUS_*.

Implements : CSEC_HAL_ReadStatus_Activity

Definition at line 411 of file csec_hal.h.

static void CSEC_HAL_WaitCommandCompletion ( void  )
inlinestatic

Waits for the completion of a CSEc command.

This function waits for the completion of a CSEc command.

Implements : CSEC_HAL_WaitCommandCompletion_Activity

Definition at line 336 of file csec_hal.h.

START_FUNCTION_DECLARATION_RAMSECTION void CSEC_HAL_WriteCmdAndWait ( csec_cmd_t  funcId,
csec_func_format_t  funcFormat,
csec_call_sequence_t  callSeq,
csec_key_id_t  keyId 
)

Writes the command header to CSE_PRAM and waits for completion.

This function writes the header of a command and waits for completion. The function is always located in RAM, and is used for CSEc commands using pointer methods, in order to allow the MGATE to read from FLASH without causing a read collision.

Parameters
[in]funcIdThe ID of the operation to be started.
[in]funcFormatSpecifies how the data is transferred to/from the CSE.
[in]callSeqSpecifies if the information is the first or a following function call.
[in]keyIdSpecify the KeyID to be used to implement the requested cryptographic operation.

Enables/Disables the command completion interrupt.

This function enables/disables the command completion interrupt.

Parameters
[in]enableEnable/Disable the command completion interrupt.

Implements : CSEC_HAL_SetInterrupt_Activity

Definition at line 432 of file csec_hal.h.

void CSEC_HAL_WriteCommandByte ( uint8_t  offset,
uint8_t  byte 
)

Writes a command byte to CSE_PRAM.

This function writes a command byte to CSE_PRAM.

Parameters
[in]offsetThe offset (in bytes) at which the byte shall be written.
[in]byteThe byte to be written.

Definition at line 118 of file csec_hal.c.

void CSEC_HAL_WriteCommandBytes ( uint8_t  offset,
const uint8_t *  bytes,
uint8_t  numBytes 
)

Writes command bytes to CSE_PRAM.

This function writes command bytes to CSE_PRAM, at a 32-bit aligned offset.

Parameters
[in]offsetThe offset (in bytes) at which the bytes shall be written.
[in]bytesThe buffer containing the bytes to be written.
[in]numBytesThe number of bytes to be written.

Definition at line 61 of file csec_hal.c.

void CSEC_HAL_WriteCommandHalfWord ( uint8_t  offset,
uint16_t  halfWord 
)

Writes a command half word to CSE_PRAM.

This function writes a command half word to CSE_PRAM, at a 16-bit aligned offset.

Parameters
[in]offsetThe offset (in bytes) at which the half word shall be written.
[in]halfWordThe half word to be written.

Definition at line 91 of file csec_hal.c.

static void CSEC_HAL_WriteCommandHeader ( csec_cmd_t  funcId,
csec_func_format_t  funcFormat,
csec_call_sequence_t  callSeq,
csec_key_id_t  keyId 
)
inlinestatic

Writes the command header to CSE_PRAM.

This function writes the command header to CSE_PRAM, triggering the CSEc operation.

Parameters
[in]funcIdThe ID of the operation to be started.
[in]funcFormatSpecifies how the data is transferred to/from the CSE.
[in]callSeqSpecifies if the information is the first or a following function call.
[in]keyIdSpecify the KeyID to be used to implement the requested cryptographic operation.

Implements : CSEC_HAL_WriteCommandHeader_Activity

Definition at line 229 of file csec_hal.h.

void CSEC_HAL_WriteCommandWords ( uint8_t  offset,
const uint32_t *  words,
uint8_t  numWords 
)

Writes command words to CSE_PRAM.

This function writes command words to CSE_PRAM, at a 32-bit aligned offset.

Parameters
[in]offsetThe offset (in bytes) at which the words shall be written.
[in]wordsThe buffer containing the words to be written.
[in]numWordsThe number of words to be written.

Definition at line 148 of file csec_hal.c.