AM263x MCU+ SDK  10.00.00
hsmclient.c File Reference

Macros

#define GET_CACHE_ALIGNED_SIZE(x)   ((x + CacheP_CACHELINE_ALIGNMENT) & ~(CacheP_CACHELINE_ALIGNMENT - 1))
 Macro calculates the cache-aligned size for a given buffer or data structure. More...
 
#define HSM_CLIENT_MSG_QUEUE_SIZE   (1028)
 Maximum size of the HSM client message queue For Streaming Secure Boot, the break up is as follows, 1 start message (includes the certificate) + 1 finish message + 1 ELF Header Buffer update message + 1 PHT Buffer update message 1024 ELF segment update messages (including the two note segments) More...
 

Functions

void Hsmclient_updateBootNotificationRegister (void)
 
static uint16_t crc16_ccit (uint8_t *data, uint16_t length)
 Calculate crc16_ccit for a given data. More...
 
static int32_t HsmClient_SendAndRecv (HsmClient_t *HsmClient, uint32_t timeout)
 Generic send and receive message api. More...
 
static int32_t HsmClient_EnqueueAndSendMsg (HsmMsg_t message)
 Generic send message api which enqueus the message in HSM client message queue and tries to send the message via SIPC. This API is non blocking in nature. More...
 
static int32_t HsmClient_EnqueueAndSendMsgBlocking (HsmMsg_t message)
 Generic send message api which enqueus the message in HSM client message queue and ensures all the messages present in the queue are sent via SIPC. This API is blocking in nature. More...
 
static int32_t HsmClient_waitForAllResponses ()
 Generic api which waits for all responses to be received. More...
 
void HsmClient_isr (uint8_t remoteCoreId, uint8_t localClientId, uint8_t remoteClientId, uint8_t *msgValue, void *args)
 
int32_t HsmClient_checkAndWaitForBootNotification (void)
 This API waits for HSMRT load if requested and then waits for boot notification. In case of failure in HSMRT load it returns SystemP_FAILURE. More...
 
int32_t HsmClient_register (HsmClient_t *HsmClient, uint8_t clientId)
 register a client to a particular ClientId More...
 
int32_t HsmClient_init (SIPC_Params *params)
 Initialize the HSM client for current core. More...
 
void HsmClient_deinit (void)
 
void HsmClient_unregister (HsmClient_t *HsmClient, uint8_t clientId)
 unregister a client to a particular ClientId More...
 
int32_t HsmClient_getVersion (HsmClient_t *HsmClient, HsmVer_t *hsmVer, uint32_t timeout)
 populates the current HSMRT version Id by default the hsm flag is set to HSM_FLAG_AOP for this service More...
 
int32_t HsmClient_getUID (HsmClient_t *HsmClient, uint8_t *uid, uint32_t timeout)
 The service issued to HSM Server populates the Device UID by default the hsm flag is set to HSM_FLAG_AOP for this service. More...
 
int32_t HsmClient_openDbgFirewall (HsmClient_t *HsmClient, uint8_t *cert, uint32_t cert_size, uint32_t timeout)
 The service issued to HSM Server verifies the certificate and by default the hsm flag is set to HSM_FLAG_AOP for this service. More...
 
int32_t HsmClient_importKeyring (HsmClient_t *HsmClient, uint8_t *cert, uint32_t cert_size, uint32_t timeout)
 The service issued to HSM Server verifies the certificate and imports the keys from the certificate. More...
 
int32_t HsmClient_readOTPRow (HsmClient_t *HsmClient, EfuseRead_t *readRow)
 The service issued to HSM Server retrieves the data of GP OTP row based on row index provided as param. More...
 
int32_t HsmClient_writeOTPRow (HsmClient_t *HsmClient, EfuseRowWrite_t *writeRow)
 The service issued to HSM Server writes the data to extended OTP efuse row based on row index provided as param. More...
 
