AM261x MCU+ SDK  26.00.00
hsmclient.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022-24 Texas Instruments Incorporated
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef HSM_CLIENT_H_
34 #define HSM_CLIENT_H_
35 
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40 
41 /* Header file for HSM client driver */
42 #include <stdint.h>
46 #include <kernel/dpl/SemaphoreP.h>
47 
56 #define LABEL_AND_CONTEXT_LEN_MAX 48U
57 
62 #define HSMRT_LOAD_NOT_REQUESTED (0U)
63 
67 #define HSMRT_LOAD_REQUESTED (1U)
68 
72 #define HSMRT_LOAD_FAILED (2U)
73 
77 #define HSMRT_LOAD_SUCCEEDED (3U)
78 
79 /*
80  * -------------------------------------------------------------------------
81  * Algorithm selectors — used in CryptoServiceReq_t.algoId
82  * -------------------------------------------------------------------------
83  */
85 #define HSM_CRYPTO_SVC_MAC_CMAC (0x0001U)
86 
87 #define HSM_CRYPTO_SVC_MAC_HMAC (0x0002U)
88 
89 #define HSM_CRYPTO_SVC_MAC_GMAC (0x0003U)
90 
91 /*
92  * -------------------------------------------------------------------------
93  * Hash mode selectors for HMAC — used in HMACArgs_t.hashMode
94  * -------------------------------------------------------------------------
95  */
97 #define HSM_CRYPTO_HMAC_SHA256 (0x6U) /* matches DTHE_SHA_ALGO_SHA256 */
98 
99 #define HSM_CRYPTO_HMAC_SHA512 (0x4U) /* matches DTHE_SHA_ALGO_SHA512 */
100 
101 /*
102  * -------------------------------------------------------------------------
103  * Sub-service selectors — used in CryptoServiceReq_t.subSvcId
104  * -------------------------------------------------------------------------
105  */
107 #define HSM_CRYPTO_SVC_MAC_GENERATE (0x0001U)
108 
109 #define HSM_CRYPTO_SVC_MAC_VERIFY (0x0002U)
110 
111 /*
112  * -------------------------------------------------------------------------
113  * Service macros — used in DeviceConfigRead_t
114  * -------------------------------------------------------------------------
115  */
117 #define DEVICE_CONFIG_TYPE_SAFETY (0U)
118 
120 #define DEVICE_CONFIG_TYPE_SECURITY (1U)
121 
123 #define DEVICE_CONFIG_TYPE_DEBUG (2U)
124 
126 #define DEVICE_CONFIG_TYPE_ALL (0xFFU)
127 
129 #define SIZE_OF_SAFETY_DEVICE_CONFIG (8U)
130 
132 #define SIZE_OF_SECURITY_DEVICE_CONFIG (44U)
133 
135 #define SIZE_OF_DEBUG_DEVICE_CONFIG (16U)
136 
142  typedef union HsmVer_t_
143  {
144  uint64_t HsmrtVer ;
145  struct
146  {
147  uint8_t PatchVer;
148  uint8_t MinorVer;
149  uint8_t MajorVer;
150  uint8_t ApiVer;
151  uint8_t SocType;
152  uint8_t BinType;
153  uint8_t HsmType;
154  uint8_t DevType;
157 #if defined(_TMS320C6X)
158  } __attribute__((packed)) HsmVer_t_;
159 #else
160 } __attribute__((packed)) HsmVer_t;
161 #endif
162 
168  typedef struct HsmClient_t_
169  {
170  SemaphoreP_Object Semaphore;
172  HsmMsg_t ReqMsg;
173  HsmMsg_t RespMsg;
174  uint8_t RespFlag;
175  uint8_t ClientId;
177  } HsmClient_t;
178 
186  typedef struct NvmOtpRead_t_
187  {
188  uint32_t rowData;
189  uint16_t rowIdx;
190  uint8_t rsvd[2];
191  } NvmOtpRead_t;
192 
200  typedef struct NvmOtpRowWrite_t_
201  {
202  uint32_t rowData;
203  uint32_t rowBitMask;
204  uint16_t rowIdx;
205  uint8_t rsvd[2];
207 
213  typedef struct NvmOtpRowCount_t_
214  {
215  uint32_t rowCount;
216  uint8_t rowSize;
217  uint8_t rsvd[3];
219 
227  typedef struct NvmOtpRowProt_t_
228  {
229  uint16_t rowidx;
230  uint8_t readProt;
231  uint8_t writeProt;
232  } NvmOtpRowProt_t;
233 
239  typedef struct keywriter_cert_header_t_
240  {
241  uint8_t *certAddress; /*For holding cerificate address*/
242  uint32_t certSize; /*Cerificate size*/
243  uint32_t debugResponse; /*Debug response*/
244  uint32_t reserved; /*reserved for future use*/
246 
252  typedef struct FirewallRegionReq_t_
253  {
254  uint16_t firewallId;
255  uint16_t region;
257  uint32_t startAddress;
258  uint32_t endAddress;
260 
266  typedef struct FirewallReq_t_
267  {
268  uint16_t regionCount;
269  uint16_t crcArr;
272  } FirewallReq_t;
273 
280  typedef struct FirewallIntrReq_t_
281  {
282  uint16_t firewallId;
283  uint8_t interruptEnable;
286  uint8_t faultClear;
288 
298  typedef struct SWRev_t_
299  {
300  uint32_t revValue;
301  uint8_t revId;
302  uint8_t rsvd[3];
303  } SWRev_t;
304 
315  typedef struct DKEK_t_
316  {
317  uint8_t label_length;
318  uint8_t context_length;
319  uint8_t label_and_context[LABEL_AND_CONTEXT_LEN_MAX];
320  uint32_t dkek[8];
321  } DKEK_t;
322 
334  typedef struct RNGReq_t_
335  {
336  uint8_t *resultPtr;
337  uint32_t resultLength;
338  uint8_t DRBGMode;
339  uint32_t *seedValue;
341  uint8_t reserved;
342  } RNGReq_t;
343 
349  typedef struct SecureBoot_Stream_t_
350  {
351  uint8_t *dataIn;
352  uint32_t dataLen;
353  uint8_t canBeEncrypted;
354  } __attribute__((packed)) SecureBoot_Stream_t;
355 
368  typedef struct FirmwareUpdateReq_t_
369  {
370  uint8_t *pStartAddress; /* Start address of data to be programmed in flash memory */
371  uint32_t dataLength; /* Length of data to be programmed in flash memory */
372  void *pDecryptionBuffer; /* Address of Scratchpad memory to be used to decrypt image, valid only for HsmClient_firmwareUpdate_CodeVerify API */
373  uint32_t decryptionBufferLength; /* Length of Scratchpad memory to be used to decrypt image, valid only for HsmClient_firmwareUpdate_CodeVerify API */
375 
376 
382 typedef struct OTFA_Region_t
383 {
384  uint8_t authMode ; /* mode of authentication - disable-0/GMAC-1/CMAC-2 ; */
385  uint8_t encMode ; /* mode of decryption - disable-0 or AES_CTR-1 */
386  uint16_t reservedArea ; /* reserved to align with 4kB structure */
387  uint32_t regionStAddr ; /* start address of the flash region for which the configuration should apply */
388  uint32_t regionSize ; /* size of the flash region in kB for which the configuration should apply */
389  uint8_t authKeyID ; /* Keyring ID of key to be used for authentication */
390  uint8_t encrKeyID ; /* Keyring ID of key to be used for encryption */
391  uint8_t encrKeyFetchMode ; /* specify which 16 bytes of DSMEK are to be used - 1 for fist 16/2 for last 16/ 3 for XOR of both */
392  uint8_t authAesKey [16] ; /* actual key value to be written to the register for authentication ; fetched from keyring */
393  uint8_t encrAesKey [16] ; /* actual key value to be written to the register for decryption ; fetched from keyring */
394  uint8_t regionIV[16] ; /* IV to be used for encryption */
395 }OTFA_Region_t ;
396 
401 typedef struct OTFA_readRegion_t
402 {
403  uint8_t regionNumber ; /* Index of the region - 0/1/2/3 */
404  uint8_t authMode ; /* mode of authentication - disable-0/GMAC-1/CMAC-2 ; */
405  uint8_t encMode ; /* mode of decryption - disable-0 or AES_CTR-1 */
406  uint8_t authKeyHash[64] ; /* hash of the authentication key stored in OTFA register */
407  uint8_t encKeyHash[64] ; /* hash of the encryption key stored in OTFA register */
408  uint32_t regionStAddr ; /* start address of the flash region for which the configuration should apply */
409  uint32_t regionSize ; /* size of the flash region in kB for which the configuration should apply */
410  uint16_t regionIV[16] ; /* IV to be used for encryption */
412 
418 typedef struct OTFA_Config_t
419 {
420  OTFA_Region_t OTFA_Reg[4] ; /* array of all registers' information of 4 OTFA Regions */
421  uint8_t numRegions ; /* number of OTFA regions to be configured */
422  uint8_t keySize ; /* options - 128/256 */
423  uint8_t macSize ; /* options - 4/8/12/16 */
424  uint8_t masterEnable ; /* specifies whether OTFA IP has to be enabled/disabled ; 0 or 1 */
425 }OTFA_Config_t ;
426 
436 typedef struct SecCfgValidate_t_
437 {
438  uint8_t *pCertAddress;
439  uint32_t certType;
443 
454 typedef struct FlashBankCopy_t_
455 {
458 
470 typedef struct CryptoServiceReq_t_
471 {
472  uint32_t algoId;
473  uint32_t subSvcId;
474  uint32_t keyId;
475  uint32_t errCode;
476  void *ptrArgs;
478 
493 typedef struct CMACArgs_t_
494 {
495  uint8_t *ptrData;
496  uint32_t dataLen;
497  uint8_t *ptrTag;
498 } CMACArgs_t;
499 
515 typedef struct HMACArgs_t_
516 {
517  uint32_t hashMode;
518  uint8_t *ptrData;
519  uint32_t dataLen;
520  uint8_t *ptrTag;
521 } HMACArgs_t;
522 
538 typedef struct GMACArgs_t_
539 {
540  uint8_t *ptrData;
541  uint32_t dataLen;
542  uint8_t *ptrTag;
543  uint8_t *ptrIV;
544  uint32_t ivLen;
545 } GMACArgs_t;
546 
561 typedef struct BankSwapReq_t_
562 {
563  uint8_t c29CpuId;
564  uint8_t syncFlag;
565  uint32_t timeout;
567  uint32_t c29CpuBankSwapVal;
568 } BankSwapReq_t;
569 
570 /*
571  * @brief
572  * Safety configuration structure containing safety-related device information.
573  * Total size: SIZE_OF_SAFETY_DEVICE_CONFIG (8 bytes)
574  */
575 typedef struct DeviceConfigSafety_t_
576 {
577  uint32_t dedFotaInfo;
578  uint32_t hsmPbistStatus;
580 
603 typedef struct DeviceConfigSecurity_t_
604 {
605 #if defined (SOC_F29H85X)
606  uint32_t c29Cpu2SecCfgValidationStatus;
607  uint32_t c29Cpu3SecCfgValidationStatus;
608  uint32_t certSwRevSSU;
609  uint32_t certSwRevR5SBL;
610  uint32_t certSwRevHSM;
611  uint32_t certSwRevApp;
612 #elif defined (SOC_F29P32X)
613  uint32_t c29Cpu2SecCfgValidationStatus;
614  uint32_t reserved1;
615  uint32_t certSwRevSSU;
616  uint32_t certSwRevR5SBL;
617  uint32_t certSwRevHSM;
618  uint32_t certSwRevApp;
619 #else
620  uint32_t reserved1;
621  uint32_t reserved2;
622  uint32_t reserved3;
623  uint32_t reserved4;
624  uint32_t reserved5;
625  uint32_t reserved6;
626 #endif
627  uint32_t bootRetryCounts;
635 
641 typedef struct DeviceConfigDebug_t_
642 {
643  uint32_t publicDebugStatus;
645  uint32_t secureDebugStatus;
648 
659 typedef struct DeviceConfigRead_t_
660 {
661  uint32_t configType;
662  uint32_t *configData;
663  uint32_t configSize;
664  uint16_t configDataCRC;
666 
678 
689  int32_t HsmClient_init(SIPC_Params *params);
690 
696  void HsmClient_deInit(void);
697 
704 void HsmClient_SecureBootQueueInit(uint32_t configured_hsm_client_msg_queue_size);
720 int32_t HsmClient_getVersion(HsmClient_t *HsmClient ,
721  HsmVer_t* verId,uint32_t timeToWaitInTick);
722 
738  int32_t HsmClient_getUID(HsmClient_t *HsmClient,
739  uint8_t *uid, uint32_t timeout);
740 
757  int32_t HsmClient_openDbgFirewall(HsmClient_t *HsmClient,
758  uint8_t *cert,
759  uint32_t cert_size,
760  uint32_t timeout);
761 
778  int32_t HsmClient_importKeyring(HsmClient_t *HsmClient,
779  uint8_t *cert,
780  uint32_t cert_size,
781  uint32_t timeout);
782 
795  int32_t HsmClient_readOTPRow(HsmClient_t *HsmClient,
796  NvmOtpRead_t *readRow);
797 
810  int32_t HsmClient_writeOTPRow(HsmClient_t *HsmClient,
811  NvmOtpRowWrite_t *writeRow);
812 
825  int32_t HsmClient_lockOTPRow(HsmClient_t *HsmClient,
826  NvmOtpRowProt_t *rowProt);
827 
840  int32_t HsmClient_getOTPRowCount(HsmClient_t *HsmClient,
841  NvmOtpRowCount_t *rowCount);
842 
855  int32_t HsmClient_getOTPRowProtection(HsmClient_t *HsmClient,
856  NvmOtpRowProt_t *rowProt);
857 
874  int32_t HsmClient_procAuthBoot(HsmClient_t *HsmClient,
875  uint8_t *cert,
876  uint32_t cert_size,
877  uint32_t timeout);
878 
893  int32_t HsmClient_procAuthBootStart(HsmClient_t *HsmClient,
894  SecureBoot_Stream_t *secureBootInfo);
895 
910  int32_t HsmClient_procAuthBootUpdate(HsmClient_t *HsmClient,
911  SecureBoot_Stream_t *secureBootInfo);
912 
927  int32_t HsmClient_procAuthBootFinish(HsmClient_t *HsmClient,
928  SecureBoot_Stream_t *secureBootInfo);
929 
945  int32_t HsmClient_setFirewall(HsmClient_t *HsmClient,
946  FirewallReq_t *FirewallReqObj,
947  uint32_t timeout);
963  int32_t HsmClient_FirewallIntr(HsmClient_t *HsmClient,
964  FirewallIntrReq_t *FirewallIntrReqObj,
965  uint32_t timeout);
966 
979  int32_t HsmClient_keyWriter(HsmClient_t *HsmClient,
980  KeyWriterCertHeader_t *certHeader,
981  uint32_t timeout);
982 
995  int32_t HsmClient_readSWRev(HsmClient_t *HsmClient,
996  SWRev_t *readSWRev);
997 
1010  int32_t HsmClient_writeSWRev(HsmClient_t *HsmClient,
1011  SWRev_t *writeSWRev);
1012 
1029  int32_t HsmClient_getDKEK(HsmClient_t *HsmClient,
1030  DKEK_t *getDKEK,
1031  uint32_t timeout);
1043  int32_t HsmClient_register(HsmClient_t *HsmClient, uint8_t clientId);
1044 
1053  void HsmClient_unregister(HsmClient_t *HsmClient, uint8_t clientId);
1054 
1068  int32_t HsmClient_waitForBootNotify(HsmClient_t *HsmClient, uint32_t timeToWaitInTicks);
1069 
1080  int32_t Hsmclient_loadHSMRtFirmware(HsmClient_t *gHSMClient, const uint8_t *pHSMRt_firmware);
1081 
1091  int32_t Hsmclient_loadHSMRtFirmwareNonBlocking(const uint8_t *pHSMRt_firmware);
1092 
1104  int32_t HsmClient_getRandomNum(HsmClient_t *HsmClient,
1105  RNGReq_t *getRandomNum);
1106 
1122  FirmwareUpdateReq_t *pFirmwareUpdateObject);
1123 
1138  FirmwareUpdateReq_t *pFirmwareUpdateObject);
1139 
1155  FirmwareUpdateReq_t *pFirmwareUpdateObject);
1156 
1173  uint8_t *cert,
1174  uint32_t cert_size,
1175  uint32_t timeout);
1176 
1191  int32_t HsmClient_UpdateKeyRevsion(HsmClient_t *HsmClient,
1192  uint32_t timeout);
1193 
1205 int32_t HsmClient_configOTFARegions(HsmClient_t* HsmClient,
1206  OTFA_Config_t* OTFA_ConfigInfo,
1207  uint32_t timeout);
1208 
1220 int32_t HsmClient_readOTFARegions(HsmClient_t* HsmClient,
1221  OTFA_readRegion_t* OTFA_readRegion,
1222  uint32_t timeout);
1223 
1236 int32_t HsmClient_secCfgValidate(HsmClient_t *HsmClient,
1237  SecCfgValidate_t *pSecCfgParams,
1238  uint32_t timeout);
1239 
1254  FlashBankCopy_t *pFlashBankCopyObject,
1255  uint32_t timeout);
1256 
1268 int32_t HsmClient_SecCfgUpdate(HsmClient_t *HsmClient,
1269  FirmwareUpdateReq_t *pFirmwareUpdateObject);
1270 
1285 int32_t HsmClient_getDeviceConfig(HsmClient_t *HsmClient,
1286  DeviceConfigRead_t *pDeviceConfigObject,
1287  uint32_t timeout);
1288 
1303 int32_t HsmClient_CryptoService(HsmClient_t *HsmClient,
1304  CryptoServiceReq_t *svcReq,
1305  uint32_t timeout);
1306 
1318 int32_t HsmClient_runTimeBankSwap(HsmClient_t *HsmClient,
1319  BankSwapReq_t *pBankSwapObject);
1320 
1323 #ifdef __cplusplus
1324 }
1325 #endif
1326 
1327 #endif /* HSM_CLIENT_H_ */
CMACArgs_t::dataLen
uint32_t dataLen
Definition: hsmclient.h:496
DeviceConfigSecurity_t::reserved1
uint32_t reserved1
Definition: hsmclient.h:620
CMACArgs_t
Args for CMAC generate and verify Note: These services are only available in HSSE mode.
Definition: hsmclient.h:494
OTFA_Region_t::encrAesKey
uint8_t encrAesKey[16]
Definition: hsmclient.h:393
OTFA_Config_t
This is the entire OTFA structure which holds all regions' information 4 regions in AM263Px and AM261...
Definition: hsmclient.h:419
SIPC_Params
Parameters used by SIPC_init.
Definition: sipc_notify.h:84
KeyWriterCertHeader_t::certSize
uint32_t certSize
Definition: hsmclient.h:242
HsmVer_t_
type for reading HSMRt version.
Definition: hsmclient.h:143
OTFA_readRegion_t::encMode
uint8_t encMode
Definition: hsmclient.h:405
HsmClient_checkAndWaitForBootNotification
int32_t HsmClient_checkAndWaitForBootNotification(void)
This API waits for HSMRT load if requested and then waits for boot notification. In case of failure i...
Definition: hsmclient.c:407
LABEL_AND_CONTEXT_LEN_MAX
#define LABEL_AND_CONTEXT_LEN_MAX
Definition: hsmclient.h:56
DeviceConfigDebug_t::publicRegisterAccessStatus
uint32_t publicRegisterAccessStatus
Definition: hsmclient.h:644
FirmwareUpdateReq_t::decryptionBufferLength
uint32_t decryptionBufferLength
Definition: hsmclient.h:373
HsmClient_getDeviceConfig
int32_t HsmClient_getDeviceConfig(HsmClient_t *HsmClient, DeviceConfigRead_t *pDeviceConfigObject, uint32_t timeout)
Client request to get device configuration from HSM This is a blocking call that waits for HSM respon...
Definition: hsmclient.c:2710
DeviceConfigRead_t::configData
uint32_t * configData
Definition: hsmclient.h:662
HsmClient_setFirewall
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.
Definition: hsmclient.c:1319
CryptoServiceReq_t::ptrArgs
void * ptrArgs
Definition: hsmclient.h:476
HsmClient_writeSWRev
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.
Definition: hsmclient.c:1667
HsmVer_t_::PatchVer
uint8_t PatchVer
Definition: hsmclient.h:147
GMACArgs_t
Args for GMAC generate and verify Note: These services are only available in HSSE mode.
Definition: hsmclient.h:539
OTFA_Config_t::keySize
uint8_t keySize
Definition: hsmclient.h:422
DeviceConfigDebug_t::secureDebugStatus
uint32_t secureDebugStatus
Definition: hsmclient.h:645
SecureBoot_Stream_t_::dataIn
uint8_t * dataIn
Definition: hsmclient.h:351
CMACArgs_t::ptrData
uint8_t * ptrData
Definition: hsmclient.h:495
DeviceConfigRead_t
This is device configuration read request structure passed to HSM core via SIPC as argument,...
Definition: hsmclient.h:660
HsmClient_firmwareUpdate_CodeProgram
int32_t HsmClient_firmwareUpdate_CodeProgram(HsmClient_t *HsmClient, FirmwareUpdateReq_t *pFirmwareUpdateObject)
service request issued to HSM server to program the incoming firmware to device dormant banks This se...
Definition: hsmclient.c:1889
NvmOtpRowCount_t::rowSize
uint8_t rowSize
Definition: hsmclient.h:216
DeviceConfigRead_t::configType
uint32_t configType
Definition: hsmclient.h:661
DeviceConfigDebug_t::publicDebugStatus
uint32_t publicDebugStatus
Definition: hsmclient.h:643
FirewallRegionReq_t::region
uint16_t region
Definition: hsmclient.h:255
HsmClient_t::RespFlag
uint8_t RespFlag
Definition: hsmclient.h:174
SecureBoot_Stream_t_
This is the SecureBoot Stream type which holds the data for a specific bootloader to HSM call....
Definition: hsmclient.h:350
HsmClient_firmwareUpdate_CodeVerify
int32_t HsmClient_firmwareUpdate_CodeVerify(HsmClient_t *HsmClient, FirmwareUpdateReq_t *pFirmwareUpdateObject)
service request issued to HSM server to decrypt the firmware programmed in dormant flash bank in plac...
Definition: hsmclient.c:1964
HsmClient_CryptoService
int32_t HsmClient_CryptoService(HsmClient_t *HsmClient, CryptoServiceReq_t *svcReq, uint32_t timeout)
Submit a generic crypto service request to the HSM. Set svcReq->algoId to the algorithm (HSM_CRYPTO_S...
Definition: hsmclient.c:2425
HMACArgs_t::ptrData
uint8_t * ptrData
Definition: hsmclient.h:518
RNGReq_t::resultLength
uint32_t resultLength
Definition: hsmclient.h:337
DKEK_t
This is DKEK type which holds the label and context for derivation. This also holds the 256 derived K...
Definition: hsmclient.h:316
NvmOtpRead_t::rowIdx
uint16_t rowIdx
Definition: hsmclient.h:189
OTFA_Region_t::reservedArea
uint16_t reservedArea
Definition: hsmclient.h:386
SecureBoot_Stream_t_::canBeEncrypted
uint8_t canBeEncrypted
Definition: hsmclient.h:353
DeviceConfigRead_t::configDataCRC
uint16_t configDataCRC
Definition: hsmclient.h:664
GMACArgs_t::dataLen
uint32_t dataLen
Definition: hsmclient.h:541
SecCfgValidate_t::pCertAddress
uint8_t * pCertAddress
Definition: hsmclient.h:438
HsmClient_readOTPRow
int32_t HsmClient_readOTPRow(HsmClient_t *HsmClient, NvmOtpRead_t *readRow)
The service issued to HSM Server retrieves the data of GP OTP row based on row index provided as para...
Definition: hsmclient.c:804
NvmOtpRowWrite_t
This is an NvmOtpRowWrite type which holds the information regarding programming NvmOtp row....
Definition: hsmclient.h:201
HsmClient_readSWRev
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.
Definition: hsmclient.c:1599
Hsmclient_loadHSMRtFirmwareNonBlocking
int32_t Hsmclient_loadHSMRtFirmwareNonBlocking(const uint8_t *pHSMRt_firmware)
Loads the HSMRt firmware but does wait for ROM response and boot notification. This is typically call...
Definition: hsmclient_loadhsmrt.c:408
HsmClient_importKeyring
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.
Definition: hsmclient.c:732
BankSwapReq_t::timeout
uint32_t timeout
Definition: hsmclient.h:565
HsmVer_t_::HsmType
uint8_t HsmType
Definition: hsmclient.h:153
OTFA_Config_t::OTFA_Reg
OTFA_Region_t OTFA_Reg[4]
Definition: hsmclient.h:420
BankSwapReq_t::syncFlag
uint8_t syncFlag
Definition: hsmclient.h:564
DeviceConfigSafety_t::hsmPbistStatus
uint32_t hsmPbistStatus
Definition: hsmclient.h:578
HsmClient_procAuthBootStart
int32_t HsmClient_procAuthBootStart(HsmClient_t *HsmClient, SecureBoot_Stream_t *secureBootInfo)
The service issued to HSM Server helps with extended secure boot for applications.
Definition: hsmclient.c:1212
GMACArgs_t::ptrTag
uint8_t * ptrTag
Definition: hsmclient.h:542
RNGReq_t::seedValue
uint32_t * seedValue
Definition: hsmclient.h:339
HsmVer_t_::MajorVer
uint8_t MajorVer
Definition: hsmclient.h:149
DeviceConfigDebug_t
Debug status structure containing debug access information. Total size: SIZE_OF_DEBUG_DEVICE_CONFIG (...
Definition: hsmclient.h:642
FirewallIntrReq_t::firewallId
uint16_t firewallId
Definition: hsmclient.h:282
OTFA_Region_t::regionStAddr
uint32_t regionStAddr
Definition: hsmclient.h:387
OTFA_Region_t::regionIV
uint8_t regionIV[16]
Definition: hsmclient.h:394
FirewallReq_t::FirewallRegionArr
FirewallRegionReq_t * FirewallRegionArr
Definition: hsmclient.h:270
NvmOtpRowWrite_t::rowIdx
uint16_t rowIdx
Definition: hsmclient.h:204
FirmwareUpdateReq_t::pStartAddress
uint8_t * pStartAddress
Definition: hsmclient.h:370
FirewallRegionReq_t
This is a FirewallRegionReq type which holds the information of Firewall region configuration.
Definition: hsmclient.h:253
RNGReq_t::resultPtr
uint8_t * resultPtr
Definition: hsmclient.h:336
HsmClient_t
This is a HSMClient type which holds the information needed by hsm client to communicate with HSM .
Definition: hsmclient.h:169
HsmClient_UpdateKeyRevsion
int32_t HsmClient_UpdateKeyRevsion(HsmClient_t *HsmClient, uint32_t timeout)
service request issued to HSM server to update key revision to 0x2 which changes the root of trust ke...
Definition: hsmclient.c:2168
OTFA_Region_t::encrKeyFetchMode
uint8_t encrKeyFetchMode
Definition: hsmclient.h:391
NvmOtpRowProt_t
This is a NvmOtpRowProt type which holds the information of NvmOtp row index and protection status co...
Definition: hsmclient.h:228
HsmVer_t_::SocType
uint8_t SocType
Definition: hsmclient.h:151
GMACArgs_t::ivLen
uint32_t ivLen
Definition: hsmclient.h:544
HsmVer_t_::ApiVer
uint8_t ApiVer
Definition: hsmclient.h:150
SemaphoreP.h
HMACArgs_t
Args for HMAC generate and verify Note: These services are only available in HSSE mode.
Definition: hsmclient.h:516
HsmClient_procAuthBootFinish
int32_t HsmClient_procAuthBootFinish(HsmClient_t *HsmClient, SecureBoot_Stream_t *secureBootInfo)
The service issued to HSM Server helps with extended secure boot for applications.
Definition: hsmclient.c:1280
HsmVer_t_::HsmrtVer
uint64_t HsmrtVer
Definition: hsmclient.h:144
NvmOtpRowProt_t::writeProt
uint8_t writeProt
Definition: hsmclient.h:231
OTFA_Region_t::encrKeyID
uint8_t encrKeyID
Definition: hsmclient.h:390
sipc_notify.h
HsmVer_t_::DevType
uint8_t DevType
Definition: hsmclient.h:154
OTFA_readRegion_t::authMode
uint8_t authMode
Definition: hsmclient.h:404
HMACArgs_t::ptrTag
uint8_t * ptrTag
Definition: hsmclient.h:520
CryptoServiceReq_t
Outer request struct for HSM_MSG_CRYPTO_SERVICE. Note: These services are only available in HSSE mode...
Definition: hsmclient.h:471
RNGReq_t::seedSizeInDWords
uint8_t seedSizeInDWords
Definition: hsmclient.h:340
HsmClient_firmwareUpdate_CertProcess
int32_t HsmClient_firmwareUpdate_CertProcess(HsmClient_t *HsmClient, FirmwareUpdateReq_t *pFirmwareUpdateObject)
service request issued to HSM server to parse the certificate to validate authenticity and identify t...
Definition: hsmclient.c:1813
NvmOtpRowProt_t::readProt
uint8_t readProt
Definition: hsmclient.h:230
HsmClient_t::RespMsg
HsmMsg_t RespMsg
Definition: hsmclient.h:173
FirewallRegionReq_t::endAddress
uint32_t endAddress
Definition: hsmclient.h:258
HsmClient_openDbgFirewall
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_F...
Definition: hsmclient.c:660
SWRev_t::revValue
uint32_t revValue
Definition: hsmclient.h:300
BankSwapReq_t
This is bank swap request structure passed to HSM core via SIPC as argument, these parameters are req...
Definition: hsmclient.h:562
HsmClient_register
int32_t HsmClient_register(HsmClient_t *HsmClient, uint8_t clientId)
register a client to a particular ClientId
Definition: hsmclient.c:461
CryptoServiceReq_t::keyId
uint32_t keyId
Definition: hsmclient.h:474
GMACArgs_t::ptrIV
uint8_t * ptrIV
Definition: hsmclient.h:543
FirewallIntrReq_t
This is a FirewallIntrReq type which holds the information of MPU Firewall request for interrupt enab...
Definition: hsmclient.h:281
HsmClient_activeToDormantBankCopy
int32_t HsmClient_activeToDormantBankCopy(HsmClient_t *HsmClient, FlashBankCopy_t *pFlashBankCopyObject, uint32_t timeout)
Client request to copy active flash bank contents to dormant flash bank Valid only for F29x family of...
Definition: hsmclient.c:2630
NvmOtpRowWrite_t::rowBitMask
uint32_t rowBitMask
Definition: hsmclient.h:203
HsmClient_getOTPRowCount
int32_t HsmClient_getOTPRowCount(HsmClient_t *HsmClient, NvmOtpRowCount_t *rowCount)
The service issued to HSM Server retrieves the count of extended OTP rows.
Definition: hsmclient.c:1006
CMACArgs_t::ptrTag
uint8_t * ptrTag
Definition: hsmclient.h:497
FirmwareUpdateReq_t::pDecryptionBuffer
void * pDecryptionBuffer
Definition: hsmclient.h:372
HsmClient_VerifyROTSwitchingCertificate
int32_t HsmClient_VerifyROTSwitchingCertificate(HsmClient_t *HsmClient, uint8_t *cert, uint32_t cert_size, uint32_t timeout)
service request issued to HSM server to validate RoT Switching Certificate
Definition: hsmclient.c:2098
NvmOtpRead_t::rowData
uint32_t rowData
Definition: hsmclient.h:188
FirewallReq_t
This is a FirewallReq_t type which holds the information of Firewall configuration.
Definition: hsmclient.h:267
FirewallIntrReq_t::interruptEnableClear
uint8_t interruptEnableClear
Definition: hsmclient.h:284
FirewallRegionReq_t::permissionAttributes
uint32_t permissionAttributes
Definition: hsmclient.h:256
OTFA_readRegion_t::regionIV
uint16_t regionIV[16]
Definition: hsmclient.h:410
NvmOtpRowProt_t::rowidx
uint16_t rowidx
Definition: hsmclient.h:229
HsmClient_runTimeBankSwap
int32_t HsmClient_runTimeBankSwap(HsmClient_t *HsmClient, BankSwapReq_t *pBankSwapObject)
Client request to Swap C29 CPU flash banks Valid only for F29x family of devices.
Definition: hsmclient.c:2673
HsmClient_init
int32_t HsmClient_init(SIPC_Params *params)
Initialize the HSM client for current core.
Definition: hsmclient.c:491
HsmClient_FirewallIntr
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.
Definition: hsmclient.c:1394
DeviceConfigSafety_t
Definition: hsmclient.h:576
HMACArgs_t::hashMode
uint32_t hashMode
Definition: hsmclient.h:517
CryptoServiceReq_t::subSvcId
uint32_t subSvcId
Definition: hsmclient.h:473
SWRev_t
This is SWRev type which holds the information regarding Revision identifier and value corresponding ...
Definition: hsmclient.h:299
DeviceConfigSafety_t::dedFotaInfo
uint32_t dedFotaInfo
Definition: hsmclient.h:577
HsmVer_t_::BinType
uint8_t BinType
Definition: hsmclient.h:152
SecCfgValidate_t
This is Sec-Cfg validation request structure passed to HSM core via SIPC as argument,...
Definition: hsmclient.h:437
BankSwapReq_t::c29CpuId
uint8_t c29CpuId
Definition: hsmclient.h:563
FirewallRegionReq_t::startAddress
uint32_t startAddress
Definition: hsmclient.h:257
HsmVer_t_::VerStruct
struct HsmVer_t_::@0 VerStruct
OTFA_Region_t::encMode
uint8_t encMode
Definition: hsmclient.h:385
DeviceConfigSecurity_t::reserved5
uint32_t reserved5
Definition: hsmclient.h:624
DeviceConfigSecurity_t::hsmFirmwareUpdateStatus
uint32_t hsmFirmwareUpdateStatus
Definition: hsmclient.h:630
SecureBoot_Stream_t_::dataLen
uint32_t dataLen
Definition: hsmclient.h:352
FirewallReq_t::statusFirewallRegionArr
uint16_t statusFirewallRegionArr
Definition: hsmclient.h:271
DeviceConfigRead_t::configSize
uint32_t configSize
Definition: hsmclient.h:663
FirewallReq_t::regionCount
uint16_t regionCount
Definition: hsmclient.h:268
OTFA_readRegion_t::encKeyHash
uint8_t encKeyHash[64]
Definition: hsmclient.h:407
DKEK_t::context_length
uint8_t context_length
Definition: hsmclient.h:318
HsmClient_readOTFARegions
int32_t HsmClient_readOTFARegions(HsmClient_t *HsmClient, OTFA_readRegion_t *OTFA_readRegion, uint32_t timeout)
Client request to read the OTFA regions.
Definition: hsmclient.c:2287
BankSwapReq_t::c29CpuBankSwapVal
uint32_t c29CpuBankSwapVal
Definition: hsmclient.h:567
FlashBankCopy_t
This is active bank to dormant bank copy request structure passed to HSM core via SIPC as argument,...
Definition: hsmclient.h:455
FlashBankCopy_t::cpuFlashBankType
uint8_t cpuFlashBankType
Definition: hsmclient.h:456
SWRev_t::revId
uint8_t revId
Definition: hsmclient.h:301
OTFA_readRegion_t::regionStAddr
uint32_t regionStAddr
Definition: hsmclient.h:408
HsmClient_unregister
void HsmClient_unregister(HsmClient_t *HsmClient, uint8_t clientId)
unregister a client to a particular ClientId
Definition: hsmclient.c:517
FirewallIntrReq_t::faultClear
uint8_t faultClear
Definition: hsmclient.h:286
CryptoServiceReq_t::algoId
uint32_t algoId
Definition: hsmclient.h:472
OTFA_readRegion_t::regionSize
uint32_t regionSize
Definition: hsmclient.h:409
hsmclient_msg.h
DeviceConfigSecurity_t
Security configuration structure containing security-related device information.
Definition: hsmclient.h:604
FirmwareUpdateReq_t::dataLength
uint32_t dataLength
Definition: hsmclient.h:371
FirewallIntrReq_t::interruptEnable
uint8_t interruptEnable
Definition: hsmclient.h:283
KeyWriterCertHeader_t::certAddress
uint8_t * certAddress
Definition: hsmclient.h:241
NvmOtpRowWrite_t::rowData
uint32_t rowData
Definition: hsmclient.h:202
Hsmclient_loadHSMRtFirmware
int32_t Hsmclient_loadHSMRtFirmware(HsmClient_t *gHSMClient, const uint8_t *pHSMRt_firmware)
Loads the HSMRt firmware. This is typically called by SBL.
Definition: hsmclient_loadhsmrt.c:323
OTFA_readRegion_t::authKeyHash
uint8_t authKeyHash[64]
Definition: hsmclient.h:406
HsmClient_procAuthBootUpdate
int32_t HsmClient_procAuthBootUpdate(HsmClient_t *HsmClient, SecureBoot_Stream_t *secureBootInfo)
The service issued to HSM Server helps with extended secure boot for applications.
Definition: hsmclient.c:1246
NvmOtpRowCount_t
This is an NvmOtpRowCount type which holds the information regarding NvmOtp row count and size of eac...
Definition: hsmclient.h:214
DeviceConfigDebug_t::secureRegisterAccessStatus
uint32_t secureRegisterAccessStatus
Definition: hsmclient.h:646
HsmClient_getOTPRowProtection
int32_t HsmClient_getOTPRowProtection(HsmClient_t *HsmClient, NvmOtpRowProt_t *rowProt)
The service issued to HSM Server retrieves the extended otp efuse row protection status....
Definition: hsmclient.c:1073
OTFA_readRegion_t
This is the OTFA Region structure which holds individual region specific information to be read from ...
Definition: hsmclient.h:402
DeviceConfigSecurity_t::sblFirmwareUpdateStatus
uint32_t sblFirmwareUpdateStatus
Definition: hsmclient.h:631
DeviceConfigSecurity_t::reserved4
uint32_t reserved4
Definition: hsmclient.h:623
HsmClient_waitForBootNotify
int32_t HsmClient_waitForBootNotify(HsmClient_t *HsmClient, uint32_t timeToWaitInTicks)
Current core will wait for bootnotify message from HSM core.
HsmClient_t::Semaphore
SemaphoreP_Object Semaphore
Definition: hsmclient.h:170
HsmClient_lockOTPRow
int32_t HsmClient_lockOTPRow(HsmClient_t *HsmClient, NvmOtpRowProt_t *rowProt)
The service issued to HSM Server sets the protection status bit of the specified row to 1....
Definition: hsmclient.c:939
HsmClient_writeOTPRow
int32_t HsmClient_writeOTPRow(HsmClient_t *HsmClient, NvmOtpRowWrite_t *writeRow)
The service issued to HSM Server writes the data to extended OTP efuse row based on row index provide...
Definition: hsmclient.c:872
HsmVer_t_::MinorVer
uint8_t MinorVer
Definition: hsmclient.h:148
FirewallRegionReq_t::firewallId
uint16_t firewallId
Definition: hsmclient.h:254
DeviceConfigSecurity_t::hostCpu1FirmwareUpdateStatus
uint32_t hostCpu1FirmwareUpdateStatus
Definition: hsmclient.h:632
HsmClient_getUID
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_...
Definition: hsmclient.c:592
DeviceConfigSecurity_t::bootRetryCounts
uint32_t bootRetryCounts
Definition: hsmclient.h:627
OTFA_Config_t::masterEnable
uint8_t masterEnable
Definition: hsmclient.h:424
SecCfgValidate_t::certType
uint32_t certType
Definition: hsmclient.h:439
HsmClient_keyWriter
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,...
Definition: hsmclient.c:1529
DeviceConfigSecurity_t::reserved2
uint32_t reserved2
Definition: hsmclient.h:621
OTFA_Region_t::authMode
uint8_t authMode
Definition: hsmclient.h:384
OTFA_Config_t::macSize
uint8_t macSize
Definition: hsmclient.h:423
HsmClient_t::ClientId
uint8_t ClientId
Definition: hsmclient.h:175
GMACArgs_t::ptrData
uint8_t * ptrData
Definition: hsmclient.h:540
HsmClient_getRandomNum
int32_t HsmClient_getRandomNum(HsmClient_t *HsmClient, RNGReq_t *getRandomNum)
Returns the Random Number Generated.
Definition: hsmclient.c:1735
KeyWriterCertHeader_t::debugResponse
uint32_t debugResponse
Definition: hsmclient.h:243
HsmClient_getDKEK
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.
Definition: hsmclient.c:1462
RNGReq_t::reserved
uint8_t reserved
Definition: hsmclient.h:341
HsmClient_configOTFARegions
int32_t HsmClient_configOTFARegions(HsmClient_t *HsmClient, OTFA_Config_t *OTFA_ConfigInfo, uint32_t timeout)
Client request to configure the OTFA regions.
Definition: hsmclient.c:2219
KeyWriterCertHeader_t::reserved
uint32_t reserved
Definition: hsmclient.h:244
OTFA_Region_t::authKeyID
uint8_t authKeyID
Definition: hsmclient.h:389
NvmOtpRowCount_t::rowCount
uint32_t rowCount
Definition: hsmclient.h:215
OTFA_Region_t::regionSize
uint32_t regionSize
Definition: hsmclient.h:388
HsmClient_secCfgValidate
int32_t HsmClient_secCfgValidate(HsmClient_t *HsmClient, SecCfgValidate_t *pSecCfgParams, uint32_t timeout)
Client request to validate sec-cfg Valid only for F29x family of devices.
Definition: hsmclient.c:2355
FirmwareUpdateReq_t
This is Firmware Update request structure passed to HSM core via SIPC as argument,...
Definition: hsmclient.h:369
DKEK_t::label_length
uint8_t label_length
Definition: hsmclient.h:317
__attribute__
union HsmVer_t_ __attribute__((packed)) HsmVer_t
type for reading HSMRt version.
KeyWriterCertHeader_t
This is a keywriter_cert_header type which holds the information of customer key certificate and debu...
Definition: hsmclient.h:240
HsmClient_SecureBootQueueInit
void HsmClient_SecureBootQueueInit(uint32_t configured_hsm_client_msg_queue_size)
Customize the size of the HSM client message queue.
Definition: hsmclient.c:506
DeviceConfigSecurity_t::hostCpu2FirmwareUpdateStatus
uint32_t hostCpu2FirmwareUpdateStatus
Definition: hsmclient.h:633
FirewallIntrReq_t::interruptEnableStatusClear
uint8_t interruptEnableStatusClear
Definition: hsmclient.h:285
HsmClient_SecCfgUpdate
int32_t HsmClient_SecCfgUpdate(HsmClient_t *HsmClient, FirmwareUpdateReq_t *pFirmwareUpdateObject)
Client request to update device Sec-Cfg Valid only for F29x family of devices.
Definition: hsmclient.c:2045
OTFA_readRegion_t::regionNumber
uint8_t regionNumber
Definition: hsmclient.h:403
FirewallReq_t::crcArr
uint16_t crcArr
Definition: hsmclient.h:269
RNGReq_t
This is RNG type which holds the resultPtr for derivation which is returned by TIFS....
Definition: hsmclient.h:335
HMACArgs_t::dataLen
uint32_t dataLen
Definition: hsmclient.h:519
OTFA_Config_t::numRegions
uint8_t numRegions
Definition: hsmclient.h:421
HsmClient_procAuthBoot
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.
Definition: hsmclient.c:1140
HsmClient_getVersion
int32_t HsmClient_getVersion(HsmClient_t *HsmClient, HsmVer_t *verId, uint32_t timeToWaitInTick)
populates the current HSMRT version Id by default the hsm flag is set to HSM_FLAG_AOP for this servic...
Definition: hsmclient.c:523
OTFA_Region_t
This is the OTFA Region structure which holds individual region specific information to be written to...
Definition: hsmclient.h:383
RNGReq_t::DRBGMode
uint8_t DRBGMode
Definition: hsmclient.h:338
OTFA_Region_t::authAesKey
uint8_t authAesKey[16]
Definition: hsmclient.h:392
hsmclient_utils.h
DeviceConfigSecurity_t::reserved3
uint32_t reserved3
Definition: hsmclient.h:622
HsmClient_t::ReqMsg
HsmMsg_t ReqMsg
Definition: hsmclient.h:172
NvmOtpRead_t
This is an NvmOtpRead type which holds the information of NvmOtp row index and row data corresponding...
Definition: hsmclient.h:187
CryptoServiceReq_t::errCode
uint32_t errCode
Definition: hsmclient.h:475
HsmClient_deInit
void HsmClient_deInit(void)
De initialize the HSM client for current core.
DeviceConfigSecurity_t::reserved6
uint32_t reserved6
Definition: hsmclient.h:625