Hi NXP,
I am trying to use C code to test SMR install API(service ID:
HSE_SRV_ID_SMR_ENTRY_INSTALL
), However, I always got service response A5AAA399 which meas parameter is incorrect.
there is so many Argument in this API, could someone help me to check?
the signature and address have benn vailded is this test.
the HSE FW version is 0.2.6
memcpy(
(void *)&IVT,
(const void *)BLOCK0_IVT_ADDRESS,
0x100);
uint32_t AppAddress = (uint32_t) app_start_real;
SmrEntry[4].pSmrsrc=AppAddress; /* Start of APP code */
SmrEntry[4].smrSize = 1024UL; /* Length of APP code */
SmrEntry[4].authKeyHandle = aaa_pub_HANDLE;
SmrEntry[4].authScheme.sigScheme.signSch = HSE_SIGN_RSASSA_PSS;
SmrEntry[4].authScheme.sigScheme.sch.rsaPss.hashAlgo = HSE_HASH_ALGO_SHA2_256;
SmrEntry[4].authScheme.sigScheme.sch.rsaPss.saltLength = 32UL;
SmrEntry[4].pInstAuthTag[0] = test_sign_real; /* signature tag address */
SmrEntry[4].pInstAuthTag[1] = (uint32_t)NULL; /* In this example, AES keys is used hence 2nd tag address is NULL */
/**** RSA ****/
srvResponse = RsaPssSignSrv(
aaa_pri_HANDLE,
32UL,
HSE_HASH_ALGO_SHA2_256,
SmrEntry[4].smrSize,
(const uint8_t *)SmrEntry[4].pSmrSrc,
FALSE,
0U,
&signLength,
outputSig);
debug_print("%s RsaPssSignSrv(1) = %x\r\n", sl_tag, srvResponse);
if(FLASH_Erase(FLS_SWAP_OFFSET, S32K312_SECTOR_SIZE, MAX_ERASE_TIME) == E_OK){
if(FLASH_Write(FLS_SWAP_OFFSET, sizeof(outputSig), outputSig, MAX_ERASE_TIME) == E_OK){
debug_print("%s FLASH_Write = OK\r\n", sl_tag);
}
else{
debug_print("%s FLASH_Write = NG\r\n", sl_tag);
}
}
else{
debug_print("%s FLASH_Erase = NG\r\n", sl_tag);
}
srvResponse = RsaPssVerSrv(
aaa_pub_HANDLE,
32UL,
HSE_HASH_ALGO_SHA2_256,
SmrEntry[4].smrSize,
(const uint8_t *)SmrEntry[4].pSmrSrc,
FALSE,
0U,
&signLength,
(const uint8_t *)test_sign_real);
debug_print("%s RsaPssVerSrv(1) = %x\r\n", sl_tag, srvResponse);
srvResponse = HSE_InstallSmrEntry((4),
(const hseSmrEntry_t *)&SmrEntry[4],
(const uint8_t *)SmrEntry[4].pSmrSrc,
SmrEntry[4].smrSize,
(const uint8_t *)tag_addr[0][4],
(const uint8_t *)tag_addr[1][4],
tag_len[4],
tag_len[4]);
debug_print("%s HSE_InstallSmrEntry(0) = %x\r\n", sl_tag, srvResponse);
And, here is result.

Also, I refer to demo_app\services\src\secure_boot\hse_secure_boot.c which is below(Snippet)
srvResponse = HSE_InstallSmrEntry((Index),
(const hseSmrEntry_t *)&smrEntry[Index],
(const uint8_t *)smrEntry[Index].pSmrSrc,
smrEntry[Index].smrSize,
(const uint8 *)tag_addr[0][Index],
(const uint8 *)tag_addr[1][Index],
tag_len[Index],
tag_len[Index]);
smrEntry[i].configFlags = HSE_SMR_CFG_FLAG_INSTALL_AUTH; /* Indicate that verification should be done on provided signature */
smrEntry[i].pSmrDest = 0U; /* destination address shall be NULL for flashed based devices */
smrEntry[i].checkPeriod = 0U;
smrEntry[i].pSmrsrc=AppAddress; /* Start of APP code */
smrEntry[i].smrSize = 1024UL; /* Length of APP code */
smrEntry[i].authKeyHandle = HSE_DEMO_NVM_RSA2048_PUB_CUSTAUTH_HANDLE0;
smrEntry[i].authScheme.sigScheme.signSch = HSE_SIGN_RSASSA_PSS;
smrEntry[i].authScheme.sigScheme.sch.rsaPss.hashAlgo = HSE_HASH_ALGO_SHA2_256;
smrEntry[i].authScheme.sigScheme.sch.rsaPss.saltLength = SALT_LENGTH;
smrEntry[i].pInstAuthTag[0] = RSA_TAG_CODE_FLASH_ADDRESS; /* signature tag address */
smrEntry[i].pInstAuthTag[1] = (uint32_t)NULL; /* In this example, AES keys is used hence 2nd tag address is NULL */