int32_t HsmClient_lockOTPRow (HsmClient_t *HsmClient, EfuseRowProt_t *protRow)
 The service issued to HSM Server sets the protection status bit of the specified row to 1. More...
 
int32_t HsmClient_getOTPRowCount (HsmClient_t *HsmClient, EfuseRowCount_t *rowCount)
 The service issued to HSM Server retrieves the count of extended OTP rows. More...
 
int32_t HsmClient_getOTPRowProtection (HsmClient_t *HsmClient, EfuseRowProt_t *rowProt)
 The service issued to HSM Server retrieves the extended otp efuse row protection status. More...
 
int32_t HsmClient_procAuthBoot (HsmClient_t *HsmClient, uint8_t *cert, uint32_t cert_size, uint32_t timeout)
 The service issued to HSM Server helps with extended secure boot for applications. More...
 
int32_t HsmClient_procAuthBootStart (HsmClient_t *HsmClient, SecureBoot_Stream_t *secureBootInfo)
 The service issued to HSM Server helps with extended secure boot for applications. More...
 
int32_t HsmClient_procAuthBootUpdate (HsmClient_t *HsmClient, SecureBoot_Stream_t *secureBootInfo)
 The service issued to HSM Server helps with extended secure boot for applications. More...
 
int32_t HsmClient_procAuthBootFinish (HsmClient_t *HsmClient, SecureBoot_Stream_t *secureBootInfo)
 The service issued to HSM Server helps with extended secure boot for applications. More...
 
int32_t HsmClient_setFirewall (HsmClient_t *HsmClient, FirewallReq_t *FirewallReqObj, uint32_t timeout)
 The service issued to HSM Server sets the firewall for the given firewall id and region. More...
 
int32_t HsmClient_FirewallIntr (HsmClient_t *HsmClient, FirewallIntrReq_t *FirewallIntrReqObj, uint32_t timeout)
 The service issued to HSM Server sets the firewall interrupt request for the given firewall id. More...
 
int32_t HsmClient_getDKEK (HsmClient_t *HsmClient, DKEK_t *getDKEK, uint32_t timeout)
 The service issued to HSM Server retrieves the derived KEK based on identifier as param. More...
 
int32_t HsmClient_waitForBootNotify (HsmClient_t *HsmClient, uint32_t timeout)
 Current core will wait for bootnotify message from HSM core. More...
 
int32_t HsmClient_keyWriter (HsmClient_t *HsmClient, KeyWriterCertHeader_t *certHeader, uint32_t timeout)
 The service issued to HSM Server verifies the certificate and process the keywriter operations,. More...
 
int32_t HsmClient_readSWRev (HsmClient_t *HsmClient, SWRev_t *readSWRev)
 The service issued to HSM Server retrieves the SWRevision value based on identifier as param. More...
 
int32_t HsmClient_writeSWRev (HsmClient_t *HsmClient, SWRev_t *writeSWRev)
 The service issued to HSM Server writes the SWRevision value based on identifier as param. More...
 
int32_t HsmClient_getRandomNum (HsmClient_t *HsmClient, RNGReq_t *getRandomNum)
 Returns the Random Number Generated. More...
 

Variables

volatile uint32_t gHsmrtLoadStatus = HSMRT_LOAD_NOT_REQUESTED
 
static volatile int32_t gSecureBootStatus = SystemP_SUCCESS
 
static volatile int32_t gBootNotificationReceived = SystemP_FAILURE
 
static int32_t gLastSentIndex = -1
 
static int32_t gLastEnqueuedIndex = -1
 
static int32_t gNum_HsmRequestSent = 0
 
static volatile int32_t gNum_HsmResponseReceived = 0
 
static HsmMsg_t gHsmClientMsgQueue [HSM_CLIENT_MSG_QUEUE_SIZE]
 

Macro Definition Documentation

◆ GET_CACHE_ALIGNED_SIZE

#define GET_CACHE_ALIGNED_SIZE (   x)    ((x + CacheP_CACHELINE_ALIGNMENT) & ~(CacheP_CACHELINE_ALIGNMENT - 1))

Macro calculates the cache-aligned size for a given buffer or data structure.

◆ HSM_CLIENT_MSG_QUEUE_SIZE

#define HSM_CLIENT_MSG_QUEUE_SIZE   (1028)

Maximum size of the HSM client message queue For Streaming Secure Boot, the break up is as follows, 1 start message (includes the certificate) + 1 finish message + 1 ELF Header Buffer update message + 1 PHT Buffer update message 1024 ELF segment update messages (including the two note segments)

  • PT note for boot sequence info
  • PT note containing Random string for decryption verification

Function Documentation

◆ Hsmclient_updateBootNotificationRegister()

void Hsmclient_updateBootNotificationRegister ( void  )

◆ crc16_ccit()

static uint16_t crc16_ccit ( uint8_t *  data,
uint16_t  length 
)
static

Calculate crc16_ccit for a given data.

Parameters
datadata pointer
lengthdata length
Returns
16 bit crc calculated from given data.

◆ HsmClient_SendAndRecv()

static int32_t HsmClient_SendAndRecv ( HsmClient_t HsmClient,
uint32_t  timeout 
)
static

Generic send and receive message api.

Parameters
HsmClientclient type
timeouttime to wait for interrupt from HSM before throwing timeout exception.
Returns
SystemP_SUCCESS if transaction is successful else SystemP_FAILURE.

◆ HsmClient_EnqueueAndSendMsg()

static int32_t HsmClient_EnqueueAndSendMsg ( HsmMsg_t  message)
static

Generic send message api which enqueus the message in HSM client message queue and tries to send the message via SIPC. This API is non blocking in nature.

Parameters
messagemessage that needs to be sent to the HSM core.
Returns
SystemP_SUCCESS if transaction is successful else SystemP_FAILURE.

◆ HsmClient_EnqueueAndSendMsgBlocking()

static int32_t HsmClient_EnqueueAndSendMsgBlocking ( HsmMsg_t  message)
static

Generic send message api which enqueus the message in HSM client message queue and ensures all the messages present in the queue are sent via SIPC. This API is blocking in nature.

Parameters
messagemessage that needs to be sent to the HSM core
Returns
SystemP_SUCCESS if transaction is successful else SystemP_FAILURE.

◆ HsmClient_waitForAllResponses()

static int32_t HsmClient_waitForAllResponses ( )
static

Generic api which waits for all responses to be received.

Returns
SystemP_SUCCESS if all responses are successful else SystemP_FAILURE.

◆ HsmClient_isr()

void HsmClient_isr ( uint8_t  remoteCoreId,
uint8_t  localClientId,
uint8_t  remoteClientId,
uint8_t *  msgValue,
void *  args 
)

◆ HsmClient_deinit()

void HsmClient_deinit ( void  )

Variable Documentation

◆ gHsmrtLoadStatus

volatile uint32_t gHsmrtLoadStatus = HSMRT_LOAD_NOT_REQUESTED

◆ gSecureBootStatus

volatile int32_t gSecureBootStatus = SystemP_SUCCESS
static

◆ gBootNotificationReceived

volatile int32_t gBootNotificationReceived = SystemP_FAILURE
static

◆ gLastSentIndex

int32_t gLastSentIndex = -1
static

◆ gLastEnqueuedIndex

int32_t gLastEnqueuedIndex = -1
static

◆ gNum_HsmRequestSent

int32_t gNum_HsmRequestSent = 0
static

◆ gNum_HsmResponseReceived

volatile int32_t gNum_HsmResponseReceived = 0
static

◆ gHsmClientMsgQueue

HsmMsg_t gHsmClientMsgQueue[HSM_CLIENT_MSG_QUEUE_SIZE]
static